0% found this document useful (0 votes)
4 views18 pages

Transport Layer Services Explained

The document discusses the Transport Layer's services, including process-to-process delivery, port addressing, segmentation, connection control, flow control, and error control. It also explains TCP header format, TCP congestion control, the three-way handshake for connection establishment, and the issues related to Silly Window Syndrome. Additionally, it covers UDP header format and the RTP protocol, emphasizing its role in real-time data transmission.

Uploaded by

itisychere
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views18 pages

Transport Layer Services Explained

The document discusses the Transport Layer's services, including process-to-process delivery, port addressing, segmentation, connection control, flow control, and error control. It also explains TCP header format, TCP congestion control, the three-way handshake for connection establishment, and the issues related to Silly Window Syndrome. Additionally, it covers UDP header format and the RTP protocol, emphasizing its role in real-time data transmission.

Uploaded by

itisychere
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Unit – 4

Q1) List and explain transport layer services. [6 Marks]

The Transport Layer provides services to the Application Layer and uses the services of the Network
Layer. Its primary function is to provide Process-to-Process delivery. The key services provided by the
Transport Layer are:

1. Process-to-Process Delivery While the Network Layer is responsible for Source-to-Destination


delivery (host-to-host), the Transport Layer is responsible for delivery of the message to the
appropriate process (application program) running on the host. It ensures the data reaches the
correct application among many running on the computer.

2. Service-Point (Port) Addressing To enable process-to-process delivery, the Transport Layer must
define a type of address called a Port Address (or Service Point Address). The Network Layer header
includes the IP address to identify the computer, but the Transport Layer header includes the port
address to identify the specific process on that computer.

3. Segmentation and Reassembly A message received from the Application Layer is divided into
transmittable segments. Each segment contains a sequence number. This enables the Transport
Layer at the destination to reassemble the message correctly upon arrival and to identify and replace
any packets that were lost in transmission.

4. Connection Control The Transport Layer provides two types of connection services:

• Connectionless Service: The transport layer treats each segment as an independent packet
and delivers it to the transport layer at the destination machine (e.g., UDP).

• Connection-Oriented Service: A connection is established with the destination machine


before sending any packets. After all data is transferred, the connection is released (e.g.,
TCP).

5. Flow Control Like the Data Link Layer, the Transport Layer handles flow control, but it is performed
end-to-end rather than across a single link. It ensures that the sender does not overwhelm the
receiver with data by synchronizing their transmission speeds.

6. Error Control The Transport Layer performs error control end-to-end. It ensures that the entire
message arrives at the receiving transport layer without error (damage, loss, or duplication). Error
correction is usually achieved through retransmission

a) Draw and explain TCP header format. [6 Marks]

1. TCP Header Format Diagram

The TCP packet is called a segment. The header is a minimum of 20 bytes and can be larger if options
are used.

2. Explanation of Fields

• Source Port Address (16 bits):

This field defines the port number of the application program in the host that is sending the
segment1.

• Destination Port Address (16 bits):


This field defines the port number of the application program in the host that is receiving the
segment2.

• Sequence Number (32 bits):

This field indicates the unique number assigned to the first byte of data contained in this segment3.
It helps in reordering segments at the destination.

• Acknowledgment Number (32 bits):

This field defines the byte number that the receiver of the segment is expecting to receive next4. If
the receiver sends an ACK number of $x$, it means it has received bytes up to $x-1$.

• Header Length (HLEN) (4 bits):

Also called Data Offset. It indicates the number of 32-bit words in the TCP header5. This is required
because the options field is variable.

• Reserved (6 bits):

These bits are reserved for future use and are usually set to 06.

• Control Flags (6 bits):

These bits control specific functions of the connection7:

o URG: Urgent pointer is valid.

o ACK: Acknowledgment number is valid.

o PSH: Request for push (send data to application immediately).

o RST: Reset the connection.


o SYN: Synchronize sequence numbers (used to initiate a connection).

o FIN: Terminate the connection.

• Window Size (16 bits):

This field defines the size of the sliding window (in bytes) that the sender of this segment is willing to
accept8. It is used for flow control.

