Fundamentals 55 min read

TCP/IP Protocol Stack Overview and Layer Functions

This article provides a comprehensive introduction to the TCP/IP protocol stack, explaining its four-layer architecture, the role of each layer from the physical to the application layer, and detailed mechanisms such as framing, addressing, routing, error control, and connection management.

Deepin Linux
Deepin Linux
Deepin Linux
TCP/IP Protocol Stack Overview and Layer Functions

The TCP/IP protocol suite is the core framework for network communication, defining how devices connect to the Internet and how data is transmitted between them. It follows a four‑layer structure: Application, Transport, Network, and Link layers, each relying on the services of the layer below.

TCP/IP Concept

Physical Media : The physical medium (fiber, twisted pair, wireless) carries binary signals (0 and 1). Different media affect bandwidth, speed, distance, and interference.

Link Layer : Data is grouped into Ethernet frames, each consisting of a header (14 bytes), payload (46‑1500 bytes), and trailer (4 bytes). The header contains source and destination MAC addresses, which uniquely identify network adapters.

Network connectors: e.g., NICs, device interfaces
Transmission media: e.g., cables, wireless
Bit stream: transmitted data

The link layer broadcasts frames on the local network; each host discards frames whose destination MAC does not match its own.

Network Layer

The network layer introduces IP addressing to identify hosts across subnets. It encapsulates transport‑layer segments into IP packets, handles routing, and performs fragmentation when packets exceed the MTU of the underlying link.

Key IPv4 header fields include source/destination IP, TTL, protocol, and checksum. Routing decisions are made using routing tables that map destination networks to next hops or gateways.

0x0021 – IP packet
0xC021 – LCP (Link Control Protocol)
0x8021 – NCP (Network Control Protocol)
0xC023 – PAP authentication
0xC025 – LQR
0xC223 – CHAP authentication

Routing protocols (RIP, OSPF, etc.) dynamically populate these tables, while static routes are configured manually.

Transport Layer

The transport layer provides end‑to‑end communication. UDP offers connectionless, best‑effort delivery, while TCP provides reliable, connection‑oriented byte streams with three‑way handshake connection establishment, flow control, and congestion control.

TCP uses sequence numbers, acknowledgments, sliding windows, and retransmission mechanisms (timeout‑based and fast‑retransmit) to ensure reliable delivery.

1. Data link layer unit is a frame (D)
2. Functions not belonging to data link layer: congestion control (D)
3. Shared Ethernet uses CSMA/CD; 802.11 uses CSMA/CA

Session, Presentation, and Application Layers

The session layer manages the creation, maintenance, and termination of communication sessions, similar to a telephone call. The presentation layer handles data format translation, encryption, compression, and protocol conversion. The application layer defines protocols such as HTTP, FTP, and SMTP, specifying how data is formatted and interpreted by end applications.

Practical Learning Path

The article also outlines a hands‑on curriculum for building a user‑space TCP/IP stack with DPDK, covering topics such as DPDK environment setup, ARP handling, ICMP, UDP/TCP implementation, socket API design, sliding windows, connection management, and performance testing with tools like hping3 and tcpdump.

Students are encouraged to join a systematic learning program, scan the QR code to contact the instructor, and receive a discount coupon for the course.

protocolsTCP/IPnetworkingOSI modelComputer Networksnetwork layers
Deepin Linux
Written by

Deepin Linux

Research areas: Windows & Linux platforms, C/C++ backend development, embedded systems and Linux kernel, etc.

0 followers
Reader feedback

How this landed with the community

login 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.