Transport Layer Protocols (TCP & UDP)

The transport layer within the TCP/IP protocol suite oversees two primary protocols: the Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP). TCP operates as a connection-oriented protocol, ensuring reliable end-to-end delivery of data. On the other hand, UDP is a connection-less protocol, prioritizing well-sequenced transport function when size and speed take precedence over reliability and strict delivery assurance. Transport layer services are executed by transport protocols, establishing communication between two transport entities.

While data link services and transport layer services share similarities, the key distinction lies in their scope. The data link layer is tailored to deliver services within a singular network, whereas the transport layer extends its services across an internetwork composed of numerous interconnected networks. In the upcoming discussion, we will delve into a comprehensive exploration of TCP and UDP, elucidating their distinct characteristics and the services they offer.


Transport Services

The transport layer is tasked with overseeing protocols that facilitate the transfer of data between application programs on different devices. Positioned as the initial end-to-end layer in the OSI model, it extends its services to upper layers, enabling it to utilize the offerings of the network layer and various lower-layer protocols.

The transport layer provides a comprehensive range of services, categorized into seven key functions. The primary transport services encompass end-to-end delivery, addressing, reliable delivery, flow control, connection management, multiplexing, congestion control, and quality of service (QoS).

 

End-to-End Delivery

While the network layer utilizes logical addresses to transport data from a source to a destination device, both the sender and receiver may engage in multiple processes communicating concurrently. Therefore, it becomes crucial not only to deliver the data from the sender to the receiver but also to ensure that it reaches the correct process on both ends. The transport layer is responsible for the end-to-end delivery of data, guaranteeing its integrity and sequential arrangement, ensuring it reaches the appropriate processes on both the sender and receiver sides.

 

Addressing

In order to achieve process-to-process delivery, the transport layer employs port addresses to distinguish data between sending and receiving processes. A port address serves as the identifier or label for a process and is represented by a 16-bit address. For instance, TELNET is associated with port address 23, while HTTP uses port address 80. Port addresses are also referred to as Service Point Addresses.

 

Segmentation and Reassembly

Data can be transmitted using either a connection-oriented or connectionless approach. In a connection-oriented scenario, all segments are received in a specific order, while in a connectionless setting, segments are received independently and may arrive out of order, necessitating rearrangement. The Transport layer is tasked with segmenting and reassembling messages into segments, each assigned a sequence number. This sequencing allows the receiving transport layer to properly arrange the segments in the correct order.


Flow Control & Error Control

The transport layer is responsible for implementing flow control and error control functions, which differ from those at the data link layer as they operate on an end-to-end basis rather than a node-to-node basis.

 

Connection Management

Achieving end-to-end delivery involves two approaches: connection-oriented and connectionless. TCP (Transmission Control Protocol) is employed for a Connection-Oriented Internet service. TCP provides reliable transport, flow control, and congestion control services to applications, and these services are acknowledged. TCP's congestion control mechanism is utilized to maintain throughput.

The connection-oriented mode is the more commonly used of the two. A connection-oriented protocol establishes a virtual circuit or pathway through the network between the sender and receiver. All packets belonging to a message are sent over this same path, simplifying the acknowledgment process and retransmission of damaged or lost frames. Connection-oriented services are generally considered reliable.

Reliable services encompass features such as flow control, error control, and sequence delivery. Flow control ensures that neither side of a connection overwhelms the other by sending too many packets too quickly.

Connection-oriented transmission involves three stages:

  1. Connection establishment
  2. Data transfer
  3. Connection termination

 

1. Connection Establishment:

Before a communicating device can send data to another, the initiating device must first ascertain the availability of the other device for data exchange, and a pathway must be identified through the network for data transmission. This step is known as connection establishment, and it involves three Transport Layer actions, often referred to as a three-way handshake, as illustrated in the figure below.

The computer initiating the connection sends a connection request packet to the intended receiver.

  • The responding computer sends a confirmation packet back to the initiating computer.
  • The initiating computer returns a packet acknowledging the confirmation.
