Lecture - 4
Introduction to Transport Layer & Protocols
Core Topics
❏ Introduction to Transport Layer
❏ TCP ( Transmission Control Protocol )
❏ TCP’s three-way Handshake Process
❏ Congestion Control in TCP
❏ UDP ( User Datagram Protocol )
❏ SCTP (Stream Control Transmission Protocol)
❏ TCP Vs UDP Vs SCTP
❏ Multiplexing & Demultiplexing
Transport Layer
❏ Fourth layer in the OSI model, sits above
the network layer.
❏ Provides end-to-end communication
between applications on different hosts.
❏ Responsible for segmentation, flow
control, error handling, and reliable data
transfer.
Core Functionalities:
● Segmentation and Reassembly: Divides messages into smaller segments at the sender
and reassembles them at the receiver.
● Connection Management: Establishes, maintains, and terminates logical connections
(TCP).
● Error Detection & Recovery: Ensures data integrity using checksums and retransmissions.
● Flow Control: Prevents sender from overwhelming receiver (e.g., TCP's sliding window).
● Congestion Control: Manages traffic load to avoid network congestion (TCP algorithms).
● Multiplexing/Demultiplexing: Uses port numbers to allow multiple services over a single
connection.
Follow Up Questions:
Q. Which layer ensures end-to-end Q. Which is not a function of the transport layer?
communication?
a) Flow Control
a) Network Layer b) Error Correction
b) Transport Layer c) IP Addressing
c) Data Link Layer d) Multiplexing
d) Application Layer
Q. What is segmentation in the transport layer? Q. Transport layer ensures delivery between
______.
a) Dividing IP addresses
b) Breaking data into smaller chunks a) Routers
c) Securing data b) Processes
d) Compressing files c) Hosts
d) Packets
TCP (Transport Layer Protocol):
● TCP (Transmission Control Protocol) is a connection-oriented protocol that ensures
reliable communication between devices over a network.
● It establishes a connection using a three-way handshake and guarantees the ordered
and error-free delivery of data.
● TCP provides flow control, congestion control, and retransmission mechanisms for
robust data transfer.
● It is widely used in applications where reliability is crucial, such as Web browsing
(HTTP/HTTPS), File transfer (FTP), and Email (SMTP).
Three-Way Handshake Process in TCP :
Three-Way Handshake Process:
Step 1: SYN (Synchronize) – Step 2: SYN-ACK Step 3: ACK (Acknowledge) –
Client to Server (Synchronize-Acknowledge) – Client to Server
Server to Client
❖ The client initiates the ❖ The client receives SYN-
connection. ❖ The server receives the ACK from the server.
❖ Sends a TCP segment with SYN request. ❖ Sends a final segment with
the SYN flag set. ❖ Sends back a segment with the ACK flag set.
❖ Includes the client’s Initial both SYN and ACK flags ❖ Acknowledges the server’s
Sequence Number (ISN). set. ISN (ACK = y + 1).
❖ Indicates the client wants to ❖ Acknowledges the client’s ❖ Connection is now
establish a connection and ISN (ACK = x + 1). established and ready for
begin communication. ❖ Sends its own ISN (Seq = data transmission.
y).
Follow Up Questions:
Q. What does the client send after receiving SYN-ACK Q. What is the purpose of the 3-way handshake in
from the server? TCP?
a) SYN a) Error detection only
b) ACK b) Congestion control
c) FIN c) Connection establishment and sequence number
d) RST synchronization
d) Authentication
Q. What happens if the client sends a SYN, but the Q. What is the significance of initial sequence numbers
server does not respond? (ISN) exchanged during handshake?
a) Client sends ACK again a) Help in window sizing
b) Client retransmits SYN after timeout b) Used for reliable byte-stream tracking
c) Connection is immediately established c) Used for encryption
d) Server initiates connection d) Used to assign port numbers
Activity ( Level 1 )
Activity 1: Protocol Identification Table Activity 2: Port Number Classification
Problem : Fill in the table below by identifying whether the Problem: Find the port number of the given protocols.
following statements relate to TCP or UDP.
Service Port Number
Statement TCP/UDP
HTTP 80
Connection-oriented TCP
Suitable for video streaming UDP DNS 53
Has error-checking and TCP FTP 20/21
correction
No handshake before UDP SMTP 25
communication
Telnet 23
Reliable Transmission TCP
DHCP 67/68
TCP Header:
TCP Header:
Field Size (bits) Description
Port number of the sender (e.g.,
Source Port 16
54321)
Port number of the receiver (e.g.,
Destination Port 16
80 for HTTP)
Number of the first byte of data in
Sequence Number 32 this segment. Used for tracking
data.
Next expected byte from the
Acknowledgment Number 32
other side (used in ACK).
Length of the TCP header in 32-
Data Offset (Header Length) 4 bit words (minimum 5 = 20
bytes).
TCP Header:
Field Size (bits) Description
Control Flags (9 bits)
9 Control bits (e.g., SYN, ACK, FIN):
Amount of data (in bytes) the
receiver can accept (used in flow
Window Size 16
control).
For error-checking the header and
Checksum 16
data.
Urgent Pointer 16 Points to urgent data in the segment
(only if URG is set).
Options (if any) Variable Used for things like window scaling,
timestamps, etc.
Padding Variable Ensures the header is a multiple of 32
bits.
Follow Up Questions:
Q. What is the minimum size of a TCP Q. Which TCP header field is used for Q. What is the purpose of the TCP
header (without options)? reordering and reliable data transfer? Checksum field?
a) 10 bytes a) Acknowledgment Number a) To check sequence numbers
b) 24 bytes b) Sequence Number b) To detect errors in the TCP
c) 20 bytes c) Flags segment
d) 32 bytes d) Window Size c) To determine congestion
d) To track retransmissions
Q. What does the Acknowledgment Q. The TCP header contains a field Q. The field responsible for
Number in the TCP header represent? called 'Flags'. Which of the following is differentiating multiple TCP connections
NOT a TCP flag? on the same host is:
a) Last received byte
b) Total data bytes a) FIN a) Sequence Number
c) Next expected byte from sender b) PUSHACK b) Source and Destination Ports
d) Sequence number of sender c) URG c) Acknowledgment Number
d) SYN d) Checksum
TCP Congestion Control:
● TCP Congestion Control is a set of mechanisms used to prevent network overload by
controlling the rate of data transmission.
● It dynamically adjusts the sender’s transmission rate based on network feedback,
ensuring efficient and fair bandwidth usage.
● Key algorithms include Slow Start, Congestion Avoidance, Fast Retransmit, and Fast
Recovery.
● Congestion control is essential for maintaining network stability, reducing packet
loss, and optimizing throughput in TCP communications.
Phases in TCP Congestion Control:
Slow Start Phase: Congestion Avoidance Phase:
❏ Starts with cwnd = 1 MSS. ❏ Starts when cwnd ≥ ssthresh.
❏ Doubles cwnd each RTT (exponential growth). ❏ Increases cwnd linearly (by 1 MSS per RTT).
❏ Stops when cwnd ≥ ssthresh, then switches to ❏ Reduces cwnd if packet loss is detected.
linear growth.
Congestion Control:
Follow Up Questions:
Q. What does the TCP slow start Q. In TCP slow start, the cwnd increases Q. What is the threshold value that
algorithm initially set the congestion by how much per RTT? determines the switch from slow start to
window (cwnd) to? congestion avoidance?
a) Linearly by 1 MSS
a) 0 bytes b) Constantly by 2 MSS a) cwnd
b) 1 MSS c) Doubles (exponentially) b) RTT
c) 10 MSS d) Decreases gradually c) MSS
d) ssthresh d) ssthresh
Q. In congestion avoidance, how is cwnd Q. What is the purpose of the slow start Q. What happens to ssthresh when packet
increased? phase? loss is detected?
a) Doubled each RTT a) To probe the network capacity a) It is increased
b) Increases linearly (1 MSS per RTT) gradually b) It is reset to zero
c) Reset to 1 b) To detect packet errors c) It is halved (usually)
d) Randomly c) To reduce data rate d) It is doubled
d) To close the connection
UDP (User Datagram Protocol):
● UDP (User Datagram Protocol) is a connectionless transport layer protocol that
allows fast transmission of data without establishing a prior connection.
● It provides minimal overhead by not guaranteeing delivery, order, or error correction
— making it lightweight and efficient.
● UDP is ideal for applications that prioritize speed over reliability, such as real-time
audio/video streaming and online gaming.
● Common protocols that use UDP include DNS, DHCP, VoIP, and live broadcasts, where
some data loss is acceptable.
UDP Header:
1. Source Port (16 bits): 2. Destination Port (16 bits):
● Indicates the port number of ● Indicates the port number of the
the sending application. receiving application.
● Helps the receiver identify ● The most important field for
which application sent the directing the datagram to the right
data. process.
● Can be zero if the sender does ● Common UDP destination ports:
not need a reply. ● DNS → 53, HTTP→ 80,
HTTPS→ 443.
3. Length (16 bits): 4. Checksum (16 bits):
● Specifies the total length of the ● Provides error detection for the
UDP datagram (header + data) header and data.
in bytes. ● Mandatory in IPv6; optional in
● Minimum value = 8 bytes (if no IPv4 (but usually used).
data). ● It Covers: UDP header, UDP data
● Total Length = UDP Header and a pseudo-header from the IP
(8 bytes) + Data length layer which includes Source IP
address, Destination IP address,
Protocol ,UDP Length.
Follow up Questions:
Q. What is the size of the UDP header? Q. UDP provides which of the following?
a) 16 bytes a) Congestion control
b) 32 bytes b) Flow control
c) 8 bytes c) Multiplexing using ports
d) 20 bytes d) Reliable delivery
Q. What happens if a UDP segment is lost during Q. Which of the following is NOT a field in the UDP header?
transmission?
a) Source Port
a) It is automatically retransmitted b) Destination Port
b) The receiver sends a NACK c) Sequence Number
c) A TCP segment is sent instead d) Length
d) It is lost; no retransmission is done
SCTP (Stream Control Transmission Protocol):
● SCTP (Stream Control Transmission Protocol) is a reliable, message-oriented,
transport layer protocol.
● It combines features of TCP (reliability) and UDP (message-based) with advanced
functionalities like multi-streaming and multi-homing.
● SCTP is suitable for applications that require robust and redundant communication.
● It ensures ordered and unordered delivery options across multiple independent
streams within a single connection, preventing head-of-line blocking.
Key Features of SCTP:
SCTP Packet Format:
❏ Message-Oriented
❏ Reliable Delivery
❏ Ordered and Unordered Delivery
❏ Multi-Streaming
❏ Multi-Homing
❏ 4-Way Handshake
TCP Vs UDP Vs SCTP:
Aspect TCP UDP SCTP
Reliability Yes No Yes
Connection-Oriented Yes No Yes (Association-based)
Message-Oriented No (Byte stream) Yes Yes
Multi-Streaming No No Yes
Multi-Homing No No Yes
Congestion Control Yes No Yes
Ordered Delivery Yes No Optional per stream
Port Address:
❖ A port address (also called a port number) is a logical address used by the Transport Layer to
identify specific processes or services on a host.
❖ While the IP address identifies the device (host) on the network, the port number identifies
the specific application or service running on that device.
❖ A port number is a 16-bit unsigned integer.
❖ Range: 0 – 2^16 -1
ie, 0 - 65,535.
Socket Address:
★ A Socket Address is a unique identifier used to establish communication between two
processes (applications) across a network.
★ It is a combination of two components:
Socket Address = IP Address + Port Number
Follow Up Questions:
Q. Which of the following is a unique Q. What does SCTP use instead of TCP’s Q. What is the size of the port number
feature of SCTP? sequence numbers? field in TCP and UDP headers?
a) Reliable byte-stream service a) Window size a) 8 bits
b) Connectionless communication b) Transmission Sequence Number (TSN) b) 64 bits
c) Multi-streaming and multi-homing c) Acknowledgment field c) 32 bits
support d) Urgent pointer d) 16 bits
d) In-order delivery only
Q. What is the port number for SMTP Q. Port numbers are used in networking to: Q. What is a “chunk” in SCTP?
(Simple Mail Transfer Protocol)?
a) Identify IP addresses a) A fixed-size packet
a) 110 b) Identify specific applications/services b) A unit of data or control
b) 23 c) Set MAC addresses information in the message
c) 25 d) Encrypt data c) A part of IP address
d) 21 d) A TCP segment
Activity ( Level 2 )
Activity 1: Address Type
Problem: Match the address types with their correct definitions.
Address Type Specification
I. IP Address A. Uniquely identifies a service running
on a host
I. Port Address B. Combines an IP address and a port
number
I. Socket Address C. Uniquely identifies a host on a
network (logical address)
I. MAC Address D. Hardware address that uniquely
identifies a device on a LAN
Sol : I → C, II → A, III → B, IV → D
Multiplexing:
❖ Multiplexing is a technique that allows multiple signals or data streams to be combined and
transmitted over a single shared communication medium (e.g., wire, fiber, or channel).
❖ It enables simultaneous communication by allowing multiple users or applications to
efficiently share the same physical link without interference.
❖ Multiplexing addresses the limitation of physical communication channels by maximizing
bandwidth utilization and reducing infrastructure costs.
❖ This technique ensures that different data streams do not collide, using methods like Time
Division (TDM), Frequency Division (FDM), and Code Division (CDM).
❖ It is applied at both the physical layer (e.g., signal multiplexing) and transport layer (e.g.,
port-based multiplexing in TCP/UDP) to support scalable and efficient networking.
Demultiplexing:
❖ Demultiplexing is the process of delivering incoming data to the correct application or
process based on identifiers like port numbers.
❖ It is the reverse of multiplexing — while multiplexing combines data streams for
transmission, demultiplexing separates and directs them at the receiver’s end.
❖ At the Transport Layer, demultiplexing uses information such as destination IP address and
port number to forward segments to the appropriate socket.
❖ It enables multiple applications to receive data correctly and simultaneously, even when
using the same network interface.
❖ For example, a host receiving data on port 80 (HTTP) will deliver it to the web browser, while
data on port 21 (FTP) goes to the file transfer client.
Follow up Questions:
Q. In demultiplexing, how does the receiver identify the Q. What happens if two applications on the same host use
correct application to deliver the data to? the same port number?
a) Using source IP address only a) Port conflict occurs; demultiplexing fails
b) Using protocol number only b) Data gets divided equally
c) Using destination port number c) They share data
d) Using MAC address d) TCP assigns new port numbers automatically
Q. Which component in the OS helps in multiplexing Q. In TCP, demultiplexing is more accurate than in UDP
data from multiple applications to the transport layer? because TCP uses:
a) NIC a) Port numbers only
b) Firewall b) Port numbers + sequence numbers + connection
c) Socket Interface state (4-tuple)
d) DNS Resolver c) Only application names
d) Only MAC addresses
Activity ( Level 3 )
Activity 1: TCP Header Analysis
Problem: A TCP segment is captured with the following hexadecimal header (first 20 bytes only):
0050 1F90 00000001 00000000 5002 7210 A1B2 C3D4
Identify the following fields:
1. What is the source port number and destination port number?
2. What is the sequence number?
3. What is the acknowledgment number?
4. What is the window size?
Solution:
❏ Source Port → 0x0050 = 80 & Destination Port → 0x1F90 = 8080
❏ Sequence Number → 0x00000001 → 1
❏ Acknowledgment Number → 0x00000000 → 0
❏ Window Size → 0x7210 = 29200