The Transmission Control Protocol (TCP) is a connection-oriented, stateful, and reliable protocol that handles the delivery of data packets across a network. Packets can be routed via different destinations, and TCP also handles the reassembly of packets at the destination end. It is used typically for larger volumes of data that need to be exchanged between hosts . TCP has the following features:
When TCP establishes a connection, it carries out what is called a three-way handshake , in which the sending host sends a SYN (synchronize) message, and then the receiver sends an acknowledgement (ACK) of the SYN and also sends a SYN message of its own. The sender then receives the SYN and the ACK and sends a final ACK . The sender can now start to send data. Figure 9.1 shows how this works. Figure 9.1. Three-way handshake.
TCP HeaderTCP uses segments as its basic unit of transfer, as IP uses datagrams and ethernet uses packets. A TCP header consists of a number of 32-bit words (4 bytes). The header must be a minimum of 5 words or 20 bytes, and contains a number of fields that control the delivery of the data across the network. The format of the TCP segment header is shown in Figure 9.2. Figure 9.2. TCP header format.
The following are TCP header fields:
TCP Flow ControlTCP is not only a reliable protocol, able to guarantee the delivery of data through an acknowledgement and retransmit mechanism; it also regulates the flow of data at both the sender and receiver side. The flow control mechanism is known as a sliding window because it is variable and can change in size according to how many packets have been received and processed. The window dictates how much data can be read-ahead; the window reduces when data can't be processed fast enough by the local application, and increases when the local application processes data at the rate it's being transferred. Window Advertisements (Receiver)The receiving side sends a window advertisement back to the sender, along with an acknowledgement. This tells the sender how many more bytes can be sent before the sender has to wait for further acknowledgements. Figure 9.3 shows how the receiving station controls how many bytes are sent and manages the flow of data between the two hosts. Notice that as the window moves through the packets to send, the size of the window varies according to how many acknowledgements have been received. In Figure 9.3 (a), the window size is set to 4, but in (b), some acknowledgements have obviously not been received, hence the window size is reduced. As acknowledgements are received, Figure 9.3 (c) shows the window size increasing, allowing the sender to transmit more packets. Figure 9.3. TCP sliding window using window advertisements.
Note from Figure 9.3 that the sending window is constantly updated with the current size of the window and, as time progresses, the window slides along (varying in size), dictating how many packets can be sent ”hence the name , sliding window . Congestion Window (Sender)The sending side also manages the flow of data across the network by adjusting the amount of data it can send according to the number of segments that have recently been acknowledged or lost. Congestion is identified by the sending side in the form of lost packets. When this occurs, the sender halves the size of the congestion window, allowing less data to be transmitted (and thereby easing the congestion). When acknowledgements are received for segments recently sent, it is an indication that the congestion has cleared, so the congestion window doubles in size, allowing more data to be sent. TCP Large WindowThe standard TCP segment header, as you have seen, contains a 16-bit field for the window, giving a maximum window size of 64K (or 2 16 ). RFC 1323 provides TCP extensions to allow a larger window size, up to 1GB (or 2 30 ). For this extension to function correctly, both the sender and the receiver must support RFC 1323 extensions. Further details on RFC 1323 can be found on the Web at www.ietf.org/rfc.html. |