Computer network summary two UDP

A UDP packet format

Insert picture description here
UDP datagram is divided into header and user data part

Two difference from TCP

  1. UDP provides best-effort delivery and does not guarantee reliable delivery. All work to maintain transmission reliability requires users to complete at the application layer. There is no TCP confirmation mechanism or retransmission mechanism.
  2. UDP is message-oriented. For the messages handed down by the application layer, the header is added and delivered directly to the IP layer. It neither merges nor splits, and retains the boundaries of these messages. The UDP user datagram delivered to the IP layer is delivered to the upper application process intact after the header is removed. The message is indivisible and is the smallest unit of UDP datagram processing.

Three largest transmission unit

Since the largest data frame of Ethernet II is 1518Bytes, the frame header of the Ethernet frame is removed (DMAC destination MAC address 48bits=6Bytes+SMAC source MAC address 48bits=6Bytes+Type domain 2Bytes) 14Bytes and the CRC check part at the end of the frame 4Bytes Then the place where the upper layer protocol is carried is that the Data field can only have a value of 1500 Bytes at the maximum. We call it MTU (Maximum Transmission Unit).

The size of the UDP packet should be 1500-IP header (20)-UDP header (8) = 1472 (Bytes)
The size of TCP packet should be 1500-IP header (20)-TCP header (20) = 1460 (Bytes)

If the TCP and UDP packets we define do not exceed the range, then our packets do not need to be sub-packaged at the IP layer, so that errors in packet grouping at the IP layer are avoided during transmission; if they exceed the range, the IP datagram is larger than 1500 bytes, the sender's IP layer needs to divide the data packet into several pieces, and the receiver's IP layer needs to reorganize the datagram. More seriously, if the UDP protocol is used, when an error occurs in the IP layer grouping of packets, the packet will be discarded. The receiver's inability to reassemble the datagram will cause the entire IP datagram to be discarded. UDP does not guarantee reliable transmission; however, when a packet group error occurs in TCP, the packet will be retransmitted to ensure reliable transmission.

Guess you like

Origin blog.csdn.net/GreedySnaker/article/details/114838690
Recommended