Hub, Switch, and Router — Explained Using a Game of Cricket

Hub, Switch, and Router — Explained Using a Game of Cricket

集线器、交换机与路由器——用板球比赛来解释

Networking terms can feel like alphabet soup when you’re starting out — Hub, Switch, Router, MAC address, IP address, Subnet Mask — thrown at you all at once, usually with zero real-world context. Here’s how I finally made sense of it, using something a lot more familiar: cricket. 对于初学者来说,网络术语就像一锅“字母乱炖”——集线器(Hub)、交换机(Switch)、路由器(Router)、MAC地址、IP地址、子网掩码——一股脑儿地向你砸来,通常还没什么实际背景。我是如何理解这些概念的呢?我用了一个大家更熟悉的东西:板球。

The Cricket Analogy

板球类比

Imagine a cricket team with three players: a hub, a switch, and a router. All three are part of the same game, but each has a completely different job — one’s a batsman, one’s a bowler, one’s a fielder. Networking devices work the same way: they’re all part of one network, but each does something distinct. 想象一支有三名队员的板球队:集线器、交换机和路由器。他们都参与同一场比赛,但每个人的职责完全不同——一个是击球手,一个是投球手,一个是外野手。网络设备也是如此:它们都属于同一个网络,但各自执行不同的任务。

Hub — The One Who Shouts to Everyone

集线器 (Hub) —— 对所有人大喊大叫的人

A hub is the simplest of the three. If only two devices need to talk, you don’t even need one — but the moment more than two devices are connected, a hub becomes necessary to relay traffic between them. Here’s the catch: a hub has no idea who’s talking to whom. If Device A wants to send data to Device B, it sends that data to the hub — and since the hub doesn’t know which device Device A actually wants to reach, it just broadcasts the data to every single connected device. So a hub’s “functionality” is really a lack of intelligence — it doesn’t figure out who wants to speak with whom; it just floods the message everywhere and lets the devices sort it out. 集线器是三者中最简单的。如果只有两台设备需要通信,你甚至不需要它——但一旦连接了超过两台设备,就需要集线器来中转流量。问题在于:集线器根本不知道谁在和谁说话。如果设备A想给设备B发送数据,它会把数据发给集线器——由于集线器不知道设备A到底想联系谁,它只会把数据广播给所有连接的设备。所以,集线器的“功能”其实就是缺乏智能——它不去判断谁想和谁通信,只是把消息到处泛洪,然后让设备自己去处理。

Switch — The One Who Knows Everyone by Name

交换机 (Switch) —— 叫得出每个人名字的人

A switch does the same basic job as a hub — moving data between connected devices — but with one major upgrade: it actually knows who’s who. Instead of blindly broadcasting to every device, a switch keeps a table of each connected device’s MAC address, so it can send data directly to the right recipient. 交换机执行的基本任务与集线器相同——在连接的设备之间移动数据——但有一个重大升级:它确实知道谁是谁。交换机不会盲目地向每个设备广播,而是维护一张连接设备的MAC地址表,因此它可以直接将数据发送给正确的接收者。

What Is a MAC Address?

什么是 MAC 地址?

Every device that connects to a network — a laptop, phone, router, anything — has a Network Interface Card (NIC). That NIC comes with a MAC address: a permanent ID burned in by the manufacturer. If your laptop has an Ethernet port, the NIC lives right behind it. If you’re connecting over Wi-Fi instead, the NIC is built into the Wi-Fi card. Either way, that hardware is what gives your device its MAC address. 每一台连接到网络的设备——笔记本电脑、手机、路由器等等——都有一个网络接口控制器(NIC)。该NIC带有一个MAC地址:这是由制造商烧录的永久ID。如果你的笔记本电脑有以太网端口,NIC就在它后面。如果你是通过Wi-Fi连接的,NIC则内置在Wi-Fi卡中。无论哪种方式,正是这些硬件赋予了你的设备MAC地址。

Router — The One Who Connects Networks Together

路由器 (Router) —— 连接不同网络的人

While hubs and switches move data within one network, a router’s job is to connect one network to another. The clearest everyday example: your router is what connects your home network to the wider internet. 集线器和交换机是在同一个网络内移动数据,而路由器的任务是将一个网络连接到另一个网络。最直观的日常例子是:你的路由器负责将你的家庭网络连接到更广阔的互联网。

Network Adapter and RJ45

网络适配器与 RJ45

