Computer NetworksUnit 58 min read
Transport Layer: Services, Protocols, and Reliability Mechanisms
Unit 5 of Computer Networks: This note explains the Transport Layer’s role in end‑to‑end communication, details TCP/UDP operation, flow and error control, congestion handling, and practical examples of segmentation and ARQ.
Key points
- The Transport Layer provides reliable, ordered, and error‑free data delivery through TCP, while UDP offers lightweight, connectionless service.
- Sequence numbers, acknowledgements, and sliding windows enable flow control and error recovery.
- Congestion control algorithms (slow start, congestion avoidance, fast retransmit) prevent network overload.
- Port numbers and sockets multiplex multiple applications over a single IP address.
- Understanding ARQ protocols and TCP state transitions is essential for exam questions.
Transport Layer Overview
The Transport Layer (Layer 4 of the OSI model) sits between the Network Layer (Layer 3) and the Application Layer (Layer 5). Its primary responsibilities are:
- End‑to‑end communication – ensuring that data sent by an application on one host arrives intact at the application on the destination host.
- Segmentation and reassembly – breaking large application messages into manageable segments and reassembling them at the receiver.
- Multiplexing – allowing multiple applications to share a single network connection through port numbers.
- Reliability, flow control, and congestion control – guaranteeing correct delivery, preventing sender overload, and avoiding network congestion.
The Transport Layer is defined by the Internet Engineering Task Force (IETF) in RFC 793 (TCP) and RFC 768 (UDP).
Key Protocols
| Feature | TCP | UDP |
|---|---|---|
| Connection | Connection‑oriented (handshake) | Connectionless |
| Reliability | Yes (ACK, retransmission) | No |
| Ordering | Yes (sequence numbers) | No |
| Flow control | Yes (windowing) | No |
| Congestion control | Yes (slow start, congestion avoidance) | No |
| Overhead | 20‑bytes header | 8‑bytes header |
| Typical use | Web, email, file transfer | DNS, VoIP, streaming |
TCP – Transmission Control Protocol
TCP is a stateful, byte‑stream protocol that guarantees reliable, ordered delivery. Its header fields include:
sequenceDiagram
participant Client
participant Server
Client->>Server: SYN (Seq=x)
Server->>Client: SYN-ACK (Seq=y, Ack=x+1)
Client->>Server: ACK (Ack=y+1)
Note right of Server: Connection Established
Client->>Server: Data (Seq=z)
Server->>Client: ACK (Ack=z+1)
Client->>Server: FIN
Server->>Client: ACK
Server->>Client: FIN
Client->>Server: ACK
Note right of Server: Connection TerminatedTCP Three-Way Handshake and Connection Termination
- Source/Destination Port – 16‑bit identifiers for application processes.
- Sequence Number – byte offset of the first byte in the segment.
- Acknowledgement Number – next expected byte from the peer.
- Data Offset – header length.
- Flags – SYN, ACK, FIN, RST, PSH, URG.
- Window Size – number of bytes the receiver can accept.
- Checksum – error detection.
TCP Handshake (Three‑Way)
- SYN – Client → Server:
Seq = x - SYN‑ACK – Server → Client:
Seq = y,Ack = x+1 - ACK – Client → Server:
Ack = y+1
After the handshake, data transfer begins.
Example: Segmentation and Reassembly
Suppose an application sends a 1,200‑byte message. The TCP Maximum Segment Size (MSS) is 500 bytes.
| Segment | Sequence # | Data | ACK # | Window |
|---|---|---|---|---|
| 1 | 0 | 500 bytes | 500 | 1500 |
| 2 | 500 | 500 bytes | 1000 | 1500 |
| 3 | 1000 | 200 bytes | 1200 | 1500 |
The receiver acknowledges each segment. If segment 2 is lost, the sender retransmits it after a timeout or upon receiving a duplicate ACK.
Flow Control – Sliding Window
TCP uses a receiver window to inform the sender of available buffer space. The sender may transmit up to Window Size bytes without waiting for ACKs.
graph LR
A[Sender Buffer] -->|Window=1000| B[Network]
B --> C[Receiver Buffer]
C -->|ACK| A
style A fill:#f9f,stroke:#333
style C fill:#bbf,stroke:#333
style B fill:#f99,stroke:#333
note right of A: Sender transmits up to window size
note right of C: Receiver advertises available spaceTCP Sliding Window Flow Control
Worked Example
- Receiver window = 1,000 bytes.
- Sender transmits 1,000 bytes (segments 1–2).
- Receiver acknowledges 1,000.
- Sender can now send next 1,000 bytes.
If the receiver’s buffer becomes full, it advertises a window of 0, forcing the sender to pause.
Congestion Control
TCP employs several algorithms:
- Slow Start – starts with
cwnd = 1segment; doubles each RTT until reachingssthresh. - Congestion Avoidance – increases
cwndlinearly afterssthresh. - Fast Retransmit – retransmits a segment after receiving three duplicate ACKs.
- Fast Recovery – reduces
cwndtossthreshand enters congestion avoidance.
These mechanisms adapt the sending rate to network capacity, preventing congestion collapse.
UDP – User Datagram Protocol
UDP is a lightweight, connectionless protocol. Its header contains only source/destination ports, length, and checksum. It offers no sequencing, flow control, or congestion control. UDP is suitable for real‑time applications where occasional packet loss is acceptable.
Transport Layer Services
| Service | Description | Example |
|---|---|---|
| Segmentation | Splits application data into segments. | TCP divides a 10 KB file into 1 KB segments. |
| Reassembly | Reorders segments at the receiver. | TCP reorders out‑of‑order segments using sequence numbers. |
| Multiplexing/Demultiplexing | Uses port numbers to map segments to applications. | HTTP uses port 80. |
| Reliability | Ensures error‑free delivery via ACKs and retransmission. | TCP retransmits lost segments. |
| Flow Control | Prevents sender from overwhelming receiver. | TCP sliding window. |
| Congestion Control | Avoids network congestion. | TCP slow start. |
| Error Detection | Checksums detect corrupted packets. | TCP checksum. |
ARQ Protocols – Error Control
Stop‑and‑Wait ARQ
- Sender transmits one frame and waits for ACK.
- If ACK not received within timeout, retransmit.
- Simple but low throughput.
graph TD
A[Send Frame 1] -->|Timeout?| B{No ACK?}
B -->|No| C[Proceed]
B -->|Yes| D[Retransmit Frame 1]
D --> A
C --> E[Send Frame 2]
style A fill:#f9f,stroke:#333
style D fill:#f99,stroke:#333
style E fill:#bbf,stroke:#333
note right of B: Wait for ACK or timeoutStop-and-Wait ARQ Process Flow
Worked Example
Assume a 1 kB frame, transmission time = 10 ms, RTT = 50 ms.
Throughput = Frame Size / (Transmission Time + RTT)
= 1 kB / (10 ms + 50 ms) = 16.7 kB/s.
Sliding‑Window ARQ (TCP)
- Sender can transmit multiple frames up to the window size.
- Receives cumulative ACKs.
- Improves throughput by keeping the pipeline full.
Illustration
Sender: [S1] [S2] [S3] [S4] [S5]
| | | | |
Receiver ACKs: | | | | |
If S3 is lost, the receiver acknowledges up to S2. The sender retransmits S3 and continues with S4, S5.
Distance Vector Algorithm – Brief Mention
Although primarily a routing protocol at the Network Layer, the Distance Vector algorithm’s principles (e.g., Bellman‑Ford) influence Transport Layer congestion control by estimating path costs (RTT, loss). Understanding its operation helps in analyzing TCP’s RTT estimation and timeout calculations.
Practical Applications
| Application | Transport Protocol | Reason |
|---|---|---|
| Web browsing | TCP (HTTP/HTTPS) | Reliable, ordered delivery |
| TCP (SMTP, POP3, IMAP) | Integrity of messages | |
| DNS | UDP (port 53) | Low latency, small queries |
| VoIP | UDP (RTP) | Real‑time, tolerant to loss |
| File transfer | TCP (FTP, SCP) | Full reliability |
Advantages & Disadvantages
| Aspect | TCP | UDP |
|---|---|---|
| Reliability | ✔ | ✘ |
| Ordering | ✔ | ✘ |
| Overhead | High | Low |
| Latency | Higher (handshake, ACKs) | Lower |
| Suitability | Applications requiring accuracy | Real‑time, streaming |
Exam Tip
- Define each Transport Layer service clearly.
- Compare TCP and UDP using a table.
- Explain the TCP three‑way handshake and state transitions.
- Illustrate a Stop‑and‑Wait or Sliding‑Window ARQ with a simple diagram.
- Calculate throughput for Stop‑and‑Wait given frame size, transmission time, and RTT.
- Discuss congestion control phases (slow start, congestion avoidance).
- Answer “Why is DNS required?” by highlighting name resolution and the role of UDP.
Focus on concise, structured answers, use tables and diagrams where appropriate, and practice tracing TCP segment exchanges to reinforce understanding.
Based on the TU BSc CSIT syllabus for Computer Networks (CSC263), unit 5.
Discussion
Loading…