Buffl

Capital 5: The Transport Layer

as
by abdullah S.

Transport Layer

The Transport Layer is the fourth layer of the OSI (Open Systems Interconnection) model and is responsible for end-to-end communication between devices in a network. It ensures that data is delivered accurately, efficiently, and reliably from the source to the destination.

Functions of the Transport Layer

  1. Segmentation & Reassembly

    • Breaks large messages into smaller packets (segmentation).

    • Reassembles packets in the correct order at the destination.

  2. Flow Control

    • Prevents overwhelming a slow receiver by controlling the data flow.

    • Uses techniques like Sliding Window Protocol.

  3. Error Control

    • Ensures data is received without errors using checksums and acknowledgments.

  4. Multiplexing & Demultiplexing

    • Allows multiple applications to share the same network connection using port numbers.

    • Ensures data is delivered to the correct application.

  5. Connection Management

    • Supports connection-oriented and connectionless communication.

    • Example: TCP establishes a connection using a three-way handshake before data transfer.

Transport Layer Protocols

Protocol

Type

Features

TCP (Transmission Control Protocol)

Connection-Oriented

Reliable, error-checking, ordered delivery

UDP (User Datagram Protocol)

Connectionless

Faster, no error checking, unordered delivery

Example of Transport Layer in Action

  • When you visit a website (HTTP request), the Transport Layer uses TCP to:

    • Establish a connection.

    • Break the request into packets.

    • Ensure packets arrive correctly at the web server.

    • Reassemble packets at the destination.

  • When you stream a video (YouTube, Netflix), the Transport Layer may use UDP because:

    • It prioritizes speed over reliability.

    • Minor packet loss doesn’t significantly impact the experience.

Summary

  • The Transport Layer ensures reliable or fast data delivery.

  • It uses TCP (for reliability) and UDP (for speed).

  • It handles segmentation, error control, flow control, and multiplexing.


Transport Layer Headers: TCP & UDP (Detailed Explanation)


Transport Layer Headers: TCP & UDP (Detailed Explanation)

The Transport Layer in the OSI model uses headers to manage communication between devices. These headers contain important information like source and destination ports, sequence numbers, and error-checking fields.

1. TCP (Transmission Control Protocol) Header

TCP is a connection-oriented protocol, meaning it ensures reliable communication by establishing a connection, maintaining data integrity, and ensuring error checking and retransmission if necessary.

TCP Header Structure (20–60 bytes)

A TCP header has mandatory 20 bytes and can extend up to 60 bytes with options.

Field

Size (Bits)

Description

Source Port

16

Identifies the sending application/process

Destination Port

16

Identifies the receiving application/process

Sequence Number

32

Keeps track of the order of data being sent

Acknowledgment Number

32

Acknowledges receipt of data from the other side

Data Offset (Header Length)

4

Specifies the length of the TCP header

Reserved

3

Reserved for future use, usually set to 0

Flags (Control Bits)

9

Controls connection setup, teardown, and data transfer

Window Size

16

Indicates the amount of data the receiver can handle

Checksum

16

Error-checking field for data integrity

Urgent Pointer

16

Indicates if there is urgent data to process

Options (Optional)

0-320 (variable)

Used for extra features like timestamps, window scaling

TCP Flags (Control Bits)

TCP uses flags (control bits) to manage the connection and data flow. Here are the important ones:

Flag

Meaning

Function

SYN

Synchronize

Initiates a connection (used in the 3-way handshake)

ACK

Acknowledge

Confirms receipt of data

FIN

Finish

Gracefully closes a connection

RST

Reset

Abruptly closes a connection

PSH

Push

Tells the receiver to process data immediately

URG

Urgent

Indicates urgent data that should be processed first

Example of a TCP Header in Action

Imagine you are loading a webpage (using HTTP, which runs on TCP). Here’s what happens:

  1. Your computer sends a TCP SYN packet (with a random sequence number) to the web server.

  2. The server responds with SYN-ACK, acknowledging your request.

  3. Your computer sends ACK, completing the three-way handshake.

  4. Data transfer begins, with each packet carrying a sequence number.

  5. After the data is received, TCP sends an ACK to confirm delivery.

  6. When done, the connection is closed using FIN and ACK.

2. UDP (User Datagram Protocol) Header

UDP is a connectionless, faster, but unreliable protocol. Unlike TCP, it does not guarantee data delivery, order, or retransmission.

UDP Header Structure (8 bytes)

UDP has a fixed 8-byte header, making it lightweight and fast.

Field

Size (Bits)

Description

Source Port

16

Identifies the sending application/process

Destination Port

16

Identifies the receiving application/process

Length

16

Specifies the total size of the UDP packet (header + data)

Checksum

16

Provides basic error-checking (optional in IPv4, mandatory in IPv6)

Example of a UDP Header in Action

Imagine you are streaming a video on YouTube (which uses UDP). Here’s what happens:

  1. The server sends video packets to your device using UDP.

  2. If a packet is lost, UDP does not retransmit it (to keep the stream smooth).

  3. The video may momentarily glitch, but playback continues.

  4. Since UDP does not require acknowledgments, it is faster than TCP.

Comparison of TCP vs. UDP Headers

Feature

TCP

UDP

Header Size

20–60 bytes

8 bytes

Connection

Connection-oriented

Connectionless

Reliability

Reliable (ensures data delivery)

Unreliable (no guarantees)

Error Checking

Checksum + Retransmission

Checksum only

Use Cases

Web browsing, email, file transfer (FTP)

Streaming, gaming, VoIP

Conclusion

  • TCP header is larger and contains more fields for reliable data transfer.

  • UDP header is smaller, making it faster but with no guarantees of delivery.


Author

abdullah S.

Information

Last changed