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:
- SYN: Client sends SYN (seq = x)
- SYN-ACK: Server sends SYN-ACK (seq = y, ack = x+1)
- ACK: Client sends ACK (seq = x+1, ack = y+1)
Connection Established
Four-Way Handshake
Terminating Connection:
- FIN: Client sends FIN
- ACK: Server sends ACK
- FIN: Server sends FIN
- 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
- TCP vs UDP: Connection-oriented vs connectionless
- Three-Way Handshake: Connection establishment
- Flow Control: Sliding window protocol
- Congestion Control: Slow start, congestion avoidance
- TCP States: State transitions
Practice Tips
- TCP Handshake: Understand three-way and four-way
- Flow Control: Practice sliding window problems
- Congestion Control: Understand algorithms
- Port Numbers: Know common ports
- Previous Year Questions: Solve GATE transport layer questions