0% found this document useful (0 votes)
8 views15 pages

Understanding the Transport Layer in OSI

The Transport Layer, the fourth layer of the OSI model, is responsible for reliable end-to-end data delivery, connection management, and flow control between applications. It includes protocols like TCP, which is connection-oriented and ensures reliable delivery, and UDP, which is connectionless and faster but less reliable. Key functions include connection establishment and termination, error detection, and multiplexing of data streams.

Uploaded by

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

Understanding the Transport Layer in OSI

The Transport Layer, the fourth layer of the OSI model, is responsible for reliable end-to-end data delivery, connection management, and flow control between applications. It includes protocols like TCP, which is connection-oriented and ensures reliable delivery, and UDP, which is connectionless and faster but less reliable. Key functions include connection establishment and termination, error detection, and multiplexing of data streams.

Uploaded by

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

CN UNIT - 4

1) Transport Layer – OSI Model (Layer 4)


Definition

The Transport Layer is the fourth layer in the OSI model. It lies between the Network
Layer (Layer 3) and Session Layer (Layer 5). Its main responsibility is to provide
reliable end-to-end data delivery from source to destination across a network.

Responsibilities of Transport Layer

Accepts data from the Session Layer, breaks it into smaller units (TPDUs), and
passes them to the Network Layer.

Ensures correct and complete reception of data at the receiving end.

Establishes, maintains, and terminates connections between communicating devices.

Performs multiplexing, allowing multiple applications to share a single network


connection.

Provides flow control so that a fast sender does not overwhelm a slow receiver.

Uses error detection and correction to guarantee reliable data transfer.

Transport Layer Protocols

TCP (Transmission Control Protocol)

Connection-oriented and reliable.

Breaks data into segments and ensures correct sequencing at the receiver.

Performs error control and flow control.

Example: File transfer, email, web browsing.

UDP (User Datagram Protocol)

Connectionless and unreliable.

Faster delivery, but no guarantee of sequence or error correction.


Suitable for real-time applications where speed is more important than reliability
(e.g., VoIP, video streaming).

Services Provided by Transport Layer to Upper Layers

Connection-Oriented Service

Similar to a “virtual circuit” over the network.

Ensures data reaches the destination reliably and in order.

Example: TCP.

Connectionless Service

Sends independent messages called datagrams.

Faster but no guarantee of delivery or order.

Example: UDP.

Why Transport Layer Exists Above Network Layer

User control: Network layer runs on routers (not user-controllable); transport layer
runs on user machines.

Reliability: Transport layer can detect lost or damaged packets; network layer
cannot.

Independence: Transport layer services can run without depending entirely on


network layer primitives.

Connection recovery: Even if a network connection fails, the transport layer can re-
establish connections and continue communication.

2) Transport Layer Service Primitives


Transport layer provides services to the upper layers through a set of primitives,
which are operations performed by the transport entity to manage connections and
data transfer.
List of Primitives and Their Functions

Primitive Function
LISTEN Server waits for incoming connection requests from clients.
Client initiates a connection by sending a CONNECTION
CONNECT
REQUEST TPDU to the server.
SEND Transfers data from one transport entity to another.
RECEIVE Receives data sent from a peer transport entity.
DISCONNECT Terminates the connection using DISCONNECT TPDU.

Usage of Transport Service Primitives

Connection Establishment

Client executes CONNECT primitive → sends a connection request to the server.

Server executes LISTEN primitive → waits for requests.

Server responds with CONNECTION ACCEPT TPDU → client unblocks and


connection is established.

Data Transfer

Both client and server can now use SEND and RECEIVE primitives for full-duplex
communication.

Connection Termination

When communication is finished, DISCONNECT primitive is executed.

Two types:

i) Asynchronous: Either side can initiate disconnect.

ii) Synchronous: Both sides close connection independently.


3) TCP Connection Management
TCP is a connection-oriented protocol and ensures reliable end-to-end
communication. Connection management includes establishment and termination
of a TCP connection.

1. Connection Establishment (Three-Way Handshake)

