UDP maximum message length

Ethernet UDP maximum message length

UDP packet length for transmission in the Ethernet environment problems in

  first look at the TCP / IP protocol, involving four: a link layer, network layer, transport layer and application layer.

  Wherein the Ethernet (Ethernet) frames of data link layer

  IP packets at the network layer,

  TCP or UDP in the transport layer packet

  of data in the TCP or UDP (Data) in the application layer

  thereof relationship data frame {{TCP or UDP packet IP {Data}}} package

  in the application we use the maximum length is the number of Data is directly determined by the limitations of the underlying.

  We analyzed from the lower to about:

  the link layer, determined by the physical characteristics of the Ethernet length of the data frame (46 + 18) - (1500 + 18), where 18 is the head and end of the data frame, that data frame content of at most 1500, i.e., MTU (maximum transmission unit) 1500;

  the network layer because the IP header of a packet takes up 20 bytes, so that the MTU of 1500-20 = 1480;

  at the transport layer, for the UDP packet to header occupies 8 bytes, so that the MTU of 1480-8 = 1472;

  thus, in the application layer, the maximum length of your Data 1472.

  (When we UDP data packet than MTU (1472), IP layer of the sender needs to transmit fragmented fragmentation at the receiving side of the IP layer datagrams required reorganization, since UDP is an unreliable transport protocol If fragmentation results in recombination loss failure will cause the UDP packet is discarded).

  From the above analysis, under ordinary LAN environment, UDP data maximum (recombinant avoid fragmentation) is preferably 1472 bytes.

  However, in network programming, the Internet router may have a different set of values (values less than the default), the standard value of 576 MTU on the Internet, the Internet UDP program data length is preferably 576-20-8 = 548 bytes or less.

  MTU is very important for our UDP programming, then how to view routing MTU value of it?

  For windows OS: ping -f -l <data_length > <gateway_IP>

  such as: ping -f -l 1472 192.168.0.1

  If Tip: Packets needs to be fragmented but DF set.

  Indicates MTU less than 1500, the continuous improvement and data_length value, you can finally measure the MTU value of the gateway;

  for linux OS: ping -c <number> -M do -s <data_length> <gateway_IP>

  such as: ping -c 1 -M do -s 1472 192.168.0.1

  if prompted Frag needed and DF set ......

  indicates MTU less than 1500, can be measured again to calculate the MTU Gateway.

  Of course you want to modify the MTU value, and that is something the network (which most people do not privilege it), we can only wait for the application plus ^ - ^ 

Guess you like

Origin www.cnblogs.com/lihaodonglala/p/11074101.html