Why do we need "total length" field in ipv4 datagram?

  • MHB
  • Thread starter shivajikobardan
  • Start date
  • Tags
    Field Length
In summary: Essentially, the total length field in an IPv4 datagram helps with the reassembly process when a datagram is fragmented into smaller pieces for transmission. It allows the receiving machine to know the total size of the original datagram and how to reassemble it correctly.
  • #1
shivajikobardan
674
54
TBH I don't really understand the question that I am asking myself.
I was inspired asking this from my textbook "Do you know".
Can you make me understand why would not we require total length field?

Here's a similar question-:

https://serverfault.com/questions/508866/why-is-there-a-total-length-field-in-the-ipv4-header

references-: http://units.folder101.com/cisco/sem1/Notes/ch2-osi/osi.htm

I will write the answer that my book says(please explain this, i understand little bit of this vaguely)-:
in many cases, we really don't need the value of this field. however, there are occasions in which the datagram is not the only thing encapsulated in a frame, it may be that padding has been added. eg the ethernet protocol has a minimium and maximum restriction on the size of data that can be encapsulated in a frame(46-1500 bytes). If the size of an IP datagram is less than 46 bytes, some padding will be added to meet this requirement. In this case, when a machine decapsulates the datagram, it needs to check the total length field to determine how much is data and how much is padding.

Is there some visual ways to understand this? I feel like understanding this will clear lots of my basics of networking (about TCP/IP model and how it works even tho I have already studied about it.)
 
Technology news on Phys.org
  • #2
Why do we need the total length field in an IPv4 datagram?
The answer is shown in the text you quoted; namely, that sometimes padding bytes have to be added.
shivajikobardan said:
however, there are occasions in which the datagram is not the only thing encapsulated in a frame, it may be that padding has been added.
Here's a link to a wikipedia article that might help clear things up for you: https://en.wikipedia.org/wiki/IPv4
The sections titled "Fragmentation" and "Reassembly" might be helpful.
 
  • Informative
Likes anorlunda

1. Why is the "total length" field necessary in an IPv4 datagram?

The "total length" field in an IPv4 datagram is necessary because it specifies the total size of the entire datagram in bytes. This includes the header and data sections. Without this field, the receiving device would not know the size of the datagram and would not be able to properly reassemble it.

2. How is the "total length" field calculated in an IPv4 datagram?

The "total length" field is calculated by adding the size of the header (20 bytes) to the size of the data section. The maximum size for this field is 65,535 bytes, which is the maximum size of an IPv4 datagram.

3. What happens if the "total length" field is smaller than the actual size of the datagram?

If the "total length" field is smaller than the actual size of the datagram, the receiving device will discard the datagram as it is considered to be corrupted. This can happen if the sender incorrectly calculates the size or if the datagram is modified during transmission.

4. Can the "total length" field be larger than the actual size of the datagram?

No, the "total length" field cannot be larger than the actual size of the datagram. If the field is larger, it will be considered an invalid datagram and will be discarded by the receiving device.

5. Why is the "total length" field a 16-bit value in an IPv4 datagram?

The "total length" field is a 16-bit value because it allows for a maximum size of 65,535 bytes. This was deemed to be a sufficient size for most datagrams when the IPv4 protocol was designed. If larger datagrams are needed, the IPv6 protocol with a 32-bit "total length" field can be used.

Similar threads

  • Programming and Computer Science
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
8
Views
1K
Replies
10
Views
2K
  • Special and General Relativity
Replies
11
Views
3K
  • Calculus and Beyond Homework Help
Replies
5
Views
3K
Back
Top