Connection Establishment

2. Data Transfer:

Following the successful connection establishment, the process of data transfer commences. Throughout this period, the connection remains dedicated exclusively to the ongoing data transfer. Once all the data packets reach their destination, the connection termination process is initiated.

 

 

3. Connection Termination:

After the successful transfer of all data, the connection needs to be terminated. This process also involves a three-way handshake, as depicted in the figure below:

  • The requesting computer sends a disconnection request packet.
  • The responding computer confirms the disconnection request.
  • The requesting computer acknowledges the confirmation.
Connection Termination

 

Multiplexing

To enhance transmission efficiency, the transport layer can employ multiplexing, which occurs in two ways:

1. Upward Multiplexing:

Multiple transport layer connections share the same network connection in upward multiplexing. Here, the transport layer utilizes virtual circuits based on the services of the lower three layers. Each virtual circuit connection incurs a charge from the underlying network. To cost-effectively utilize an established circuit, the transport layer employs upward multiplexing by sending several transmissions for the same destination along the same path.

2. Downward Multiplexing:

In downward multiplexing, one transport layer connection utilizes multiple network connections. This approach allows the transport layer to divide a single connection among several different paths, thereby improving throughput (speed of delivery). Downward Multiplexing is valuable when the underlying networks have low or slow capacity. For instance, certain network layer protocols may impose restrictions on the sequence number that can be handled; for instance, X.25 uses a three-bit numbering code, limiting sequence numbers to the range of 0 to 7. In such cases, throughput can be unacceptably low. To address this issue, the transport layer can utilize more than one virtual circuit at the network layer, sending multiple data segments at once to expedite delivery.

 

Congestion Control:

Congestion control encompasses methods and mechanisms designed to either prevent congestion before it occurs or alleviate congestion after it has occurred.

 

Quality of Service (QoS):

A sequence of packets traveling from a source to a destination is termed a flow. In a connection-oriented network, all packets within a flow follow the same route, while in a connectionless network, they may take different paths. The requirements of each flow can be characterized by four primary parameters:

  1. Reliability: Reliability is the system's ability to perform and maintain its functions under normal and unexpected conditions.
  2. Delay: Delay is defined as the time interval between the departure of data from the source to its arrival at the destination.
  3. Jitter: Jitter refers to the variation in time between packets arriving at the destination.
  4. Bandwidth: Bandwidth denotes the data rate supported by a network connection or interface.

 

Introduction to TCP

TCP (Transmission Control Protocol) is specifically designed to facilitate reliable communication between pairs of processes (TCP users) operating across diverse networks and the internet, whether they are reliable or unreliable. TCP operates in a streaming-oriented, connection-oriented manner. The term "stream" signifies that each connection is treated as a continuous flow of bytes. Unlike UDP (User Datagram Protocol), where data must be packaged into individual datagrams, TCP manages connections by establishing a link between the sender and receiver.

For TCP, the establishment of a connection is imperative. This connection initiates a Virtual Circuit (VC) at the IP layer, which remains active throughout the entire transmission. In contrast to IP and UDP, which treat multiple datagrams belonging to a single transmission as independent and unrelated units, TCP takes responsibility for the reliable delivery of entire segments. Each segment must be received and acknowledged before the Virtual Circuit is terminated.

 

TCP Segment Header

In this segment, we will delve into the TCP Segment Header, exploring various fields and their respective purposes.

TCP header format

The roles of the fields depicted in the figure above are outlined as follows:

  • Source Port: This 16-bit number identifies the Source Port (the TCP Port of the sending computer).
  • Destination Port: A 16-bit number indicating the Destination Port (the receiving port).
  • Sequence Number: Utilized for byte-level numbering of TCP segments, this 32-bit number assigns a sequence number to each byte of data when using TCP. If the SYN flag is set during the initial three-way handshake for connection initiation, this serves as the initial sequence number. The sequence number of the actual first data byte is then the sequence number plus 1.
  • Acknowledgment Number: This 32-bit number field signifies the next sequence number the sending device expects from the other device.
  • Header Length: Represented by a 4-bit field, this indicates the number of 32-bit words in the header, also known as the Data Offset field. The minimum header size is 5 words, denoted by the binary pattern 0101.
  • Reserved: Allocated for potential future use, this 6-bit field is always set to 0.