Two more pieces worth knowing: 还有两个值得了解的部分:

  • Network Adapter (NIC): The hardware inside your device that lets it join a network at all — wired via Ethernet or wireless via Wi-Fi. Think of it as the bridge between your device and the network. Every NIC carries its own unique MAC address. 网络适配器 (NIC): 设备内部让你能够加入网络的硬件——通过以太网有线连接或通过Wi-Fi无线连接。可以把它看作是你的设备与网络之间的桥梁。每个NIC都有其唯一的MAC地址。
  • RJ45: The physical connector at the end of an Ethernet cable (the connector itself, not the cable) — used to plug into ports on NICs, switches, and routers. RJ45: 以太网线末端的物理连接器(指连接器本身,而非线缆)——用于插入NIC、交换机和路由器上的端口。

IP Address and Its Components

IP 地址及其组成部分

An IP address is a numerical label assigned to every device on a network. An IPv4 address looks like this: 192.168.1.50. Every IP address is made up of two parts: IP地址是分配给网络上每台设备的数字标签。IPv4地址看起来像这样:192.168.1.50。每个IP地址由两部分组成:

PartWhat it identifiesAnalogy
Network IDThe network segment the device belongs toThe street name
Host IDThe specific device within that networkThe house number
部分标识内容类比
网络ID设备所属的网络段街道名称
主机ID该网络内的特定设备门牌号

For example, given 192.168.1.50 with subnet mask 255.255.255.0: 例如,给定192.168.1.50,子网掩码为255.255.255.0:

  • Network ID: 192.168.1.0
  • Host ID: 50

The Role of the Subnet Mask

子网掩码的作用

The subnet mask is what actually splits an IP address into its Network ID and Host ID. With 255.255.255.0, the first three numbers (192.168.1) mark the network, and the last number (50) marks the specific host — the device — within it. (Worth flagging: this clean “three numbers for network, one for host” split only happens with a /24 mask like this one. Other subnet masks can split the address at different points — sometimes within a single number rather than neatly along the dots — but that’s a topic for a future post.) 子网掩码实际上是将IP地址拆分为网络ID和主机ID的工具。对于255.255.255.0,前三个数字(192.168.1)标记网络,最后一个数字(50)标记该网络内的特定主机(设备)。(值得注意的是:这种“三个数字代表网络,一个数字代表主机”的整齐拆分仅适用于像这样的/24掩码。其他子网掩码可以在不同的点拆分地址——有时是在单个数字内部,而不是整齐地沿着点拆分——但这将是未来文章的主题。)

IP Address vs. MAC Address — The Pen Name Analogy

IP 地址与 MAC 地址 —— 笔名类比

This is the comparison that made it click for me: An IP address is like a pen name — it identifies a device, but it can change over time, just like an author might use different pen names. A MAC address is like the author’s real name — it’s assigned permanently to the hardware by the manufacturer and doesn’t change under normal use. (One exception worth knowing: MAC addresses can technically be overridden at the software level — a technique called MAC spoofing — but the original, hardware-burned address itself never changes.) 这个对比让我豁然开朗:IP地址就像笔名——它标识了一台设备,但它会随时间改变,就像作者可能会使用不同的笔名一样。MAC地址就像作者的真名——它由制造商永久分配给硬件,在正常使用下不会改变。(值得了解的一个例外:MAC地址在技术上可以在软件层面被覆盖——这种技术称为MAC地址欺骗——但原始的、烧录在硬件上的地址本身永远不会改变。)

An IP address itself splits into the same two pieces mentioned above: IP地址本身也分为上述提到的两部分:

  • Network ID — shared by every device on the same network, showing they all belong to one group. 网络ID —— 同一网络上的每台设备共享,表明它们都属于同一个组。
  • Host ID — unique to each individual device, identifying exactly which one is communicating. 主机ID —— 每台设备独有,准确标识正在通信的是哪一台。

Key Takeaways

关键要点

  • Hub: dumb but simple — broadcasts to everyone, every time. 集线器: 笨但简单——每次都广播给所有人。
  • Switch: smart — knows each device’s MAC address and sends data only where it needs to go. 交换机: 聪明——知道每台设备的MAC地址,只将数据发送到需要去的地方。
  • Router: connects separate networks together, most commonly your home network to the internet. 路由器: 连接不同的网络,最常见的是将你的家庭网络连接到互联网。
  • MAC address: permanent, hardware-based identity assigned by the manufacturer — technically spoofable in software, but the original hardware address itself never changes. MAC地址: 由制造商分配的永久性、基于硬件的身份——在技术上可以通过软件伪造,但原始的硬件地址本身永远不会改变。
  • IP address: logical, assignable identity — can change, and is split into a Network ID and Host ID via the subnet mask. IP地址: 逻辑性的、可分配的身份——可以更改,并通过子网掩码拆分为网络ID和主机ID。

Understanding these basics is the foundation for pretty much everything else in networking — VLANs, routing tables, subnetting — so if this is where you’re starting too, you’re in the right place. 理解这些基础知识是网络中几乎所有其他内容(如VLAN、路由表、子网划分)的基石,所以如果你也是从这里开始,那么你来对地方了。