Fundamentals 29 min read

Master the OSI Model and TCP/IP: Complete Guide to Network Layers, IP Addressing, and Protocols

This comprehensive article explains computer networking fundamentals, covering network layer classification, the OSI seven‑layer model, detailed functions of each layer, IP address types, subnet mask calculations, ARP/RARP, routing protocols, TCP/UDP, DNS, NAT, DHCP, HTTP, and a step‑by‑step example of accessing a website.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master the OSI Model and TCP/IP: Complete Guide to Network Layers, IP Addressing, and Protocols

OSI Seven‑Layer Model

The OSI reference model defines seven layers of network communication (from bottom to top): Physical, Data Link, Network, Transport, Session, Presentation, and Application. TCP/IP can be mapped onto a four‑ or five‑layer variant.

Physical Layer

Provides mechanical, electrical, functional and procedural characteristics for activating, maintaining and terminating communication endpoints. Typical devices: repeaters and hubs.

Data Link Layer

Offers reliable transmission to the Network layer by framing data into frames , performing error detection, flow control and managing link establishment, maintenance and release. Primary protocol: Ethernet. Important devices: bridges and switches.

Network Layer

Implements logical addressing and routing. The core protocol is IP (unreliable, connection‑less datagram service). Supporting protocols include ARP , RARP , ICMP and IGMP . Devices: routers.

Transport Layer

Provides end‑to‑end segmentation, reliability and flow control. Main protocols:

TCP – connection‑oriented, reliable (three‑way handshake, four‑step termination, sliding‑window flow control).

UDP – connection‑less, best‑effort delivery.

Session, Presentation, Application Layers

Session manages session establishment and termination. Presentation handles data transformation (encryption, compression, format conversion). Application offers interfaces for network services.

IP Address Types

IPv4 addresses consist of a network part and a host part. Types include:

Network address (host bits all 0)

Broadcast address (host bits all 1)

Multicast address (Class D, 224.0.0.0/4)

Private address ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16

Special addresses: 255.255.255.255 (limited broadcast), 0.0.0.0 (self‑identification), 127.0.0.0/8 (loopback)

Subnet Mask and Network Segmentation

A subnet mask marks which bits of an IP address belong to the network (1) and which belong to the host (0). Common calculation methods:

Determine required number of subnets or hosts.

Convert that number to binary to find the number of bits needed (N).

Set the N most‑significant host bits to 1 in the mask.

Examples:

Dividing a Class B network 168.195.0.0 into 27 subnets → mask 255.255.248.0.

Allocating 700 hosts per subnet → mask 255.255.252.0.

ARP and RARP

ARP (Address Resolution Protocol) resolves an IPv4 address to a MAC address by broadcasting an ARP request and caching the reply. ARP spoofing can be used for attacks. The arp command can query, add or delete static entries.

RARP (Reverse ARP) performs the opposite operation: a host that knows only its MAC address can request its IP address from a RARP server.

Routing Selection Protocols

Common interior routing protocols:

RIP – distance‑vector, metric = hop count, maximum 15 hops.

OSPF – link‑state, Dijkstra algorithm, metric based on bandwidth and delay.

TCP/IP and UDP Protocols

TCP provides a reliable, connection‑oriented byte‑stream service with flow control, retransmission and ordered delivery. Its header fields include source/destination ports, sequence number, acknowledgment number, flags (SYN, ACK, FIN, etc.), window size, checksum and urgent pointer.

UDP offers a connection‑less datagram service with a simple header (source port, destination port, length, checksum). It is used by protocols such as DNS, TFTP, SNMP, NFS, BOOTP.

DNS, NAT, DHCP, HTTP

DNS translates domain names to IP addresses.

NAT maps private IP addresses to public ones, conserving IPv4 space and providing a basic firewall.

DHCP automatically assigns IP configuration parameters (address, mask, gateway, DNS) to hosts using UDP/67‑68.

HTTP defines request methods (GET, POST, PUT, DELETE). GET is safe and idempotent; POST is used to submit data.

Practical Example: Accessing www.baidu.com

1. DNS resolution : The client queries a DNS server to obtain the IP address (e.g., 220.181.27.48).

2. TCP connection : The client initiates a three‑way handshake to the server’s port 80, selecting a random source port (e.g., 5000).

3. Routing : The IP layer looks up the routing table and forwards the packet through intermediate routers toward the destination network.

4. ARP : On the local LAN, the client resolves the next‑hop router’s IP to a MAC address via ARP.

5. Data exchange : HTTP request and response are encapsulated in TCP segments, which are then encapsulated in IP packets and transmitted over the physical medium.

OSI Model Diagram
OSI Model Diagram
TCP/IP Layer Mapping
TCP/IP Layer Mapping
IP Address Types
IP Address Types
Subnet Mask Calculation
Subnet Mask Calculation
TCP Header Diagram
TCP Header Diagram
TCP Handshake Diagram
TCP Handshake Diagram
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/IPOSI modelIP addressing
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.