Control Bit Flags in TCP play a pivotal role in managing the connection-oriented nature of the protocol, governing processes such as connection establishment, data transmissions, and connection termination. The control bits include:

  • URG (Urgent Pointer): Designates urgent data, with the Urgent Pointer indicating the end of the urgent data. The URG flag prioritizes the transmission of this data over other streams.
  • ACK (Acknowledgment): Acknowledges the successful receipt of data.
  • PSH (Push): Initiates the push function, allowing the sending application to specify that accumulated data should be transmitted immediately without waiting to fill the segment.
  • RST (Reset): Resets the connection in response to unrecoverable errors, leading to an immediate termination of the connection and release of all associated resources.
  • SYN (Synchronize): Synchronizes sequence numbers, indicating the start of a new counting sequence. The TCP segment contains the Initial Sequence Number (ISN).
  • FIN (Finish): Signals the end of data transmission from the sender. Closing a TCP connection gracefully often involves the use of the FIN flag.
  • Window: Specifies the size of the receive window, indicating the number of bytes beyond the sequence number in the acknowledgment field that the receiver is willing to receive.
  • Checksum: A 16-bit field used for error-checking of the header and data.
  • Urgent Pointer: Indicates the end of urgent data, allowing interrupted data streams to resume. When the URG bit is set, the data is given priority over other streams.
  • Options (Variable): Currently, only one option is defined, specifying the maximum segment size accepted. The source and destination ports identify the users of TCP, with reserved port numbers for common applications and other port numbers arranged by mutual agreement between communicating parties.

TCP provides essential services to applications invoking it as a transport protocol. These services include:

  • Connection-Oriented Service: TCP offers a connection-oriented service, involving a full-duplex connection where two processes can simultaneously send messages to each other. The connection is established through a handshake procedure, and once the application completes its message transmission, the connection is terminated. This service is implemented through the virtual circuit mechanism.
  • Reliable Transport Service: TCP ensures that communicating processes can rely on it to deliver all sent data without errors and in the correct order. When an application sends a stream of bytes into a socket, TCP guarantees the delivery of the same stream of data to the receiving socket, avoiding missing or duplicate bytes. Reliability is maintained through acknowledgments and retransmissions.
  • Congestion-Control Mechanism: TCP incorporates a congestion-control mechanism to facilitate the smooth functioning of Internet processes. When the packet load surpasses the network's handling capacity, congestion can occur. Although the Internet's connection-oriented service includes data transfer, flow control, and congestion control mechanisms, they are not intrinsic components of the connection-oriented service. It's worth noting that a connection-oriented service can be provided without bundling these services through a different type of network.

While TCP offers crucial services, there are some aspects it does not provide:

  1. Minimum Transmission Rate Guarantee: TCP does not guarantee a minimum transmission rate.
  2. No Delay Guarantee: Although TCP guarantees the delivery of all data, it does not provide any delay guarantee, and there is no assurance regarding the rate of data delivery.

 

Introduction to UDP:

UDP , or User Datagram Protocol , is a connectionless and unreliable transport protocol. While contributing little to the IP protocol beyond multiplexing/de-multiplexing and some error correction, UDP serves specific applications that benefit from its characteristics. Let's explore the basic functions of UDP and its operational mechanism.

When opting for UDP in application development, the application essentially communicates directly with the IP layer. UDP takes messages from the application process, appends source and destination port number fields for multiplexing/de-multiplexing, adds two additional small fields, and forwards the resulting segment to the network layer. Without establishing handshaking between sending and receiving transport-layer entities, the network layer encapsulates the segment into an IP datagram, making a best-effort attempt to deliver it to the receiving host. If the segment reaches the destination, UDP employs the destination port number to deliver the segment's data to the desired application process.

