Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UDP IP Fragmentation and MTU

I'm trying to understand some behavior I'm seeing in the context of sending UDP packets.

I have two little Java programs: one that transmits UDP packets, and the other that receives them. I'm running them locally on my network between two computers that are connected via a single switch.

The MTU setting (reported by /sbin/ifconfig) is 1500 on both network adapters.

  • If I send packets with a size < 1500, I receive them. Expected.
  • If I send packets with 1500 < size < 24258 I receive them. Expected. I have confirmed via wireshark that the IP layer is fragmenting them.
  • If I send packets with size > 24258, they are lost. Not Expected. When I run wireshark on the receiving side, I don't see any of these packets.

I was able to see similar behavior with ping -s.

ping -s 24258 hostA works but

ping -s 24259 hostA fails.

Does anyone understand what may be happening, or have ideas of what I should be looking for?

Both computers are running CentOS 5 64-bit. I'm using a 1.6 JDK, but I don't really think it's a programming problem, it's a networking or maybe OS problem.

like image 929
wolfcastle Avatar asked Sep 14 '10 19:09

wolfcastle


People also ask

Is UDP affected by MTU?

The transport of an outbound session initiation protocol (SIP) request that exceeds the maximum transmission unit (MTU) does not switch from user datagram protocol (UDP) to transmission control protocol (TCP).

What is MTU and how fragmentation related to it?

Fragmentation is done by the network layer when the maximum size of datagram is greater than maximum size of data that can be held in a frame i.e., its Maximum Transmission Unit (MTU). The network layer divides the datagram received from the transport layer into fragments so that data flow is not disrupted.

What is the max size of a UDP packet?

A UDP datagram is carried in a single IP packet and is hence limited to a maximum payload of 65,507 bytes for IPv4 and 65,527 bytes for IPv6. The transmission of large IP packets usually requires IP fragmentation.

What happens when an IP packet gets fragmented?

IP fragmentation is an Internet Protocol (IP) process that breaks packets into smaller pieces (fragments), so that the resulting pieces can pass through a link with a smaller maximum transmission unit (MTU) than the original packet size. The fragments are reassembled by the receiving host.


1 Answers

Implementations of the IP protocol are not required to be capable of handling arbitrarily large packets. In theory, the maximum possible IP packet size is 65,535 octets, but the standard only requires that implementations support at least 576 octets.

It would appear that your host's implementation supports a maximum size much greater than 576, but still significantly smaller than the maximum theoretical size of 65,535. (I don't think the switch should be a problem, because it shouldn't need to do any defragmentation -- it's not even operating at the IP layer).

The IP standard further recommends that hosts not send packets larger than 576 bytes, unless they are certain that the receiving host can handle the larger packet size. You should maybe consider whether or not it would be better for your program to send a smaller packet size. 24,529 seems awfully large to me. I think there may be a possibility that a lot of hosts won't handle packets that large.

Note that these packet size limits are entirely separate from MTU (the maximum frame size supported by the data link layer protocol).

like image 171
Dan Moulding Avatar answered Oct 12 '22 15:10

Dan Moulding