See also: TCP

The Transmission Control Protocol ( TCP , “Transmission Control Protocol”), is a reliable protocol of transport, in connected mode, documented in RFC 793 of IETF.

In the model TCP/IP, TCP is located between the Couche of network (generally the protocol IP), and the Couche application. The applications transmit flows of Octet S on the network. TCP cuts out the flow of bytes in segments , whose size depends on MTU of the subjacent network (data link layer).

Operation

A session TCP functions in three phases:

  • establishment of connection;
  • transfers of information;
  • end of connection.

The establishment of connection is done by a handshake in three times. The rupture of connection, it, uses a handshake in four times. During the phase of establishment of connection, parameters as the number of sequence are initialized in order to ensure the reliable transmission (without loss and in the order) of the data.

Structure of a segment TCP

Out of bits

Significance of the fields:

  • Port source: Number of the port source

  • Port destination: Number of the port destination
  • Number of sequence: Number of sequence of the first byte of this segment
  • Number of payment: Number of sequence of the next byte awaited
  • Size of the heading: Length of the heading in words of 32 bits (the options belong to the heading)
  • Réservé: Reserved for a future use
  • ECN: announce the presence of congestion, to see RFC 3168
  • Drapeaux
    • URG: Announce the presence of data URGentes
    • ACK: Announce that the package is an acknowledgment of delivery (Acknowledgment)
    • PSH: Data to send immediately (PuSH)
    • RST: Abnormal rupture of connection (Reset)
    • SYN: Ask for Synchronization or FINE establishment of connection
    • : Ask the end of connection
  • Fenêtre: Cut of window requested, i.e. the number of bytes which the receiver wishes to receive without acknowledgment of delivery
  • Checksum: Summon of control calculated on the whole of heading TCP and the data, but also on a pseudo heading (extracted heading IP)
  • Pointeur of urgent data: Relative position of the last urgent data
  • Options: Optional
  • Filling: Zero additions to align the following fields of the package on 32 bits, if necessary
  • Given: Sequences of bytes transmitted by the application (for example: +OK POP3 server ready,…)

Establishment of a connection

Even if it is possible, for two systems, to establish a connection between them simultaneously, in the general case, a system opens a “socket” (access point to a connection TCP) and is put on standby passivates requests for connection of another system. This operation is commonly called opening passivates , and is used by the side waiter of connection. The side customer of connection carries out a opening activates in 3 times (handshake in three times):
  1. the customer sends a segment SYN to the waiter,

  2. the waiter answers him by a segment SYN/ACK,
  3. the customer confirms by a segment ACK.

During this initial exchange, the numbers of sequence of the two parts are synchronized:

  1. the customer uses his initial number of sequence in the field " Number of séquence" segment SYN (X for example),

  2. the waiter uses its initial number of sequence in the field " Number of séquence" segment SYN/ACK (there for example) and adds the number of sequence of the customer plus one (x+1) in the field " Number of acquittement" segment,
  3. the customer confirms by sending a ACK with a number of sequence increased of one (x+1) and a number of payment corresponding to the number of sequence of the waiter plus one (y+1).

Transfers of information

During the phase of transfers of information, certain key mechanisms make it possible to ensure the robustness and the reliability of TCP. In particular, the numbers of sequence are used in order to order received segments TCP and to detect the lost data, the checksums allow the detection of errors, and the payments, as well as temporizations, allow the detection of the lost or delayed segments.

Numbers of sequence and payment

Thanks to the numbers of sequence and payment, the final systems can give the data received in the order to the recipient application.

The numbers of sequence are used to deduct the data in flow of bytes. One always finds two of these numbers in each segment TCP, which are the number of sequence and the number of payment . The number of sequence represents the proper number of sequence of transmitter TCP, while the number of payment represents the number of sequence of the recipient. In order to ensure the reliability of TCP, the recipient must discharge the segments received by indicating that it received all the data of the flow of bytes until a certain number of sequence.

