OSI Model - Transport Layer

Layer 4 - Transport Layer :

The Transport Layer provides transparent transfer of data between end stations on the network. This layer is responsible for ordering and reassembling of packets. The transport connection provided by transport layer is an error free virtual circuit channel that delivers data packets in the same order in which it is sent. This layer checks the maximum size of the data packets and breaks up the request into smaller packets as required. Transport layer also checks the validity of data packets, sequencing and handling duplicate packets.

It is providing reliable data transfer services to the upper layers. The Transport Layer controls the reliability of a given link through flow control, segmentation/de-segmentation, and error control. Some protocols are state and connection oriented. This means that the Transport Layer can keep track of the segments and retransmit those that fail. The Transport layer also provides the acknowledgment of the successful data transmission and sends the next data if no errors occurred.

Transport layer protocol is typically categorized as either connection-less or connection oriented protocols. The two types of protocols used in this layers are Transmission Control Protocol (TCP) and User Data-gram Protocol (UDP). TCP is connection oriented protocol and UDP is connection-less protocol.

There are five classes of connection-mode transport protocols ranging from class 0 (which is also known as TP0 and provides the least features) to class 4 (TP4, designed for less reliable networks, similar to the Internet). Class 0 contains no error recovery, and was designed for use on network layers that provide error-free connections. Class 4 is closest to TCP, although TCP contains functions, such as the graceful close, which OSI assigns to the Session Layer. Also, all OSI TP connection-mode protocol classes provide expedited data and preservation of record boundaries, both of which TCP is incapable. Detailed characteristics of TP0-4 classes are shown in the following table:

Connection-mode transport protocols
Perhaps an easy way to visualize the Transport Layer is to compare it with a Post Office, which deals with the dispatch and classification of mail and parcels sent. Do remember, however, that a post office manages the outer envelope of mail. Higher layers may have the equivalent of double envelopes, such as cryptographic presentation services that can be read by the addressee only. Roughly speaking, tunneling protocols operate at the Transport Layer, such as carrying non-IP protocols such as IBM's SNA or Novell's IPX over an IP network, or end-to-end encryption with IPsec. While Generic Routing Encapsulation (GRE) might seem to be a Network Layer protocol, if the encapsulation of the payload takes place only at endpoint, GRE becomes closer to a transport protocol that uses IP headers but contains complete frames or packets to deliver to an endpoint. L2TP carries PPP frames inside transport packet.

Connection Oriented Communication versus Connection-less Communication

Connection describes communication between two end points in which a message can be sent from one end point to another without any prior arrangement. The device at one end point can transmit data to other, without first ensuring that the recipient is ready to receive the data. Internet Protocol and User Data-gram Protocol are connectionless protocol.

Connection-oriented communication describes the means of transmitting data in which devices at the end Points use protocols to establish connection before sending any data. Transmission control protocol is connection-oriented protocol. The four steps in connection-oriented communication are as follows
  1. It establishes connection between the sending and receiving station
  2. The two station notify their operating system that the connection is about to start (Synchronization).
  3. When connection between the two devices are complete, the transfer of information begins.
  4. Two devices communicate with each other and checks that the data is delivered correctly.  

Functions of Transport Layer Protocol 1.) Flow Control : Flow control is a process of controlling the rate at which a device sends data. Depending on the particular protocol, the sending and receiving device participate in the process of flow control. The three methods of implementing flow control are
  • Buffering
  • Congestion avoidance
  • Windowing
Buffering : Under normal circumstance the input buffer of the device can hold enough data packets. But sometimes data comes in at faster rate than the receiving device can process it. Under such condition, the buffer overflow and data will be lost.Flow control helps to prevent buffer overflow by signaling the sending device to stop the transmission allowing the receiving device to empty buffer before continuing again.

Congestion avoidance : Congestion can occur during data transfer for two reasons. First, a high speed computer might be capable of generating traffic faster than a network can transfer it. Second, if many computers simultaneously need to send datagrams to a single destination, that destination can experience congestion, although no single source caused the problem.

When datagrams arrive too quickly or gateway to process, they are temporarily stored in memory. It the traffic continues, the host or gateway eventually exhausts its memory and must discard additional datagrams that arrive.

Instead of allowing data to be lost, the transport function can issue a "not ready" indicator to the sender. Acting like a sop sign, this indicator signals the sender to sender to stop data. When the receiver can handle additional data, the receiver sends a "ready" transport indicator. When this indicator i received, the sender can resume the segment transmission.

In the figure below, the computer receiving the data notices that its buffers are filling.This causes separate PDU or field in the header to be send towards the sender signaling the sender to pause the transmission of data.

Congestion avoidance

Windowing : A Window size is the maximum data the sender can transmit without getting any acknowledgment. If the no acknowledgment is received and if the window is full, then the sender has to wait for acknowledgment. In the figure the line indicate the time difference the sending the PDU and its receipt.

Windowing

2.) Acknowledgment : Reliable data transfer assures that the data won't be duplicated or lost. This is achieved by a process known as positive acknowledgment with retransmission. In this process the receive machine has to communicate with the sender by sending an acknowledgment, The sending device waits for the acknowledgment before sending the next segment. When it sends a segment, the sending machine starts a timer ad retransmit the segment if the timer expires before acknowledgment is received from the receiving machine.

In the above figure the sending machine sends segment 1,2 and 3. The receiving device sends acknowledgment and request for the next segment (segment 4). When it receives the acknowledgment, the sending device sends segment 4,5 and 6. If the segment 5 doesn't reach the destination the receiving device acknowledges that event with a request for the segment to be resent. The sending device then resend the lost segment and waits for the acknowledgment which is required to send the next segment.