One of the most interesting aspects of TCP is that data get transferred as Segments from the TCP layer. Yeah! I know you will then ask me you told data to get transferred as packets right? How come you say segment now.DThe difference between segment and packet?
Segment = Transport Layer = Transport Header + Data
Packet = IP Header + Transport Layer = IP Header + (Transport Header + Data)
At each layer the data is getting encapsulated!
What is Segments do? What are the different roles Segment has?
The segment can be called as the “Jack of all Trades” messages – they are flexible and serve a variety of purposes. A single field format is used for all segments, with a number of header fields that implement the many functions and features for which TCP is responsible. One of the most notable characteristics of TCP segments is that they are designed to carry both control information and data simultaneously. This reduces the number of segments sent since they can perform more than one function.
What are the functionalities offered by headers?
In basic these are the functionalities:
- Process Addressing
- Sliding Window (Catch me up in the next post to learn about Sliding Window)
- Control Bits and Fields
Look the Below table for better Understanding.
|Source Port||2||Specifies the 16-bit source port number|
|Destination Port||2||Specifies the 16-bit destination port number|
|Sequence Number||4||Helps in ordering the packets|
|Acknowledgement Number||4||Helps in establishing the connection|
|Data Offset||1/2||Specifies the number of 32-bit words of data in the TCP header.|
|Reserved||3/4||6bits reserved for future|
|Control Bits||3/4||Explained Below *|
|Window||2||Indicate the number of octets of data the sender is willing to accept while receiving the ack no.|
|Urgent Pointer||2||Used in conjunction with URG control bit for priority data transfer|
|Options||Variable||Generic method to add one or more optional sets of data/|
|Data||Variable||The data to be transferred.|
Control Bits * : These are the bits set to inform the communication in TCP.
|URG||1||When set 1 indicates Priority data transfer.|
|ACK||1||When set to 1 to the sender is carrying Ack no|
|PSH||1||Enables the Push feature.|
|RST||1||The sender has encountered a problem and reset the connection.|
|SYN||1||The synchronization bit is used to request Sequence numbers and establish a connection.|
|FIN||1||The Finish Bit is used for closing the connection|
Well, this is it with TCP Segment and if you have any queries post here and I would reply.
To see the changes in the code with Segment check my Github!