Since the TCP header doesn't indicate the length of the packet, how does the underlying IP layer in the transmitter know the length of a TCP packet, and in the receiver, how does the TCP layer know the length of the received packet? Does TCP exchange such information with IP as additional information?

Although TCP is a streaming protocol, the data is sent in segments whose length could be any value between 1 and the maximum segment size. IP needs to know this length information for encapsulation. Should TCP tell IP the length? In the receiver, the length information is abandoned after IP deencapsulation. Does IP pass it to TCP (length=total length-IP header length)?

  • 1
    What you are asking about is really up to the specific implementation (OS). The RFC for TCP really just states: "Any lower level protocol will have to provide the source address, destination address, and protocol fields, and some way to determine the 'TCP length', both to provide the functional equivalent service of IP and to be used in the TCP checksum." There are also parts discussing providing buffer pointers and buffer length. – Ron Maupin Sep 26 '16 at 20:04
  • I was wondering if I'd missed something in the protocol which defines the methodology to find out such length information. As it is up to the implementation how to solve this issue, it's much more flexible than I've expected. Thank you for the confirmation. – fiedel Sep 27 '16 at 1:52

In general communication standards only discuss stuff that is visible to other hosts on the network. API standards usually only discuss the interface between the OS and applications.

It is clearly nessacery to pass some metadata (size, addresses etc) between the "transport" and "internet" layers but how exactly this is done is an implementation detail.

| improve this answer | |
  • Using of size and address is straightforward and effective. Thank you. – fiedel Sep 27 '16 at 1:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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