Mastering Computer Network Layers: From Physical to Application
This comprehensive guide walks through the fundamentals of computer networking, covering network classifications, the OSI/TCP‑IP layered architecture, key devices, protocols, addressing, routing, transport mechanisms, and application‑layer services, while illustrating concepts with clear diagrams and examples.
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. Each layer should be independent, flexible, and fully decoupled.
2. Physical Layer
The physical layer connects devices and transmits raw bit streams over various media. Typical devices are repeaters (signal amplifiers) and hubs (multi‑port repeaters). Three channel types are defined:
Simplex – one‑way communication.
Half‑duplex – alternating transmission.
Full‑duplex – simultaneous transmission.
3. Data Link Layer
The data link layer provides reliable transmission over the unreliable physical medium. Its responsibilities include framing, physical (MAC) addressing, flow control, error detection, and retransmission.
3.1 Error Detection
Parity check – detects single‑bit errors.
Cyclic Redundancy Check (CRC) – generates a fixed‑size checksum from the transmitted data.
3.2 Maximum Transmission Unit (MTU)
Frames are limited by the MTU; the path MTU is the smallest MTU along a route.
3.3 Ethernet Details
MAC address: 48‑bit unique identifier, usually expressed in hexadecimal.
Ethernet frame format:
Type field – 2 bytes, identifies the upper‑layer protocol.
Destination MAC – 6 bytes.
Source MAC – 6 bytes.
Payload – 46 to 1500 bytes.
CRC – 4 bytes.
Minimum Ethernet frame size is 64 bytes.
4. Network Layer
The network layer provides end‑to‑end packet forwarding, routing, and addressing. Core protocols include IP (IPv4/IPv6), ICMP, ARP, RARP, and IGMP. IP offers an unreliable, connectionless service and handles routing, fragmentation, and basic error handling.
4.1 IP Header Fields
Version (4 bits) – IPv4 or IPv6.
Header Length (4 bits) – length of the IP header.
Total Length (16 bits) – length of the entire datagram.
TTL (8 bits) – lifetime of the datagram.
Protocol (8 bits) – identifies the encapsulated upper‑layer protocol (e.g., TCP, UDP).
4.2 IP Forwarding Process
4.3 Subnetting
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 is reserved for multicast, Class E for future use.
4.4 Network Address Translation (NAT)
NAT allows many private hosts to share a single public IP address. Outbound packets have their source address replaced with the public address and a mapping is stored in a NAT table; inbound packets are translated back to the appropriate private address.
4.5 ARP & RARP
ARP maps an IPv4 address to a MAC address; RARP performs the reverse mapping.
4.6 ICMP
ICMP reports errors and diagnostic information. Common utilities are 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) contain internal (IGP) and external (EGP) routing protocols. Static routing is manually configured; dynamic routing includes link‑state (e.g., OSPF, Dijkstra) and distance‑vector (e.g., RIP, Bellman‑Ford) algorithms.
4.8 RIP vs OSPF
RIP uses hop count as metric, limits routes to 15 hops, and exchanges updates every 30 seconds.
OSPF floods link‑state advertisements, runs Dijkstra’s shortest‑path algorithm, supports equal‑cost multipath and hierarchical routing.
4.9 Border Gateway Protocol (BGP)
BGP operates between ASes, initially exchanging full routing tables and subsequently sending incremental updates over TCP.
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
Connectionless, no reliability guarantees.
Message‑oriented.
No congestion control.
Header (8 bytes): source port, destination port, length, checksum.
5.2 TCP
TCP is a connection‑oriented, byte‑stream protocol that provides reliable, full‑duplex communication.
Segmentation and reassembly of application data.
Flow control via a sliding window.
Congestion control (slow start, congestion avoidance, fast retransmit, fast recovery).
Three‑way handshake (SYN, SYN‑ACK, ACK) to establish a connection.
Four‑way termination (FIN, ACK exchanges) with a 2 MSL wait.
5.2.1 TCP Header
Source Port | Destination Port | Sequence Number | Acknowledgment Number | Data Offset | Reserved | Flags | Window Size | Checksum | Urgent Pointer | Options (if any)5.2.2 Flow Control
TCP uses a sliding window; the receiver advertises a window size indicating how many bytes it can accept.
5.2.3 Congestion Control
Algorithms include:
Slow start : congestion window (cwnd) starts at 1 MSS and grows exponentially until a threshold (ssthresh) is reached.
Congestion avoidance : cwnd grows linearly (+1 MSS per RTT) after ssthresh.
Fast retransmit : after three duplicate ACKs, the sender retransmits the missing segment without waiting for a timeout.
Fast recovery : after fast retransmit, ssthresh is set to cwnd/2 and the sender enters congestion avoidance.
6. Application Layer
The application layer provides network services to end‑user applications. Key protocols include DNS, DHCP, FTP, Telnet, SMTP, POP3, and HTTP/HTTPS.
6.1 DNS
Domain Name System translates human‑readable domain names to IP addresses using a hierarchical lookup:
Browser cache.
Local hosts file.
OS DNS cache.
Recursive/iterative queries to DNS servers (root → TLD → authoritative).
6.2 DHCP
Dynamic Host Configuration Protocol automatically assigns IP addresses, subnet masks, default gateways, and DNS server information to hosts on a LAN. DHCP operates over UDP (client → server on port 68, server → client on port 67).
6.3 HTTP/HTTPS
HTTP (TCP, port 80) is a reliable request/response protocol. HTTPS (TCP, port 443) adds SSL/TLS encryption for confidentiality, integrity, and server authentication.
GET – retrieve a resource.
POST – submit data to be processed.
DELETE – request removal of a resource.
HEAD – retrieve only the header.
OPTIONS – query supported methods.
PUT – upload a representation at a specific URI.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
