In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces you the example analysis of MAC address and IP address, the content is very detailed, interested friends can refer to, hope to be helpful to you.
In teaching computer network courses, we often encounter the question of why two addresses are needed: one is the MAC (physical address), the other is the IP address. There are all kinds of explanations, and basically one point of view is that one is a physical address and the other is a logical address. However, this explanation is too abstract, what is physics and what is logic. These abstract expressions will make it impossible to understand its nature. Now I would like to talk about this issue.
To illustrate this problem, we must first talk about the goal of the computer network. The fundamental goal of a computer network is to transfer data from one point to another. It sounds simple, but it contains a lot of meaning. For example, whether the two points are connected in the same network or across the network, how to correctly transmit the data to each other, what to do if there is an error, and so on.
In order to illustrate the nature of the problem, let's first simplify the problem: suppose two points are in the same network. In this case, only the MAC address is needed. For example, multiple computers are formed into a network through a switch. in order to find each other, it must be identified by an address. Just like sending an express delivery, if there is no address, the courier will not be able to deliver the delivery to the other party's location. This is what we call the MAC address. When point A wants to pass data to point B, the MAC address of B, that is, the destination address, is added to the head of the data. Of course, there is also a source address in the header, that is, the MAC address of the sender, as well as some other information, such as for verification, and so on. The assembled data is called a frame. Then point A sends the frame through the network card.
At this point, the switch receives the frame and looks for its own forwarding table. The forwarding table has two main columns, one is the MAC address, and the other is the port corresponding to the MAC address. There are only two kinds of search results: found or not found. If found, the data is forwarded out the port corresponding to the MAC. If not, simply, the switch broadcasts the frame to all ports (except the port on which the frame enters), so there must be a suitable port to receive it. The method of broadcasting is rough and effective.
This is what MAC addresses are for. The MAC address is recorded on the physical device of the network card and generally cannot be changed.
However, if the two points are not in the same network. At this point, the IP address is needed. Because the IP address contains two parts, one is the network address, and the other is the host address. Therefore, by the IP address of the other party, we can tell whether the other party is in the same network as the local computer. If you are in a network, as mentioned above, you only need to know the other party's MAC address to communicate.
If it is not in a network, the local network layer believes that the data should be sent to the gateway. It is obvious that if you are not in a network, you have to send the data out of the network first. How to send out the network, of course, is sent to the gateway, because the gateway is equivalent to the gatekeeper of the network. If you want to send data to the gateway, you also need to know the MAC address of the gateway. How do you know the MAC address of the gateway? This involves the ARP protocol.
There is an ARP table in the computer cache, which has two main columns: one column is the IP address, the other column is the MAC address. This table is not inborn, but is constantly learning as the network card receives all kinds of communication data in the network.
In other words, if there is a MAC address corresponding to the gateway IP address in the ARP table, the problem will be transformed into intra-network data transmission, which has been explained very clearly. If there is no MAC address for the gateway IP address in the ARP table, start the ARP protocol, that is, broadcast to the network, asking for the MAC address of the IP address. The result of the broadcast query is that when the gateway receives the broadcast, it finds that it is asking for its own MAC address, so it replies to the party's own MAC address. Then the problem of sending data to the gateway is also transformed into intra-network data transmission, which has been stated very clearly above.
Have you found that an IP address is needed for cross-network communication? Because it is necessary to use the IP address to determine whether it is on-network communication or off-network communication. One might say that making MAC addresses also have the characteristics of distinguishing networks would obviate the need for IP. In fact, it is impractical to do so. Each Nic has a unique MAC address when it comes out of the factory, and it is impossible to know which network you are using it in, that is, it is not born with the characteristics of being able to distinguish between networks. And it doesn't need to have this characteristic. Because MAC is only responsible for device-to-device communication. This layer of communication is real communication, so it is called physical communication.
When transmitting data across the network, we need to consider the transmission path, that is, where the next hop should go in order to reach the destination, so that it can be transmitted to the destination one by one. As for intra-network transmission, there is no need to consider the transmission path, as long as it is sent out, it can be reached. In the worst case, it can be reached even through radio transmission. When transmitting across the network, this trick doesn't work. Therefore, cross-network transmission needs to consider the transmission between networks, need to use the address that can represent the characteristics of the network, that is, the IP address. So the IP address is responsible for network-to-network transmission.
After sending it to the gateway, who will be sent next? this machine can't control it. This machine can only guarantee transmission within the network, that is, the concept of the next hop. The next hop can only be handled by the gateway. In fact, the gateway is an interface of the router. Determine which network the next hop should go to, and then send the data out the interface of the router connected to that network. When sent out, it is also necessary to determine whether the destination IP is the same network as the current routing interface. The question goes back to the process mentioned above. So over and over again.
It can be seen that the concepts of IP address and MAC address are not contradictory. There are different levels between them, just as there must be the masses when there is a leader, and no one can do without each other. Data from one point to another, through several networks, what the network route is, need to use IP address to solve. On the other hand, the intra-network transmission needs to use the MAC address to transmit. It can be seen that there is no real communication transmission within the network, how to achieve communication between networks. If there is no path routed by the network, it is impossible for the data to reach the destination because there is no direction.
This is the end of the case analysis of MAC address and IP address. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 296
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.