Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How big is an IP packet frame including headers?

Tags:

udp

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.

like image 599
hookenz Avatar asked Oct 13 '10 23:10

hookenz


People also ask

How big is an IP packet header?

The minimum length of an IP header is 20 bytes, or five 32-bit increments. The maximum length of an IP header is 24 bytes, or six 32-bit increments. Therefore, the header length field should contain either 5 or 6.

Does packet size include header?

The size of an IP packet includes IP headers but excludes headers from the link layer. In the case of an Ethernet frame this adds an overhead of 18 bytes, or 22 bytes with an IEEE 802.1Q tag for VLAN tagging or class of service.

Is an Ethernet header always 14 bytes?

In this case, the type field has a hex value of 08 00, which means that the next embedded protocol that should be expected is IP. The length of the Ethernet header is static at 14 bytes, so we know that 00 is the last byte of the header.

How many bits is IP frame long?

IPv4 uses a 32-bit address space which provides 4,294,967,296 (232) unique addresses, but large blocks are reserved for special networking purposes.


2 Answers

------------------------------------------------------------------------------
|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.
like image 110
nos Avatar answered Nov 08 '22 08:11

nos


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:

  • http://en.wikipedia.org/wiki/Ethernet_II_framing
  • http://en.wikipedia.org/wiki/IPv4#Header
  • http://en.wikipedia.org/wiki/IPv6_packet#Fixed_header
  • http://en.wikipedia.org/wiki/User_Datagram_Protocol
like image 45
teambob Avatar answered Nov 08 '22 09:11

teambob