03

Transport Layer

Chapter 3 • Advanced

80 min

Transport Layer

Transport Layer provides end-to-end communication between applications.

Transport Layer Protocols

TCP (Transmission Control Protocol)

TCP is connection-oriented, reliable protocol.

Features:

  • Connection-oriented
  • Reliable delivery
  • Flow control
  • Congestion control
  • Full-duplex
  • Byte-stream

TCP Header Fields:

  • Source port (16 bits)
  • Destination port (16 bits)
  • Sequence number (32 bits)
  • Acknowledgment number (32 bits)
  • Flags (SYN, ACK, FIN, etc.)
  • Window size (16 bits)
  • Checksum (16 bits)

UDP (User Datagram Protocol)

UDP is connectionless, unreliable protocol.

Features:

  • Connectionless
  • Unreliable delivery
  • No flow control
  • No congestion control
  • Low overhead
  • Message-oriented

UDP Header Fields:

  • Source port (16 bits)
  • Destination port (16 bits)
  • Length (16 bits)
  • Checksum (16 bits)

TCP Connection Management

Three-Way Handshake

Establishing Connection:

  1. SYN: Client sends SYN (seq = x)
  2. SYN-ACK: Server sends SYN-ACK (seq = y, ack = x+1)
  3. ACK: Client sends ACK (seq = x+1, ack = y+1)

Connection Established

Four-Way Handshake

Terminating Connection:

  1. FIN: Client sends FIN
  2. ACK: Server sends ACK
  3. FIN: Server sends FIN
  4. ACK: Client sends ACK

Connection Terminated

Flow Control

Flow Control prevents sender from overwhelming receiver.

Sliding Window Protocol

Window Size: Number of bytes receiver can accept.

Mechanism:

  • Receiver advertises window size
  • Sender sends up to window size
  • Receiver acknowledges received data
  • Window slides as data acknowledged

Example:

  • Window size = 4
  • Send bytes 1-4
  • ACK 1, window slides
  • Send bytes 5-8

Congestion Control

Congestion Control prevents network overload.

TCP Congestion Control Algorithms

1. Slow Start

Initial Phase:

  • Start with cwnd = 1 MSS
  • Double cwnd every RTT
  • Until threshold or loss

2. Congestion Avoidance

After Threshold:

  • Increase cwnd by 1 MSS per RTT
  • Linear growth

3. Fast Retransmit

On Duplicate ACKs:

  • Retransmit immediately
  • Don't wait for timeout

4. Fast Recovery

After Fast Retransmit:

  • Reduce cwnd
  • Enter congestion avoidance

TCP States

States:

  • CLOSED
  • LISTEN
  • SYN-SENT
  • SYN-RECEIVED
  • ESTABLISHED
  • FIN-WAIT-1
  • FIN-WAIT-2
  • CLOSE-WAIT
  • CLOSING
  • TIME-WAIT
  • LAST-ACK

Ports

Port identifies application/service.

Well-Known Ports (0-1023):

  • HTTP: 80
  • HTTPS: 443
  • FTP: 21
  • SSH: 22
  • SMTP: 25
  • DNS: 53

Registered Ports (1024-49151):

Dynamic Ports (49152-65535):

GATE CS Important Points

  1. TCP vs UDP: Connection-oriented vs connectionless
  2. Three-Way Handshake: Connection establishment
  3. Flow Control: Sliding window protocol
  4. Congestion Control: Slow start, congestion avoidance
  5. TCP States: State transitions

Practice Tips

  1. TCP Handshake: Understand three-way and four-way
  2. Flow Control: Practice sliding window problems
  3. Congestion Control: Understand algorithms
  4. Port Numbers: Know common ports
  5. Previous Year Questions: Solve GATE transport layer questions