• Checksum (16 bits):

This 16-bit field contains the checksum used for error detection9. It covers the header, data, and a
pseudo-header.

• Urgent Pointer (16 bits):

This field is valid only if the URG flag is set. It indicates the end of the urgent data within the
segment10.

• Options (Variable 0-40 bytes):

Optional information such as Maximum Segment Size (MSS), Window Scale, or Timestamp can be
included here

b) Explain TCP Congestion Control in Transport Layer. [6 Marks]

1. Definition TCP Congestion Control is a mechanism used by the transport layer to prevent the
sender from overwhelming the network with too much data. If too many packets are present in the
subnet, performance degrades (congestion), leading to packet loss and delays. TCP handles this by
maintaining a variable called the Congestion Window (cwnd).

2. Congestion Window (cwnd) The sender maintains a congestion window (cwnd) which limits the
number of bytes or segments that can be sent before waiting for an acknowledgment. The actual
window size used for transmission is the minimum of the Receiver's Advertised Window (rwnd) and
the Congestion Window (cwnd).

3. Congestion Control Phases TCP uses three main phases to manage the congestion window:

• Phase 1: Slow Start

o Goal: To rapidly gauge the network capacity.

o Operation: Initially, the cwnd is set to 1 Maximum Segment Size (MSS).

o For every acknowledgment (ACK) received, the window size is increased by 1 MSS.

o This results in exponential growth (1, 2, 4, 8...) of the window size every Round Trip
Time (RTT).

o This phase continues until cwnd reaches a specific limit called the Slow Start
Threshold (ssthresh).

• Phase 2: Congestion Avoidance

o Goal: To probe for available bandwidth cautiously without causing congestion.


o Operation: Once cwnd reaches the ssthresh, the algorithm switches to Congestion
Avoidance.

o Instead of doubling, the cwnd is increased by 1 MSS per RTT (additive increase). This
creates a linear growth in the transmission rate.

o This continues until congestion is detected (packet loss).

• Phase 3: Congestion Detection and Reaction TCP detects congestion via two events: a
Timeout or receiving 3 Duplicate ACKs. The reaction depends on the event:

o Case A: Timeout (Severe Congestion)

▪ If a timeout occurs, TCP assumes severe network congestion.

▪ Reaction:

1. Set ssthresh to half of the current cwnd.

2. Reset cwnd to 1 MSS.

3. Restart the Slow Start phase.

o Case B: 3 Duplicate ACKs (Fast Retransmit/Fast Recovery)

▪ If the sender receives 3 duplicate ACKs, it indicates a packet was lost, but the
network is not heavily congested (some packets are still arriving).

▪ Reaction:

1. Set ssthresh to half of the current cwnd.

2. Set cwnd to the new ssthresh (not 1).

3. Enter the Congestion Avoidance phase directly (skipping Slow Start).


4. AIMD (Additive Increase, Multiplicative Decrease) The combined behavior of Congestion
Avoidance (adding 1 MSS) and reaction to congestion (halving the window) is often referred to as
AIMD. This approach ensures the system is stable and fair.

Q4) a) Explain TCP connection establishment process with suitable diagram. [5 Marks]

1. The Three-Way Handshake

TCP establishes a reliable connection using a process known as the Three-Way Handshake. This
process synchronizes the sequence numbers between the sender (client) and the receiver (server) to
ensure reliable data transfer.

2. The Process (Step-by-Step)

• Step 1: SYN (Client to Server)

o The client (Active Open) initiates the connection by sending a segment with the SYN
(Synchronize) flag set to 1.

o This segment specifies the client's Initial Sequence Number ($ISN_c$ or $x$).

o This segment consumes one sequence number but carries no data2.

• Step 2: SYN + ACK (Server to Client)

o The server (Passive Open) receives the SYN. It responds with a segment having both
the SYN and ACK flags set to 1.

o Acknowledgment: It acknowledges the client's SYN by setting the ACK number to $x


+ 1$.

o Synchronization: It includes its own Initial Sequence Number ($ISN_s$ or $y$).

