Computer Networks
Computer Networks
Computer networks are the connective tissue of modern computing. They link laptops to printers, phones to cloud services, and companies to customers across the globe. At a practical level, a network is a set of devices that can exchange data using agreed rules called protocols. At a deeper level, networking is about managing trade-offs: reliability versus speed, simplicity versus flexibility, and openness versus security.
Understanding computer networks means understanding how architectures are layered, how addressing and routing work, and how common protocols like TCP, UDP, DNS, and HTTP fit together.
Network architectures and what they optimize
Most networks today follow a packet-switched model. Data is split into packets, each packet is forwarded independently, and the receiver reassembles the original message. Packet switching scales well and tolerates failures because traffic can take alternate paths.
Common architectures you will see in real deployments include:
- LANs (Local Area Networks): A home or office network, usually Ethernet and Wi-Fi, optimized for low latency and high throughput in a small area.
- WANs (Wide Area Networks): Networks spanning cities or countries, connecting LANs through service providers. WAN links often have higher latency and more constraints than LANs.
- Client-server: Clients request resources from servers (websites, email, databases). This is the dominant model for enterprise and internet services.
- Peer-to-peer: Devices act as both clients and servers, used in some file sharing systems and decentralized designs.
Increasingly, software-defined networking (SDN) and virtualization make the “network” partly a software construct. Still, the same fundamentals apply: frames and packets on the wire, addresses for identification, and routing for path selection.
Layering: OSI vs TCP/IP models
Layering is the key organizing idea in networking. Each layer provides services to the layer above and relies on the layer below. This makes complex systems manageable and allows components to evolve independently.
The OSI model (7 layers)
The OSI model is a conceptual framework:
- Physical: Electrical, optical, or radio signals (copper, fiber, Wi-Fi).
- Data Link: Local delivery, framing, MAC addressing (Ethernet, Wi-Fi).
- Network: End-to-end packet delivery across networks (IP).
- Transport: End-to-end communication between applications (TCP, UDP).
- Session: Managing sessions (less explicitly separated in the modern internet).
- Presentation: Data formats and encryption (often handled in application libraries, e.g., TLS).
- Application: Protocols used by user applications (HTTP, DNS, SMTP).
In real systems, the boundaries between session/presentation/application are often blurred.
The TCP/IP model (internet model)
The internet is typically described with four layers:
- Link: Ethernet/Wi-Fi and local delivery
- Internet: IP and routing across networks
- Transport: TCP and UDP
- Application: HTTP, DNS, and many others
The TCP/IP model matches how the internet is implemented and is the most useful for troubleshooting: you can usually ask, “Is it link, IP, transport, or application?”
The application, transport, and network layers in practice
A user action like loading a website touches multiple layers:
- Application layer: Browser uses HTTP to request a page.
- Transport layer: Usually TCP (or QUIC over UDP) handles delivery details.
- Network layer: IP moves packets between the client and the server across multiple routers.
Each layer adds its own headers. This encapsulation is why a single HTTP request can traverse Ethernet inside your home, then fiber in a provider backbone, and finally a data center network, all without HTTP needing to know the details.
TCP and UDP: choosing the right transport
The transport layer determines how applications talk across IP networks.
TCP (Transmission Control Protocol)
TCP is designed for reliable, ordered delivery. It provides:
- Connection establishment: A handshake creates shared state.
- Sequencing and acknowledgments: Ensures correct order and detects loss.
- Retransmission: Lost packets are resent.
- Flow control: Prevents overwhelming the receiver.
- Congestion control: Adjusts sending rate to avoid congesting the network.
TCP is the default for web browsing (HTTP/1.1 and HTTP/2), email, file transfer, and most business applications. The reliability comes with overhead and latency, especially noticeable on high-loss or high-latency links.
UDP (User Datagram Protocol)
UDP is connectionless and minimal. It provides:
- No guarantee of delivery or ordering
- Low overhead and low latency
- Message-oriented behavior that suits real-time traffic
UDP is widely used for voice/video streaming, online gaming, and DNS. Many modern protocols build reliability at the application layer on top of UDP. A major example is QUIC, which carries HTTP/3 and adds congestion control and encryption while avoiding some TCP limitations.
A practical rule: choose TCP when correctness and ordering matter more than raw responsiveness; choose UDP when timeliness matters and the application can tolerate or manage loss.
IP addressing: identity and reachability
IP addressing is how devices are located on a network.
IPv4 and IPv6
- IPv4: 32-bit addresses (for example, 192.0.2.10). Scarcity led to widespread NAT.
- IPv6: 128-bit addresses (for example, 2001:db8::1). Designed for ample address space and better end-to-end connectivity.
An IP address has two parts: a network prefix and a host identifier. Routers forward packets based mainly on the prefix, not the full address.
Subnets and CIDR
CIDR notation expresses prefix length, such as 192.0.2.0/24. A /24 means 24 bits are the network prefix, leaving 8 bits for hosts. Subnetting organizes networks for performance, security boundaries, and administrative control.
NAT and private addressing
NAT (Network Address Translation) allows many private devices to share one public IPv4 address. Private ranges include 10.0.0.0/8 and 192.168.0.0/16. NAT conserves IPv4 addresses but complicates inbound connectivity and can interfere with some protocols. IPv6 reduces the need for NAT, though firewalls still control exposure.
Routing: how packets find a path
Routing is how networks decide where to send packets next.
Routers, forwarding tables, and default gateways
A router maintains a forwarding table mapping destination prefixes to next hops. Your home router is typically your device’s default gateway, meaning “send anything not on the local subnet here.”
Routing uses the principle of longest prefix match: a route to 203.0.113.0/24 is preferred over 203.0.0.0/16 for destinations within that /24.
Routing protocols
Routing protocols automate how routers learn paths.
- OSPF (Open Shortest Path First): Common inside organizations. It is a link-state protocol that builds a map of the network and computes shortest paths.
- BGP (Border Gateway Protocol): The protocol of the internet between autonomous systems (ISPs, large networks). BGP is policy-driven and prioritizes control and scalability over “shortest” paths.
The distinction matters: OSPF typically optimizes internal efficiency; BGP reflects business relationships, traffic engineering, and resilience.
DNS: the internet’s naming system
Humans use names; networks route by IP addresses. DNS (Domain Name System) bridges that gap.
When you type a domain name, a resolver queries DNS to find records such as:
- A / AAAA: IP addresses for IPv4/IPv6
- CNAME: Aliases
- MX: Mail servers
DNS uses caching to reduce load and improve speed, controlled by TTL values. Because DNS is foundational, it is also a common target for attacks, and protections like DNSSEC and encrypted DNS transports (DoT/DoH) are often discussed in security planning.
HTTP: the web’s application protocol
HTTP (Hypertext Transfer Protocol) is the language of web applications.
- HTTP/1.1: Text-based, widely supported, but can suffer from head-of-line blocking in some scenarios.
- HTTP/2: Multiplexes multiple requests over one connection, improving performance.
- HTTP/3: Runs over QUIC (UDP), improving behavior on lossy networks and enabling faster connection setup in many cases.
Modern HTTP almost always runs over TLS, producing HTTPS. TLS provides confidentiality, integrity, and server authentication, which are essential for protecting user data and preventing interception.
Network security: protecting connectivity and data
Network security is not a single tool; it is a posture built from layers, just like the network itself.
Key practices include:
- Segmentation: Use subnets and VLANs to limit lateral movement.
- Firewalls and access control: Enforce which ports and protocols are allowed.
- Encryption in transit: TLS for applications; VPNs for private network access.
- Secure routing and monitoring: Detect anomalies, route leaks, and unexpected paths.
- Hygiene and patching: Many network breaches begin with exposed, unpatched services.
Security also involves operational discipline: clear asset inventories, logging, and incident response procedures.
Putting it all together
A working mental model of computer networks is layered: IP addressing identifies endpoints, routing finds paths, transport protocols define delivery behavior, and application protocols like DNS and HTTP enable real services. When something breaks, this structure guides diagnosis and design decisions. When performance matters, it