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

  • Thread starter Thread starter shivajikobardan
  • Start date Start date
  • Tags Tags
    Field Length
AI Thread Summary
The discussion centers on the necessity of the total length field in an IPv4 datagram. It highlights that while this field may seem unnecessary in many scenarios, it becomes crucial when padding is added to meet frame size requirements, particularly in protocols like Ethernet. When an IP datagram is smaller than the minimum size allowed by the Ethernet protocol, padding is added, and the total length field helps determine the actual data size versus the padding. Understanding this concept is essential for grasping the fundamentals of networking and the TCP/IP model. Visual aids and resources, such as specific sections on fragmentation and reassembly in Wikipedia, are suggested to enhance comprehension.
shivajikobardan
Messages
637
Reaction score
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
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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top