o This segment also consumes one sequence number3.

• Step 3: ACK (Client to Server)

o The client receives the server's SYN+ACK segment.

o It sends a final segment with the ACK flag set to 1.

o Acknowledgment: It acknowledges the server's SYN by setting the ACK number to $y


+ 1$.

o The connection is now established, and data transfer can begin. This segment usually
does not consume a sequence number unless it carries data4.

3. Diagram

Diagram Explanation:

1. Host A (Client) sends SYN, SEQ=x. State changes from CLOSED to SYN-SENT.

2. Host B (Server) receives it and sends SYN, SEQ=y, ACK=x+1. State changes from LISTEN to
SYN-RCVD.
3. Host A receives the SYN+ACK and sends ACK=y+1. State changes to ESTABLISHED.

4. Host B receives the ACK. State changes to ESTABLISHED.

Silly Window Syndrome (SWS) is a serious performance problem in TCP networking where data is
transmitted in tiny, inefficient chunks (often just 1 byte) rather than full-sized segments.

It is called "silly" because the network spends more time sending headers than actual data. For
example, sending 1 byte of data requires a 20-byte IP header and a 20-byte TCP header. That is 40
bytes of overhead for 1 byte of payload (only ~2.4% efficiency).

1. What Causes It?

SWS occurs when either the sending application produces data very slowly, or the receiving
application consumes data very slowly. The most common cause usually starts at the receiver end.

The "Slow Receiver" Scenario

1. Full Buffer: The receiver’s buffer (memory) is full, so it advertises a Window Size of 0 to the
sender. The sender stops.

2. The "Sip": The receiving application reads just 1 byte of data from the buffer and processes
it.

3. The Bad Update: The receiver's TCP sees 1 byte of free space and immediately sends a
Window Update saying: "Window = 1".

4. The Reaction: The sender sees the opening and eagerly sends a 1-byte segment.

5. The Cycle: The receiver's buffer is full again. It advertises Window = 0. The cycle repeats,
flooding the network with tiny packets.

2. How is it Avoided?
To fix this, we need rules that force TCP to "wait" for a reasonable amount of data before talking. We
apply fixes on both ends.

Solution A: Receiver-Side (Clark's Solution)

The receiver must stop advertising tiny windows.

• The Rule: If the free space in the buffer is small, the receiver should lie and advertise a
Window Size of 0.

• The Threshold: It should only advertise a new window size when the free space is equal to
either:

1. One full Maximum Segment Size (MSS), or

2. Half the size of the receive buffer.

• Effect: This forces the sender to wait until a large chunk of space is available, preventing the
"1-byte update" loop.

Solution B: Sender-Side (Nagle's Algorithm)

The sender should not transmit tiny scraps of data immediately.

• The Rule: If the sender has small data (less than 1 MSS) to send, it must hold it in the buffer
if there is any unacknowledged data currently in flight.

• The Trigger: It can only send the data when:

1. It has accumulated enough to fill a full packet (MSS), OR

2. It receives an ACK for the previous packet (meaning the network is clear).

• Effect: This batches small keystrokes (like in Telnet) into larger, efficient groups.
Q4) a) Draw and explain UDP header format. [6 Marks]

1. UDP Header Format Diagram The User Datagram Protocol (UDP) has a very simple header
compared to TCP. It is a fixed-size header of 8 bytes.

2. Explanation of Fields The UDP header consists of four fields, each 16 bits (2 bytes) long:

1. Source Port Number (16 bits):

o This field identifies the port number of the application process on the sender's
machine that generated the message.

o It is used so the destination knows where to send a reply (if required).

2. Destination Port Number (16 bits):

o This field identifies the port number of the application process on the receiver's
machine that should receive the message.

o This allows the Transport layer to deliver the data to the correct process
(demultiplexing).

3. UDP Length (16 bits):

o This field defines the total length of the user datagram, including the header and the
data, in bytes.

o The minimum value is 8 bytes (which indicates a packet with only a header and no
data).

o Since the field is 16 bits, the theoretical maximum size of a UDP datagram is 65,535
bytes (though usually limited by the underlying IP MTU).