For example, in the case of an exchange of segments by telnet:

  1. the host has sends a segment to the host B containing a byte of data, a number of sequence equal to 42 (Seq = 42) and a number of payment equal to 79 (Ack = 79),

  2. the host B sends a segment ACK to the host has containing the same byte of data. The number of sequence of this segment corresponds to the number of payment of the host B (Seq = 79) and the number of aquittement to the number of sequence of has such as receipt by B, increased received quantity of data in bytes (Ack = 42 + 1 = 43),
  3. the host has confirms the reception of the segment by sending a ACK to the host B, with like number of sequence its new number of sequence , namely 43 (Seq = 43) and like number of aquittement the number of sequence of the segment previously received, increased quantity of data received (Ack = 79 + 1 = 80).

The numbers of sequence are integers not signed on 32 bit S, which total zero after having reached 2^32-1. The choice of the initial number of sequence is one of the keys of the robustness and the safety of connections TCP.

An improvement of TCP, named selective payment (selective acknowlegement or SACK), authorizes recipient TCP to discharge storage blocks received in the disorder.

Summon of control

A checksum on 16 bits, consisted the ones complement of the sum complémentée with one of all the elements of a segment TCP (heading and data), is calculated by the transmitter, and is included in the emitted segment. The recipient recomputes the sum of control of the received segment, and if it corresponds to the sum of control received, it is considered that the segment was received intact and without error.

The sum of control in addition to one used by TCP is relatively not very reliable according to the modern standards. This restricts the use of offering TCP to networks of the low error rates. If TCP were redefined today, one would probably use a CRC on 32 bits instead of the current mechanism. This unreliability of the sum of control is partially compensated by the frequent use of a CRC or a better control of integrity on level 2 (data link layer), below TCP and IP, such as for example in the screens PPP or Ethernet. However, that does not mean that the sum of control TCP is redundant: studies on the traffic Internet showed that one usually meets material errors and software which introduce errors into the packages between the nodes protected by CRC, and which the principle of nap of end-to-end control of TCP detects the majority of these errors.

Temporization

The loss of a segment is managed by TCP by using a mechanism of temporization and retransmission. After the sending of a segment, TCP will await a certain time the reception of the corresponding ACK. A too short time involves a great number of useless retransmissions and a too long time slows down the reaction in the event of loss of a segment.

In the facts, the time before retransmission must be higher than the average RTT of a segment, i.e. at the time which a segment takes to carry out the return ticket between the customer and the waiter. As this value can vary in time, one " prélève" samples with regular interval and one calculates a weighted average of it:

Average RTT = (1- \ alpha) * average RTT + \ alpha * RTT sample

A typical value for \ alpha is 0.125. The influence of the samples decreases in an exponential way in time.

The time to be used is obtained starting from this estimate of the average RTT and by adding a safety margin to it. More the difference between a sample and the average are large, more the safety margin to be envisaged is important. Calculation is done starting from the variance balanced between the sample and the average:

Variance RTT = (1- \ beta) * Variance RTT + \ beta * |RTT sample - average RTT|

A typical value for \ beta is 0.25. The time to be used is finally given by the following formula:

Time = average RTT + 4 * Variance RTT

Sometimes, when the time is too long, it is advantageous not to await before retransmettre a segment. If a host receives 3 ACKs for the same segment, then he considers that all the segments transmitted after the discharged segment were lost and retransmet thus immediately ( Fast retransmit ).

Control flow

Each partner in a connection TCP has a plug of reception whose size is not unlimited. In order to prevent that a host does not overload the other, TCP envisages several control mechanisms of flow. Thus, each segment TCP contains the size available in the plug of reception of the host who sent it. In answer, the distant host will limit the size of the window of sending in order not to overload it.

Other algorithms like Nagle or Clarck also facilitate the control of flow.

Control congestion

The congestion intervenes when too many sources try to send too many data too quickly so that the network is able to transmit them. This involves the loss of many packages and long times.

