cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2740
Views
0
Helpful
3
Replies

Need for "Total Length" in IP header

Hi,

   IP header has two fields IHL and Total length. Below is the reason I found for having both these fields instead of one.

 

"The Total Length field is required in the header because some lower-layer protocols that carry IPv4 datagrams do not(accurately) convey the size of encapsulated datagrams on their own. Ethernet,

for example, pads small frames to be a minimum length (64 bytes). Even though

the minimum Ethernet payload size is 46 bytes (see Chapter 3), an IPv4 datagram

can be smaller (as few as 20 bytes). If the Total Length  field were not provided, the

IPv4 implementation would not know how much of a 46-byte Ethernet frame was

really an IP datagram, as opposed to padding, leading to possible confusion."

 

I am not clear with this explanation because it can still find out the end of IP header just by using IHL. Starting from 0th byte in datagram to Xth byte(value in IHL) is all ip header. We dont need Total Length for this. Is this correct? Can someone please throw some light on this?

 

Thanks

3 Replies 3

Giuseppe Larosa
Hall of Fame
Hall of Fame

Hello,

the total length field refers to the size of the IP packet not to the size of the IPv4 header only.

IP size = IPv4 header + payload

 

>> I am not clear with this explanation because it can still find out the end of IP header just by using IHL. Starting from 0th byte in datagram to Xth byte(value in IHL) is all ip header. We dont need Total Length for this. Is this correct? Can someone please throw some light on this?

 

As explained above, one thing is the IPv4 header size (default 20 bytes expressed as a 5 can be greater if using IP options) another thing is the total size of the packet that is how long is the packet header + payload.

 

There are cases where the total packet size does not fit the the ethernet minimum size of 64 bytes if the total size is less then 46 bytes and so the total packet size allow to discard the last padding bytes from the received frame.

 

Hope to help

Giuseppe

 

Hi Giuseppe.. Let us assume IHL is 5 which means 20 bytes, whereas Total length is 120 bytes. From IHL, we can find out where IP header ends ie starting from 1st byte of IP header to 20th byte. Where do you use Total Length here. why do you need to worry about padding and ethernet min size. 

Hello Balajee,

we need to know how long is the IPv4 packet to be able to check the packet size with the stated total packet length.

See this as a check the router or IP host performs to verify that the packet is not truncated.

 

It is useful for all possible packet sizes not only for IP packets so small that they require padding  at OSI layer 2 level.

 

Hope to help

Giuseppe

 

Review Cisco Networking for a $25 gift card