4. UDP Checksum (16 bits):

o This field is used to detect errors over the entire user datagram (header + data).

o It is optional in IPv4 (can be all zeros if unused) but is typically mandatory in IPv6 to
ensure data integrity.

3. Key Characteristics

• Low Overhead: Because the header is small (8 bytes vs. TCP's 20 bytes), UDP is efficient for
applications that need speed over reliability (e.g., real-time video, DNS, SNMP).

• Connectionless: No connection establishment is performed before sending the data


Q3) a) Give the difference between TCP and UDP.

Q4) a) Explain RTP protocol in detail. [6 Marks]


1. Definition and Purpose

RTP (Real-time Transport Protocol) is a protocol designed to handle real-time traffic (like audio and
video) over the Internet. Unlike standard TCP which prioritizes reliability (retransmission), RTP
prioritizes timely delivery. It provides end-to-end network transport functions suitable for
applications transmitting real-time data.

2. Position in the Protocol Stack Although RTP acts as a transport protocol, it is often implemented
in the application layer or acts as an interface between the application and the transport layer.

• It typically runs on top of UDP (User Datagram Protocol) because real-time applications
cannot tolerate the delay caused by TCP retransmissions.

• RTP does not provide a mechanism to ensure timely delivery or provide quality of service
guarantees; it relies on lower-layer services for that.

3. Functions of RTP RTP provides the following facilities to real-time applications:

• Timestamping: To allow the receiver to play back data at the correct speed and synchronize
different streams (e.g., lip-syncing audio and video).

• Sequence Numbering: To detect packet loss and restore packet order.

• Payload Type Identification: To tell the receiver what format the data is in (e.g., PCM audio,
MPEG video).

• Source Identification: To identify who is sending the stream.

4. RTP Header Format The RTP header provides the information required to manage the real-time
stream. It typically follows the IP and UDP headers.

Explanation of Header Fields:

• Version (V) (2 bits): Identifies the version of RTP (current version is 2).

• Padding (P) (1 bit): If set, it indicates that the packet contains extra padding bytes at the end
(not part of the payload).

• Extension (X) (1 bit): If set, indicates that an extension header follows the fixed header.

• CSRC Count (CC) (4 bits): Indicates the number of CSRC identifiers that follow the fixed
header.

• Marker (M) (1 bit): Used by applications to mark significant events, such as the end of a
video frame.

• Payload Type (7 bits): Identifies the format of the payload (e.g., audio encoding type).

• Sequence Number (16 bits): Increments by one for each RTP data packet sent. It allows the
receiver to detect lost packets.

• Timestamp (32 bits): Reflects the sampling instant of the first byte in the payload. It is crucial
for jitter compensation and synchronization.

• SSRC (Synchronization Source Identifier) (32 bits): A random number that uniquely identifies
the source of the stream (e.g., a microphone or camera).
• CSRC (Contributing Source Identifiers): A list of sources that contributed to the packet (used
when streams are mixed).

5. RTP Control Protocol (RTCP) RTP is often used in conjunction with RTCP. While RTP carries the
actual data, RTCP is used to monitor the quality of service (QoS) and convey information about
participants in an on-going session.

c) Explain SCTP protocol in detail. [6 Marks]

1. Definition SCTP (Stream Control Transmission Protocol) is a reliable, message-oriented transport


layer protocol. It combines the best features of UDP and TCP. It preserves message boundaries (like
UDP) while providing reliable connection-oriented service (like TCP). It is designed to transport
signaling messages over IP networks (e.g., for VoIP).

2. Key Features

• Message-Oriented: Unlike TCP, which is byte-oriented, SCTP treats data as messages. It


preserves the boundaries of the message defined by the application.
• Multi-homing: SCTP supports multi-homing, meaning a connected association can have
multiple IP addresses for the sender and receiver. This provides fault tolerance; if one path
fails, another interface can be used for delivery without interrupting the connection.

• Multi-streaming: An SCTP connection (called an association) can carry multiple independent


