Computer Networks Basics: Types, Topologies, Devices

Computer networks from the ground up: LAN, MAN and WAN, network topologies, hubs, switches and routers, circuit vs packet switching, and delays worked out.

What is a computer network?

A computer network is a set of devices connected by communication links so they can exchange data and share resources such as files, printers and an internet connection. Networks are classed by the area they cover (PAN, LAN, MAN, WAN), by topology (bus, star, ring, mesh, tree) and by how they move data (circuit or packet switching). The internet is a network of networks.

A computer network is two or more devices joined by links so they can exchange data. Networks exist so that resources can be shared (one printer, one internet connection, one database for a whole office), so that people can communicate (email, video calls) and so that a service can keep running when one machine fails. Everything else in this subject, from the OSI model to TCP's handshake, is a detailed answer to one question: how does a stream of bits get from one program to another program on a different machine, correctly and quickly?

What a network is made of

Every network, from two laptops on a Wi-Fi hotspot to the internet, has the same four ingredients:

  • Nodes. End devices (hosts) that create or consume data, such as laptops, phones and servers, and intermediate devices that pass data along, such as switches and routers.
  • Links (transmission media). Wired media are twisted-pair copper (Ethernet cables), coaxial cable and optical fibre. Wireless media are radio (Wi-Fi, Bluetooth, cellular), microwave and satellite.
  • Protocols. Agreed rules for the format and order of messages and the actions taken on them. IP, TCP and HTTP are protocols. Two devices can only talk if they follow the same ones.
  • Services. What the network offers the programs above it: delivering a web page, a file transfer or a DNS lookup.

Links also differ in direction, called the transmission mode:

ModeDirectionExample
SimplexOne way onlyKeyboard to computer, TV broadcast
Half-duplexBoth ways, one at a timeWalkie-talkie, classic Wi-Fi channel
Full-duplexBoth ways at onceTelephone call, switched Ethernet

Types of networks by size

Networks are named by the area they cover. The distances are typical, not hard limits.

TypeFull nameTypical spanTypical technologyExample
PANPersonal area networkA few metresBluetooth, USBPhone paired with a smartwatch
LANLocal area networkA room to a campusEthernet, Wi-FiCollege lab, office floor
MANMetropolitan area networkA cityFibre rings, metro EthernetCable operator's city network
WANWide area networkCountries, continentsLeased lines, MPLS, the internetA bank linking all its branches

A LAN is usually owned by one organisation and runs at high speed with low delay. A WAN is usually built from links rented from telecom carriers, and it is slower and costlier per bit. The internet is not one network: it is tens of thousands of independently run networks joined by routers and the BGP routing protocol.

Network topologies

Topology is the layout of the links: who is connected to whom.

BusABCDE1 shared cable, 1 port eachStarSWABCDE5 links, switch has 5 portsRingABCDE5 links, 2 ports eachFull meshABCDE5×4/2 = 10 links, 4 ports each
Five devices wired four ways. The same 5 devices as a bus, a star, a ring and a full mesh. The bus shares one cable, the star gives each device its own link to a switch, the ring passes data one way round, and the mesh links every pair: 10 links for 5 devices.
TopologyLayoutAdvantagesDisadvantages
BusEvery device taps one shared cable (backbone) with terminators at both endsCheap, little cableA break in the backbone stops everything; collisions grow with devices; hard to troubleshoot
StarEvery device has its own link to a central hub or switchEasy to add devices; one bad cable affects one device; easy to manageThe centre is a single point of failure; more cable than a bus
RingEach device connects to the next, forming a closed loop; data travels in one direction, often with a tokenOrderly access, no collisions with token passingOne break stops the ring (unless it is a dual ring); adding a device disturbs the ring
MeshDevices connect directly to many (partial) or all (full) other devicesVery reliable, many paths; no shared linkExpensive: many links and ports
TreeA hierarchy of stars connected to a rootScales well, easy to segmentA failure near the root cuts off whole branches
HybridAny mix of the aboveFits real buildingsDesign and management are more complex

Full mesh arithmetic. Every pair has its own link, so n devices need n(n − 1)/2 links and n − 1 ports each. Ten devices already need 45 links, which is why full mesh is kept for places where reliability justifies the cost, such as between core routers.

Network devices and the layer they work at

The layer numbers refer to the OSI model, covered in the next note.

DeviceOSI layerWhat it does
Repeater1, PhysicalRegenerates a weakened signal so it can travel further
Hub1, PhysicalA multiport repeater: copies every incoming signal to every other port
Modem1, PhysicalModulates digital data onto an analogue carrier and demodulates it back (DSL, cable)
Bridge2, Data linkJoins two LAN segments and forwards a frame only if its destination MAC address is on the other side
Switch2, Data linkA multiport bridge: learns which MAC address is on which port and forwards each frame only there
Access point2, Data linkConnects wireless devices to a wired LAN
Router3, NetworkForwards packets between different networks using IP addresses and a routing table
GatewayAny, often up to 7Connects networks that use different protocols and translates between them

