cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2749
Views
5
Helpful
4
Replies

Transport and Application Layer Relationship Via Segmentation

Hi !

i have a question and i didnt know in which section i can ask that .

i understand the application layer data goes to the transport layer . and there it is being segmented into "segments" .

if it really being segmented , sliced , then it should be stored somewhere , not ?

when a request for a specific retransmit of a segment is arriving - where does the tcp takes that segment from ? from memory ?

so does that memory has the complete data and the transport layer simply have a description of "from a-c thats segment 1" "from d-e thats segment 2" ?

or all the segments are really being stored "sliced" somewhere ?

i feel funny asking this but it poped up and it sound interesting ,

hope my question is understandable

1 Accepted Solution

Accepted Solutions

Peter Paluch
Cisco Employee
Cisco Employee

Hello,

You are basically asking about how the TCP or UDP is implemented in an operating system. There are no standards for that, just best practices that evolved over the years.

When your application want to communicate over network with a server using TCP, for example, it first needs to open a socket. The socket represents an endpoint of a communication, and it is your object you are using in your application to talk to the other party. Under C, the socket is a file description, very similar to an open file. If you want to talk to other endpoint, you write some data to the socket, and if you want to see what data the other party sent you, you read from the socket.

As soon as you write a certain amount of data to the socket, it is taken by your operating system. It copies the data from your program (so-called userspace) into the internal buffers maintained by your operating system's kernel (so-called kernelspace). Note that as soon as the data is copied from the userspace to the kernelspace, the kernel has its own copy of the data you wanted to transfer to the other side, and can chop it, segment it, encapsulate it according to its wishes, without modifying the original data in your userspace program. That does not mean, however, that the copied data must be modified - read further.

So in the kernelspace, after you called the write() function, the amount of data you have written into the socket is segmented, encapsulated and sent along its way. If an unreliable transport protocol is used then the segments are deallocated from the kernelspace immediately after sending. If a reliable transport protocol is used then the segments are deallocated only after a successful acknowledgement from the other side. So the buffering does take place, yes, and it is in a part of memory that is maintained by your kernel for its internal usage.

so does that memory has the  complete data and the transport layer simply have a description of "from  a-c thats segment 1" "from d-e thats segment 2" ?

or all the segments are really being stored "sliced" somewhere ?

This is an implementation-specific question. This depends on how well your TCP/IP driver is written and what is more effective for the particular operating system. In general, however, it is more effective to store the original piece of data unmodified, and instead, have only a set of pointers that point to the specific offsets where the piece of data should be split and separately encapsulated. This way, it is easy to adapt to changing TCP window size, for example. If you already split and encapsulated data, and the TCP window size changed, you would need to defragment the data and repackage them which would be very inefficient.

Best regards,

Peter

View solution in original post

4 Replies 4

Peter Paluch
Cisco Employee
Cisco Employee

Hello,

You are basically asking about how the TCP or UDP is implemented in an operating system. There are no standards for that, just best practices that evolved over the years.

When your application want to communicate over network with a server using TCP, for example, it first needs to open a socket. The socket represents an endpoint of a communication, and it is your object you are using in your application to talk to the other party. Under C, the socket is a file description, very similar to an open file. If you want to talk to other endpoint, you write some data to the socket, and if you want to see what data the other party sent you, you read from the socket.

As soon as you write a certain amount of data to the socket, it is taken by your operating system. It copies the data from your program (so-called userspace) into the internal buffers maintained by your operating system's kernel (so-called kernelspace). Note that as soon as the data is copied from the userspace to the kernelspace, the kernel has its own copy of the data you wanted to transfer to the other side, and can chop it, segment it, encapsulate it according to its wishes, without modifying the original data in your userspace program. That does not mean, however, that the copied data must be modified - read further.

So in the kernelspace, after you called the write() function, the amount of data you have written into the socket is segmented, encapsulated and sent along its way. If an unreliable transport protocol is used then the segments are deallocated from the kernelspace immediately after sending. If a reliable transport protocol is used then the segments are deallocated only after a successful acknowledgement from the other side. So the buffering does take place, yes, and it is in a part of memory that is maintained by your kernel for its internal usage.

so does that memory has the  complete data and the transport layer simply have a description of "from  a-c thats segment 1" "from d-e thats segment 2" ?

or all the segments are really being stored "sliced" somewhere ?

This is an implementation-specific question. This depends on how well your TCP/IP driver is written and what is more effective for the particular operating system. In general, however, it is more effective to store the original piece of data unmodified, and instead, have only a set of pointers that point to the specific offsets where the piece of data should be split and separately encapsulated. This way, it is easy to adapt to changing TCP window size, for example. If you already split and encapsulated data, and the TCP window size changed, you would need to defragment the data and repackage them which would be very inefficient.

Best regards,

Peter

Peter ,Hallelujah !!

Thats all i can say

Thanks for the thorough answer !

it was a pleasure receiving it even more then it was interesting to ask it

Richard Burts
Hall of Fame
Hall of Fame

Peter

Very excellent response. +5 for this.

HTH

Rick

Sent from Cisco Technical Support iPhone App

HTH

Rick

Hello Rick,

Thank you very much - I am honored!

Best regards,

Peter

Review Cisco Networking for a $25 gift card