Fundamentals 26 min read

Why TCP Matters: A Deep Dive into Reliable Transport and Network Layers

This article explains the essential concepts of TCP and UDP, covering the OSI model layers, socket communication, reliable transmission mechanisms such as stop‑and‑wait and sliding‑window, congestion control, connection establishment, and practical differences between TCP and UDP, providing a comprehensive networking fundamentals overview.

Open Source Linux
Open Source Linux
Open Source Linux
Why TCP Matters: A Deep Dive into Reliable Transport and Network Layers

Doing IT work inevitably involves networks, and TCP is the most important protocol.

Physical Layer

Two hosts connected by a cable define the physical layer; the rules (e.g., USB, 10 V, 2.4 GHz) constitute the physical‑layer protocol.

Data Link Layer

Connecting multiple computers via a switch creates a LAN (Ethernet). Each machine is identified by a unique, permanent MAC address, which the switch uses to forward frames.

Network Layer

To avoid managing many MAC addresses, an IP address is introduced as a logical host identifier. The IP address works like a postal address: the router forwards packets based on the destination IP, while ARP resolves the IP‑to‑MAC mapping within a LAN.

Transport Layer

The transport layer provides process‑to‑process communication using sockets. A socket is defined by source IP, source port, destination IP, and destination port. Sockets enable multiple applications on the same host to communicate independently.

Application Layer

On top of the transport layer, protocols such as HTTP, FTP, etc., implement specific business logic.

TCP Header

TCP adds a 20‑byte fixed header (plus optional fields) to the data segment. Important fields include source port, destination port, sequence number, acknowledgment number, and window size.

Reliable Transmission

TCP guarantees that data arrives intact by using sequence numbers, acknowledgments, timeout retransmission, and sliding‑window flow control.

Stop‑and‑Wait Protocol

Each packet is sent and the sender waits for an ACK before sending the next one. Lost packets are detected by timeout and retransmitted.

Continuous ARQ (Sliding Window)

To improve efficiency, the sender transmits multiple packets within a window. The receiver sends cumulative ACKs, and the sender slides the window forward as ACKs arrive. Selective ACK (SACK) allows retransmission of only missing segments.

Congestion Control

TCP limits the sending rate to avoid network congestion. The algorithm includes slow start, congestion avoidance, fast retransmit, and fast recovery, adjusting the congestion window based on packet loss signals.

Connection Establishment (Three‑Way Handshake)

Host A sends SYN, Host B replies with SYN‑ACK, and Host A finishes with ACK. After this exchange both sides are in the ESTABLISHED state.

Connection Termination (Four‑Way Handshake)

FIN and ACK packets are exchanged in four steps, with the initiator entering TIME_WAIT to ensure all delayed packets are cleared before closing.

UDP Protocol

UDP provides a lightweight, connectionless transport with only source port, destination port, length, and checksum fields. It is faster but unreliable, making it suitable for streaming, DNS, and other latency‑sensitive applications.

Summary

Physical, data‑link, network, transport, and application layers each have distinct responsibilities.

TCP offers reliable, ordered delivery using sequence numbers, ACKs, timeout retransmission, sliding‑window flow control, and congestion control.

UDP is simple and fast but does not guarantee delivery.

Understanding these mechanisms is essential for designing robust networked applications.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

TCPReliabilityNetworkingcongestion controltransport layer
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.