The IP address and MAC address can be compared to the process of sending express delivery in life. In the entire network, data is encapsulated into datagrams for transmission, just like putting items into parcels when sending express delivery in our daily life. The jump of data between routers can also be regarded as the handover of logistics by couriers in different regions. IP addressThe IP address is equivalent to the recipient address on the express package. The courier connects the package from the departure point to the destination through the recipient's address, and then transfers the package through logistics between different regions and finally delivers it to the recipient. The destination address can be reached from the path described by the thick arrow in the above picture: Shaanxi Province-Xi'an City-xx County-xx Street-… Similarly, IP addresses also have this function. The network bits of an IP address can be used to determine the location of a host on the network, thereby clarifying a data transmission path. For example, if the destination address is 192.168.10.110/26, then the network where the address is located is 192.168.10.64. Using the addressing method shown in the previous figure, we can simulate this process So, the question is, why do we need MAC addresses? MAC AddressThe MAC address is equivalent to the recipient's name on the express package. MAC address is used to confirm the recipient's information. Just like when a courier arrives at your location across several cities, the courier needs to confirm with you whether the following recipient is correct before handing the package to you. Here we simulate a scenario, for example, in a school, students in the same class all know each other, so they don’t need to use student IDs (here abstracted into IP addresses) to communicate with each other, they can just call each other’s names. “Hey, so-and-so, let me copy your homework.” This process can correspond to the communication of LANs connected to the same switch or hub in the network. Communication in the LAN needs to be carried out through MAC addresses. When encapsulating data into frames, the source MAC address and the destination MAC address will be inserted (if the MAC address of the other party is unknown, an ARP broadcast message will be sent to obtain the MAC address of the other party). Ethernet frame structure: (———Picture from the Internet, please delete if infringed) Then, the IP header information is added to the frame structure again. Although there is an IP address here, it does not work in a LAN, because ARP is used for addressing in the network, and all hosts in a LAN are visible to each other. (In addition, the IP address in a LAN is at most used as a basis for the host receiving the packet to determine whether it is the destination host when decompressing the packet during ARP broadcast, and thus choose whether to respond to the ARP reply). The condition for using IP addresses is after crossing networks. If two networks want to communicate, they need to use a medium, because the host inside the network cannot locate a host outside the network, even if they are only separated by a network segment. (Welcome to follow the official account: Network Engineer Aaron) The medium for crossing network segments is the router. As long as the IP address is told to it, it can find the network where the other party is located. It's like I'm a student of Class 1, Computer Science, 2020 (student number 202015162, 15 refers to the major of Computer Science, 62 refers to my student number in the class), and I want to find a junior student of Class 2022, yy (student number 2022...). We don't know each other, but I can find a middleman to help me deliver the letter. This middleman is the LAN gateway, a router. Their function is to relay my message and send it to the next "middleman" according to the destination IP address, and finally to "yy". The following is a love-hate relationship between MAC addresses and IP addresses... The following content is referenced from the article: "Flasher Sun (Low Concurrency Programming): If You Were Asked to Design a Network" First of all, we need to make it clear that MAC addresses were created before IP addresses. When computers were first designed, devices used MAC addresses to identify each other. Because the network topology was not large at the time, we could allow two computers to send data to each other. If there were five hosts that needed to communicate, the topology might be like this: If this is the case, we don't actually need MAC addresses, because each network card clearly corresponds to a host. But the reality is that it costs more money to configure so many network cards on a computer, and you don't want to buy a dozen network cards after buying a computer. Therefore, it will be more convenient if we use a hub to gather all computers together through network cables. Before sending data, each host needs to carry its own and the other party's destination MAC address, because the hub only sends all data out from other interfaces, and it leaves it to the host to decide whether to receive the data. The hub just mindlessly sends data, so we consider it a data link layer device. The hub is too stupid. It sends every communication to all hosts. When there is frequent communication between hosts, it will cause network congestion or even paralysis. Therefore, we upgraded and used switch equipment. The switch maintains a MAC address table inside, recording the relationship between the MAC address and each port of the switch, so that all data does not need to be sent to the LAN. The MAC address table of the switch can be seen through Cisco's Cisco packet tracer simulation software. In this way, when pc0 (192.168.1) pings pc3 (192.168.4), the switch checks its own MAC table and finds that the exit of its Ethernet fa0/4 interface corresponds to the destination host MAC address, so the switch forwards its data packet out of the fa0/4 interface. At the same time, pc3 receives the data packet from pc0. Compared with a hub, a switch has the function of deciding which port the data is forwarded from, so we believe that the switch is at the data link layer (deciding which link the data is forwarded to). The above hubs and switches are all LAN-accessible, without the involvement of IP addresses. However, as the network expands, LAN rules are no longer suitable. Many LANs like the above form a large Internet. They are connected and communicate with each other. If you want to access the data shared by a research institution within the school network, this is cross-network access. At this time, the IP address comes in handy. The IP address gives a series of hierarchical digital addresses. It is like a mind map that can efficiently find the item we want through a given address. When a network is connected to the Internet, it is assigned an IP address, so that the location of the other network (or device) in the Internet can be determined through these IP addresses, so that it can be accessed. A device with an IP address connected to the Internet can be a single device, such as a server, a network camera, etc., or it can be a local area network, such as a school campus network, a company's internal network, etc. (the local area network and the public network communicate using NAT, PAT, etc., or intranet penetration and other technologies). In order to achieve cross-segment access in the network, a new device called a router was born. It can decide which network to forward the data packet to based on the built-in routing entries, and finally reach the destination network. It should be noted that the router is the middleman between multiple networks. It has many ports that are located in different networks (each port of the router has an independent MAC address and IP address), so it can "forward information from network A to network B because the router's interface is connected to these networks at the same time." Routers allow data to communicate across networks, so we consider routers to be devices at the network layer. Finally, we have figured out the relationship between IP and MAC. To summarize:
|
<<: Meituan second interview: TCP's four waves, can it be reduced to three?
>>: How 5G will change engineering design
DediPath has released its latest summer promotion...
While the Internet of Things is changing people’s...
The ubiquitous wireless technology Wi-Fi has beco...
spinservers is a site under Majestic Hosting Solu...
[[182056]] Recently, the news that "Huawei...
The world is moving towards a more connected futu...
"Connected World: Smart Homes Are Key to Fut...
Tribes often share information about CloudCone, m...
[[182609]] The first 560Tb/s ultra-large capacity...
[[311931]] This article will explain the followin...
I'm afraid everyone is familiar with Wi-Fi, a...
At the Huawei Developer Conference on September 1...
If the elderly are the ones abandoned by the Inte...
In 2020, the sudden outbreak of COVID-19 is havin...
On December 3, the highly anticipated 2019 Micros...