DEV Community

Cover image for Understanding the Transport Layer and Its Protocols
Vignesh J
Vignesh J

Posted on

Understanding the Transport Layer and Its Protocols

This is the sixth part of the computer networking series. Check out the previous parts if you haven’t! In this post, we’ll dive into the Transport Layer and its protocols: TCP and UDP.

Table of Contents

  1. What Is the Transport Layer?
  2. How Does the Transport Layer Work?
  3. Ensuring Data Integrity
  4. Transport Layer Protocols
  5. TCP’s 3-Way Handshake

What Is the Transport Layer?

The Transport Layer plays a crucial role in moving data between applications and networks.

Example

Imagine texting your friend on WhatsApp:

  • The Network Layer ensures your message reaches your friend’s device.
  • The Transport Layer ensures the data moves from the WhatsApp app on your device to the network, and then from the network to WhatsApp on your friend’s device.

How Does the Transport Layer Work?

Data Transmission

  • Packets: Data is divided into packets for transmission.
  • Multiplexing: The transport layer sends packets to the network using a multiplexer.
  • Demultiplexing: It receives packets from the network and sends them to the correct application.
  • Port Numbers: The transport layer attaches port numbers to packets for identification.

Data transmission

Congestion Control

The transport layer monitors network traffic to prevent congestion.

Ensuring Data Integrity

Checksums

Checksums help detect corruption during data transfer.

  1. The sender calculates a checksum using an algorithm and sends it along with the data.
  2. The receiver calculates a checksum for the received data.
  3. If the checksums match, the data is intact. If not, the data is corrupted.

Timers

Timers ensure data delivery:

  • When a packet is sent, a timer starts.
  • If no acknowledgment (ACK) is received before the timer expires, the sender knows the data didn’t arrive and resends it.
  • Sequence Numbers: Prevent duplicate packets from causing confusion.

Transport Layer Protocols

The Transport Layer has two main protocols:

1. User Datagram Protocol (UDP)

  • Unreliable: Data may or may not be delivered.
  • Connectionless: It doesn’t establish a connection before sending data.
  • Error Handling: UDP uses checksums but doesn’t handle errors—it simply discards corrupted packets.
  • Speed: It’s faster because it doesn’t check for delivery or errors.

UDP

Applications of UDP

  • Video conferencing (e.g., Zoom, Teams)
  • DNS (Domain Name System)
  • Online gaming

2. Transmission Control Protocol (TCP)

  • Reliable: Ensures data is delivered without errors.
  • Connection-Oriented: Data is sent only after a connection is established.
  • Order Preservation: Ensures packets arrive in the correct order.
  • Error and Congestion Control: Checks for errors and manages network congestion.
  • Full Duplex: Data can be sent and received simultaneously.

TCP

How TCP Works

  1. Segmentation:
    • TCP divides large chunks of data into smaller segments, adding headers and checksums.
    • At the receiver’s end, it reassembles segments into the original data.
  2. Features:
    • Error control
    • Congestion control
    • Sequence numbers to maintain order

TCP’s 3-Way Handshake

The 3-way handshake is a process to establish a TCP connection.

  1. SYN: The client sends a connection request with:

    • A synchronization (SYN) flag
    • A random sequence number for security
  2. SYN-ACK: The server responds with:

    • A SYN flag
    • An acknowledgment (ACK) flag
    • A new sequence number and an acknowledgment number (client's sequence number + 1)
  3. ACK: The client sends:

    • An ACK flag
    • Its updated sequence and acknowledgment numbers

Once this process is complete, a reliable connection is established.

3-way

This wraps up the Transport Layer and its protocols. Stay tuned for the next part, where we’ll dive deeper into more networking concepts!

Follow me on Linkedin | GitHub | Twitter

Top comments (2)

Collapse
 
sowmiya_jayakumar profile image
Sowmiya Jayakumar

Informative! Thank you

Collapse
 
vignesh_j profile image
Vignesh J

Thank you!