开发者

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 c开发者_开发问答omputers 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.


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).


I found the following which may be of interest:

  • Determine the maximum size of a UDP datagram packet on Linux
  • Set the DF bit in the IP header and send continually larger packets to determine at what point a packet is fragmented as per Path MTU Discovery. Packet fragmentation should then result in a ICMP type 3 packet with code 4 indicating that the packet was too large to be sent without being fragmented.

Dan's answer is useful but note that after headers you're really limited to 65507 bytes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