Chapter 4: Transport Layer – Study Notes for BSc Computer Science Students

The Transport Layer is crucial in ensuring reliable data communication between devices over a network. It ensures that data sent by an application on one machine reaches the appropriate application on another machine in a correct, reliable, and orderly manner. This blog post will guide you through the key concepts of the Transport Layer, including its services, protocols, and how they function within the OSI and TCP/IP models.


4.1 Transport Layer Services

The Transport Layer offers several critical services that ensure the correct transfer of data between processes on different machines. Below are some of the core services:

  • Process-to-Process Communication: The transport layer enables communication between specific processes on devices (such as web servers or email clients) rather than just devices themselves. It is the intermediary between the application layer and the network layer.
  • Addressing: To ensure the data reaches the correct process, the transport layer uses port numbers to identify the source and destination processes.
  • Encapsulation and Decapsulation: The transport layer encapsulates the data from the application layer into segments, adding headers that include information like sequence numbers and port numbers. When the data reaches its destination, the transport layer decapsulates the segment, removing the headers, and passes the data to the application layer.
  • Multiplexing and Demultiplexing: The transport layer uses multiplexing to combine multiple data streams from different applications into one communication channel, and demultiplexing when the data reaches its destination to direct it to the correct process.
  • Flow Control: Flow control mechanisms are used to manage the rate at which data is sent to avoid overwhelming the receiver. Common techniques include the sliding window protocol.
  • Buffers: Buffers temporarily hold the data in memory before sending or after receiving, allowing smooth data transmission without loss.
  • Sequence Numbers: Sequence numbers are used to keep track of the order of segments, ensuring that data is reassembled correctly at the destination.
  • Acknowledgements: Acknowledgements (ACK) confirm the receipt of data segments, helping ensure reliable communication.
  • Sliding Window: The sliding window mechanism in flow control allows the sender to send multiple segments before needing an acknowledgment for earlier ones, improving efficiency and speed.
  • Congestion Control: This service helps prevent the network from becoming overloaded, avoiding packet loss and delays due to excessive traffic.

4.2 Connectionless and Connection-Oriented Services, Port Numbers

The transport layer provides two types of services:

  1. Connection-Oriented Service: In this service, a connection is established between the sender and receiver before data transfer begins. It ensures reliable delivery, error checking, and data sequencing. TCP (Transmission Control Protocol) is a prime example of a connection-oriented service.
  2. Connectionless Service: In this service, no connection is established before data transfer. Each packet is treated independently, with no guarantee of delivery or order. UDP (User Datagram Protocol) is an example of a connectionless service.

Port Numbers: These are used in both connection-oriented and connectionless communication to direct data to the appropriate process on a device. Port numbers range from 0 to 65535 and are divided into:

  • Well-Known Ports (0-1023): Assigned to common services like HTTP (80), FTP (21), etc.
  • Registered Ports (1024-49151): Used by software applications.
  • Dynamic/Private Ports (49152-65535): Typically used for ephemeral communication.

4.3 Transport Layer Protocols – UDP (User Datagram Protocol)

UDP (User Datagram Protocol) is a connectionless transport layer protocol that allows quick, lightweight communication between devices. Key characteristics of UDP include:

  • UDP Services:
    • Connectionless: No connection setup is required between sender and receiver.
    • Unreliable: Data may be lost, duplicated, or arrive out of order.
    • Minimal Overhead: UDP has a smaller header size compared to TCP, making it ideal for time-sensitive applications (e.g., streaming media or online gaming).
    • No Acknowledgements: UDP does not use acknowledgements for data packets, reducing latency.

UDP Datagram: The basic unit of data in UDP is the datagram, which contains the source port, destination port, length, checksum, and the data payload.

UDP is suitable for applications that prioritize speed over reliability, such as video conferencing or VoIP (Voice over IP).


4.4 Transmission Control Protocol (TCP)

TCP (Transmission Control Protocol) is a connection-oriented, reliable transport layer protocol that ensures accurate and in-order delivery of data. Some of the key features and components of TCP include:

  • TCP Services:
    • Reliability: TCP ensures that data is reliably delivered through acknowledgements and retransmissions of lost packets.
    • Ordered Data: Data segments are ordered by sequence numbers, so they are delivered in the correct order.
    • Flow Control: TCP uses flow control (sliding window) to prevent congestion and ensure smooth data transfer.
    • Congestion Control: TCP dynamically adjusts the transmission rate to avoid network congestion.
  • TCP Features:
    • Connection Establishment: Before data transfer can begin, TCP establishes a connection using a process called the three-way handshake.
    • Connection Termination: After data transfer, TCP gracefully terminates the connection through a four-way handshake.
  • TCP Segment Format: Each segment in TCP consists of:
    • Source and Destination Port Numbers
    • Sequence Number: Indicates the position of the segment in the sequence of transmitted data.
    • Acknowledgement Number: Indicates the next expected byte.
    • Flags: Control bits like SYN, ACK, FIN to manage the connection.
    • Window Size: Specifies the amount of data the receiver can buffer.
  • Three-Way Handshake for Connection Establishment: The process used to establish a connection between the sender and receiver:
  • SYN: The client sends a SYN (synchronize) packet to the server to initiate the connection.
  • SYN-ACK: The server acknowledges the client’s SYN with a SYN-ACK packet.
  • ACK: The client sends an ACK (acknowledgment) packet to confirm the connection.
  • Connection Termination: The termination process involves four steps:
    1. FIN: The client sends a FIN (finish) packet to indicate that it is done sending data.
    2. ACK: The server acknowledges the FIN.
    3. FIN: The server sends a FIN to the client to indicate it is done sending data.
    4. ACK: The client acknowledges the server’s FIN, and the connection is closed.
  • State Transition Diagram: TCP has a state machine that defines the states a connection goes through during its lifetime (e.g., LISTEN, ESTABLISHED, FIN_WAIT).
  • Windows in TCP: TCP uses a sliding window to manage flow control. The window size indicates how much data can be sent before receiving an acknowledgment. This helps to avoid congestion and optimize performance.

Conclusion

The Transport Layer plays a vital role in ensuring that data is reliably delivered from one process to another across networks. Whether using the reliable TCP protocol or the faster, connectionless UDP, understanding the services and protocols of the Transport Layer is key to understanding how the Internet and applications function.

In this chapter, we covered:

  • The services provided by the transport layer (e.g., flow control, multiplexing).
  • The differences between connection-oriented (TCP) and connectionless (UDP) services.
  • TCP features like the three-way handshake and flow control mechanisms.

Mastering these concepts will strengthen your understanding of network communication, which is essential for BSc Computer Science students.

Scroll to Top