tags:

views:

63

answers:

3

A bit of background.

I'm writing an application that uses UDP. The application will run on a LAN (not internet). I've been assuming that if my MTU is 1500 then thats how big a UDP payload can be, but I'm not sure if the UDP header is meant to fit within that too.

I'm suspecting that if I send a UDP packet with a 1500 byte payload and the machine MTU is 1500 bytes will it end up sending two packets?

Searching the internet for a clear answer here seems harder than it should be, I've seen conflicting information.

+2  A: 

Maybe this article helps: http://sd.wareonearth.com/~phil/net/overhead/

Lucero
Thanks, a very useful link. The throughput rates for gig-e are useful. I'm achieving 760GB/s on non-server hardware so I think thats not too bad. But, if I set my packet data correctly it may improve.
Matt H
+5  A: 
------------------------------------------------------------------------------
|Ethernet  | IPv4         |UDP    | Data                   |Ethernet checksum|
------------------------------------------------------------------------------
  14 bytes    20 bytes     8 bytes    x bytes                4 bytes
           \ (w/o options)                               /
            \___________________________________________/
                              |
                             MTU

If your MTU is 1500, you have 1500-20-8 = 1472 bytes for your data.

  • If you exceed that, the packets will be fragmented ,i.e. split into more packets.
  • There might be more layers involved, e.g. 4 byte a vlan header if you're on top of a vlan ethernet.
  • Some routers inbetween you and the destination might add more layers.
nos
AFAIK the MTU does NOT include the Ethernet header and the trailing CRC32 (which you omitted), but is the effective Ethernet payload, where you have to subtract the IP protocol overhead.
Lucero
Thanks, thats what I suspected but wasn't certain.
Matt H
@Lucero Yes, you might be right, depending on which layer you define the MTU as. MTU of an IP datagram in this case I guess.
nos
@nos: The MTU for Ethernet is the one we're talking about, so there is little speculation to which layer it applies.
Lucero
Notable extra layer is subnetting, 8 bytes for 802.2 SNAP LLC.
Steve-o
+1  A: 

Yes your example would not fit in one frame.

The ethernet data payload is 1500 bytes. IPv4 requires a minimum of 20 bytes for its header. Alternatively IPv6 requires a minimum of 40 bytes. UDP requires 8 bytes for its header. That leaves 1472 bytes (ipv4) or 1452 (ipv6) for your data.

More information:

teambob