What is a Computer Network?
Understand computer networking, packets, OSI 7-layer model, and TCP/IP protocol suite for modern software developers.
Overview
A Computer Network is a collection of interconnected computing devices (nodes) that communicate and exchange data using standardized protocols.
How Data Moves: Packets
Information transferred across the internet is not sent as one continuous stream. Large payloads (files, images, web pages) are sliced into smaller units called Packets. Each packet contains:
- Header: Metadata including Source IP, Destination IP, sequence number, and protocol type.
- Payload: The actual application data slice.
- Trailer / Checksum: Error detection bits to verify data was not corrupted in transit.
The OSI 7-Layer Model vs TCP/IP Model
The OSI Model describes network communication across 7 conceptual layers, while the practical TCP/IP Model condenses this into 4 functional layers:
| Layer # | OSI Layer Name | TCP/IP Layer | Primary Role | Key Protocols / Examples |
|---|---|---|---|---|
| 7 | Application | Application | High-level user & app protocols | HTTP, HTTPS, SSH, DNS, WebSockets |
| 6 | Presentation | Data formatting, TLS encryption | JSON, TLS/SSL, Gzip, UTF-8 | |
| 5 | Session | Manages persistent connections | Sockets, RPC sessions | |
| 4 | Transport | Transport | End-to-end reliability & ports | TCP, UDP, QUIC |
| 3 | Network | Internet | Routing packets between hosts | IP (IPv4/IPv6), ICMP, BGP |
| 2 | Data Link | Network Access | Physical frame delivery on local link | Ethernet, Wi-Fi (802.11), MAC addresses |
| 1 | Physical | Raw bit transmission over cables/radio | Fiber optics, copper cables, radio signals |
Encapsulation & Decapsulation
When a developer calls fetch("https://api.example.com"):
- Application Layer: Generates the HTTP request string.
- Transport Layer: Wraps HTTP string into TCP segments with source and destination ports.
- Network Layer: Wraps TCP segment into IP packets with source and destination IP addresses.
- Data Link Layer: Wraps IP packet into Ethernet frames with MAC addresses.
- Physical Layer: Converts frames into electrical voltages or light pulses over wire.
Upon reaching the server, the reverse process (Decapsulation) extracts the payload back up to the web server.
Shell Exit Codes & Error Propagation
Understand process exit statuses ($?), exit 0 vs non-zero errors, logical chaining (&&, ||), and standard POSIX exit conventions.
LAN, WAN, Routers & Gateways
Understand Local Area Networks (LAN), Wide Area Networks (WAN), the role of routers, switches, and default gateways.