TCP uses a three-way handshake to establish a connection:

Client → Server:

Client sends a SYN (synchronize) packet with an initial sequence number N.

Indicates a request to start communication.

Server → Client:

Server responds with SYN-ACK:

SYN = 1 → server wants to synchronize.

ACK = N + 1 → acknowledges client’s SYN.

Sequence number = M (server’s initial sequence).

Client → Server:

Client sends ACK = M + 1 → acknowledges server’s SYN.

Connection is now established.

Notes:

Both hosts agree on sequence numbers to avoid confusion with delayed segments.

Two hosts can simultaneously initiate a connection, each acting as client and server.

2. Connection Termination (Four-Way Handshake)

TCP uses a four-step process to close a connection:

Client → Server: Sends FIN → indicates no more data to send.


Server → Client: Sends ACK → acknowledges client’s FIN.

Server → Client: Sends FIN → server has no more data to send.

Client → Server: Sends ACK → acknowledges server’s FIN.

Notes:

Connection termination is graceful, allowing both sides to finish transmitting data.

If an ACK is lost, the host resends the FIN until acknowledgment is received or timer
expires.

Summary Table

Process Steps Purpose


SYN → SYN-ACK → Synchronize sequence numbers, establish
Establishment
ACK connection
FIN → ACK → FIN → Gracefully close connection, ensure all data
Termination
ACK transmitted

4) Transmission Control Protocol (TCP)


TCP is a connection-oriented transport layer protocol widely used in the Internet. It
provides reliable, ordered, and error-checked delivery of a stream of bytes between
applications running on hosts.

Key Features of TCP

Connection-Oriented: Establishes a logical connection between sender and receiver


before data transfer.

Reliable Delivery: Uses acknowledgments and retransmissions to ensure data


reaches the destination.

Byte-Stream Service: Data is transmitted as a continuous stream of bytes; message


boundaries are not preserved.

Full-Duplex Communication: Data can flow simultaneously in both directions.


Error Detection & Correction: TCP detects lost, corrupted, or duplicated segments
and ensures retransmission.

Flow Control: Prevents the sender from overwhelming the receiver using the sliding
window protocol.

Sequencing: Each byte is assigned a unique 32-bit sequence number for ordered
delivery.

TCP Segment: TCP transmits data in segments.

Each segment has:

i) Fixed 20-byte header (includes sequence number, acknowledgment number, flags,


window size, etc.)

ii) Optional header fields

iii) Data payload

Sliding Window Protocol: Sender maintains a window of unacknowledged


segments. Retransmits if acknowledgment is not received within the timeout.

TCP Service Model


Sockets: Connection endpoints are called sockets, identified by a combination of:

IP address and 16-bit port number

Multiple connections can be established using a single socket.

Well-Known Ports: Ports 0–1023 are reserved by ICANN for standard services.

Full-Duplex: Supports bidirectional communication simultaneously.

Point-to-Point: TCP connections are peer-to-peer, not multicast or broadcast.

Urgent Data Handling: TCP uses the URG flag to push urgent data immediately to
the receiver.

Push Function: Application data can be transmitted immediately using the PSH flag
instead of buffering.

Advantages of TCP
Reliable and ordered delivery.

Guarantees data delivery with error detection and correction.

Flow control prevents congestion and data loss.

Disadvantages of TCP

Retransmission causes delays if packets are lost.

Lost acknowledgments require waiting for timeout before resending.

Overhead due to connection management and reliability mechanisms.

5) TCP Segment Header


A TCP segment consists of a header and a data/payload. The header provides
essential information for reliable, ordered delivery, flow control, and connection
management.

Header Length: Minimum 20 bytes, may extend with options.

Fields in TCP Header

Source Port (16 bits): Identifies the sending application on the source host.

Destination Port (16 bits): Identifies the receiving application on the destination
host.

Sequence Number (32 bits): Used for ordering bytes and identifying missing
segments in reliable delivery.

Acknowledgment Number (32 bits): Specifies the next expected byte from the
sender. Only valid if ACK flag is set.