The question may arise:  Why choose UDP when TCP appears suitable for all application layers/protocols? 

Consider DNS (Domain Name System), a core Internet function that translates host names to IP addresses. DNS operates exclusively in UDP. Unlike user-interactive applications, DNS is a background process essential for Internet functionality. When DNS wants to make a query, it constructs a DNS query message and passes it to UDP without handshaking. UDP adds header fields, and the network layer encapsulates the UDP segment into a datagram sent to a name server. The querying host's DNS application awaits a reply, handling scenarios where a reply isn't received.

Several applications are better suited for UDP for the following reasons:

  • No Connection Establishment: UDP doesn't introduce delays in connection establishment, making it suitable for applications like DNS. In contrast, TCP (used by HTTP) prioritizes reliability for critical web pages.
  • More Client Support: Unlike TCP, which maintains connection state in end systems, UDP doesn't track parameters like receiving and sending buffers. Servers supporting applications can handle more active clients when using UDP, as it lacks the connection state maintenance overhead of TCP.

Because UDP lacks reliable data service and congestion control, it avoids the need for maintaining and tracking connection states, resulting in lower overhead. While TCP segments have 20 bytes of header overhead, UDP only incurs eight bytes. Applications like remote file servers, streaming media, internet telephony, network management, and routing protocols like RIP utilize UDP. Conversely, applications like e-mail, remote terminal access, web surfing, and file transfer typically rely on TCP.

 

UDP Segment Structure:

UDP, serving as an end-to-end transport-level protocol, appends essential elements such as port addresses, checksum error control, and length information to the data received from the upper layer. The data field within the UDP segment accommodates the application-specific content. For instance, in DNS, this field contains either a query or a response message, while in a streaming audio application, it holds audio samples. The outcome of UDP's processing is termed a "user datagram."

UDP segment structure


The UDP header is concise, comprising only four fields, each spanning two bytes, as depicted in the figure above. Let's delve into each field individually:

1. Source Port Address:

  • This denotes the address of the application program responsible for generating the message.

2. Destination Port Address:

  • Signifying the address of the application program set to receive the message.

3. Total Length:

  • Specifies the overall length of the UDP segment, encompassing both the header and data, measured in bytes.

4. Checksum:

  • Employed by the receiving host, the checksum verifies whether errors have been introduced into the segment. It's worth noting that the checksum computation extends to certain fields in the IP header, in addition to the UDP segment itself.

 

UDP Services

UDP, characterized by its unique set of services, presents several key features:

1. Connectionless Communication:

  • UDP operates in a connectionless manner, meaning there is no prerequisite handshaking before two processes initiate communication. This absence of a formalized setup allows for a more straightforward interaction between communicating entities.

2. Unreliable Data Transfer:

  • Providing an unreliable data transfer service, UDP lacks a guarantee that messages will reach their destination. Consequently, messages may arrive at the receiving process at arbitrary times, introducing an element of unpredictability.

3. No Congestion-Control Mechanism:

  • Unlike certain transport layer protocols, UDP does not incorporate a congestion-control mechanism. This characteristic permits the sending process to transmit data into a UDP socket at its desired rate, without restrictions on pumping data.

While the absence of reliability and congestion control may seem counterintuitive, there are specific scenarios where UDP proves invaluable. Real-time applications, characterized by their ability to tolerate some data loss but requiring a minimum transmission rate, often leverage UDP. In such applications, waiting for acknowledgments for data input is not feasible.

Examples of real-time applications using UDP include Internet telephony, where the emphasis is on immediate communication rather than ensuring every packet's delivery. On the contrary, TCP, with its assurance of packet delivery, finds its usage in protocols like SMTP (E-mail), Telnet, HTTP, and FTP, where reliable communication is paramount. Additionally, protocols like NFS and Streaming Multimedia may opt for either TCP or UDP based on their specific requirements.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Ok, Go it!