LINUXMAKER, OpenSource, Tutorials

Transport Layer

This layer provides the "application-oriented" layers with a logical transmission channel so that they send their data sequentially to the interface. Transport layer protocols control the block lengths, the speed with which packets are passed on to the lower layers, and (often) fail-over. Transport Layer tasks include segmentation of the data stream and congestion avoidance.


A data segment is a service data unit that is used for data encapsulation on the fourth layer (transport layer). It consists of protocol elements that contain Layer 4 control information. As addressing, the data segment is assigned a layer 4 address, ie a port. The data segment is encapsulated in layer 3 in a data packet. The transport layer offers the application-oriented layers 5 to 7 uniform access, so that they do not need to take into account the properties of the communication network.

In order for the sender and receiver to understand each other, the same transport protocol must be used on both sides, i. E. both communication partners must speak the same language.

Well-known protocols are TCP and UDP.

Transmission Control Protocol (TCP)

From the point of view of an application, the Transmission Control Protocol opens a bidirectional, virtual data channel between the two communication endpoints. The data appears to be transmitted in a stream. Internally, these naturally go over the network in blocks, whereby the block size is adapted dynamically on the basis of parameters such as the network load, the window size or the receive or send buffer. In contrast to the User Datagram Protocol mentioned below, TCP itself handles the secure transmission. It uses sequence numbers, checksums, acknowledgments and repetition of the transfer in case of a timeout. Other key features include the sliding window method and the tagging of priority data.

The meaning of the fields of the protocol header

Senderport, receiverport

Analogous to the telephone call, the transmitter plays an active part and the receiver a passive part. The sender addresses the partner via the IP address of the target computer and a 16-bit long port number. Both together are called Unix as a socket. In order to be able to address the receiver, the sender must know its port number. The sender, in turn, can (usually) choose any free port number because he shares his own number with the communication partner. For standard services, the port numbers are in the / etc / services file. Furthermore, it should be noted that UDP uses its own address space and the same port numbers do not overlap.

Sequence number

This 32-bit value uniquely identifies the position of a packet within the data stream in the transmit direction. The initial sequence number is specified at the beginning of the connection setup by each communication partner, provided that they for the maximum possible life of the packet (TimetoLive of the Internet Protocol) bez. the connected computer is unique.  The sequence number of a following packet is calculated from the initial sequence number and the number of bytes sent so far. Thus, it is possible to selectively send this in case of loss or damage of a package.

Receipt number

The acknowledgment number is sent by the receiver of a packet as acknowledgment for the reception. It indicates how many bytes have so far arrived intact at the partner. If the sequence number or acknowledgment number overflows during a session, it will continue at 0.

Offset

Terminate the connection. A partner who sets this bit must, in turn, keep the connection open until the other party sends the FIN bit. He himself may not send any further data (exception are the receipts on arriving packages).

Reserve

No use

Window size

Current capacity of the receiving buffer on the sender side. His counterpart may send as much data as possible (even split into several packets), as indicated by the window size. TCP now works to automatically adjust the window size to the capacity of the transmission medium. For this purpose, the window is gradually enlarged until packets have to be discarded due to the excessive amount of data. Now occur more such transmission errors, the window is reduced again, then try again with an increase. This sliding window principle is very good for downloading files, with a constant data transfer rate.

Checksum

Checksum over the entire package.

Pointer to priority data

The pointer indicates an offset within the data in the packet. The data following the pointer are thus declared to be particularly important. An application will be notified upon receipt of such data. She should now interrupt her previous work and edit the urgent message. Use of this mechanism probably makes only Telnet.

Options

When establishing a connection, usually "MaximumSegmentSize" is sent to inform the partner that larger packets can be received. The other options are "EndOfOptionList" and "NoOperation".

The six control bits

URG  

The data in the "Priority Data" field is valid

ACK

The receipt number is valid

PSH

The data should be transferred to the application immediately

RES

Reset the connection

SYN

Desire to establish a connection

FIN

Terminate the connection. A partner who sets this bit must, in turn, keep the connection open until the other party sends the FIN bit. He himself may not send any further data (exception are the receipts on arriving packages).

The interplay of sequence and receipt numbers will in most cases guarantee the integrity of the transmitted data. However, a pending receipt requires waiting for this. Now, if the partner has failed, a station would lurk for all eternity on the confirmation of the receipt of his package. To prevent such a "hanger", several timers are started when a package is sent.

The most important ticker stops the time that has passed since the transmission. If he leaves without a receipt, the package must be sent again on the trip. However, this time span is calculated dynamically (from the average of the previous package delays), so that it gradually adapts to changed situations (high network load, alternative route).

Another alarm clock is used to check the willingness of the recipient. This timer guarantees that a data transfer will not be blocked because its window size is 0, but the packet was lost to open the receive window.

The last timer presented here keeps a port closed for some time after the connection has already been disconnected. The time span roughly corresponds to the maximum lifetime (TimeToLive) of a data packet and is useful in order not to confuse the next connection opened on the same port with old misdirected packets.

User Datagram Protocol (UDP)

In addition to TCP, the User Datagram Protocol plays an important role as a transport protocol. It works connectionless and does not guarantee success of the transmission. It only contains a checksum over the data in order to be able to control the integrity of the receiver. Services that use UDP often implement their own error recovery routines.

UDP uses ports to send data sent to the correct program on the target machine. For this purpose, each datagram contains the port number of the service to receive the data. This extension of Internet Protocol host-to-host transmission to process-to-process transmission is referred to as application multiplexing and demultiplexing. In addition, UDP offers the possibility of an integrity check by sending a checksum. As a result, erroneously transmitted datagrams can be detected.

The lean protocol header and the absence of any security mechanisms or flow control predestine the protocol for time-ticked transmissions on secure media (where data loss is unlikely). Also, most RPC-based services use UDP, since such a query is more of a telegram character (one-time, short messages).