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
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:
- reads the MAC address of the computer the message is for;
- looks that address up in its table to find the port;
- 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.
Send a message and watch which computers receive it. Only one does.
| MAC address of the card | Computer | Port |
|---|---|---|
| 00:1A:2B:3C:4D:0A | PC A | 1 |
| 00:1A:2B:3C:4D:0B | PC B | 2 |
| 00:1A:2B:3C:4D:0C | PC C | 3 |
| 00:1A:2B:3C:4D:0D | PC D | 4 |
3Why a switch is better than a hub
A message uses only the two cables it needs. The rest of the network is free for other messages.
A→B and C→D can happen at the same time without colliding.
Other computers never receive a message that is not for them.
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.
| Hub | Switch | |
|---|---|---|
| Sends a message to | Every port (broadcast) | Only the addressee's port (unicast) |
| Intelligent? | No | Yes — keeps a table of MAC addresses |
| Two messages at once | Collide | Both get through |
| Damaged data | Passed on to everyone | Dropped |
| Traffic | High — every cable carries every message | Low — only the cables needed |
| Privacy | Every computer receives everything | Only the addressee receives it |
| Cost | Cheaper | Costs a little more |
5Check yourself
What does a switch use to decide which port to send a message out of?
Which statement about hubs and switches is correct?
PC A sends a message to PC C through a switch with four computers. Which computers receive it?