LambdaLabTM
Computer Networks · Class 12 · Network Devices
networksdevices⏱️ 6 min read

Switch

A switch looks almost exactly like a hub: a box with a row of ports and blinking lights. The difference is inside. A switch remembers which computer is on which port — and that one idea fixes every problem a hub has.

1What a switch is

Switch
A switch is a network device that connects several computers in a LAN. It sends each message only out of the port that leads to the computer it is meant for.

Sending to exactly one computer is called unicast. Because a switch decides where each message goes, it is called an intelligent device.

2How a switch knows where to send

Remember that every network card (NIC) bears its own MAC address, and every message carries the MAC address of the card it is for. A switch keeps a MAC address table: a list of which MAC address is on which of its ports. When a message arrives, the switch:

  1. reads the MAC address of the computer the message is for;
  2. looks that address up in its table to find the port;
  3. sends the message out of that one port only.

The switch builds the table by itself: each time a computer sends something, the switch notes that computer’s MAC address against the port it arrived on. Send a few messages below and watch which row of the table it looks up.

Four computers on a switch

Send a message and watch which computers receive it. Only one does.

From
to
A switch knows which port each computer's MAC address is on (the table below). Pick who sends to whom, and send.
The switch’s MAC address table
MAC address of the cardComputerPort
00:1A:2B:3C:4D:0APC A1
00:1A:2B:3C:4D:0BPC B2
00:1A:2B:3C:4D:0CPC C3
00:1A:2B:3C:4D:0DPC D4

3Why a switch is better than a hub

🚀 Less traffic, more speed

A message uses only the two cables it needs. The rest of the network is free for other messages.

🔀 Many messages at once

A→B and C→D can happen at the same time without colliding.

🔒 More private

Other computers never receive a message that is not for them.

🩹 Drops damaged data

A switch checks each message and throws away one that arrived damaged, instead of passing it on. It then has to be sent again.

4Hub vs switch

Exam papers often ask for one similarity and one difference. Here are both.

The similarity
Both a hub and a switch connect several computers in one LAN, each computer on its own cable to a port. Both are the central device of a star topology.
HubSwitch
Sends a message toEvery port (broadcast)Only the addressee's port (unicast)
Intelligent?NoYes — keeps a table of MAC addresses
Two messages at onceCollideBoth get through
Damaged dataPassed on to everyoneDropped
TrafficHigh — every cable carries every messageLow — only the cables needed
PrivacyEvery computer receives everythingOnly the addressee receives it
CostCheaperCosts a little more

5Check yourself

Quick Check

What does a switch use to decide which port to send a message out of?

Quick Check

Which statement about hubs and switches is correct?

Quick Check

PC A sends a message to PC C through a switch with four computers. Which computers receive it?