Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP) provides a logical full-duplex connection between two application processes across a datagram network with a connection-oriented, reliable, in-sequence and byte-stream service. It also provides flow control and multiple application processes in the same systems.

Before starting data communication, TCP establishes the connection between the two application processes with the help of connection records that is known as Transmission Control Block (TCB). TCP uses selective repeat ARQ to implement reliable transmission. It terminates data flow in each direction separately.

TCP doesn’t preserve the message boundaries and treats the data that gets from the application layer as a byte stream. In other words, TCP may split or combine the application information in the way it finds most appropriate for the underlying network.

Transmission Control Protocol (TCP)

The header contains 20 bytes of fixed part plus a variable size option field. Each field is described below:

1. Source Port & Destination Port: Source port and Destination port identify sending and receiving applications respectively.

2. Sequence Number: This field identifies the position of the first data byte in this segment in the sender’s byte stream during the data transfer. The sequence number wraps back to 0 after 232-1. TCP identifies the sequence number as 160 and the data part contains five bytes then the next sequence number is 165.

If the SYN bit is set to 1, the sequence number indicates Initial Sequence Number (ISN). It is used in the sender’s byte stream. The sequence number of the first data byte is ISN+1. As the TCP connection is a full duplex, each end maintains its sequence number.

3. Acknowledgement Number: This field identifies the sequence number of the next data byte that the sender expects to receive if the ACK bit is set. Once a connection is established, the ACK bit must be set.

4. Header Length: This field identifies the length of the TCP header in the unit of 32 bits. It helps in getting the beginning of the data part in the segment.

5. Reserved: This field is reserved for future use and set to 0.

6. URG: If this bit is set then urgent pointer is valid.

7. ACK: If this bit is set then acknowledgement number is valid.

8. PSH: If this bit is set then it tells the receiving TCP module to send the data immediately to the application. Otherwise, the receiving TCP module may buffer the data until it becomes full.

9. RST: If this bit is set it tells the receiving TCP module to abort the connection because of some abnormal conditions.

10. SYN: This bit requests for a connection.

11. FIN: If this bit is set it tells the receiver that the sender has no more data to send. The sender can still receive data until it gets a segment with the FIN bit set.

12. Window Size: This field specifies the number of bytes the sender is willing to accept.

13. Checksum: This field detects error in TCP segment.

14. Urgent Pointer: When the URG bit is set, this field value when added to the sequence number points to the last byte of the urgent data.

15. Options: It specifies some other information.

Example: Maximum Segment Size, Window Scale, Time Stamp etc.