streams of data. If one stream is blocked (e.g., due to packet loss), the other streams can
continue to deliver data, preventing the "head-of-line blocking" problem found in TCP.

3. SCTP Packet Format An SCTP packet differs significantly from TCP or UDP packets. It consists of a
Common Header followed by one or more blocks of data called Chunks.

• Common Header (12 Bytes): Every SCTP packet starts with this header.

o Source & Destination Port (16 bits each): Identifies the communicating applications.

o Verification Tag (32 bits): Used to validate the sender and prevent packet injection
attacks from previous connections.

o Checksum (32 bits): Used for error detection (CRC-32 is used).

• Chunks: The payload of the SCTP packet is carried in chunks. A packet can contain control
chunks (for connection management) and data chunks (carrying user data).

o Control Chunks: Used to establish, maintain, and terminate associations (e.g., INIT,
SACK, HEARTBEAT).

o Data Chunks: Carry the actual user data.

4. SCTP Data Chunk Format The Data Chunk carries the application data and specific sequencing
information.
• TSN (Transmission Sequence Number): A global sequence number for the entire association,
used for reliability and reassembly.

• Stream Identifier (SI): Identifies which stream this data belongs to.

• Stream Sequence Number (SSN): Distinguishes messages within a specific stream.

• Payload Protocol Identifier: Identifies the type of data being carried.

5. Comparison with TCP and UDP

• Reliability: Like TCP, SCTP ensures data is delivered.

• Ordering: TCP enforces strict ordering for all data. SCTP enforces ordering only within a
stream.

• Connections: TCP connects two IP addresses. SCTP connects two sets of IP addresses (multi-
homing).

b) Explain TCP State Transition Diagram. [6 Marks]

1. Introduction

TCP connection management is modeled using a finite state machine. The TCP State Transition
Diagram describes the life cycle of a connection, showing the various states a TCP connection goes
through during establishment, data transfer, and termination1.

2. State Transition Diagram

The diagram below illustrates the states (ovals) and the transitions (lines) caused by events like user
commands (e.g., OPEN, CLOSE) or receiving segments (e.g., SYN, ACK, FIN).

3. Description of States

• CLOSED: This is the initial state where there is no connection. It is the starting and ending
point for all connections2.

• LISTEN (Server): The server is waiting for an incoming call (Passive Open). It listens for a
connection request from any remote TCP3.

• SYN-SENT (Client): The client has performed an Active Open. It sends a SYN segment and
waits for an acknowledgment4.

• SYN-RCVD (Server): The server has received a SYN request from a client, sent its own SYN +
ACK, and is waiting for the final ACK from the client to confirm the connection5.

• ESTABLISHED: The connection is open, and data transfer can take place. This is the steady
state where data is exchanged6.

4. Connection Termination States

• FIN-WAIT-1 (Client): The application closes the connection. The client sends a FIN segment
and waits for an ACK or FIN from the server7.
• FIN-WAIT-2 (Client): The client has received an ACK for its FIN and is now waiting for the
server to close its side (send its own FIN)8.

• CLOSE-WAIT (Server): The server has received a FIN from the client and sent an ACK. It is
waiting for the local application to close9.

• LAST-ACK (Server): The server has finished sending data, sent its own FIN, and is waiting for
the final ACK from the client10.

• TIME-WAIT (Client): The client has received the server's FIN and sent the final ACK. It waits
for a period (typically 2 MSL) to ensure the server received the ACK before fully closing 11.

• CLOSING: This state is reached if both sides try to close the connection simultaneously
(Simultaneous Close)12.

c) What is Quality of Service? Explain any two methods to improve QoS? [6 Marks]

1. Definition of Quality of Service (QoS) Quality of Service (QoS) refers to the ability of a network to
provide better service to selected network traffic over various technologies. It essentially acts as a
control mechanism to ensure the reliable delivery of data applications. QoS is characterized by four
primary parameters:

• Reliability: Lack of errors or packet loss.

• Delay: The time it takes for a packet to travel from source to destination.

• Jitter: The variation in packet arrival time (crucial for audio/video).


• Bandwidth: The maximum data transfer rate.

