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
- What Is the Transport Layer?
- How Does the Transport Layer Work?
- Ensuring Data Integrity
- Transport Layer Protocols
- 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.
Congestion Control
The transport layer monitors network traffic to prevent congestion.
Ensuring Data Integrity
Checksums
Checksums help detect corruption during data transfer.
- The sender calculates a checksum using an algorithm and sends it along with the data.
- The receiver calculates a checksum for the received data.
- 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.
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.
How TCP Works
-
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.
-
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.
-
SYN: The client sends a connection request with:
- A synchronization (SYN) flag
- A random sequence number for security
-
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)
-
ACK: The client sends:
- An ACK flag
- Its updated sequence and acknowledgment numbers
Once this process is complete, a reliable connection is established.
This wraps up the Transport Layer and its protocols. Stay tuned for the next part, where we’ll dive deeper into more networking concepts!
Top comments (2)
Informative! Thank you
Thank you!