Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The size of the UDP packet

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

The problem comes from the log information, which is summarized here, and new content will be added later.

In the link layer, the physical characteristics of Ethernet determine the length of the data frame is (46mm 18)-- (1500mm 18), in which 18 is the head and tail 18Bytes of the link layer, that is to say, the maximum content of the data frame is 1500 (excluding the header and trailer). In fact, this 1500 is the length limit of the IP Datagram in the network layer, that is, MTU (Maximum Transmission Unit) is 1500;

In the network layer, because the header of the IP packet takes up 20 bytes, the MTU here is 150020 bytes 1480. This 1480 is used to store the TCP message segment from TCP or the UDP Datagram from UDP.

At the transport layer, the header of the UDP packet takes 8 bytes, so the MTU here is 1480 broadcast 1472, which is what the user can use.

So, at the application layer, the maximum length of your Data is 1472. (when there is more data in our UDP packet than MTU (1472), the sender's IP layer needs sharded fragmentation for transmission, while at the receiver's IP layer, Datagram reorganization is needed. Because UDP is an unreliable transport protocol, if the reassembly fails due to fragmentation loss, the UDP packet will be discarded.

Therefore, in the ordinary local area network environment, when using UDP transmission, it is recommended that the data of UDP should be controlled below 1472.

The maximum length of an IP packet is 65535, because 2 bytes are used to describe the length of the message in the IP header, and the size represented by 2 bytes is 65535

In terms of specific functions:

When sending with UDP protocol, the maximum length of data that can be sent by sendto function is: 65535-IP header (20)-UDP header (8) = 65507 bytes. When sending data with the sendto function, if the length of the sent data is greater than this value, the function returns an error.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report