Module 4 -- Transport Layer -- Computer Networks


Index

  1. Transport Layer
  2. Protocols of the Transport Layer
  3. 1. User Datagram Protocol (UDP)
  4. 2. Transmission Control Protocol (TCP)
  5. Three-Way Handshake in TCP
  6. TCP Connection Termination
  7. TCP Congestion Control
  8. QoS (Quality of Service) Implementations
  9. 1. Leaky Bucket Algorithm
  10. 2. Token Bucket Algorithm

Transport Layer

https://www.geeksforgeeks.org/transport-layer-responsibilities/

https://www.youtube.com/watch?v=kAty4mKczEg&list=PLxCzCOWd7aiGFBD2-2joCpWOLUrDLvVV_&index=64

The Transport Layer, which is the 4th layer in the OSI model, acts as the interface between the application and network layers. Its main job is to ensure that data sent by an application on one host is delivered reliably, in order, and to the correct process on another host.

While Data Link Layer requires the MAC address (48 bits address contained inside the Network Interface Card of every host machine) of source-destination hosts to correctly deliver a frame and the Network layer requires the IP address for appropriate routing of packets, in a similar way Transport Layer requires a Port number to correctly deliver the segments of data to the correct process amongst the multiple processes running on a particular host. A port number is a 16-bit address used to identify any client-server program uniquely.

Pasted image 20250329143817.png

1. End-to-End (Port-to-Port) Delivery

Pasted image 20250329143838.png


2. Protocols: TCP and UDP


3. Segmentation


4. Multiplexing and Demultiplexing

Pasted image 20250329143711.png


5. Flow Control and Congestion Control

Pasted image 20250329143619.png


6. Error Control

Pasted image 20250329144416.png


7. Overall Summary


Protocols of the Transport Layer

1. User Datagram Protocol (UDP)

https://www.youtube.com/watch?v=HF_znV8x9a0&list=PLxCzCOWd7aiGFBD2-2joCpWOLUrDLvVV_&index=72

https://www.geeksforgeeks.org/user-datagram-protocol-udp/

User Datagram Protocol (UDP) is a Transport Layer protocol. UDP is a part of the Internet Protocol suite, referred to as UDP/IP suite. Unlike TCP, it is an unreliable and connectionless protocol. So, there is no need to establish a connection before data transfer. The UDP helps to establish low-latency and loss-tolerating connections over the network. The UDP enables process-to-process communication.

Pasted image 20250330124005.png

1. Connectionless Nature


2. UDP Header Structure

The UDP header is very simple and consists of only four fields, each 16 bits in size:

Pasted image 20250330124029.png

a. Source Port

b. Destination Port

c. Length

d. Checksum


3. Key Characteristics of UDP


4. Use Cases for UDP

Because of its characteristics, UDP is commonly used in scenarios where low latency is more important than reliability, and where the application can tolerate some data loss:


2. Transmission Control Protocol (TCP)

https://www.youtube.com/watch?v=c8aet11HNxg&list=PLxCzCOWd7aiGFBD2-2joCpWOLUrDLvVV_&index=66 (Part 1)

https://www.youtube.com/watch?v=hsNuqtfxgRI&list=PLxCzCOWd7aiGFBD2-2joCpWOLUrDLvVV_&index=67 (Part 2)

https://www.geeksforgeeks.org/what-is-transmission-control-protocol-tcp/

TCP, or Transmission Control Protocol, is a cornerstone protocol at the Transport Layer that provides reliable, ordered, and error-checked delivery of data between applications. Unlike UDP, TCP is connection-oriented and builds a reliable channel between two endpoints.

1. Core Features of TCP

a. Connection-Oriented Communication

b. Byte Streaming and Segmentation

c. Full-Duplex Communication

d. Reliable Data Transfer and Error Control

e. Flow Control and Congestion Control

f. Piggybacking


2. Overview of the TCP Header

TCP adds a header to every segment. The header contains various fields that control the behavior of the protocol:

a. Source and Destination Ports (16 bits each)

b. Sequence Number (32 bits)

c. Acknowledgement Number (32 bits)

d. Data Offset (Header Length) (4 bits)

e. Reserved Bits (6 bits)

f. Control Flags (6 bits)

g. Window Size (16 bits)

h. Checksum (16 bits)

i. Urgent Pointer (16 bits)

j. Options and Padding (Variable)


3. Summary of TCP Functionality


Three-Way Handshake in TCP

https://www.youtube.com/watch?v=qIEHUUt2Wfc&list=PLxCzCOWd7aiGFBD2-2joCpWOLUrDLvVV_&index=68

https://www.geeksforgeeks.org/tcp-3-way-handshake-process/

The TCP three-way handshake is the process used to establish a reliable connection between two endpoints before any actual data is transmitted. This handshake ensures that both the client and server are ready to communicate, agree on initial sequence numbers, and set up necessary parameters like window size and maximum segment size (MSS). Here’s a detailed explanation of the process:


1. Purpose of the Three-Way Handshake


2. Steps of the Three-Way Handshake

