Fundamentals 23 min read

Master Computer Networks: From Physical Layer to Application Protocols

This comprehensive guide walks through computer networking fundamentals, covering layer classifications, physical and data link devices, error detection, MTU, Ethernet framing, IP addressing, NAT, routing protocols, transport mechanisms like TCP/UDP, and essential application protocols such as DNS, DHCP, HTTP, and HTTPS.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Computer Networks: From Physical Layer to Application Protocols

1. Overview of Computer Networks

Computer networks are classified by scope (WAN, MAN, LAN) and by user type (public, private). The layered architecture is illustrated by the TCP/IP four‑layer model compared with the OSI seven‑layer model. Design principles for layers emphasize independence, flexibility, and complete decoupling.

Layers must be independent.

Each layer should be flexible.

Layers are fully decoupled.

2. Physical Layer

The physical layer connects devices and transmits raw bit streams, providing a reliable medium for upper layers. Key devices include repeaters (amplifiers) and hubs (multi‑port repeaters). Communication channels are categorized as simplex, half‑duplex, and full‑duplex.

Simplex: one‑direction communication.

Half‑duplex: two‑way but not simultaneous.

Full‑duplex: simultaneous two‑way communication.

3. Data Link Layer

3.1 Overview

The data link layer builds on physical‑layer services to provide reliable transmission to the network layer, handling physical addressing, framing, flow control, error detection, and retransmission. Important concepts include MAC addressing, framing, and devices such as bridges and switches.

3.2 Error Detection

Common error‑checking methods are parity bits (limited to single‑bit errors) and cyclic redundancy check (CRC) codes.

3.3 Maximum Transmission Unit (MTU)

MTU defines the maximum frame size; the path MTU is determined by the smallest MTU along a route.

3.4 Ethernet Protocol

Ethernet uses 48‑bit MAC addresses (hexadecimal) and is the dominant LAN technology. Ethernet frame structure includes:

Type (2 bytes) indicating the upper‑layer protocol.

Destination and source MAC addresses (6 bytes each).

Payload (46–1500 bytes).

CRC (4 bytes).

The minimum Ethernet frame is 64 bytes.

Ethernet frame
Ethernet frame

4. Network Layer

The network layer provides end‑to‑end packet delivery, addressing, and routing. The core protocol is IP (IPv4/IPv6), which offers an unreliable, connectionless service. Supporting protocols include ARP, RARP, ICMP, and IGMP.

4.1 IP Protocol Details

IP packets contain the following fields:

Version (4 bits) – IPv4 or IPv6.

Header Length (4 bits) – length of the IP header.

Total Length (16 bits) – size of the entire datagram.

TTL (8 bits) – time‑to‑live.

Protocol (8 bits) – identifies the encapsulated transport protocol (e.g., TCP=6, UDP=17).

4.2 IP Forwarding Process

Routers examine the destination address of each packet, consult their routing tables, and forward the packet to the next hop toward the destination.

4.3 Subnetting

Classic classful address schemes:

Class A: 8‑bit network, 24‑bit host.

Class B: 16‑bit network, 16‑bit host.

Class C: 24‑bit network, 8‑bit host.

Class D: multicast.

Class E: reserved.

4.4 Network Address Translation (NAT)

NAT maps multiple private IP addresses to a single public IP address, conserving address space while adding translation state.

4.5 ARP and RARP

ARP resolves IPv4 addresses to MAC addresses; RARP performs the reverse mapping.

4.6 ICMP

ICMP reports errors and network conditions. Common utilities include ping (echo request/reply) and traceroute (path discovery).

4.7 Routing Overview

Routing algorithms must be correct, simple, adaptable, stable, and fair. Autonomous Systems (AS) use internal gateway protocols (IGP) such as RIP and OSPF, and external gateway protocols (EGP) such as BGP. Static routing is manually configured; dynamic routing includes:

Link‑state (LS) algorithms – each router floods link information and computes shortest paths using Dijkstra’s algorithm.

Distance‑vector (DV) algorithms – routers exchange distance vectors; convergence is slower and may suffer routing loops (Bellman‑Ford basis).

