All posts

Network Fundamentals: Switching and Routing — VLANs, STP, OSPF and BGP

Hubs, switches and routers, VLANs and trunks, Spanning Tree, static vs dynamic routing, TTL, MTU, copper and fibre.

Marijan Kopčić••2 min read
Network Fundamentals: Switching and Routing — VLANs, STP, OSPF and BGP

Switching moves frames inside a network, routing moves packets between networks. Most questions in this area come down to knowing which of the two you are looking at.

Hub, switch, router

  • Hub — repeats everything to every port. Layer 1.
  • Switch — forwards frames by MAC address, only to the port where the destination is. Layer 2.
  • Router — connects different networks and forwards packets by IP address. Layer 3.

VLANs and trunks

A VLAN splits one physical switch into several separate logical networks. An access port belongs to a single VLAN. A trunk is a link that carries several VLANs at once, with each frame tagged according to 802.1Q so the other side knows which VLAN it belongs to.

Spanning Tree

STP prevents loops at layer 2. Redundant links between switches would otherwise make broadcasts circle forever, so STP blocks the extra links and brings them back up when the main one fails.

Static and dynamic routing

Static routes are entered by an administrator. Dynamic routing protocols exchange routes on their own and react when a link goes down.

  • OSPF — a link-state protocol used inside one organisation's network. It picks the path with the lowest cost.
  • BGP — connects autonomous systems (AS), meaning networks of different organisations. It is the protocol that holds the internet together.

TTL and MTU

TTL is a counter that every router decreases by one. When it reaches zero, the packet is dropped — that protects the network from routing loops.

MTU is the largest packet size a link can carry. On Ethernet it is 1,500 bytes.

Copper and fibre

  • UTP copper (Cat5e, Cat6) reaches up to 100 metres.
  • Multimode fibre is for shorter distances, single-mode for long ones.
  • Optical modules are usually SFPs, and signal attenuation is measured in dB.

Keep reading