Header Length (4 bits): Length of the TCP header in 32-bit words.

Reserved (6 bits): Reserved for future use; must be set to 0.

Control Flags (6 bits):

URG: Urgent pointer is valid.

ACK: Acknowledgment field is valid.


PSH: Push data to application immediately.

RST: Reset the connection.

SYN: Synchronize sequence numbers for connection setup.

FIN: Indicates the sender has finished sending data.

Window Size (16 bits): Size of the sender’s receive window, i.e., number of bytes
the sender is willing to accept.

Checksum (16 bits): Verifies header + data integrity.

Urgent Pointer (16 bits): Points to the byte following urgent data (valid if URG flag
is set).

Options (variable length): Optional features like Maximum Segment Size (MSS),
timestamps, etc. Must be multiple of 32 bits.

Data/Payload (variable length): Actual application data carried in the segment.

6) TCP Transmission Policy


TCP uses a sliding window mechanism to provide reliable, flow-controlled, and
efficient data transmission between a sender and a receiver. The main ideas are:

1. Window Advertisement

The receiver advertises the available buffer space as the TCP window size in each
acknowledgment (ACK).

Example: If the receiver has a 4096-byte buffer and has received 2048 bytes, it
acknowledges the segment and advertises 2048 bytes available.

When the buffer becomes full, the receiver advertises a window size of zero,
instructing the sender to pause until space becomes available.

Exceptions for Zero Window:

Urgent data can still be sent.

1-byte segment can be sent to probe and re-advertise window size.


2. Sliding Window Mechanism

The sender maintains a window representing the amount of unacknowledged data that
can be in transit.

As acknowledgments arrive, the window “slides forward,” allowing more data to be


sent. This ensures continuous data flow without overwhelming the receiver.

3. Silly Window Syndrome

Occurs when:

The sender transmits small amounts of data frequently.

The receiver advertises tiny window increments, leading to inefficient small


segments.

Example:

Receiver buffer: 2 KB

Sender sends 2 KB → buffer full → receiver advertises window = 0

Receiver reads 1 byte → window = 1 → sender sends 1 byte → inefficient traffic

Solution:

Nagle’s Algorithm (Sender-side):

Buffer small data at the sender.

Send data only when acknowledgment is received for previous data or enough data is
accumulated for a full segment.

Solves inefficient sending of tiny segments.

Clark’s Solution (Receiver-side):

Receiver delays window advertisement until either:

Enough space for maximum segment size (MSS) is available, or


Half of the buffer is empty.

Solves the problem caused by receiver advertising tiny windows.

Together, Nagle’s algorithm and Clark’s solution prevent silly window


syndrome, ensuring efficient use of network resources.

4. TCP Data Flow Example

Sender transmits data up to advertised window size.

Receiver processes data and updates window size in ACK.

Sender slides the window and continues transmission as ACKs arrive.

Urgent or probe bytes may bypass the window restrictions if needed.

7) UDP Header
UDP (User Datagram Protocol) is a connectionless and unreliable transport layer
protocol. Its header is simple and fixed in size (8 bytes) and provides minimal
control information.

Features of UDP:

Connectionless: No handshake is needed.

Unreliable: No acknowledgments or retransmissions.

Fast: Low overhead, suitable for applications like DNS, VoIP, and streaming.

Provides transport-layer addressing via port numbers.

UDP Header Structure (8 bytes)

Size
Field Description
(bytes)
Source Port 2 Port number of the sender. Can be set to 0 if not used.
Destination
2 Port number of the receiver. Identifies the target application.
Port
Total length of UDP header + data (minimum 8 bytes,
Length 2
maximum 65535 bytes).
Size
Field Description
(bytes)
Optional error-checking for header and data. Includes
Checksum 2
pseudoheader, UDP header, and data. If unused, set to 0.

UDP Header Diagram

0 7 8 15 16 23 24 31
+--------+--------+--------+--------+
| Src Port | Dest Port |
+--------+--------+--------+--------+
| Length | Checksum |
+--------+--------+--------+--------+

