0% found this document useful (0 votes)
5 views29 pages

Transport Layer 2

The document discusses the Transport Layer (Layer 4 of the OSI model), focusing on two key services: Connectionless and Connection-Oriented Service. It details the Transmission Control Protocol (TCP), highlighting its features such as reliable data transfer, flow control, and error detection, along with the processes of connection establishment and termination. Additionally, it compares TCP with User Datagram Protocol (UDP) regarding reliability, data transfer methods, and use cases.

Uploaded by

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

Transport Layer 2

The document discusses the Transport Layer (Layer 4 of the OSI model), focusing on two key services: Connectionless and Connection-Oriented Service. It details the Transmission Control Protocol (TCP), highlighting its features such as reliable data transfer, flow control, and error detection, along with the processes of connection establishment and termination. Additionally, it compares TCP with User Datagram Protocol (UDP) regarding reliability, data transfer methods, and use cases.

Uploaded by

snehajanjal54
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 29

TRANSPORT

LAYER
PART 2:TCP
Connectionless and Connection
Oriented Service
Introduction

The Transport Layer (Layer 4 of the OSI model) is responsible for end-to-end
communication between devices. It ensures reliable data transfer, flow
control, and error detection. Two key services provided by this layer are:

1.Connectionless Service
2.Connection-Oriented Service

These services define how data is transmitted between sender and receiver.
1. Connectionless Service

Definition

Connectionless service is a communication method where data is sent without


establishing a dedicated connection beforehand. Each packet (datagram) is treated
independently and may take different paths to reach the destination.

Explanation

• No initial handshaking (connection setup) is required.


• Packets may arrive out of order or get lost (no guarantee).
• Faster but less reliable compared to connection-oriented service.
• Used in applications where speed is more important than reliability.

Example

• UDP (User Datagram Protocol) is a connectionless transport protocol.


• Applications: Video streaming, online gaming, DNS queries.
2. Connection-Oriented Service

Definition

Connection-oriented service establishes a dedicated connection before data transfer


begins. It ensures reliable and ordered delivery of data.

Explanation

• Involves three phases:


• Connection Establishment (Handshaking, e.g., TCP’s 3-way handshake).
• Data Transfer (Packets are sequenced and acknowledged).
• Connection Termination (Proper closing of the connection).
• Provides reliability, flow control, and error recovery.
• Slower due to overhead but ensures data integrity.

Example

• TCP (Transmission Control Protocol) is a connection-oriented protocol.


• Applications: Web browsing (HTTP), email (SMTP), file transfer (FTP).
Transmission Control Protocol (TCP)
Introduction

Transmission Control Protocol (TCP) is a connection-oriented transport layer


protocol that ensures reliable, ordered, and error-checked delivery of data between
applications. It is one of the core protocols of the Internet Protocol Suite (TCP/IP).

1. Process-to-Process Communication

TCP provides end-to-end communication between applications running on different


hosts using port numbers.
2. Stream Delivery Service

•TCP treats data as a continuous byte stream (not individual packets).


•No fixed boundaries—data is read in the order it was sent.
•Ensures ordered delivery using sequence numbers.

Example:

•When downloading a file, TCP ensures all bytes arrive in order without gaps.

3. Sending and Receiving Buffers

•Sender Buffer: Temporarily holds data before transmission.


•Receiver Buffer: Stores incoming data before processing.

Why Buffers are Used?

✔ Flow Control – Prevents overwhelming the receiver.


✔ Retransmission – Stores unacknowledged data for possible resending.
✔ Smooth Data Flow – Compensates for speed mismatches (e.g., fast sender & slow
receiver).
4. Full-Duplex Communication

• TCP allows simultaneous two-way communication.


• Both sender and receiver can transmit and receive data at the same time.

Example:

• Video Conferencing (Both parties can speak & hear simultaneously).

5. TCP Segments

Definition

TCP breaks the data stream into smaller units called segments for transmission. Each segment
contains a header and payload.

Key Points

• Segments are numbered for ordered delivery