Step 1: SYN (Synchronize) — Active Open


Step 2: SYN-ACK (Synchronize-Acknowledge) — Passive Open


Step 3: ACK (Acknowledge) — Active Confirmation

Pasted image 20250330130535.png


3. Key Concepts Illustrated in the Handshake


4. Summary


Piggybacking and Pure Acknowledgement in TCP

https://www.youtube.com/watch?v=7zPfuIf4GL0&list=PLxCzCOWd7aiGFBD2-2joCpWOLUrDLvVV_&index=69

TCP supports two methods for conveying acknowledgements during data transfer:

1. Piggybacking

Definition:

How It Works:


2. Pure Acknowledgement

Definition:

How It Works:


3. Why Both Methods Are Important


4. Summary


TCP Connection Termination

https://www.youtube.com/watch?v=dJIAComFq9U&list=PLxCzCOWd7aiGFBD2-2joCpWOLUrDLvVV_&index=70

Pasted image 20250330132309.png

TCP connection termination is the process by which a TCP session is gracefully closed once no further data is to be exchanged. Unlike connection establishment—which uses a three-way handshake—termination can occur in either a three-step or a four-step process depending on whether one side immediately closes its half of the connection or delays it to send remaining data.


1. Key Concepts


2. The Termination Process

Scenario 1: Three-Step (Three-Way) Termination

This is the most common scenario when both sides are ready to close the connection simultaneously:

  1. FIN from the Initiator (Client):

    • Action: The client sends a FIN packet to the server.

    • Meaning: The client indicates that it has no more data to send.

    • Sequence Impact: This FIN consumes one sequence number.

  2. FIN+ACK from the Peer (Server):

    • Action: Upon receiving the FIN, the server releases its resources (for the client-to-server direction) and sends back a combined FIN and ACK packet.

    • ACK Component: This acknowledges the client’s FIN (for example, if the client’s FIN used sequence number X, the server’s ACK number will be X+1).

    • FIN Component: Simultaneously, the server indicates that it, too, is ready to terminate its side of the connection by setting the FIN flag.

    • Sequence Impact: The server’s FIN consumes one sequence number from its own sequence space.

  3. Final ACK from the Initiator (Client):

    • Action: The client sends an ACK packet acknowledging the server’s FIN (e.g., if the server’s FIN used sequence number Y, the client sends an ACK number Y+1).

    • Note: This final ACK is sent solely for acknowledgment and does not consume a sequence number.

    • Result: After this ACK, both sides have agreed that no more data will be sent, and the connection is terminated.

Scenario 2: Four-Step Termination

In some cases, one side (say, the server) may have additional data to send even after receiving a FIN, leading to a delayed termination:

  1. FIN from the Initiator (Client):

    • The client sends a FIN to indicate it has finished sending data.
  2. Pure ACK from the Peer (Server):

    • Instead of immediately sending its own FIN, the server sends a pure ACK for the client’s FIN, confirming that it has received the termination request.

    • Implication: The connection is half-closed; the client cannot send further data, but the server can continue to transmit any remaining data.

  3. Server Sends Data (if needed):

    • The server may now continue to send remaining data or control messages. During this period, the server’s connection remains open for sending data even though it has acknowledged the client’s FIN.
  4. Server Sends FIN (and possibly FIN+ACK):

    • When the server has finished sending its data, it sends a FIN packet (or a FIN+ACK packet) to indicate that it too is done.

    • The client then responds with a final ACK, just as in the three-step process.


3. Important Points to Remember


4. Visualizing the Process

Imagine two people (client and server) on a phone call:


TCP Congestion Control

TCP congestion control is a set of algorithms designed to prevent network congestion and ensure efficient data transmission. Its primary goal is to adapt the rate of data transmission based on the network’s capacity, thereby avoiding packet loss due to overload.


1. Why Congestion Control?


2. Key Components of TCP Congestion Control

a. Congestion Window (cwnd)

b. Slow Start

c. Congestion Avoidance

d. Multiplicative Decrease

e. Fast Retransmit and Fast Recovery


3. How These Algorithms Work Together


4. Impact on Network Efficiency


5. Summary

TCP congestion control is essential for maintaining efficient, stable network communications. It does this by:


QoS (Quality of Service) Implementations

1. Leaky Bucket Algorithm

https://www.geeksforgeeks.org/leaky-bucket-algorithm/

Pasted image 20250331125100.png

Concept Overview

How It Works

Key Points


2. Token Bucket Algorithm

Pasted image 20250331125134.png

Concept Overview

How It Works

Key Points


3. Comparison: Leaky Bucket vs. Token Bucket

Aspect Leaky Bucket Token Bucket
Output Rate Constant, fixed rate Average rate fixed by token generation; bursts allowed
Burst Handling Cannot handle bursts; excess packets are dropped Allows bursts up to accumulated token capacity
Traffic Shaping Smooths traffic to a constant rate Controls average rate while allowing bursty traffic
Implementation Focus Often used for strict rate-limiting and traffic policing Used for both rate limiting and traffic shaping with burst tolerance

4. Practical Implications