Content

| 6.1 |  | Characteristics of Transport Layer Technologies |
| 6.1.3 |  | Transport Control Protocol |

Unlike UDP, TCP is connection-oriented. Because TCP implements packet sequencing, acknowledgment, and retransmission mechanisms at the transport layer, it is considered to be an inherently reliable protocol. These additional features at Layer 4 give TCP a larger operational overhead, which do not carry a data payload and consume bandwidth. Because of these reliability features, TCP is better suited to one-to-one communications and is rarely used for streaming and one-to-many communications. -

TCP implements two main mechanisms for maximizing reliability and efficiency. They are the three-way handshake and windowing. Understanding these technologies is important to troubleshooting network performance issues and failures.

TCP three-way handshake
The TCP three-way handshake occurs during TCP connection establishment and consists of three stages:

1. Session request (TCP SYN) – the initiating host sends a TCP synchronization packet, which has the SYN bit set on, and contains the initiating host’s own sequence number (seq = x) for the connection. This packet also contains information about the initiating hosts TCP receive-window size.
2. Session request acknowledgment (TCP SYN-ACK) – the target host responds to the packet from the initiating host by sending its own ‘synchronization acknowledgment’ packet. This packet has both the ACK and SYN bits set on, and contains the acknowledgment number generated by incrementing the sequence number from the initiating host by one (ack = x+1) plus the new sequence number from the target host (seq = y). The purpose of this packet is to inform the initiating host that the target host has received and understood the information from the initiating host and inform the initiating host of the TCP receive-window size of the target.
3. Session acknowledgment (TCP ACK) – the initiating hosts received the TCP SYN/ACK packet from the target host and responds with a session acknowledgment packet. This packet has the SYN bit set off and the ACK bit set on. The acknowledgment number in this packet is generated by incrementing the sequence number from the target host by one (ack = y + 1). The purpose of this packet is to inform the target host that the initiating host has received and understood the information sent by the target host. Once the target host has received this packet, the TCP session has been established, and reliable data exchange can begin.

A similar process is followed at TCP connection termination, ensuring full and complete transfer of data and the orderly termination of processes.

TCP sliding windows
TCP sliding window is the mechanism used to implement flow control and packet retransmission. Before discussing the operation of TCP windows, several terms should be explained:

- Transmit window – where segmented data is sequenced and buffered for transmission on a sending host.
- Receive window – where segments are buffered for re-sequencing on the receiving host.
- Segment size – The maximum size TCP will make each segment (before transmission) when processing data from higher layers.
- Acknowledgment – A packet sent from the receiving host to the sending host, acknowledging the receipt of particular packets.
- Acknowledgment trigger – An event that triggers the transmission of an acknowledgment packet on the receiving host, such as when two sequential segments are received or when a predefined window threshold is reached.
- Delayed acknowledgment timer – the amount of time a receiving host will wait for an acknowledgment trigger before sending ‘delayed acknowledgment’.
- Delayed acknowledgment – an acknowledgment packet triggered by the ‘delayed acknowledgment timer’.
- Retransmission timer – the amount of time the sending host will wait for an acknowledgment before retransmitting a packet.

Recall that TCP receive-window sizes are exchanged between hosts as part of the TCP connection establishment. When hosts in a TCP connection exchange data, they follow this process:

1. The sending host initiates the TCP connection establishment process, during which, each host transmits its own receive-window size to the other, and sets its own transmit window to the same size as the receive window of the other host.
2. TCP on the sending host processes data from higher layer protocols into segments (according to the configured segment size) and buffers them for transmission in the transmit window. Segments waiting to be put into the transmit window are buffered in the transmit buffer.
3. Segments in the transmit window are copied, and the copies are passed to the IP process for transmission. At this point, the retransmit timer for each segment is started. When passing the segments to IP, TCP tags each of them with a TCP header containing a sequence number. A copy of each packet will remain in the transmit window until an acknowledgment is received accounting for each segment.
4. The receiving host places the received segments in its receive window in sequence according to the sequence number of each segment and starts a delayed acknowledgment timer for each. When two sequential segments are received or a pre-defined window threshold is reached, the receiving host sends an acknowledgment packet for the received segments to the sending host. This acknowledgment also contains the current size of the receive window of the receiving host.
5. If an acknowledgment is not triggered on the receiving host before the delayed acknowledgment timer for a segment expires, the receiving host sends a delayed acknowledgment packet for that segment.
6. The sending host receives the acknowledgment (or delayed acknowledgment) from the receiving host and discards the acknowledged segments from its own transmit window. The transmit window now ‘slides’ past the acknowledged segments and accepts new segments waiting for transmission. These new segments are passed to the IP process for transmission (as described in Step 3).
7. If the sending host does not receive the acknowledgment (or delayed acknowledgment) before the retransmit timer expires on a segment (because either the data segment or the acknowledgment was lost in transit), the sending host will resend that data segment and reset the appropriate retransmit timer to double its original time.
8. Once all segments have been transmitted and acknowledged, the sending host initiates the TCP connection termination process to properly terminate the connection and associated processes on each host.

Because TCP window size is important to the efficient operation of the network, TCP window size is able to dynamically change during the course of the transmission. In other words, TCP is effectively self-tuning its efficiency according to the conditions on the network. This self-tuning mechanism depends on the number of TCP packets successfully received by the receiving host over a percentage of the receive-window size.

If the receiving host is receiving a large number of sequential data within a short period of time, it will exceed a threshold defined as a percentage of the receive-window size. This causes the receiving host to increase the size of its receive window and informs the sending host of the change by putting this information into one of the outbound acknowledgement packets.

Once the sending host receives the acknowledgement packet with the new receive-window size for the receiving host, the sending host increases the size of the transmit window. The receive-window size of the receiving host will continue to get bigger until the growth threshold of the window is the same as the rate at which the network can support data transfer.

This process will continue until the capacity of the slowest network link is saturated and network contention is starting to occur. As the gap between the data transfer rate and threshold get smaller, the rate at which the window grows gets smaller. This explains why, when downloading large files from the Internet or across a wide area network, the transfer rate initially increases rapidly, but plateaus to a fairly constant transfer rate for the remainder of the download.

If the network becomes congested from another source, packets and acknowledgements in existing traffic flows will be lost. This will cause the same process to operate in reverse, reducing the receive-window size of the receiving host until there is little or no gap between the data transfer rate and the threshold of the window.

| Web Links Protocol Numbers http://www.iana.org/assignments/protocol-numbers