• Typical segment size matches Maximum Segment Size (MSS)
• Header overhead is 20-60 bytes
6. Connection-Oriented Service

Three-Phase Process

1.Connection Establishment
1. Uses 3-way handshake:
1. SYN (Client → Server)

2. SYN-ACK (Server → Client)

3. ACK (Client → Server)

2.Data Transfer
1. Segments transmitted with sequencing

2. Acknowledgments ensure delivery

3. Flow control via sliding window

3.Connection Termination
1. Graceful shutdown using 4-way handshake:
1. FIN (Host A → Host B)

2. ACK (Host B → Host A)

3. FIN (Host B → Host A)


7. Reliable Service
Mechanisms Ensuring Reliability
Error Handling Process
1.Sender transmits segment with sequence number
2.Receiver sends ACK for received segments
3.If ACK not received before timeout:
•Segment is retransmitted
4.Duplicate segments are discarded using sequence numbers

Mechanism Function
Acknowledgments Receiver confirms segment receipt
Retransmission Timer Resends unacknowledged segments
Sequence Numbers Detects missing/duplicate data
Checksums Identifies corrupted segments
Flow Control Prevents receiver overload
TCP Features
1. Numbering System
•TCP assigns a number to each byte of data it sends.
•This numbering helps identify, track, and manage the data in transmission.
•The numbering is essential for data reassembly at the receiver’s end.
•The first byte sent during a connection has an Initial Sequence Number (ISN), randomly
selected.
•Following bytes are numbered sequentially.
Example:
If the Initial Sequence Number (ISN) is 1000,
then the next byte will be 1001, then 1002, and so on.
2. Byte Number
• Byte Number represents the position of a byte in the entire data stream.
• It allows TCP to handle out-of-order packets by reordering them correctly.
• Each byte's number helps the receiver to place it in the correct order.
Key Point:
TCP treats the data as a stream of bytes, not as separate messages.
3. Sequence Number
• A Sequence Number indicates the byte number of the first byte carried in a TCP segment.
• It is placed in the TCP header and is used for data tracking and reassembly.
Working:
• Sender assigns a sequence number to the first byte of the segment.
• If a segment carries 100 bytes, and the sequence number is 2000,
then the next segment’s sequence number will start from 2100
4. Acknowledgment
• Acknowledgment (ACK) is used to confirm the successful receipt of data.
• TCP uses an Acknowledgment Number to indicate the next expected byte from the sender.
• This ensures reliable delivery.
Example:
If the receiver successfully receives bytes up to 3000,
it sends an ACK with an Acknowledgment Number 3001.
• TCP uses positive acknowledgment (confirm what is received) and retransmission for lost data.
5. Flow Control
• Flow Control ensures that the sender does not overwhelm the receiver by sending too much data at once.
• TCP uses a Sliding Window Protocol for flow control.
• The receiver advertises a window size (number of bytes it can accept) to the sender.
Working:
• Sender can only send data within the allowed window size.
• The window size dynamically adjusts according to the receiver’s capacity.
Example:
If the window size is 5000 bytes, the sender must wait after sending 5000 bytes until an ACK is received.
6. Error Control
• Error Control ensures the reliable delivery of data without corruption.
• TCP uses checksums for error detection:
• Each segment has a checksum value.
• Receiver recalculates and compares the checksum.
• If mismatch, the segment is discarded and retransmitted.

• Retransmission is triggered by:


• Timeouts (if ACK is not received in time).
• Duplicate ACKs (indicates loss).
7. Congestion Control
•Congestion Control prevents excessive data injection into the network to avoid network
congestion.
•TCP uses several mechanisms for congestion control:
• Slow Start:
Initially sends data slowly to probe network capacity.
• Congestion Avoidance:
Gradually increases data transmission until signs of congestion appear.
• Fast Retransmit:
Quickly retransmits lost packets after receiving multiple duplicate ACKs.
• Fast Recovery:
Adjusts the congestion window quickly after packet loss to avoid starting from scratch.
TCP Segment Format
In TCP, data is transmitted in the form of segments.
Each segment has a TCP header followed by application data (payload).
The TCP header contains important information for managing the connection and ensuring
reliable communication.
Fields of TCP Segment
1. Source Port (16 bits)
• Identifies the sending application (process) on the host.
• A port number assigned by the sender.
2. Destination Port (16 bits)
• Identifies the receiving application (process) on the remote host.
• A port number assigned by the receiver.
3. Sequence Number (32 bits)
• Indicates the byte number of the first byte in this segment’s data.
• Helps receiver reorder segments and detect missing data.
4. Acknowledgment Number (32 bits)
• If the ACK flag is set, this field contains the next expected byte number from the sender.
• Used for reliable delivery and flow control.
5. Data Offset (4 bits)
• Also called Header Length.
• Specifies the size of the TCP header in 32-bit words.
• Important to know where the data (payload) starts.
5. Data Offset (4 bits)
• Also called Header Length.
• Specifies the size of the TCP header in 32-bit words.
• Important to know where the data (payload) starts.
6. Reserved (3 bits)
•Reserved for future use.
•Must be set to zero.
Flag
7. Control Flags (9 bits) Meaning
URG Urgent Pointer field is significant
ACK Acknowledgment field is significant
PSH Push the data to the receiving app
RST Reset the connection
Synchronize sequence numbers (connection
SYN
establishment)
FIN No more data; connection termination
8. Window Size (16 bits)
• Specifies the number of bytes the sender is willing to receive.
• Used for flow control (sliding window).
9. Checksum (16 bits)
• Error checking for the header and data.
• Ensures data integrity during transmission.
10. Urgent Pointer (16 bits)
• If the URG flag is set, this field points to the urgent data's end.
• Used for priority communication.
11. Options (Variable length)
• Optional additional settings for TCP.
• Common Options:
• Maximum Segment Size (MSS)
• Window Scaling
• Timestamps

• If options are used, the header length increases.


12. Data (Payload)
• Actual application-layer data carried by TCP.
• Size varies depending on the MSS (Maximum Segment Size).
TCP Connection Establishment
and Termination
TCP is a connection-oriented protocol.
This means before data transfer can begin, a connection must be established between the two communicating
devices.
After communication is complete, the connection must be properly terminated to free up resources.
TCP Connection Establishment: 3-Way Handshake
To establish a reliable TCP connection, TCP uses a process known as the Three-Way Handshake.
Steps of Three-Way Handshake:
Step Action
SYN: The client sends a SYN (synchronize) packet to
1
the server to initiate the connection.
SYN-ACK: The server responds with a SYN-ACK
2
(synchronize + acknowledgment) packet.
ACK: The client sends an ACK (acknowledgment)
3
packet back to the server.
Detailed Explanation:
Step 1: Client Sends SYN
• The client wants to establish a connection.
• It sends a TCP segment with the SYN flag set.
• It also selects an Initial Sequence Number (ISN) (randomly chosen) for the first byte.
Example:
Client sends: SYN, ISN = 1000
Step 2: Server Sends SYN-ACK
• The server receives the SYN request.
• Server responds with a segment that has both SYN and ACK flags set.
• It acknowledges the client’s ISN (Client’s ISN + 1).
• Server also chooses its own ISN for its side.
Example:
Server sends: SYN-ACK, Acknowledgment = 1001, Server’s ISN = 5000
Step 3: Client Sends ACK
• Client receives SYN-ACK.
• Client sends an ACK back to the server, acknowledging the server's ISN.
Example:
Client sends: ACK, Acknowledgment = 5001
TCP Connection Termination: 4-Way Handshake
To terminate a TCP connection properly, TCP uses a Four-Way Handshake.
Steps of Four-Way Handshake:
Step Action
FIN: Client sends a FIN (finish) segment to the
1
server indicating no more data to send.
ACK: Server acknowledges the FIN with an ACK
2
segment.
FIN: Server sends its own FIN segment when ready
3
to close.
ACK: Client acknowledges the server's FIN with an
4
ACK segment.
Detailed Explanation:
Step 1: Client Sends FIN
•The client decides to terminate the connection.
•It sends a segment with the FIN flag set.
Step 2: Server Sends ACK
•Server acknowledges the client’s FIN.
•It sends a segment with the ACK flag set.
Step 3: Server Sends FIN
•After finishing its remaining data transmission, the server sends its own FIN to the client.
Step 4: Client Sends ACK
•Client acknowledges the server’s FIN.
•Connection is now fully closed.
State transition Diagram

