8. Link layer Ethernet protocol, ARP protocol 32

The network layer IP protocol describes the start point to the end point in the communication, but the data does not fly over, but is forwarded by a large number of intermediate nodes.

1. Ethernet protocol

1. MAC address

The physical hardware address is the address set by each network card when it leaves the factory. It is fixed and cannot be modified (in the early days, it can be modified now but it is not necessary)

48-bit peer & 48-bit source MAC address: describes two adjacent specified physical hardware devices

16-bit upper layer protocol: describes the protocol used by the data in the Ethernet frame, and is used for protocol selection when data sharing

32-bit data frame tail: contains checksum

 2. ARP protocol

A protocol between the link layer and the network layer, the function is to obtain the mac address of the specified device through the IP address

  1. Broadcast ARP request: Set the destination MAC address to all 1s (broadcast address), which contains its own IP and MAC address, as well as the IP address of the specified device
  2. The host receiving the ARP request will verify whether the target IP address is consistent with itself. If it is not consistent, it will be discarded. If it is consistent, it will organize the ARP response to fill in its own MAC address to reply

3. ARP spoofing attack

There is a malicious host in the LAN, which continuously sends a large number of ARP responses to each host in the LAN, overwrites the information in the ARP mapping table on the host, tells the host that it is a gateway, and then sends ARP responses to the gateway that it is a host. (Set firewall, mac whitelist in LAN)

4. MTU link layer limit maximum transmission unit: Ethernet default is 1500

Impact on upper layer protocols:

4.1tcp

MSS - the maximum data segment size, which is calculated based on the MTU. When tcp sends data at the transport layer, it takes out a data encapsulation header that is not larger than the MSS size from the buffer for transmission. (When tcp transmits data, there will be no data fragmentation at the network layer)

MSS = MTU - Minimum IP Header - Minimum TCP Header Size

4.2udp

There is no MSS negotiation, as long as the size of the data is less than 64k after encapsulating the header, it can be sent. However, if the IP header is encapsulated at the network layer, it will be fragmented if it is larger than the MTU. However, once the data is fragmented at the network layer, on the peer host The network layer needs to be fragmented and reorganized (what data is handed over to the network layer by the source transport layer, and what data is handed over to the transport layer by the peer network layer)

However, once a fragment is lost during the transmission process, fragment reassembly will fail, and the entire message will be discarded (udp does not guarantee reliable transmission - lost is gone). This means that the more fragments, the greater the transmission risk
. big

 

Therefore, our programmers usually don’t need to manage tcp communication, but when it comes to udp communication, programmers should consider more factors at the application layer, that is, if the data is large, it should be at the application layer. It is necessary to consider the MTU and reduce the possibility of fragmentation as much as possible.

Guess you like

Origin blog.csdn.net/weixin_56316833/article/details/131756591