Fundamentals 12 min read

Master the OSI Model, TCP/IP Layers, and Core Network Protocols in One Guide

This comprehensive guide explains the OSI and TCP/IP layered architectures, IP address classes, TCP three‑way handshake and four‑way termination, key network protocols, the DNS resolution process, and the step‑by‑step flow when a browser accesses www.baidu.com, providing essential networking fundamentals for developers.

Java Backend Technology
Java Backend Technology
Java Backend Technology
Master the OSI Model, TCP/IP Layers, and Core Network Protocols in One Guide

1. OSI, TCP/IP, and Five‑Layer Protocol Architecture

OSI model (7 layers): Physical, Data Link, Network, Transport, Session, Presentation, Application.

TCP/IP model (4 layers): Network Interface, Internet, Transport, Application.

Five‑layer model (5 layers): Physical, Data Link, Network, Transport, Application.

Typical protocols per layer:

Physical: RJ45, CLOCK, IEEE802.3 (repeaters, hubs, gateways)

Data Link: PPP, FR, HDLC, VLAN, MAC (bridges, switches)

Network: IP, ICMP, ARP, RARP, OSPF, IPX, RIP, IGRP (routers)

Transport: TCP, UDP, SPX

Session: NFS, SQL, NETBIOS, RPC

Presentation: JPEG, MPEG, ASCII

Application: FTP, DNS, Telnet, SMTP, HTTP, WWW, NFS

Functions of each layer:

Physical: Transmit bits over a medium, define mechanical and electrical specifications.

Data Link: Assemble bits into frames and handle point‑to‑point delivery.

Network: Route packets from source to destination across internetworks.

Transport: Provide reliable end‑to‑end segment delivery and error recovery.

Session: Establish, manage, and terminate sessions.

Presentation: Translate, encrypt, and compress data.

Application: Enable access to network services (APDU).

2. IP Address Classification

Class A: starts with 0, first octet 0‑127 (e.g., 1.0.0.0‑126.255.255.255).

Class B: starts with 10, first octet 128‑191.

Class C: starts with 110, first octet 192‑223.

Private address ranges: 10.0.0.0‑10.255.255.255, 172.16.0.0‑172.31.255.255, 192.168.0.0‑192.168.255.255.

IP address AND subnet mask yields the host identifier.

3. TCP Three‑Way Handshake and Four‑Way Termination

Three‑Way Handshake:

1) Client sends SYN, enters SYN_SEND.

2) Server replies with SYN‑ACK, enters SYN_RECV.

3) Client sends ACK, both enter ESTABLISHED.

No data is transferred during the handshake; data transmission starts after establishment.

Four‑Way Termination:

1) Active closer sends FIN.

2) Passive side ACKs the FIN.

3) Passive side sends its own FIN.

4) Active side ACKs the second FIN, completing termination.

4. Common Network Protocols

ICMP – Internet Control Message Protocol, used for control messages between hosts and routers.

TFTP – Trivial File Transfer Protocol, simple file transfer over UDP.

HTTP – HyperText Transfer Protocol, application‑layer protocol for web communication.

DHCP – Dynamic Host Configuration Protocol, provides automatic IP configuration.

NAT – Network Address Translation, converts private addresses to public IPs.

5. End‑to‑End Process When Accessing www.baidu.com

Browser resolves the domain via DNS to IP 220.181.27.48 and initiates an HTTP request.

Transport layer creates TCP segments, using a random source port (e.g., 5000) and destination port 80.

Network layer routes the packets through routers based on the routing table.

Link layer obtains the destination MAC address via ARP, then sends the frames to the router.

6. TCP vs. UDP Differences

TCP: connection‑oriented, reliable, stream‑based, uses segments.

UDP: connection‑less, unreliable, datagram‑based, uses user datagrams.

TCP ensures data integrity and ordering; UDP offers lower latency.

7. Protocols Using TCP and UDP

TCP‑based: FTP (port 21), Telnet (23), SMTP (25), POP3 (110), HTTP (80).

UDP‑based: DNS (53), SNMP (161), TFTP (69).

8. DNS Working Principle

A DNS client queries a DNS server to resolve a hostname to an IP address. Queries contain the domain name, query type, and class, and are sent over UDP port 53. The resolved IP is then used by applications such as HTTP or SMTP.

9. Why TCP Requires a Three‑Way Handshake

The three‑step process prevents old duplicate connection requests from being accepted, ensuring both sides agree on sequence numbers before data transfer. A two‑way handshake cannot guarantee this safety, leading to potential resource waste.

10. Common Port Numbers and Their Services

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 ProtocolsTCP handshakeOSI modelIP addressing
Java Backend Technology
Written by

Java Backend Technology

Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!

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.