Fundamentals 23 min read

From Hubs to Routers: How Computers Connect Across Networks

This article explains the evolution from simple hubs to intelligent switches and routers, covering the OSI layers, LAN setup, MAC and IP addressing, ARP, crossover cabling, and the internal structures that enable reliable data transmission in modern networks.

NiuNiu MaTe
NiuNiu MaTe
NiuNiu MaTe
From Hubs to Routers: How Computers Connect Across Networks

What Is a Hub?

A hub (also called a hub ) is a physical‑layer device that gathers multiple Ethernet cables into a single central point, similar to a wheel hub that collects spokes.

In a LAN, a hub allows several computers to share one network segment, but it simply repeats incoming electrical signals to all ports.

LAN Basics

In a small net‑café, computers are linked into a Local Area Network (LAN) using a hub, enabling games like CS to be played together without Internet access.

Network Layering

Data travels through the OSI layers: the application layer (e.g., a game), the transport layer (TCP with source and destination ports), the network layer (IP addresses and subnet masks), the data‑link layer (MAC headers), and the physical layer (bits on a cable).

Application Layer

The application itself guarantees the required network functions, such as a game handling its own communication.

Transport Layer

Most games use TCP; the TCP header’s source and destination ports identify which process on each computer sends and receives data.

Network Layer

Each host has an IP address (e.g., 192.168.0.105) and a subnet mask (e.g., 255.255.255.0) that defines the LAN range.

Data‑Link Layer

Frames contain a MAC header with source and destination MAC addresses (e.g., 28:f9:d3:62:7d:31). If a host does not know the destination MAC, it uses ARP to resolve the IP to a MAC address.

Physical Layer

Bits are transmitted over a cable; for direct PC‑to‑PC connections a crossover cable is required (or auto‑MDI/MDIX capable NICs can use straight‑through cables).

Hub Internal Structure

Inside a hub, a PHY module converts the electrical signal from the cable into a generic format, which is then broadcast to all ports.

What Is a Switch?

A switch (or switch ) operates at the data‑link layer, maintains a MAC address table, and forwards frames only to the appropriate port, avoiding the broadcast behavior of a hub.

MAC Address Table

The switch learns which MAC address is attached to which port and updates the table dynamically; stale entries expire.

Special Cases

If the source and destination ports are the same, the switch discards the frame.

If the destination MAC is unknown, the switch floods the frame to all ports except the source (behaving like a hub).

Switch Internal Structure

Similar to a hub, a switch has a PHY module and a MAC module. The MAC module converts the signal to digital form, extracts the MAC header, checks the FCS, and stores the frame in a buffer before forwarding.

Switch vs. Bridge vs. Router

A bridge is essentially a two‑port switch. A layer‑2 switch (the common switch) works at the data‑link layer, while a layer‑3 switch or router works at the network layer, using IP addresses and routing tables.

What Is a Router?

A router operates at the network layer, forwarding packets based on IP addresses. It maintains a routing table that maps destination networks to outbound interfaces.

IP Addressing

IP addresses consist of a network part and a host part (e.g., 192.168.0.105/24 where the first 24 bits identify the network).

Routing Table

The router looks up the destination network in its routing table to decide which interface to send the packet out; if no match is found, it may drop the packet and send an ICMP error.

Router Internal Structure

Routers have a control plane (software) and a data plane (hardware). Incoming frames pass through a PHY, then a MAC module, are checked for FCS and addressed to the router itself, and finally the control plane selects the next hop based on the routing table.

Key Differences

Switches forward based on MAC addresses; routers forward based on IP addresses.

Switches broadcast when the destination MAC is unknown; routers drop unknown destinations and send ICMP messages.

Routers handle larger scale networks (the Internet), while switches are suited for LAN‑scale environments.

Router vs. Optical Network Unit (光猫)

An optical network unit (ONU) converts optical signals to electrical signals for the router; the router then processes the data and may convert it back to optical for upstream transmission.

Summary

Two PCs can communicate directly via a crossover cable.

Hubs connect many PCs but broadcast all traffic.

Switches learn MAC addresses and forward frames intelligently, eliminating unnecessary broadcasts.

Routers use IP subnets and routing tables to forward traffic across larger networks.

In typical home setups, a router often includes switch ports, making separate hubs unnecessary.

Routernetwork fundamentalsswitchLANhub
NiuNiu MaTe
Written by

NiuNiu MaTe

Joined Tencent (nicknamed "Goose Factory") through campus recruitment at a second‑tier university. Career path: Tencent → foreign firm → ByteDance → Tencent. Started as an interviewer at the foreign firm and hopes to help others.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.