Each Ethernet device has a unique MAC address at the factory. Why do I need to assign an IP address to each host? In other words, each host is assigned a unique IP address. Why should we embed a unique MAC address in the production of network devices (such as network adapters, hubs, routers, etc?
The main reasons are as follows:
(1) IP Address allocation is based on the topological structure of the network, rather than on who made network settings. If an efficient routing solution is built on the device manufacturer rather than the network topology, this solution is not feasible.
(2) When there is an additional layer of address addressing, the device is easier to move and maintain. For example, if an Ethernet Card is broken, it can be replaced without getting a new IP address. If an IP host is moved from one network to another, you can give it a new IP address instead of a new Nic.
(3) convenient data transmission. Communication between computers in the LAN or Wide Area Network eventually means that data packets are transmitted from one node to another from the initial node on a certain form of link, finally transmitted to the target node. The ARP protocol is responsible for ing IP addresses to MAC addresses for packet movement between these nodes.
An example of how IP addresses and MAC addresses are combined to send data packets:
Assume that A data packet (named PAC) is sent from A host in Beijing (named A, IP address IP_A, and MAC address MAC_A) on the network) A host sent to Washington (Name: B, IP Address: IP_ B, MAC address: MAC_ B ). The two hosts cannot be directly connected. Therefore, data packets must pass through many intermediate nodes (such as routers and servers) during transmission ), we assume that during transmission, C1, C2, and C3 (their MAC addresses are M1, M2, and M3 respectively) are required.
Before sending a pac, A sends an ARP request to find the MAC address M1 of C1, the first intermediate node that must be passed to IP_ B, then encapsulate these addresses in the data packet: IP_A, IP_ B, MAC_A, and M1.
After a PAC is transferred to C1, ARP finds the MAC address M2 of the second intermediate node C2 Based on the IP address IP_ B, then, the data packet with M2 is sent to C2.
And so on, until the MAC_ B address of host B with the IP address IP_ B is found, and finally sent to host B.
During transmission, IP_A, IP_ B, and MAC_A remain unchanged, while the MAC address of the intermediate node is constantly changing through ARP (M1, M2, M3) until the target address is MAC_ B.
Blog: http://blog.csdn.net/ghnbvfrtyujm/article/details/12013451