Take the 2-minute tour ×
Network Engineering Stack Exchange is a question and answer site for network engineers. It's 100% free, no registration required.

IPv4 Header


I know the IP header length is a minimum of 20 bytes and a maximum of 60 bytes. But why? Why is the IP header length limited to 60 bytes? Is there anybody here that can explain it to me? Thank you.

share|improve this question

2 Answers 2

The Internet Protocol (IP) is defined in RFC 791. The RFC specifies the format of the IP header. In the header there is the IHL (Internet Header Length) field which is 4 bits long and specifies the header length in 32 bit words. The IHL field can hold values from 0 (Binary 0000) to 15 (Binary 1111).

So the longest Internet Header (IP header) size can be 15*32 Bits = 480 Bits = 60 Bytes. This is why the header has a maximum size of 60 Bytes.

The shortest header size is 20 bytes, where the IHL field has the value 5 (0101). This is because all the required fields in the header need 20 Bytes of space. So while in theory you could set the IHL to a value < 5 this would always be an incorrect value and thus an invalid packet header.

share|improve this answer
    
Thanks a lot Sebastian. This is the answer i was looking for. Now i understood exactly. So my analogy was correct also. :) –  ebyrock Mar 17 at 14:43
    
But the shortest value would be 5 because its defined in RFC 791? So it can't be set to 0 (0000)? –  ebyrock Mar 17 at 14:50
    
It can be set to 0 but it would be invalid. –  Sebastian Mar 17 at 15:14
    
Min of 5 dwords (20 bytes) because those are the required parts of the header. There may be zero or more options, thus 20 to 60 bytes. –  Ricky Beam Mar 17 at 19:10
    
I added the explanation for the minimum size to make it complete. –  Sebastian Mar 18 at 8:47

Per RFC 791 where it is defined, see page 12 where it discusses datagrams:

Total Length is the length of the datagram, measured in octets, including internet header and data. This field allows the length of a datagram to be up to 65,535 octets. Such long datagrams are impractical for most hosts and networks. All hosts must be prepared to accept datagrams of up to 576 octets (whether they arrive whole or in fragments). It is recommended that hosts only send datagrams larger than 576 octets if they have assurance that the destination is prepared to accept the larger datagrams.

The number 576 is selected to allow a reasonable sized data block to be transmitted in addition to the required header information. For example, this size allows a data block of 512 octets plus 64 header octets to fit in a datagram. The maximal internet header is 60 octets, and a typical internet header is 20 octets, allowing a margin for headers of higher level protocols."

Basically the length was defined between 20 and 60 to allow for different protocol uses and to fit in the recommended datagram size.

share|improve this answer
1  
Thanks Mike again but i don't quite get it. In you response it says that "The maximal internet header is 60 octets" but doesn't explain why? I inserted a pic to my question. The size of the IP header is defined in the IHL (Internet Header Length) which is in 4-7 bits and that means its 4 bits long. if we set all the bits are 1 in Base2 (1111) that would be 15 in Base10. And the the Internet header length is 32 bit words. We multiply 15 x 32 = 480 bits which is equal to 60 bytes (480/8). I am not sure it is a correct analogy. :( –  ebyrock Mar 17 at 14:07
    
Not trying to be short but the 'why' is: this is how it is defined. All internet protocols have definitions. These definitions are the standards which all internet traffic protocols follow. –  Mike Naylor Mar 17 at 14:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.