Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Headers of IPv4 datagrams feature a field called total length coded on 16 bits. As there already is information about the header length of the datagram, having the total length seems redundant: it can be computed by substracting the header length from the total length of the data passed from the link layer.

Is that field really necessary?

share|improve this question

closed as not constructive by growse, mdpc, Jenny D, Magellan, petrus May 18 '13 at 21:06

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

    
How is a question regarding a design decision taken 40 years ago, 'practical' within the meaning of our faq? –  Iain May 18 '13 at 10:43
    
IPv4 might have been designed 40 years ago, it is still quite used today, and new devices capable of connecting to networks are created every year. If this field could be ignored, it would be useful to do so. –  qdii May 18 '13 at 10:47
    
It can't be ignored - lots of people are almost certainly checking it, since checking it is faster than subtracting the header length from the total length of the link layer. –  Cian May 18 '13 at 10:49
2  
Yes but how is knowing why useful in a practical manner from an administration point of view ? ie why is this topical for Server Fault ? –  Iain May 18 '13 at 10:50
    
@lain I see, I think I understand the purpose of server fault better now. I will delete the question. –  qdii May 18 '13 at 10:53

2 Answers 2

The short answer is yes - the IPv4 spec says its necessary, and so it is, at least for compatibility purposes.

The long answer is that some layer 2 transports will pad a datagram if it's under a particular size. the IP length header is important when this occurs, so that the layer two padding can be discarded.

share|improve this answer
    
Yikes: I totally forgot about padding. It also happens usually on odd-sized packets as most L2 protocols require an even-size packet. –  Tonny May 18 '13 at 10:54

This is probably an off-topic question, but I clearly remember asking the same question some 25 years ago in university when we discussed TCP/IP in networking 101.

The 2 answers I got then and which still makes sense where:

"At the time TCP/IP v4 was designed it was far from certain there wouldn't be an extension to IPv4 in the future that would make it more useful. So they left this in as an opening to future changes."

"If the software processing the TCP-IP packets has no knowledge of the L2 aspects of the data-transfer if needs a method to find the size. Either you put it in the packet or you provide a separate argument to the software that specifies the length. So you just might as well put it in the header in the first place."

(To illustrate the last: You mention this yourself in the question: "The total length of the data passed from the link layer" is the addiitonal argument.)

share|improve this answer

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