Payments of the transmitted data, or the absence of payments, are used by the transmitters to interpret in an implicit way the state of the network between the final systems. Using temporizations, the transmitters and recipients TCP can modify the behavior of the data flow. It is what is called generally the control of congestion.

Others

TCP uses a certain number of mechanisms in order to obtain a good robustness and high performances. These mechanisms include/understand the use of a slipping window, the algorithm of slow starting ( slow fox trot start ), the algorithm of avoidance of congestion ( congestion avoidance ), the algorithms of fast retransmission ( fast retransmit ) and of fast recovery ( fast recovery ), etc Of research are currently carried out in order to improve TCP to treat the losses effectively, to minimize the errors, to manage the congestion and to be fast in environments very high banc.

Termination of a connection

The phase of termination of a connection uses a handshake in four times, each end of the connection carrying out its termination in an independent way. Thus, the end of a connection requires a pair of segments END and ACK for each end.

Ports TCP

TCP uses the concept of number of port to identify the applications. At each end of connection TCP is associated a number with port on 16 bits assigned with the transmitting or receiving application. The ports can belong to three basic categories: well-known ports, recorded ports and dynamic/private ports. The well-known ports are assigned by IANA (Internet Assigned Numbers Authority) and are often used by processes system or having privileged rights. The well-known applications which function as a waiter and are on standby of connections generally use these types of ports. Examples: ftp (21), telnet (23), smtp (25) and HTTP (80). The recorded ports are generally used by user applications like transitory ports sources to be connected to a waiter, but they can also identify services not recorded by the IANA. The dynamic/private ports can also be used by user applications, but more rarely. They do not have a direction apart from a particular connection TCP.

Development of TCP

It is the American ministry of the Defense which in the beginning developed the model of reference TCP/IP, because it needed a network which can resist all the situations. TCP is a rather complex protocol, and in evolution. Even if significant improvements were made during the years, its basic operation changed little since the RFC 793, published in 1981. The RFC 1122 (Host Requirements for Internet Hosts), clarified a certain number of pre-necessary for the implementation of protocol TCP. The RFC 2581 (TCP Congestion Control), one of most important of these last years, described new algorithms used by TCP to avoid the congestions. In 2001, the RFC 3168 was written in order to present a mechanism of indication of the congestions (explicit congestion notification or ECN), and is added to the list of RFCs important which supplement the original specification. At the beginning of the 21e century, TCP is used roughly for 95% of all the traffic Internet. The most current applications which use TCP are HTTP/HTTPS (World Wide Web), SMTP/POP3/IMAP (transport) and ftp (transfer of file). Its very widespread use is the proof of the quality of the design carried out by its original creators.

Alternatives with TCP

However, TCP is not adapted for many applications, and new protocols of transport are created and deployed in order to fill some of its gaps. For example, of many applications in real-time do not need, and can even suffer, of the mechanisms of reliable transport of TCP. In this type of applications, it is often preferable to manage the losses, errors or congestions, rather than to try to avoid them. The applications of multi-media diffusion (audio and video, etc), or certain plays multi-players in real-time, for example, do not use TCP. Any application which does not require the reliability of TCP, or has a need limited in functionalities, can choose not to use it. In many cases, UDP (User Datagram Protocol) can be used in the place of TCP when only the services of multiplexing applicatifs are necessary.

See too

Internal bonds

External bonds

  • RFC793

  • IANA assignment of the ports
  • Sally Floyd' S homepage
  • vision of John Kristoff on TCP
  • When The CRC and TCP Checksum Disagree
  • Introduction to TCP/IP - with images
  • Course of introduction to TCP/IP
  • TCP/IP

Random links:Animals (television channel) | Motonautism speed inshore | Sahaba | Xuxa | Johannes Smuts

© 2007-2008 speedlook.com; article text available under the terms of GFDL, from fr.wikipedia.org