4.8 RIP Protocol

RIP is a distance‑vector protocol that uses hop count as its metric, limited to 15 hops, suitable for small autonomous systems.

4.9 OSPF Protocol

OSPF is a link‑state protocol based on Dijkstra’s algorithm, supporting large networks, hierarchical areas, and multiple equal‑cost paths.

4.10 BGP Protocol

BGP is an external gateway protocol that runs over TCP. It exchanges full routing tables initially and incremental updates thereafter, enabling inter‑AS routing on the Internet.

5. Transport Layer

The transport layer segments data and provides either reliable (TCP) or unreliable (UDP) end‑to‑end delivery, together with flow and congestion control.

5.1 UDP Details

UDP is connectionless, message‑oriented, and lacks congestion control. Its header is 8 bytes:

0      7 8     15 16    23 24    31
+--------+--------+--------+--------+
| Source | Dest   | Length | Checksum |
| Port   | Port   |        |          |
+--------+--------+--------+--------+

5.2 TCP Details

TCP provides a connection‑oriented, byte‑stream service with features such as segmentation/reassembly, flow control, congestion control, reliable delivery, and error detection.

5.2.1 TCP Header Fields

Sequence Number – identifies each byte in the stream.

Acknowledgment Number – next expected byte.

Header Length – minimum 20 bytes, maximum 60 bytes, multiple of 4 bytes.

5.3 Reliable Transmission Principles

Reliability is achieved through error detection (checksum), acknowledgments, retransmission, sequencing, and timers. Protocols include Stop‑and‑Wait and sliding‑window ARQ (used by TCP).

5.4 TCP Flow Control

TCP uses a sliding window advertised by the receiver to prevent the sender from overwhelming the receiver.

5.5 TCP Congestion Control

Congestion control is network‑wide and includes:

Slow Start – exponential growth of the congestion window (cwnd) until a threshold (ssthresh) is reached.

Congestion Avoidance – linear increase of cwnd.

Fast Retransmit – triggered by three duplicate ACKs.

Fast Recovery – reduces cwnd to half of the current value and enters Congestion Avoidance.

5.6 Three‑Way Handshake

Establishing a TCP connection:

Client sends SYN with initial sequence number x.

Server replies with SYN‑ACK, sequence y, acknowledgment x+1.

Client sends ACK with sequence x+1 and acknowledgment y+1. Both sides enter ESTABLISHED state.

5.7 Four‑Way Termination

Closing a TCP connection:

Client sends FIN (seq = x).

Server acknowledges with ACK (ack = x+1).

Server sends its own FIN (seq = y).

Client acknowledges with ACK (ack = y+1) and enters TIME_WAIT for 2 MSL before moving to CLOSED.

6. Application Layer

The application layer provides network services to software. Key protocols include:

DNS – resolves domain names to IP addresses.

DHCP – dynamically assigns IP addresses to hosts.

HTTP/HTTPS – request/response protocols for web resources; HTTPS adds SSL/TLS encryption.

6.1 DNS Details

DNS operates over UDP/port 53 (TCP for large responses). Resolution order: browser cache → hosts file → DNS cache → recursive query to authoritative servers (root → TLD → authoritative).

6.2 DHCP Details

DHCP runs over UDP (ports 67/68) to automatically allocate IP configuration parameters (address, subnet mask, gateway, DNS servers) to clients on a LAN.

6.3 HTTP/HTTPS Details

HTTP is a stateless, request/response protocol over TCP (port 80). Common methods:

GET – retrieve a resource.

POST – submit data to be processed.

PUT – store a resource at a specific URI.

DELETE – remove a resource.

HEAD – retrieve only headers.

HTTPS uses TLS (port 443) to provide confidentiality, integrity, and server authentication.

TCP/IP model
TCP/IP model
Ethernet frame
Ethernet frame
IP packet
IP packet
TCP three‑way handshake
TCP three‑way handshake
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.

TCP/IPnetwork fundamentalsOSI modelComputer Networksnetwork layers
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

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.