Previous article I described how a simple data packet is forwarded on the LAN, a quick review process:
- Host encapsulated data packet, which contains
请求体
,源IP
,目标IP
and源MAC地址
other information. - After the packet switch, the switch sends the packet to the router to parse.
- The packet router
目标IP
with routing table subnet mask逻辑与
operation to obtain the target segment, and forwards the target segment matches the gateway router.
I said at the end of the article, if the switch has been recorded in the mapping of all the devices on your LAN, then the message will not be forwarded through a router, then the switch is how to do it? We come to know a protocol -ARP协议
What is the ARP protocol
First, ARP协议
the three-tier network protocol, which is based on the network protocol layer. In the network layer protocol, the data packets will only focus IP地址
and MAC地址
information, LVS
in fact, is based on a three-layer network protocol (actually a pseudo-three, because the handshake LVS will peeping packets).
Vernacular terms, ARP
the agreement is used to broadcast a unified LAN segment of the machine IP
and MAC
information.
Workflow ARP protocol
Or in the previous local area network topology as an example:
If the host 10
wants and 11
communicate, go through the following steps:
- Create an ARP protocol format packets, packet destination MAC address is all F, IP-11 target.
- Message to the switch, which is found in a packet of ARP protocol, this message will be broadcast through the port own records.
- 11 and 12 both hosts receives the ARP packet, finding the target 12 with its own local IP IP do not match, the packet will be discarded; 11 findings are consistent with the local IP, own MAC address is encapsulated into packets of the protocol ARP message, is sent to the switch.
- 10 host receiving the packet, the MAC address 11 of the cache to the local ARP list.
It is noted that, in the third step, the host 11
will be its own MAC address encapsulated ARP packets, is actually a the original packet process of being replaced, as follows:
switch the communication of these messages a second to go in process, keep track of their relationships with the connected port mapping host:
for example on connection of the switch of FIG. 3 hosts, corresponding 1,5,7 port respectively. The first host sends packets through the switch time, MAC address, switch port corresponding to the host will be recorded, so the communication times, the switch can be provided inside the respective ability to inform the host node outward path. Since only records the switch MAC address, all switches are Layer 2 protocol devices.
Next article we will enter the Internet communications, the Internet proved how two hosts are communicating and introduces NAT
, DR
, TUN
and other knowledge.