Two clarifications interviewers check. A layer 3 switch also routes between VLANs, so "switch = layer 2" is the textbook default, not a law. And in everyday use, the default gateway on your laptop simply means the router that leads out of your network.

Hub vs switch vs router: collision and broadcast domains

A collision domain is the part of a network where two simultaneous transmissions collide. A broadcast domain is the set of devices that receive a broadcast frame.

DeviceCollision domainsBroadcast domains
8-port hub1 (all ports share it)1
24-port switch24 (one per port)1 (unless VLANs split it)
Router with 3 interfaces33 (routers do not forward broadcasts)

So switches break up collision domains and routers break up broadcast domains.

broadcast domain 1broadcast domain 2RouterSwitchHubH1H2H3H4H5H6broadcast domains: 2
Collision and broadcast domains around a router.
  1. Each of the switch's 4 ports is its own collision domain, so H1, H2 and H3 never collide. The hub repeats every signal out of every port, so its 4 links are one domain, 5 in all.
  2. A broadcast from H1 is forwarded by the switch to every port but stops at the router, and the hub side is the same: 2 broadcast domains, one per router interface.

Circuit switching vs packet switching

Circuit switching sets up a dedicated path with reserved capacity before any data flows, keeps it for the whole conversation and then tears it down. The classic telephone network works this way. Packet switching splits data into packets, each carrying the destination address; every router stores a packet, looks at the address and forwards it (store and forward). Packets from many users share every link. The internet works this way. (A third, older scheme, message switching, stores and forwards whole messages.)

Circuit switchingAswitchBsetupmessagedone at 6Packet switchingArouterB112233done at 50123456time
The same message by circuit and by packets. The circuit spends 2 units reserving the path, then the bits stream through the switch without stopping and the last arrives at 6. Packets start at once, but the router must hold each whole packet before sending it on; the last arrives at 5.
AspectCircuit switchingPacket switching
PathDedicated, set up before data flowsNo reservation; each packet forwarded on its own
Setup phaseNeeded (call setup)Not needed for datagrams
Capacity useReserved even when idleShared on demand, efficient for bursty traffic
DelayConstant once connectedVariable, because of queuing at routers
Order of arrivalAlways in orderPackets may arrive out of order
On link failureThe call dropsPackets can be rerouted
ExampleTraditional telephone callsThe internet (IP)

Bandwidth, latency and throughput

  • Bandwidth is a link's capacity in bits per second (bps). A "100 Mbps" link can carry at most 100 million bits each second.
  • Latency is the time a message takes to get from source to destination. The round-trip time (RTT) is the time to go there and back.
  • Throughput is the rate actually achieved end to end. It is limited by the slowest link on the path (the bottleneck): a server on a 1 Gbps link sending to a phone on a 20 Mbps connection gets at most 20 Mbps.

The delay a packet sees at each hop has four parts:

DelayFormulaDepends on
TransmissionL / R (packet size in bits ÷ link rate)Packet size and bandwidth
Propagationd / s (distance ÷ signal speed)Distance and medium, not bandwidth
QueuingVariesHow busy the router's output link is
ProcessingUsually microsecondsRouter speed (header check, table lookup)

Signals travel at about 2 × 10^8 m/s in copper and fibre, roughly two-thirds of the speed of light in a vacuum.

Worked example: transmission and propagation delay

A host sends one 1,000-byte packet over a single 10 Mbps link that is 2,000 km long. Take the signal speed as 2 × 10^8 m/s and ignore queuing and processing.

StepWorkingResult
Packet size in bits1,000 × 8L = 8,000 bits
Transmission delay8,000 ÷ (10 × 10^6)0.0008 s = 0.8 ms
Propagation delay(2,000 × 10^3 m) ÷ (2 × 10^8 m/s)0.01 s = 10 ms
Total one-way delay0.8 ms + 10 ms10.8 ms
Bandwidth-delay product10^7 bps × 0.01 s100,000 bits = 12,500 bytes
1,000 km1,000 kmARB0 ms0.8 ms5.8 ms11.6 ms2 × 0.8 ms + 2 × 5 ms = 11.6 msthe router waits for the last bit before it sends
Transmission and propagation delay for one packet. Example: 1,000-byte packet, 10 Mbps link, 2,000 km
  1. Time runs down the page. Pushing 8,000 bits onto a 10 Mbps link takes 0.8 ms, the slab's thickness; each bit then needs 10 ms to cross 2,000 km, its slope. The last bit lands at 10.8 ms.
  2. Put a router halfway and the propagation adds up to the same 10 ms, but the router must receive all 8,000 bits before it sends the first one on, so the transmission time is paid twice: 11.6 ms.

