TCP/IP Model : Transport Layer

Computer Networking Series Part 4

ยท

5 min read

TCP/IP Model : Transport Layer

Introduction

This article will take you through the Transport Layer of the TCP/IP Model. It is the Part - IV of the 6-article series on Computer Networking.

Difference between Transport & Network Layer

  • Transport Layer - Lies inside the device. Its job is to take data from the network to the application and vice versa.

  • Network Layer - Lies outside the device. Transportation from network to network is done here.

  • Network layer takes care of delivering the message from one computer to another but when the message is reached on the computer, the transport layer delivers it to the applications.

  • Important protocols in the Transport Layer are Transmission Control Protocol(TCP) and User Datagram Protocol(UDP).

  • Transport Layer takes care of congestion control

  • Congestion control algorithms are inbuilt in TCP.

  • Data is in the form of Segments in Transport Layer, while data is in the form of Packets in Network Layer.

  • Transport Layer has TCP & UDP. Network Layer has IP.

Multiplexing & De-Multiplexing

MUX

  • Sockets have port numbers.

  • Data Travels in packets. Transport layer attaches socket port numbers on these data packets, so that they reach the correct applications in the device.

Checksums

Checksums

  • When data is sent, you will calculate a checksum for your data using an algorithm.

  • When the receiver receives the data, that computer also calculates a checksum using the same algorithm used by sender.

  • If checksum values match, then all data has been received without corruption.

  • If checksum values don't match, then some data or files are lost.

Timers

Timer

There are 4 types of Timers in TCP :

Retransmission Timeout (RTO) Timer

  • Purpose
    The RTO timer is used to manage retransmissions of data segments that are not acknowledged within a certain time frame.

  • Function
    When a TCP sender transmits a segment and does not receive an acknowledgment within a specified time (RTO), it assumes that the segment was lost or corrupted and re-transmits it.

  • Adjustment
    The RTO timer dynamically adjusts based on network conditions, such as round-trip time (RTT) and variance.

Persistence Timer

  • Purpose
    The persistence timer is used to manage situations where a sender has data to transmit, but the window size of the receiver is zero (i.e., the receiver's buffer is full).

  • Function
    When the sender encounters a zero window condition, it sets the persistence timer. Upon expiration, it sends a small probe segment to the receiver, allowing it to update its window size.

Keepalive Timer

  • Purpose
    The keepalive timer is employed to detect if a connection is still active in the absence of data traffic.

  • Function
    After a certain period of inactivity, the TCP stack can send a small keepalive segment to the peer. If no response is received, the connection may be considered idle or broken.

  • Usage
    Keepalive is often used in applications where long-lived connections need to be maintained, such as those used for file transfers or remote login sessions.

Time Wait Timer

  • Purpose
    The time wait timer is associated with the TIME_WAIT state, which occurs after a TCP connection is closed.

  • Function
    It ensures that any delayed segments related to the closed connection are not misinterpreted as belonging to a new connection. The TIME_WAIT state allows the network to clear any lingering segments.

  • Duration
    The time wait timer typically lasts twice the maximum segment lifetime (2MSL), where MSL is the maximum time a segment can exist in the network.

User Datagram Protocol(UDP)

  • Data may or may not be delivered.

  • Data may change on the way.

  • Data may not be in order.

  • It is a connection-less protocol.

  • UDP uses checksums. It will be aware if the data has been corrupted or lost but it will not do anything about it.

UDP Packets

UDP

  • Total size = 2^16 bytes - 8 bytes for the header = 65,536 bytes.

  • 65,536 bytes is the amount of data you can send in one UDP Packet.

  • UDP Packet contains a header which is 8 bytes in size.

  • Header contains :

    • Source Port Number(2 bytes)
    • Destination Port Number(2 bytes)
    • Length of Datagram/Length of Packet(2 bytes)
    • Checksum(2 bytes).

Use Cases

  • Very fast.

  • Used in gaming, video conferencing apps.

  • DNS also uses UDP because it is faster.

Transmission Control Protocol(TCP)

  • Transport layer protocol.

  • Application Layer sends a lot of data. TCP segments this data in a process called segmentation

  • Divide data in chunks, add headers, add checksums.

  • It may also collect the data from network layer.

  • Congestion Control

  • Takes care of :

    • When data doesn't arrive.
    • Rearranges or maintains the order of data.

Features of TCP

  • Connection Oriented

  • Error Control

  • Congestion Control

  • Full Duplex - Send files from both directions simultaneously.

  • One TCP Connection has only 2 computers, not more than that.

  • 3-Way Handshake
    Sequence numbers are random because otherwise they would be very easy to guess for hackers to create a connection with the server. It is for security purposes.

3 Way Handshake

This was all about the Transport Layer of TCP/IP Model.

Conclusion

You can read other articles written by me through these links.

System Design Series
Introduction To Parallel Computing
Deep Dive Into Virtualization
Insights Into Distributed Computing

Cloud Computing Series
1. Cloud Service Models
2. Cloud Deployment Models
3. Cloud Security
4. Cloud Architecture
5. Cloud Storage
6. Networking In The Cloud
7. Cloud Cost Management
8. DevOps In Cloud & CI/CD
9. Serverless Computing
10. Container Orchestration
11. Cloud Migration
12. Cloud Monitoring & Management
13. Edge Computing In Cloud
14. Machine Learning In Cloud

Computer Networking Series
1. Computer Networking Fundamentals
2. OSI Model
3. TCP/IP Model : Application Layer
4. TCP/IP Model : Transport Layer
5. TCP/IP Model : Network Layer
6. TCP/IP Model : Data Link Layer

Version Control Series
1. Complete Guide to Git Commands
2. Create & Merge Pull Requests
3. Making Open Source Contributions

Linux
Complete Guide to Linux Commands

Thanks For Reading! ๐Ÿ’™
Garvit Singh

ย