• No results found

Transport Control Protocol

2.2 Transport Layer Protocols

2.2.2 Transport Control Protocol

The Transmission Control Protocol (TCP) [Pos80c] is known as a reliable host-to-host protocol between hosts in IP networks, such as the Internet. It offers connection-oriented, end-to-end, inter-process communication between any pair of hosts connected to the Inter- net. TCP makes only very few assumption on the network protocol. It provides reliability, even on top of the unreliable datagram services offered by IP. Interfacing both, the appli- cation process and the lower level network protocol, makes TCP a general “inter-process” communication protocol for multi-network environments. Its main design features are ex- amined and discussed here:

Data Transfer: TCP is intended to transfer streams of data octets in a bi-directional manner between pairs of hosts. The data stream is transmitted in segments (or packets) including a variable number of data octets. In TCP streaming mode, the TCP stacks on both hosts decide (see TCP flow control) when to block and forward data at their own convenience. TCP can also be operated in record mode. This mode, however, is hardly used anymore.

Reliability: Since TCP guarantees reliable data transmission, it must recover from data which is damaged, lost, duplicated, or delivered out of order by the underlying net- work protocol. This is achieved by assigning a sequence number to every octet trans- mitted. The Sequence Number field of the TCP header (see Figure 2.6) identifies the first data octet in the packet. Sending hosts wait for a positive acknowledgment (ACK) from the receiver after a certain amount of data octets is sent. If the ACK, indicating the successful receipt of data up to the Acknowledgment Number, is not received within a timeout interval, the sender starts retransmission. The sequence numbers are used at the receiver to correctly order segments which may be received out-of-order and to eliminate duplicates. Bit-errors in the payload data are detected by means of the Checksum transmit as part of the protocol header.

.

0 8 16 24 31

.

Source Port Destination Port

Sequence Number Acknowledgement Number

DataOffset Reserved Window

Checksum Urgent Pointer

Options Padding

Payload Data (variable length) Control Bits

Figure 2.6: The TCP Protocol Header

Flow Control: TCP uses the well known sliding window algorithm as a flow control mechanism. This is a means for the receiver to control the data rate transmitted by the sender. TCP receivers simply return a “window” with every ACK indicating a range of acceptable sequence numbers beyond the last segment (or packet) success- fully received. The sliding window indicates an allowed number of data bytes that the sender may transmit before receiving an acknowledgment for the first data segments. After receipt of new ACK, the sender scrolls forward its transmission window, and starts transmitting new data segments. If the sender does not receive an ACK within the timeout period, it retransmits the data encompassed by the sliding window. This process is repeated until the ACK arrives at the sender side.

Multiplexing: Like UDP (see section 2.2.1), TCP supports simultaneous data commu- nication for many processes of a single host. The port concept is used to demultiplex multiple data streams at a receiver. It provides a means to classify data packets and pass them to their corresponding application processes. The tuple of the sender and receiver sockets uniquely identifies a TCP connection between two application processes.

Connections: A TCP connection encompasses the following state information: the end-

host sockets, sequence numbers, sliding window size. This “connection state” is

required to achieve flow control and the other mechanisms described above. The TCP implementation of the processes that wish to communicate must first estab- lish a connection (initialize the status information on each side). TCP supports a passive and an active mode for connection establishment. A node in passive mode listens on the socket, waiting to accept incoming connection requests rather than attempting to initiate a connection. In order to establish a connection, at least one

2.2. TRANSPORT LAYER PROTOCOLS 41 of the partners must actively initiate the connection establishment. The active node uniquely specifies the destination host and port of the communication partner. Since connections are usually established between “unreliable” hosts and via “unreliable” networks, such as the Internet, a handshake mechanism with clock-based sequence numbers is used to avoid erroneous initialization of connections. This mechanism is commonly known as three-way handshake [DS78].

In Internet communication TCP has been very successfully used for many years. Most applications (for example, WWW and Email) and application support layer protocols (for example, HTTP, FTP, RTSP and SIP) rely on TCP as their transport protocol. However, experience with TCP has shown that early implementations had some drawbacks if used in large-scale environments, such as the Internet. As a result, most modern implementa- tions of TCP contain four intertwined algorithms that improve fault tolerance, resource utilization, efficiency, and scalability [Ste97].

Slow Start Algorithm: According to the TCP version 1 specification [Pos80c], TCP starts communicating by sending multiple packets into the network, up to the window size advertised by the receiver. As a result, intermediate routers must queue packets if there are low-bandwidth links between the sender and the receiver. Since TCP is used within the Internet where thousands of TCP connections are used simultaneously, routers, particularly in the core network, can quickly run out of queue space, and hence, have to drop packets which then have to be retransmitted. This naive flow control approach can reduce the throughput of TCP connections drastically [Pos80b]. The slow start algorithm resolves this problem by adapting the rate at which new packets are injected into the network to the rate at which the receiver returns the ACKs.

Congestion Avoidance: The congestion avoidance algorithm is the counterpart of the slow start algorithm. The algorithm reduces the packet transmission rate as soon as it detects network congestion. Congestion is assumed if the packet loss rate increases

10. After the transmission rate is reduce, congestion avoidance then invoke the slow

start algorithm to adjust the maximal throughput again. Thus, both algorithms can be deemed to be complementary counterparts.

Fast Retransmission: The idea of the fast retransmission algorithm is to retransmit (most likely) missing packets as soon as packet loss is detected without waiting until the retransmission timer expires. Thus, the problem to resolve here is to identify lost packets (or congestion) as soon as possible in order to retransmit these packets very quickly. Congestion or packet loss is indicated by duplicate ACKs being observed at the sender. However, duplicate ACKs might also be caused by packets which 10Research on Internet traffic has shown that this implicit assumption of congestion avoidance, namely

arrive out-of-order. The trick is to wait for a small number of duplicate ACKs to be received. If only a re-ordering of the packets occurred, there should only be one or two duplicate ACKs. On the other hand, if three or more duplicate ACKs are received in a row, it is a strong indication that a packet has been lost.

Fast Recovery: After the fast retransmission algorithm has sent the packets that were most likely been discarded by intermediate router, the fast recovery algorithm initiates congestion avoidance rather than slow start (which would be normally invoked when congestion occurs). This improvement enables high throughput even under moderate congestion, especially for large windows. The reason for avoiding slow start is that the receipt of duplicate ACKs indicates that data is still flowing between the two end- nodes. Thus, only a moderate or short-term congestion occurred. Preventing TCP from abruptly reducing the flow (which would be the case if slow start is activated) is the trick here.