The bandwidth-delay product is how many bits are "on the wire" at once: 12.5 packets of this size fit in the link before the first one arrives. Protocols that wait for an acknowledgement after every packet waste most of such a link, which is why TCP keeps a window of many packets in flight.

Now send a 1 MB file (8 × 10^6 bits) over the same link. Transmission delay becomes 8 × 10^6 ÷ 10^7 = 0.8 s, while propagation stays 10 ms, so the total is 0.81 s. Small messages are dominated by latency; big transfers are dominated by bandwidth. Doubling the bandwidth would halve the file's time but would not change the 10 ms propagation delay at all.

With a router halfway (two 10 Mbps links of 1,000 km), store and forward pays the transmission delay twice: 2 × 0.8 ms + 2 × 5 ms = 11.6 ms.

Common mistakes

  • Saying a switch sends frames to all ports: it floods only unknown or broadcast destinations; known MAC addresses go to one port.
  • Mixing up transmission delay (depends on packet size and bandwidth) with propagation delay (depends on distance and medium).
  • Writing that more bandwidth reduces latency for a small packet: it shrinks only the transmission part.
  • Calling the internet a WAN owned by someone: it is a network of independently run networks.
  • Giving full-mesh links as n(n − 1): each link joins two devices, so divide by 2.
  • Placing a router at layer 2 or a hub at layer 2: a hub is layer 1, a router is layer 3.

Interview questions

What is the difference between a hub and a switch? A hub is a layer 1 device that repeats every signal to every port, so all ports share one collision domain and the bandwidth. A switch is a layer 2 device that learns MAC addresses and forwards each frame only to the destination's port, giving each port its own collision domain and allowing full-duplex links.

How many collision and broadcast domains does a 24-port switch create? Twenty-four collision domains, one per port, and one broadcast domain, because a switch forwards broadcasts out of every port. Configuring VLANs splits the broadcast domain; only a router (or a layer 3 switch) forwards between them.

Why is the star topology preferred over the bus for LANs? In a star, each device has its own cable to the switch, so a faulty cable or device affects only that device and faults are easy to find. In a bus, one break in the shared backbone stops the whole network and every device competes for the same medium.

How many links does a full mesh of n devices need? n(n − 1)/2 links, with n − 1 ports on every device. Six devices need 15 links. The cost grows with the square of n, so full mesh is kept for small sets of critical nodes.

What is the difference between latency and bandwidth? Bandwidth is how many bits per second a link can carry; latency is how long a bit takes to arrive. A satellite link can have high bandwidth and high latency at the same time. For a small request, such as a DNS lookup, latency matters far more than bandwidth.

Does the internet use circuit switching or packet switching, and why? Packet switching. Data traffic is bursty, so sharing links among many users is far more efficient than reserving capacity per conversation, and packets can be rerouted around failures. The price is variable delay and occasional loss, which the transport layer handles.

What is a gateway, and how is it different from a router? A gateway connects networks that use different protocols and translates between them, and it can work at any layer up to the application layer. A router forwards packets between networks that all speak IP. In daily use, "default gateway" just means the router a host sends off-network traffic to.

What is the bandwidth-delay product and why does it matter? It is bandwidth multiplied by the one-way propagation delay: the number of bits in flight on the link. A sender must be allowed at least that much unacknowledged data (TCP's window) to keep the link busy; otherwise it sits idle waiting for acknowledgements.

Next, read the OSI model, and test yourself with the Computer Networks (Basic) skill test.

Common questions

What are the four types of computer network by size?

A PAN (personal area network) links devices around one person, such as a phone and earbuds over Bluetooth. A LAN covers a home, office or campus, a MAN covers a city, and a WAN spans countries or continents. The internet is the largest WAN.

Which network topology is most common today?

The star, in the form of switched Ethernet: every device has its own cable to a central switch. A failed cable affects only one device and devices are easy to add, though the switch itself is a single point of failure. Large networks connect several stars into a tree.

What is the difference between a hub, a switch and a router?

A hub works at the physical layer and repeats every incoming signal out of every port. A switch works at the data link layer and forwards a frame only to the port where the destination MAC address lives. A router works at the network layer and forwards packets between different networks using IP addresses.

What is the difference between bandwidth and throughput?

Bandwidth is the maximum rate a link can carry, such as 100 Mbps. Throughput is the rate actually achieved end to end, which is lower because of the slowest link on the path, congestion, protocol overhead and retransmissions.

Why does the internet use packet switching instead of circuit switching?

Computer traffic comes in bursts, so reserving a circuit for each conversation would leave most of the capacity idle. Packet switching lets many users share each link, and packets can be routed around a failed link. The cost is variable delay and possible loss, which protocols such as TCP handle.

Test yourself

← Computer Networks notes · The OSI Model →