TCP Connection State Transition Diagram


In TCP, states represent different phases during the establishment and termination of a connection.
Each side (client and server) moves through these states based on the packets they send or receive.
Notes on State Transitions:
• Client Active Open: Client initiates connection (SYN → SYN-ACK → ACK).
• Server Passive Open: Server waits for a request (LISTEN → SYN-RECEIVED → ESTABLISHED).
• Both sides must close independently: That’s why 4 steps are needed for connection termination.
• TIME-WAIT State:
• Ensures that delayed packets are handled properly.
• Waits 2 × Maximum Segment Lifetime (MSL) time before fully closing.

Important TCP States:


State Description
CLOSED No connection exists.
LISTEN Server is waiting for a connection request.
SYN-SENT Client has sent SYN, waiting for SYN-ACK.
SYN-RECEIVED Server received SYN, sent SYN-ACK, waiting for ACK.
ESTABLISHED Connection is open; data transfer can happen.
FIN-WAIT-1 Sender sent FIN, waiting for ACK or FIN.
FIN-WAIT-2 Sender received ACK for its FIN, waiting for FIN.
CLOSE-WAIT Waiting to close the connection after receiving FIN.
LAST-ACK Waiting for the final ACK after sending FIN.
TIME-WAIT Waiting to ensure the receiver got the last ACK.
CLOSING Both sides sent FIN simultaneously.
Windows in TCP
In TCP communication, windows are used to control the flow of data between the sender and the receiver
efficiently.
They are important to ensure that data transmission is reliable, ordered, and efficient.
1. Sender Window
• The Sender Window defines the range of bytes that the sender can send without waiting for an acknowledgment.
• It ensures that the sender does not overwhelm the receiver.
• If the sender sends data and receives ACKs, the window slides forward — allowing more data to be sent (this is
why TCP is called Sliding Window Protocol).
Important Points:
• It starts from the last acknowledged byte.
• It includes bytes that are sent but not yet acknowledged.
• Size of the window is determined by the receiver’s advertised window size (Receiver Window).
2. Receiver Window
•The Receiver Window defines the range of bytes the receiver is willing to accept.
•It is based on the receiver’s buffer availability.
•The receiver informs the sender about the size of its receiving window in every ACK packet
(called the Advertised Window).
Important Points:
•Prevents the sender from sending more data than the receiver can handle.
•If the receiver's buffer is full, it may advertise a zero window, asking the sender to stop sending
temporarily.
Difference Between TCP and UDP

Terms TCP UDP


Full Form Transmission Control Protocol User Datagram Protocol

Connection Connection-oriented (establishes connection Connectionless (no connection setup needed)


before data transfer)

Reliable (acknowledgment, retransmission,


Reliability Unreliable (no guarantee of delivery)
sequencing)

Data Transfer Stream-based (continuous flow) Message-based (individual packets/datagrams)

Yes, error checking and correction using


Error Control checksum, ACK, and retransmission Limited error checking using checksum only

Flow Control Yes (using sliding window protocol) No flow control

Congestion Control Yes (TCP manages congestion) No congestion control

Speed Slower (due to connection setup, reliability) Faster (less overhead)

Use Cases Web browsing (HTTP/HTTPS), Email (SMTP), Video streaming, Voice calls (VoIP), Gaming,
File Transfer (FTP) DNS queries
Header Size Larger (20-60 bytes) Smaller (8 bytes)
Ordering of Packets Guaranteed ordering No guaranteed ordering
COMPUTER
NETWORKS
SECTION 2: APPLICATION, PRESENTATION, AND SESSION LAYERS
FOR SEM V

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy