Master the OSI Model and TCP/IP: A Complete Guide to Network Protocols
This comprehensive guide explains computer networking fundamentals, covering the OSI seven‑layer model, TCP/IP suite, IP addressing, subnet masks, ARP/RARP, routing protocols, TCP handshakes, UDP, DNS, NAT, DHCP, HTTP methods, and a practical example of accessing a website.
0. Introduction
Computer networking studies the protocols that define how heterogeneous devices exchange data. Protocols such as TCP/IP act as the universal language of the Internet.
1. Network Layering Models
The ISO OSI Reference Model (1978) defines seven layers: Physical, Data Link, Network, Transport, Session, Presentation, and Application. In practice, the TCP/IP suite is often represented as a four‑layer (Link, Internet, Transport, Application) or five‑layer model (Physical, Data Link, Network, Transport, Application). The correspondence between the two models is shown in the diagram below.
2. OSI Seven‑Layer Model
Physical Layer : Defines mechanical, electrical, and procedural characteristics of the transmission medium. Typical devices: repeaters, hubs.
Data Link Layer : Provides reliable node‑to‑node transfer, framing, error detection, flow control, and MAC addressing. Main protocol: Ethernet. Devices: bridges, switches.
Network Layer : Handles logical addressing, routing, and packet forwarding. Core protocols: IP, ICMP, ARP, RARP, IGMP. Device: router.
Transport Layer : End‑to‑end segmentation, reliability (TCP) or best‑effort delivery (UDP), flow and error control. Devices: gateways.
Session Layer : Manages session establishment, maintenance, and termination.
Presentation Layer : Performs data translation, encryption, compression, and format conversion.
Application Layer : Provides network services to applications (e.g., HTTP, FTP, DNS, SMTP, POP3).
3. IP Addressing
An IPv4 address consists of a network portion and a host portion. Important address types:
Network address : host bits are all 0.
Broadcast address : host bits are all 1.
Multicast address : Class D (224.0.0.0 – 239.255.255.255).
Special addresses : 255.255.255.255 (limited broadcast), 0.0.0.0 (unspecified), 127.0.0.0/8 (loopback).
Private address ranges : 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.
4. Subnet Masks and Network Segmentation
A subnet mask is a 32‑bit binary number where a “1” marks a network bit and a “0” marks a host bit. Subnetting reallocates some host bits as a subnet identifier, reducing the number of usable host addresses per subnet.
Two common calculation methods:
Based on the required number of subnets: convert the subnet count to binary, count the bits (N), then set the first N host bits of the default class mask to 1.
Based on required hosts per subnet: convert the host count to binary, determine N, then set the last N bits of a full‑ones mask to 0.
Example – 27 subnets from a B‑class network 168.195.0.0 :
# Default B‑class mask: 255.255.0.0 (binary 11111111.11111111.00000000.00000000)
# 27 = 11011₂ → N = 5
# Set first 5 host bits to 1 → 11111000.00000000
# Resulting mask: 255.255.248.05. ARP and RARP
ARP (Address Resolution Protocol) maps an IPv4 address to a MAC address. A host broadcasts an ARP request; the owner of the target IP replies with its MAC, which is cached locally. ARP spoofing can be used for man‑in‑the‑middle attacks.
RARP (Reverse ARP) performs the opposite mapping, allowing a host that knows only its MAC address to obtain an IP address from a RARP server.
6. Routing Protocols
Common interior routing protocols:
RIP (Routing Information Protocol) : Distance‑vector protocol using hop count as metric; maximum 15 hops.
OSPF (Open Shortest Path First) : Link‑state protocol that runs Dijkstra’s algorithm; metric based on bandwidth and delay.
7. TCP/IP Protocol Suite
The TCP/IP suite is the foundation of the Internet. The IP layer routes packets, while the TCP layer provides reliable, connection‑oriented transport using a three‑way handshake and a four‑way termination.
Three‑way handshake : SYN → SYN‑ACK → ACK.
Four‑way termination : FIN → ACK → FIN → ACK, ensuring both sides have finished transmitting data.
8. UDP Protocol
UDP is a connection‑less, unreliable datagram service. Its header contains four 16‑bit fields: source port, destination port, length, and checksum. Typical UDP‑based protocols include TFTP, SNMP, DNS, NFS, and BOOTP.
9. DNS
The Domain Name System translates human‑readable domain names into IP addresses, enabling users to access resources via URLs.
10. NAT
Network Address Translation converts private (reserved) IP addresses to public addresses, conserving IPv4 address space and providing a basic layer of security.
11. DHCP
Dynamic Host Configuration Protocol automatically assigns IP addresses and other network parameters (subnet mask, gateway, DNS servers) to hosts on a LAN using UDP.
12. HTTP
HyperText Transfer Protocol defines request methods such as GET, POST, PUT, and DELETE.
GET : Retrieves a resource; safe (does not modify state) and idempotent.
POST : Submits data to the server; may change server state; not idempotent.
PUT : Stores a document at a specified URL.
DELETE : Removes the specified resource.
13. Example – Accessing www.baidu.com
Browser resolves www.baidu.com to IP 220.181.27.48 via DNS.
TCP three‑way handshake establishes a connection (client random port → server port 80).
Network layer selects a route using the routing table.
Data‑link layer uses ARP to resolve the next‑hop MAC address; once resolved, IP packets are transmitted.
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.
