TCP


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:

  • Virtual circuit ” Both the sending and receiving host must establish a connection before data transmission can commence. This connection is called a virtual circuit because it is a logical connection, not a physical one.

  • Full-duplex ” TCP connections allow data to be transferred in both directions at the same time, increasing the amount of data that can be carried on the network at a given time. The application views a TCP connection as two paths moving in opposite directions. Full-duplex also makes use of piggybacking , where control information, such as acknowledgements, are sent inside data segments traveling in the opposite direction. This reduces the amount of traffic on the network.

  • Streams ” An application passes data to TCP for transmission as a stream of bytes. TCP divides the stream into segments , which comprise a header, containing control information (discussed in the next section) and data.

  • Buffers ” TCP uses both input and output buffers to regulate the flow of traffic between the sending and receiving hosts. The default value for the maximum size of the buffers is 1MB (1048576 bytes). This parameter can be viewed , or tuned , by using the ndd command as shown here:

     # ndd /dev/tcp tcp_max_buf 1048576 

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.

graphics/09fig01.gif

graphics/alert_icon.gif

Some examples of applications that use TCP are Telnet, FTP, HTTP, and the Solaris r commands, such as rlogin and rsh .


TCP Header

TCP 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.

graphics/09fig02.gif

The following are TCP header fields:

  • Source Port ” Identifies the TCP application program on the sending side.

  • Destination Port ” Identifies the TCP application program on the receiving side.

  • Sequence Number ” Identifies the position of this segment in the data stream ”the sending and receiving hosts synchronize the sequence number when the connection is established. The receiving host rejects segments that arrive too late or are lost.

  • Acknowledgement Number ” Identifies how much of the data stream has been received successfully. When a host is sending an acknowledgement, the ACK flag has to be set for the value to be treated as valid. ( ACK is discussed later in this chapter in "Code Flags.")

  • Offset ” Identifies the position in the segment where the data starts. This is necessary because the options field can vary in length.

  • Reserved ” This field is reserved and is not used.

  • Code Flags ” This 6-bit field is used to determine the purpose and contents of the TCP segment. Each flag is a single bit and is listed from left to right:

    • URG ” When this bit is set, the Urgent Pointer field becomes valid. TCP enables the sender to specify "urgent" data that should be delivered as quickly as possible.

    • ACK ” When this bit is set, the Acknowledgement field becomes valid.

    • PSH ” When this bit is set, the segment requests a push, that is, to transmit the data immediately.

    • RST ” When this bit is set, reset the connection.

    • SYN ” When this bit is set, synchronize the sequence numbers ”used when establishing a connection.

    • FIN ” Indicates that the sender has finished sending ”used when terminating a connection.

  • Window ” This field specifies how much data the receiving side can accept. This is part of the TCP flow control, discussed in the next section.

  • Checksum ” A 16-bit integer used to verify the integrity of the TCP segment header and the data.

  • Urgent Pointer ” This field specifies a position in the data stream where "urgent" data ends. The field is used only when the URG code flag bit is set to 1.

  • Options ” TCP uses this field to communicate with the TCP software at the other end of the connection. A maximum segment size is specified in this field.

  • Padding ” Padding to fill the header out to the minimum size and to ensure that the header ends on a 32-bit boundary. Padding is composed of zeros.

TCP Flow Control

TCP 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.

graphics/09fig03.gif

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 Window

The 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.



Solaris 9 Network Administration Exam Cram 2 (Exam Cram CX-310-044)
Solaris 9 Network Administrator Exam Cram 2 (Exam CX-310-044)
ISBN: 0789728702
EAN: 2147483647
Year: 2003
Pages: 174
Authors: John Philcox

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