Source Port (16 bits) – Sender’s port number.

Destination Port (16 bits) – Receiver’s port number.

Length (16 bits) – Header + data size in bytes.

Checksum (16 bits) – For error detection; optional.

8) Key Elements of Transport Protocols


The transport layer is responsible for delivering data process-to-process across a
network. Its protocols (like TCP and UDP) ensure proper communication between
applications running on different hosts. The main elements of transport protocols
include:

1. Addressing

Transport layer provides process-to-process communication, not just host-to-host.

It uses port numbers as service points to identify different applications or processes


on a host.

Example: HTTP uses port 80, FTP uses port 21.

This allows multiple applications to run simultaneously on the same machine.


2. Connection Establishment and Connection Release

Connection-oriented protocols (like TCP) require a connection to be established


before data transfer.

Three-way handshake (SYN, SYN-ACK, ACK) is used for connection setup.

Connection termination uses FIN and ACK messages in four steps to release the
connection gracefully.

Connectionless protocols (like UDP) do not require setup or teardown; each message
is sent independently.

3. Flow Control and Buffering

Ensures that the sender does not overwhelm the receiver with too much data at once.

Maintains a receiver buffer and advertises the available space (window size).

TCP uses sliding window protocol to manage flow control.

Prevents data loss and helps in efficient utilization of network resources.

4. Multiplexing and Demultiplexing

Multiplexing (at sender): Multiple application processes can send data


simultaneously; transport layer combines them into segments and passes to network
layer.

Demultiplexing (at receiver): Segments are separated based on port numbers and
delivered to the correct application process.

This allows many-to-one communication at sender and one-to-many at receiver.

5. Crash Recovery

Mechanism to recover from transport layer failures during communication.

If a host crashes, the transport layer (like TCP) coordinates with the peer to determine
which segments were acknowledged and which need retransmission.
Ensures reliable delivery even after failures.

9)Transport Layer Functions(same as OSI model layer)


10) Connection Establishment and Release
11) TCP vs UDP
12) Crash Recovery
Definition:
Crash recovery is the process by which a host or system recovers from a crash using
the status information available in the higher layer (layer N+1) after a failure at layer
N.

When a host or server crashes during communication, it loses all information about
its previous state. To continue operations without data loss or inconsistency, crash
recovery mechanisms are used.

Crash Recovery in Stop-and-Wait Protocol

Scenario:

Client and server communicate using stop-and-wait protocol.

Client sends a TPDU (transport protocol data unit) and waits for acknowledgment
(ACK) from the server.

Server crashes during transmission or before acknowledging the TPDU.

Recovery Process:

When the server restarts, it broadcasts a TPDU requesting the status of all open
connections from clients.

Clients respond based on their state:

State S₁: Waiting for ACK (TPDU outstanding) → retransmit TPDU.

State S₀: No TPDU outstanding → no retransmission needed.

Issues in Recovery:
Lost TPDU: If server sent ACK but crashed before writing TPDU to the application,
client assumes data delivered → TPDU lost.

Duplicate TPDU: If server wrote TPDU but crashed before sending ACK, client
retransmits → duplicate TPDU received.

Server Strategies for Handling Crash

First Ack, then Write: Send ACK to client before writing TPDU to application.

Risk: Lost or duplicate TPDU depending on client strategy.

First Write, then Ack: Write TPDU to application before sending ACK.

Risk: Duplicate TPDU if client retransmits after crash before ACK received.

Client Strategies

Always retransmit: Client retransmits TPDU when uncertain.

Never retransmit: Client does not retransmit TPDU after crash notification.

Event Sequences: Events at server can occur in six sequences:

Sequence Meaning
AC(W) ACK sent, then crash (write not done)
AWC ACK sent, write done, then crash
C(AW) Crash before ACK and write
C(WA) Crash before write and ACK
WAC Write done, ACK sent, then crash
WC(A) Write done, crash before ACK

The combination of client strategy and server sequence determines whether the
TPDU is lost, duplicated, or successfully processed.

You might also like