2. Methods to Improve QoS The textbook highlights several techniques to improve QoS, specifically
under Integrated Services. Two key methods are:

Method 1: Traffic Shaping Traffic shaping is a mechanism to control the amount and the rate of
traffic sent to the network. It regulates the flow of data packets to ensure they conform to a specific
traffic profile.

• Purpose: To smooth out "bursty" traffic traffic that arrives in sudden spikes to prevent
congestion and packet loss.

• Techniques:

o Leaky Bucket Algorithm: This algorithm converts a bursty flow of packets into a
constant, steady stream. Imagine a bucket with a small hole at the bottom; no
matter how fast water is poured in, it flows out at a constant rate. If the bucket
overflows, packets are discarded.

o Token Bucket Algorithm: This allows for some burstiness. Tokens are generated at a
fixed rate and accumulated in a bucket. To send a packet, a token must be removed.
This allows idle hosts to accumulate tokens and send a burst of data later.

Method 2: Admission Control Admission control is a policy-based mechanism used by routers to


decide whether to accept a new data flow request or reject it.

• Working Principle: When a new flow (e.g., a video call) requests a connection, the router
checks if it has enough available resources (bandwidth, buffer space, CPU) to guarantee the
required QoS for this new flow without compromising the service of existing flows.

• Decision:

o If resources are available, the flow is accepted, and resources are reserved.

o If resources are insufficient, the flow is rejected, preventing network overload and
ensuring existing connections remain stable.

b) What is Socket? What are different types of socket? Explain socket functions used in connection-
oriented services with diagram. [6 Marks]

1. What is a Socket?

A Socket is one endpoint of a two-way communication link between two programs running on the
network. It provides an interface between the Application Layer and the Transport Layer.

• It allows an application to send and receive data from the network.

• A socket is uniquely identified by the combination of an IP Address and a Port Number.

o Socket Address = (IP Address : Port Number)

2. Types of Sockets

There are primarily three types of sockets used in network programming:


1. Stream Sockets (SOCK_STREAM):

o These use TCP (Transmission Control Protocol).

o They provide a reliable, connection-oriented, and sequenced flow of data without


record boundaries.

o Used for applications like Web (HTTP), Email (SMTP), and File Transfer (FTP).

2. Datagram Sockets (SOCK_DGRAM):

o These use UDP (User Datagram Protocol).

o They provide a connectionless, unreliable service. Data is sent in independent


packets (datagrams) which may arrive out of order or be lost.
o Used for streaming audio/video, DNS, and VoIP.

3. Raw Sockets (SOCK_RAW):

o These provide direct access to the underlying communication protocol (like ICMP or
IP).

o Used for developing new protocols or for utilities like ping and traceroute.

3. Socket Functions for Connection-Oriented Services (TCP)

In a connection-oriented service (TCP), a logical connection must be established before data


exchange. The sequence of function calls differs for the Client and the Server.

Key Functions:

1. socket():

o Usage: Both Server and Client.

o Function: Creates a new socket endpoint and returns a socket descriptor (an
integer). It specifies the protocol family (IPv4) and type (Stream).

2. bind():

o Usage: Typically Server.

o Function: Associates the socket with a specific local IP address and Port number.
The server needs a fixed address so clients know where to connect.

3. listen():

o Usage: Server only.

o Function: Puts the server socket in a passive mode, ready to accept incoming
connection requests. It specifies the size of the backlog queue (how many pending
connections to hold).

4. accept():

o Usage: Server only.

o Function: It blocks (waits) until a connection request arrives from a client. When a
request comes, it creates a new socket specifically for this connection and returns its
descriptor. The original socket remains free to listen for other clients.

5. connect():

o Usage: Client only.

o Function: Initiates a connection to the server. It performs the Three-Way


Handshake. The client must specify the server’s IP and Port.

6. send() / recv() (or write / read):

o Usage: Both.
o Function: Used to exchange data. send() writes data to the socket, and recv() reads
data from it.

7. close():

o Usage: Both.

o Function: Terminates the connection and releases the socket resources.

You might also like