Network Devices
By the end of this lesson you will be able to say what each common network device does, choose the right one for a job, and count collision and broadcast domains, a classic exam and CCNA question.
The box your ISP installed at home is often called a "router", but it is really four or five devices packed into one case. Once you know each device on its own, the box makes sense.
The network interface card
Every device that joins a network needs a NIC (network interface card). It is the part that turns data into signals on a cable or radio, and back again. In a laptop the NIC is a small chip for Wi-Fi and sometimes another for Ethernet. Each NIC has a hardware address called a MAC address, which you will study in Ethernet, Frames & MAC Addresses.
Repeaters and hubs
A repeater receives a weak signal, cleans it up and sends it on at full strength. It lets a cable run go further. It does not understand data at all; it only boosts signals.
A hub is a repeater with many ports. Whatever arrives on one port is copied out of every other port. Think of a loudspeaker announcement at a railway station: everyone hears it, even though it is meant for one passenger.
Because all devices on a hub share the same wire, two devices sending at once cause a collision, and both messages are spoiled. Hubs are obsolete today, but they still appear in exam questions.
Switches
A switch also has many ports, but it is smarter. It reads the destination MAC address of each frame and sends the frame only out of the port where that device lives. It learns which device is on which port by watching traffic.
Think of the office peon who knows every desk in the building. A letter for Meera goes to Meera's desk only, not to all 40 desks.
Let us compare a hub and a switch with the same four computers.
ports = {1: "Aarav", 2: "Priya", 3: "Kabir", 4: "Meera"}
def hub(in_port, to):
return [p for p in ports if p != in_port]
def switch(in_port, to):
for port, name in ports.items():
if name == to:
return [port]
return [p for p in ports if p != in_port] # unknown: flood
print("Hub, Aarav -> Kabir, sent out of ports:", hub(1, "Kabir"))
print("Switch, Aarav -> Kabir, sent out of ports:", switch(1, "Kabir"))
print("Switch, Aarav -> Rohan (unknown):", switch(1, "Rohan"))Hub, Aarav -> Kabir, sent out of ports: [2, 3, 4] Switch, Aarav -> Kabir, sent out of ports: [3] Switch, Aarav -> Rohan (unknown): [2, 3, 4]
Notice the last line. When a switch does not yet know where a device is, it floods the frame out of all other ports, just like a hub. Once it learns, it sends to one port only. You will build a learning switch in Switching & ARP.
A bridge is the older two-port version of a switch. A switch is often called a "multiport bridge".
Routers
A switch joins devices inside one network. A router joins different networks. It reads the destination IP address of each packet and decides which network to send it to next. This decision is called routing.
Think of a post office. Letters inside the building are handled by the peon (the switch). Letters for another city go to the post office, which sends them towards that city's PIN code (the router).
Your home router joins your home network to your ISP's network. Big routers inside ISPs join thousands of networks together.
Access points, modems and ONTs
- An access point (AP) connects wireless devices to a wired network. It is like a switch port that talks by radio.
- A modem (modulator-demodulator) converts digital data into the kind of signal a line can carry, such as a telephone line (DSL) or a cable TV line.
- An ONT (optical network terminal) does a similar job for fibre-to-the-home connections, turning light into Ethernet signals.
The home "router" is really many devices
| Inside the box | Job |
|---|---|
| ONT or modem | Talks to the ISP's line (fibre, DSL or cable) |
| Router | Moves packets between your home network and the ISP |
| Switch | The 2 to 4 Ethernet ports at the back |
| Access point | The Wi-Fi radio |
| DHCP server | Gives each device an IP address automatically |
| Firewall and NAT | Blocks unwanted incoming traffic and shares one public address |
Which layer does each device work at?
You will learn the layers in The OSI Model. For now, remember this table; it is asked very often.
| Device | Layer | Looks at | Decides |
|---|---|---|---|
| Repeater, hub | 1 (Physical) | Signals only | Nothing: repeats everything |
| Bridge, switch | 2 (Data link) | MAC addresses | Which port to send the frame to |
| Router | 3 (Network) | IP addresses | Which network to send the packet to |
| Layer 3 switch | 2 and 3 | MAC and IP | Switches and routes at high speed |
| Firewall | 3, 4 and above | Addresses, ports, sometimes content | Allow or block |
Collision and broadcast domains
These two terms come up in GATE and CCNA questions, so let us make them concrete.
- A collision domain is a group of devices whose frames can collide with each other. Every port of a switch or router is its own collision domain. All ports of a hub are one collision domain together.
- A broadcast domain is a group of devices that all receive a broadcast (a message sent to everyone). A switch passes broadcasts to all its ports, so it does not split broadcast domains. A router does not forward broadcasts, so every router interface is its own broadcast domain.
Here is the counting rule as a small program. Step 1: list the links. Step 2: count collision domains. Step 3: count broadcast domains.
# A router with 2 interfaces.
# Interface 1 -> a switch with 6 PCs.
# Interface 2 -> a hub with 4 PCs.
switch_pcs = 6
hub_pcs = 4
collision = 0
collision += switch_pcs # each switch port to a PC is separate
collision += 1 # the switch-to-router link
collision += 1 # the whole hub plus its link to the router
broadcast = 2 # one per router interface
print("Collision domains:", collision)
print("Broadcast domains:", broadcast)Collision domains: 8 Broadcast domains: 2
The hub and everything on it share one collision domain, however many PCs it has. The switch gives each PC its own. The router splits the network into two broadcast domains.
Common mistakes
- Saying a switch uses IP addresses. A normal (layer 2) switch uses MAC addresses. Routers use IP addresses.
- Thinking a router forwards broadcasts. It does not. That is how it limits broadcast traffic.
- Calling every home box a modem. The box usually contains a modem or ONT, a router, a switch and an access point together.
- Forgetting that a switch floods unknown destinations. Until it learns a MAC address, it behaves like a hub for that frame.
Key points
- A NIC connects a device to a network and has a MAC address.
- A hub repeats every signal to every port; it is obsolete and causes collisions.
- A switch forwards frames by MAC address to the right port only, after learning.
- A router forwards packets between networks using IP addresses.
- Access points connect Wi-Fi devices; modems and ONTs connect to the ISP's line.
- Each switch port is its own collision domain; each router interface is its own broadcast domain.
Exercise
A router has 3 interfaces. Interface 1 connects to a switch with 10 PCs. Interface 2 connects to a hub with 5 PCs. Interface 3 connects directly to a server. Write Python that prints the number of collision domains and broadcast domains, with one comment per line explaining each count.
Show solution
collision = 0
collision += 10 # switch ports to 10 PCs
collision += 1 # switch to router link
collision += 1 # hub, its 5 PCs and its router link: one domain
collision += 1 # router to server link
broadcast = 3 # one per router interface
print("Collision domains:", collision)
print("Broadcast domains:", broadcast)Collision domains: 13 Broadcast domains: 3
Every switch port and every router link is a separate collision domain, but the hub counts once. Three router interfaces give three broadcast domains.
Quick Quiz
1. Which device sends an incoming frame out of every other port, always?
A hub is a multiport repeater; it has no idea where devices are.
2. What does a router use to make forwarding decisions?
Routers work at layer 3 and forward packets by destination IP address.
3. A switch with 8 connected PCs and no router forms how many broadcast domains?
A switch forwards broadcasts to all ports, so all 8 PCs are in one broadcast domain.
4. What does a switch do with a frame for a MAC address it has not learned yet?
Unknown destinations are flooded until the switch learns the right port.
Learn Computer Networks with a mentor
Free lessons get you started. Our Computer Science Fundamentals training adds real projects and code reviews from working developers.
- Project-based learning
- Mentor code reviews
- Free counselling call
