Section 8.2. Transmission Control Protocol (TCP)


8.2. Transmission Control Protocol (TCP)

The Transmission Control Protocol (TCP) is a transport-layer protocol that provides a reliable service by using an automatic repeat request (ARQ). In addition, TCP provides congestion control, using a sliding-window scheme, that introduced in Section 4.6.2. TCP is built over IP services by facilitating a two-way connection between the host application and the destination application.

As a connection-oriented protocol, TCP requires a connection to be established between each two applications. A connection is set up by defining variables the protocol requires and storing them in the transmission control block . After establishing the connection, TCP delivers packets in sequence and in bytestream. TCP can either send the data received from the application layer as a single packet or split it into multiple packets and transmit them if an underlying physical network poses a limitation.

The requisites of layer 4 are to transfer data without errors to make sure that packets follow the same sequence. A host application that needs to send a certain sort of data stores it in a send buffer. The data is then transmitted as a bytestream. The transmitting host creates a segment that contains a sequence of bytes. The segment is appended to a TCP header that specifies the destination application port and a sequence number . When it arrives at the destination, the segment is verified for its integrity. After making sure that the packet is not a duplicate and that the segment number lies in the range of the local buffer, the receiver accepts the packet. The receiver can accept packets out of order. In that case, the receiver simply repositions them in the buffer to obtain an in-order sequence before making the data available to the application. Acknowledgments are cumulative and traverse in the reverse direction.

8.2.1. TCP Segment

As defined earlier, a TCP segment is a TCP session packet containing part of a TCP bytestream in transit. The fields of the TCP header segment are shown in Figure 8.2. The TCP segment contains a minimum of 20 bytes of fixed fields and a variable-length options field. The details of the fields are as follows .

  • Source port and destination port specify, respectively, the user's port number, which sends packets and the user 's port number, which receives packets.

  • Sequence number is a 32-bit filed that TCP assigns to each first data byte in the segment. The sequence number restarts from 0 after the number reaches 2 32 - 1.

  • Acknowledgment number specifies the sequence number of the next byte that a receiver waits for and acknowledges receipt of bytes up to this sequence number. If the SYN field is set, the acknowledgment number refers to the initial sequence number (ISN).

  • Header length (HL) is a 4-bit field indicating the length of the header in 32-bit words.

  • Urgent (URG) is a 1-bit field implying that the urgent-pointer field is applicable .

  • Acknowledgment (ACK) shows the validity of an acknowledgment.

  • Push (PSH), if set, directs the receiver to immediately forward the data to the destination application.

  • Reset (RST), if set, directs the receiver to abort the connection.

  • Synchronize (SYN) is a 1-bit field used as a connection request to synchronize the sequence numbers .

  • Finished (FIN) is a 1-bit field indicating that the sender has finished sending the data.

  • Window size specifies the advertised window size.

  • Checksum is used to check the validity of the received packet. (See Section 4.5.2 for details.)

  • Urgent pointer (URG), if set, directs the receiver to add up the values in the urgent-pointer field and the sequence number field to specify the last byte number of the data to be delivered urgently to the destination application.

  • Options is a variable-length field that specifies the functions that are not available as part of the basic header.

Figure 8.2. TCP segment format

One of the possible options is maximum segment size (MSS). A receiver uses this option to specify the maximum segment size it can receive. A total of 16 bits are provided to specify this option. Thus, the maximum segment size is limited to 65,535 bytes minus 20 bytes of TCP header and minus 20 bytes of IP header, resulting in 65,495 bytes. The default MSS for TCP is 536 bytes. Another possible option is the window scale . This option is used to increase the size of the advertised window beyond the specified 2 16 - 1 in the header. The advertised window can be scaled to a maximum of 2 14 .

8.2.2. Connection Setup

As a connection-oriented protocol, TCP requires an explicit connection set-up phase. Connection is set up using a three-step mechanism, as shown in Figure 8.3 (a). Assume that host A is a sender and host B a destination. First, the sender sends a connection request to the destination. The connection request comprises the initial sequence number indicated by seq( i ), with the SYN bit set. Next, on receipt of the connection request, the destination sends an acknowledgment, ack( i + 1), back to the source, indicating that the destination is waiting for the next byte. The destination also sends a request packet comprising the sequence number, seq( j ), and the SYN bit set. Finally, at the third step, the sender returns an acknowledgment segment, ack( j + 1), specifying that it is waiting for the next byte. The sequence number of this next segment is seq( i + 1). This process establishes a connection between the sender and the receiver.

Figure 8.3. TCP signaling: (a) establishment of a connection; (b) collision of two connection requests


The connection process uses different initial sequence numbers between the sender and the receiver to distinguish between the old and new segments and to avoid the duplication and subsequent deletion of one of the packets. In Figure 8.3, both end-point hosts simultaneously try to establish a connection. In this case, since they recognize the connection requests coming from each other, only one connection is established. If one of the segments from a previous connection arrives late, the receiver accepts the packet, presuming that it belongs to the new connection. If the packet from the current connection with the same sequence number arrives, it is considered a duplicate and is dropped. Hence, it is important to make sure that the initial sequence numbers are different.

When one of the end points decides to abort the connection, a segment with the RST bit set is sent. Once an application has no data to transmit, the sender sends a segment with the FIN bit set. The receiver acknowledges receipt of this segment by responding with an ACK and notifies the application that the connection is terminated. Now, the flow from the sender to the receiver is terminated. However, in such cases, the flow from the receiver to the sender is still open . The receiver then sends a segment with the FIN bit set. Once the sender acknowledges this by responding with an ACK, the connection is terminated at both ends.



Computer and Communication Networks
Computer and Communication Networks (paperback)
ISBN: 0131389106
EAN: 2147483647
Year: 2007
Pages: 211
Authors: Nader F. Mir

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net