CN/Lesson 1 of 8/6 min read
Introduction to Computer Networks
Network types, topologies, transmission modes, circuit vs packet switching, performance metrics, the OSI model, the TCP/IP model, and encapsulation.
On this page
Computer Network
A computer network is a set of devices (nodes) connected by links to share data and resources. Key elements: nodes (hosts, routers, switches), links (wired or wireless media) and protocols (rules for communication).
Protocol
A protocol defines the format, order and meaning of messages exchanged, and the actions taken on sending or receiving them. Elements: syntax (format), semantics (meaning), timing (when and how fast).
Types of networks
| Type | Range | Example |
|---|---|---|
| PAN | A few meters | Bluetooth headset |
| LAN | Building or campus | Office Ethernet, home Wi-Fi |
| MAN | City | Cable TV network, city Wi-Fi |
| WAN | Country or global | The internet, MPLS links between offices |
LAN
A Local Area Network is privately owned, high speed and low error rate, usually Ethernet or Wi-Fi.
WAN
A Wide Area Network spans large distances, often using leased lines from telecom providers; slower and more expensive per bit than a LAN. The internet is a network of networks.
Network Topology
The physical or logical layout of nodes:
| Topology | Description | Pros | Cons |
|---|---|---|---|
| Bus | All nodes on one cable | Cheap, simple | Cable failure kills all, collisions |
| Star | All nodes to a central switch | Easy to manage, one failure isolated | Central device is a single point of failure |
| Ring | Each node connected to two neighbors in a loop | Ordered access (token) | One break can stop the ring |
| Mesh | Every node connected to many others | Highly reliable, redundant paths | Expensive: full mesh needs n(n-1)/2 links |
| Tree | Hierarchy of stars | Scalable | Root failure affects branches |
| Hybrid | Mix | Flexible | Complex |
Transmission modes
- Simplex: one direction only (keyboard to computer, TV broadcast).
- Half-duplex: both directions, one at a time (walkie-talkie, classic hubs).
- Full-duplex: both directions at once (telephone, modern switched Ethernet).
Delivery types: unicast (one to one), broadcast (one to all), multicast (one to a group), anycast (one to the nearest of a group, used by DNS root servers and CDNs).
Circuit Switching
A dedicated path is reserved for the whole conversation (classic telephone network).
- Guaranteed bandwidth, constant delay.
- Wasteful when idle; setup time before sending.
Packet Switching
Data is split into packets, each routed independently and stored-and-forwarded by routers (the internet).
- Efficient sharing of links (statistical multiplexing), robust to failures.
- Variable delay, packets can be lost or arrive out of order (higher layers fix this).
Virtual circuit packet switching (ATM, MPLS) sets up a path first, then all packets follow it. Datagram switching (IP) routes each packet independently.
Performance metrics
Bandwidth
Bandwidth is the maximum data rate of a link, in bits per second (bps). Capacity of the pipe.
Throughput
Throughput is the actual rate achieved, always less than or equal to bandwidth (limited by the bottleneck link, congestion, protocol overhead).
Latency
Latency (delay) is the time for a bit to travel from source to destination. Total delay per hop:
delay = transmission + propagation + queuing + processing
transmission delay = packet size / bandwidth (time to push bits onto the link)
propagation delay = distance / signal speed (~2 x 10^8 m/s in fiber)Example: a 1500 byte packet on a 100 Mbps link: 12000 / 10^8 = 0.12 ms transmission. Across 3000 km of fiber: 3 x 10^6 / 2 x 10^8 = 15 ms propagation.
- Round Trip Time (RTT): time for a message to go and the reply to return.
- Bandwidth-delay product = bandwidth x RTT: the amount of data "in flight" needed to fill the pipe. Important for TCP window sizing.
- Jitter: variation in delay; bad for voice and video.
OSI Model
The OSI (Open Systems Interconnection) model is a 7-layer reference model by ISO. Each layer serves the layer above and uses the layer below.
| # | Layer | Function | PDU | Examples | Devices |
|---|---|---|---|---|---|
| 7 | Application | Network services for apps | Data | HTTP, DNS, SMTP, FTP | |
| 6 | Presentation | Format, encryption, compression | Data | TLS, JPEG, ASCII, JSON | |
| 5 | Session | Establish, manage, end sessions | Data | RPC, NetBIOS, session checkpoints | |
| 4 | Transport | End-to-end delivery, ports, reliability | Segment / Datagram | TCP, UDP | |
| 3 | Network | Logical addressing, routing | Packet | IP, ICMP, OSPF | Router |
| 2 | Data Link | Framing, MAC addressing, error detection | Frame | Ethernet, Wi-Fi, PPP, ARP | Switch, bridge |
| 1 | Physical | Bits on the medium | Bit | Cables, voltages, radio | Hub, repeater |
Mnemonic (top down): All People Seem To Need Data Processing. Bottom up: Please Do Not Throw Sausage Pizza Away.
TCP/IP Model
The TCP/IP model is the practical model the internet is built on.
| TCP/IP layer | OSI layers | Protocols |
|---|---|---|
| Application | Application, Presentation, Session | HTTP, DNS, SMTP, SSH, TLS |
| Transport | Transport | TCP, UDP, QUIC |
| Internet | Network | IP, ICMP, IGMP |
| Network Access (Link) | Data Link, Physical | Ethernet, Wi-Fi |
Some books use 5 layers (splitting Link into Data Link and Physical).
OSI vs TCP/IP
| OSI | TCP/IP |
|---|---|
| Theoretical reference model | Practical, implemented model |
| 7 layers | 4 (or 5) layers |
| Model came before protocols | Protocols came first, model described them |
| Strict separation of service, interface, protocol | Less strict |
Encapsulation
As data goes down the stack, each layer adds its own header (and the data link layer a trailer). This is encapsulation. The receiver strips headers going up (decapsulation).
Application: [ HTTP data ]
Transport: [TCP hdr][ HTTP data ] = segment
Network: [IP hdr][TCP hdr][ HTTP data ] = packet
Data Link: [Eth hdr][IP hdr][TCP hdr][ HTTP data ][FCS] = frame
Physical: 0101010111010... = bitsPDU
The Protocol Data Unit is the name of the data unit at each layer: data, segment (TCP) or datagram (UDP), packet, frame, bits.
Each router only processes up to layer 3; a switch up to layer 2. Hosts process all layers.
Quick revision
- LAN small and fast, WAN large; internet is packet switched.
- Delay = transmission + propagation + queuing + processing.
- OSI 7 layers; TCP/IP 4 layers.
- PDUs: segment (L4), packet (L3), frame (L2), bit (L1).
- Router = L3, switch = L2, hub = L1.