Mastering Computer Network Architecture: From OSI to TCP/IP and Beyond
An in‑depth guide to computer network architecture covers layered models, the OSI reference model versus TCP/IP, protocol functions from the physical to application layer, TCP three‑way handshake and four‑way termination, HTTP basics, encryption methods, and common interview questions for network engineers.
Computer Network Architecture
Network architecture is based on a layered model that simplifies design, improves flexibility, and promotes standardization. A protocol defines the rules for data exchange.
Why Layer Protocols?
Simplify problem complexity by dividing it into smaller, independent layers.
Provide flexibility; changes in one layer do not affect others as long as interfaces remain unchanged.
Ease implementation and maintenance.
Facilitate standardization by describing each layer’s function separately.
Layering also introduces overhead because some functions may appear in multiple layers.
The ISO introduced the OSI seven‑layer model in 1977. Although OSI is comprehensive, it is complex and rarely used in practice. The TCP/IP four‑layer model (application, transport, internet, network interface) is widely adopted. Many textbooks combine the advantages of both models into a five‑layer scheme.
Layer Relationships
TCP/IP four‑layer: application, transport, internet, network interface.
Five‑layer: application, transport, network, data‑link, physical.
OSI seven‑layer: application, presentation, session, transport, network, data‑link, physical.
TCP/IP Protocol Suite
Application Layer
The application layer defines protocols that enable processes to communicate, such as DNS, HTTP, HTTPS, SMTP, FTP, POP3, and TELNET.
Transport Layer
The transport layer provides data‑transfer services to host processes.
TCP – connection‑oriented, reliable transmission with flow and congestion control.
UDP – connection‑less, best‑effort transmission without reliability guarantees.
UDP: no connection, unreliable, supports one‑to‑one, one‑to‑many, many‑to‑one, many‑to‑many.
TCP: connection‑oriented, reliable, uses flow and congestion control, one‑to‑one.
Application‑layer protocols typically run over either TCP or UDP: HTTP – standard web traffic (TCP). HTTPS – HTTP over SSL/TLS (TCP). FTP – file transfer (TCP). SMTP – email sending (TCP). POP3 – email retrieval (TCP). TELNET – remote terminal (TCP). SSH – secure remote login (TCP). BOOTP – boot protocol (UDP). NTP – network time (UDP). DHCP – dynamic IP allocation (UDP). DNS – domain name resolution (TCP/UDP).
Network Layer
The network layer selects routes and forwards packets. In TCP/IP it is implemented by the IP protocol, producing IP datagrams.
Data‑Link Layer
The data‑link layer frames packets for transmission over a physical link and adds control information such as addresses and error checking.
Physical Layer
The physical layer transmits raw bits over the medium, abstracting away the specific hardware.
TCP Three‑Way Handshake and Four‑Way Termination
TCP establishes a reliable connection using a three‑step handshake and closes it with a four‑step termination.
TCP Header Fields
Sequence number (32 bits) – identifies the byte stream.
Acknowledgment number – valid when ACK flag is set; ack = seq + 1.
Flags – URG, ACK, PSH, RST, SYN, FIN, each with specific meaning.
Three‑Way Handshake
Client sends SYN with initial sequence number.
Server replies with SYN + ACK, its own sequence number, and acknowledges the client’s number.
Client sends ACK acknowledging the server’s sequence number; the connection is established.
Four‑Way Termination
Client sends FIN after sending all data.
Server acknowledges with ACK.
Server sends its own FIN after completing pending data.
Client acknowledges with ACK and, after waiting 2 MSL, releases the connection.
Common Interview Questions
Why does TCP require three handshakes? To handle possible packet loss during connection establishment.
Why does connection termination need four steps? Both sides must finish sending data before the link can be closed.
Why wait 2 MSL after the final ACK? To ensure the last ACK is not lost.
How does TCP detect a dead client? Keep‑alive timers probe the client; after repeated failures the server closes the connection.
HTTP vs HTTPS
Protocol: HTTP runs plain‑text over TCP; HTTPS runs over SSL/TLS.
Port: 80 vs 443.
Resource consumption: HTTPS requires more CPU and memory for encryption.
Security: HTTPS provides encryption and authentication, HTTP does not.
HTTP Status Codes
1xx – informational.
2xx – success (e.g., 200 OK, 204 No Content, 206 Partial Content).
3xx – redirection (e.g., 301 Moved Permanently, 302 Found, 303 See Other, 304 Not Modified, 307 Temporary Redirect).
4xx – client error (e.g., 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found).
5xx – server error (e.g., 500 Internal Server Error, 501 Not Implemented, 503 Service Unavailable).
GET vs POST
GET appends data to the URL, is limited in length, and is less secure.
POST sends data in the request body, has no size limit, and is more suitable for sensitive information.
GET typically results in one TCP segment; POST may involve two segments (header and body).
Symmetric vs Asymmetric Encryption
Symmetric encryption uses the same key for encryption and decryption, but key distribution is a challenge. Asymmetric encryption uses a public‑key/private‑key pair, eliminating the need to share secret keys but being slower.
HTTP/2
HTTP/2 introduces multiplexing, allowing multiple requests to share a single TCP connection, which reduces head‑of‑line blocking and improves page performance.
Session, Cookie, and Token
Cookie stores small key‑value data on the client; vulnerable to theft.
Session stores data on the server, identified by a session ID passed via cookie.
Token (e.g., JWT) is a self‑contained string returned after authentication; the client includes it in subsequent requests, reducing server load.
Tokens are better suited for stateless, front‑end/back‑end separated architectures.
Servlet Thread Safety and Lifecycle
Servlets are not thread‑safe by default; shared instance variables can cause race conditions. Define variables inside doGet/doPost or use synchronization carefully.
Servlet interface defines five methods: init, service, destroy, getServletInfo, getServletConfig. The lifecycle consists of initialization (init), request handling (service → doGet/doPost), and destruction (destroy).
If cookies are disabled, session IDs can be passed via URL rewriting or hidden form fields.
Original source: https://thinkwon.blog.csdn.net/article/details/104903925
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.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
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.
