📚 Network Hardware Devices: Routers, Switches and Network Interface Cards | 网络硬件设备:路由器、交换机与网卡
Modern computer networks are built from a combination of hardware devices that work together to move data reliably and efficiently. Among the most essential are the network interface card (NIC), the switch, and the router. Each occupies a distinct position in the network architecture and performs a fundamentally different role in data transmission.
现代计算机网络由多种硬件设备协同工作,以可靠高效地传输数据。其中最重要的设备包括网卡(NIC)、交换机和路由器。每一种设备在网络架构中都占据着独特的位置,并在数据传输中扮演着根本不同的角色。
1. The Network Interface Card (NIC) | 网卡
A network interface card, commonly abbreviated as NIC, is the hardware component that physically connects a computer or other device to a network. Every device that communicates over a wired Ethernet network requires a NIC, either integrated into the motherboard or installed as a separate expansion card.
网卡(NIC)是将计算机或其他设备通过网络物理连接到网络的硬件组件。每个通过有线以太网通信的设备都需要网卡,无论是集成在主板上,还是作为独立的扩展卡安装。
The NIC operates at both the physical layer and the data link layer of the OSI model. It is responsible for preparing data for transmission by converting parallel data from the system bus into serial bit streams suitable for the network cable. It also performs the reverse operation when receiving data from the network. The NIC attaches a header and a trailer to each chunk of data, forming a frame, and it appends a cyclic redundancy check (CRC) value so that the receiver can detect transmission errors.
网卡在OSI模型的物理层和数据链路层同时工作。它负责准备待传输的数据,将系统总线的并行数据转换为适合网络电缆的串行比特流,同时也在接收数据时执行反向转换。网卡为每一块数据添加头部和尾部,构成帧,并附加循环冗余校验(CRC)值,使接收方能够检测到传输错误。
Each NIC has a unique 48-bit MAC address, often called a physical address or burned-in address, assigned by the manufacturer. The first 24 bits identify the manufacturer through an Organisationally Unique Identifier (OUI), while the remaining 24 bits are a device-specific serial number. This address is permanently stored in the NIC's ROM and is used at the data link layer to identify the source and destination of frames within the same local network.
每块网卡都有一个唯一的48位MAC地址,通常被称为物理地址或烧录地址,由制造商分配。前24位通过组织唯一标识符(OUI)标识制造商,后24位是设备特定的序列号。该地址永久存储在网卡的ROM中,并在数据链路层用于标识同一本地网络内帧的源和目的设备。
2. MAC Addresses and Frame Transmission | MAC地址与帧传输
A MAC address is essential for delivering frames between devices on the same local area network (LAN). Unlike an IP address, which can change depending on the network to which a device is connected, a MAC address is fixed to the hardware and cannot be modified by software in normal circumstances.
MAC地址是在同一局域网(LAN)内设备之间传递帧的关键。与IP地址不同——IP地址可能随设备连接的网络而变化——MAC地址固定在硬件上,在正常情况下无法通过软件修改。
MAC addresses can be classified into three types. A unicast MAC address is associated with a single NIC and is used for one-to-one communication. A broadcast MAC address, consisting of all 48 bits set to 1 (FF:FF:FF:FF:FF:FF), is used to send frames to every device on the local network. A multicast MAC address enables a single frame to be delivered to a selected group of devices rather than the entire network.
MAC地址可分为三类。单播MAC地址与单个网卡关联,用于一对一通信。广播MAC地址,即48位全部为1(FF:FF:FF:FF:FF:FF),用于向本地网络上的每台设备发送帧。组播MAC地址允许将一帧数据发送给选定的一组设备,而非整个网络。
When a NIC has a frame to transmit on an Ethernet network, it checks whether the transmission medium is idle before sending the data. If two devices transmit simultaneously, a collision occurs, and each device waits a random backoff time before attempting retransmission. This mechanism is part of the Carrier Sense Multiple Access with Collision Detection (CSMA/CD) protocol, which was fundamental to legacy Ethernet networks using hubs.
当网卡需要在以太网上发送帧时,它会先检测传输介质是否空闲。如果两个设备同时发送,就会产生冲突,每个设备将等待随机退避时间后重试。这一机制属于带冲突检测的载波侦听多址访问(CSMA/CD)协议,在采用集线器的传统以太网中至关重要。
3. The Switch: Intelligent Frame Forwarding | 交换机:智能帧转发
A network switch is a data-link-layer device that connects multiple devices within the same LAN. Unlike a hub, which simply repeats incoming signals to every connected port, a switch learns the MAC addresses of connected devices and uses this information to forward frames only to the appropriate destination port.
交换机是数据链路层设备,用于连接同一局域网内的多台设备。与集线器不同——集线器简单地将输入信号重复发送到每个连接端口——交换机会学习所连接设备的MAC地址,并利用这些信息将帧仅转发到正确的目的端口。
The learning process works as follows. When a frame arrives at a switch port, the switch records the source MAC address and associates it with the port on which the frame arrived. This information is stored in a switching table, sometimes called a MAC address table. The switch then looks up the destination MAC address in the table to decide the forwarding action.
学习过程如下。当一帧到达交换机的某个端口时,交换机会记录源MAC地址,并将其与该帧进入的端口关联。该信息存储在交换表(有时称为MAC地址表)中。交换机随后在表中查找目的MAC地址,以决定转发动作。
Three possible actions can result from this lookup:
查找结果可能导致以下三种动作:
- Selective forwarding: If the destination MAC address is found in the table and its associated port is different from the receiving port, the switch forwards the frame only to that port, providing security and reducing unnecessary traffic.
- Flooding: If the destination MAC address is not found in the table, the switch forwards the frame to all ports except the one from which it arrived.
- Filtering: If the destination MAC address is found in the table but is associated with the same port that received the frame, the switch drops the frame because the destination is on the same segment as the source.
- 选择性转发:如果目的MAC地址在表中找到,且其关联端口与接收端口不同,交换机仅将帧转发到该端口,从而提供安全性并减少不必要的流量。
- 泛洪:如果目的MAC地址在表中未找到,交换机将帧转发到除接收端口以外的所有端口。
- 过滤:如果目的MAC地址在表中找到,但关联端口与接收端口相同,交换机丢弃该帧,因为目的设备与源设备位于同一网段。
The switching table is not permanent. Entries are continuously refreshed based on the source addresses of incoming frames, and inactive entries are removed after an aging time, typically 300 seconds. This allows the switch to adapt to devices being moved, added, or removed from the network.
交换表不是永久性的。表项会根据帧的源地址持续刷新,不活动的表项会在老化时间(通常为300秒)之后被移除。这使得交换机能够适应设备在网络中的移动、添加或移除。
4. Switch versus Hub | 交换机与集线器的对比
The hub is an older, simpler device that operates at the physical layer. It does not examine MAC addresses or make forwarding decisions; it simply regenerates and broadcasts every incoming signal to all other ports. Consequently, all devices connected to a hub share the same collision domain.
集线器是一种较老、较简单的设备,工作在物理层。它不检查MAC地址,也不做转发决策,只是将每一个输入信号重新生成并广播到所有其他端口。因此,连接在集线器上的所有设备共享同一个冲突域。
A switch, by contrast, creates a separate collision domain for each port. Because frames are forwarded only to the intended destination port, devices on different ports can transmit simultaneously without colliding. This significantly improves network performance, especially in busy LANs.
相比之下,交换机为每个端口创建独立的冲突域。由于帧仅被转发到预期的目的端口,不同端口上的设备可以同时传输而不会冲突。这显著提高了网络性能,尤其是在繁忙的局域网中。
| Feature | Hub | Switch |
|---|---|---|
| OSI Layer | Physical (Layer 1) | Data Link (Layer 2) |
| Frame inspection | None | Reads source and destination MAC |
| Collision domains | Single shared domain | One per port |
| Latency | Lower but shared bandwidth | Slightly higher but dedicated bandwidth |
5. The Router: Connecting Networks | 路由器:连接不同网络
A router is a network-layer device that connects two or more networks and forwards data packets between them based on logical addresses, specifically IP addresses. While switches operate within a single LAN, a router allows devices on different LANs to communicate with one another, and it provides the gateway through which local traffic reaches the Internet.
路由器是网络层设备,用于连接两个或多个网络,并根据逻辑地址(特别是IP地址)在它们之间转发数据包。交换机在单个局域网内工作,而路由器允许不同局域网上的设备相互通信,并且为本地流量访问Internet提供网关。
When a packet arrives at a router interface, the router examines the destination IP address in the packet header. It then consults its routing table to determine the best path, or next hop, toward the destination network. The router sends the packet out through the appropriate interface, encapsulated in a new frame for the next segment of the journey across the link. This process, known as store-and-forward packet switching, is repeated at each router along the path until the packet reaches its destination network.
当数据包到达路由器的某个接口时,路由器检查包头的目的IP地址,然后查阅路由表,确定到达目的网络的最佳路径(即下一跳)。路由器通过适当的接口发送数据包,并为下一个网段的传输重新封装帧。这个过程称为存储转发分组交换,在路径上的每个路由器处重复,直到数据包到达目的网络。
In addition to forwarding packets, routers serve several important functions. They divide broadcast domains, preventing broadcast frames from spreading across the entire internetwork. They can implement access control lists (ACLs) to filter traffic based on source or destination addresses, ports, or protocols. They also perform network address translation (NAT), allowing multiple devices on a private LAN to share a single public IP address when accessing the Internet.
除了转发数据包,路由器还承担几项重要功能。它们划分广播域,防止广播帧在整个互联网络中扩散。它们可以实现访问控制列表(ACL),根据源或目的地址、端口或协议过滤流量。它们还执行网络地址转换(NAT),允许专用局域网上的多个设备在访问Internet时共享一个公网IP地址。
6. Routing Tables and Routing Protocols | 路由表与路由协议
The routing table is a data structure stored in a router's memory that contains information about known networks and the paths to reach them. Each entry typically includes a destination network address, a subnet mask, the next-hop router address or local interface, and an administrative distance or metric representing the cost of that route.
路由表是存储在路由器内存中的数据结构,包含已知网络及其可达路径的信息。每个表项通常包括目的网络地址、子网掩码、下一跳路由器地址或本地接口,以及表示该路由代价的管理距离或度量值。
Routes can be classified according to how they are learned:
路由可以根据学习方式分类:
- Directly connected networks: The router automatically learns the subnets attached to its own interfaces. These routes are always available as long as the interface is active.
- Static routes: A network administrator manually configures these routes. They are stable and do not consume network bandwidth, but they must be updated manually if the network topology changes.
- Dynamic routes: The router learns these routes automatically by exchanging routing information with neighbouring routers using routing protocols.
- 直连网络:路由器自动学习其自身接口所连接的子网。只要接口处于活动状态,这些路由始终可用。
- 静态路由:由网络管理员手动配置。它们稳定且不消耗网络带宽,但如果网络拓扑变化,必须手动更新。
- 动态路由:路由器通过路由协议与相邻路由器交换路由信息,自动学习这些路由。
Common dynamic routing protocols include Routing Information Protocol (RIP), which uses hop count as its metric and considers any route longer than 15 hops unreachable; Open Shortest Path First (OSPF), which uses link-state information and a cost value based on interface bandwidth to compute the shortest path; and Border Gateway Protocol (BGP), which routes traffic between autonomous systems on the Internet.
常见的动态路由协议包括:路由信息协议(RIP),以跳数作为度量,超过15跳的路由被视为不可达;开放最短路径优先(OSPF),使用链路状态信息并基于接口带宽计算代价以求得最短路径;以及边界网关协议(BGP),用于Internet上的自治系统之间路由流量。
Route priority: Directly connected → Static → Dynamic (by metric)
路由优先级:直连 → 静态 → 动态(按度量值)
7. Router versus Switch: Key Differences | 路由器与交换机的主要区别
Although routers and switches often appear similar in physical design, they differ fundamentally in how they operate and what they achieve.
尽管路由器和交换机在外观上常常相似,但它们在操作方式和实现目标上存在根本差异。
A switch forwards frames based on MAC addresses at the data link layer, learning and maintaining a MAC address table as frames pass through. It does not understand logical addressing or network topology beyond the local segment. A router forwards packets based on IP addresses at the network layer and maintains a routing table that describes the structure of the wider internetwork.
交换机在数据链路层基于MAC地址转发帧,并在帧通过时学习维护MAC地址表。它不理解逻辑寻址,也不了解本地网段之外的网络拓扑。路由器在网络层基于IP地址转发数据包,维护描述更广互联网络结构的路由表。
Another critical distinction concerns broadcast domains. A switch does not filter broadcast frames; therefore, all devices connected to the same switch belong to the same broadcast domain. Routers, however, stop broadcast frames at each interface, so each router interface defines the boundary of a broadcast domain. Furthermore, switches segment collision domains on a per-port basis, whereas routers also segment collision and broadcast domains across their interfaces.
另一个关键区别涉及广播域。交换机不过滤广播帧,因此连接到同一交换机的所有设备都处于同一个广播域中。而路由器在每个接口处终止广播帧,因此每个路由器接口都定义了广播域的边界。此外,交换机按端口划分冲突域,路由器则在其接口之间同时划分冲突域和广播域。
| Feature | Switch | Router |
|---|---|---|
| Layer | Data link (Layer 2) | Network (Layer 3) |
| Address used | MAC address | IP address |
| Table maintained | Switching (MAC) table | Routing table |
| Broadcast domain | Does not stop broadcasts | Stops broadcasts at interfaces |
8. Hardware Devices and the OSI Model | 硬件设备与OSI模型
Understanding which OSI layer each device operates at is essential for answering examination questions on networking hardware.
理解每种设备工作在OSI模型的哪一层,是回答网络硬件考试题目的关键。
The NIC, though it uses MAC addresses from the data link layer, also contains the physical interface circuitry required for line transmission, so it spans both Layers 1 and 2. A hub operates purely at Layer 1 because it only regenerates signals. A switch operates at Layer 2 because it makes forwarding decisions based on MAC addresses. A router operates at Layer 3 because it uses IP addresses and routing algorithms to forward packets across separate networks.
网卡虽然使用的是数据链路层的MAC地址,但也包含线路传输所需的物理接口电路,因此它横跨第1层和第2层。集线器纯属第1层设备,因为它只再生信号。交换机工作在第2层,因为它基于MAC地址做出转发决策。路由器工作在第3层,因为它使用IP地址和路由算法在不同网络之间转发数据包。
| Device | OSI Layer | Primary addressing |
|---|---|---|
| Hub | 1 (Physical) | None |
| NIC | 1 and 2 | MAC address |
| Switch | 2 (Data Link) | MAC address |
| Router | 3 (Network) | IP address |
9. Exam Focus: Common Misconceptions | 考试重点:常见误区
Many students lose marks on networking hardware questions because of a few recurring misconceptions. One common error is claiming that a switch can connect two different networks. In fact, a switch is only capable of forwarding frames within a single LAN and has no concept of IP addresses or network boundaries.
许多学生在网络硬件题目上丢分,是因为一些反复出现的误区。一个常见错误是声称交换机可以连接两个不同的网络。事实上,交换机只能在单个局域网内转发帧,不具备IP地址或网络边界的概念。
Another misconception is that routers broadcast packets. Routers do not generate broadcast traffic; rather, they stop broadcasts at their boundaries. Similarly, students sometimes confuse MAC tables and routing tables, or assume that switches require configuration before they can forward frames, when in fact an unmanaged switch builds its MAC address table automatically and begins forwarding after only a brief learning period.
另一个误区是认为路由器会广播数据包。路由器不会产生广播流量,相反,它们在边界处终止广播。同样,学生有时会混淆MAC地址表和路由表,或者认为交换机在转发帧之前需要配置,而事实上非管理型交换机会自动建立MAC地址表,并能在短暂的学习期后立即开始转发。
For examination purposes, remember these three well-known facts: first, a hub belongs to Layer 1, a switch to Layer 2, and a router to Layer 3. Second, switches segment collision domains but not broadcast domains, whereas routers segment broadcast domains. Third, the NIC has a unique burned-in MAC address that identifies the device within the local data link layer environment, while the IP address identifies the device logically across an internetwork.
为了应对考试,请记住以下三个要点:第一,集线器属于第1层,交换机属于第2层,路由器属于第3层。第二,交换机划分冲突域但不划分广播域,而路由器划分广播域。第三,网卡具有唯一的烧录MAC地址,用于在本地数据链路层环境中标识设备,而IP地址在互联网络中逻辑地标识设备。
10. Summary | 总结
Network hardware devices form the backbone of modern communication systems. The NIC provides the physical and data-link interface through which a device joins a network and addresses frames using MAC addresses. The switch intelligently forwards frames within a LAN by learning and maintaining a MAC address table, reducing collisions and improving efficiency. The router connects separate networks, forwards packets using IP addresses and routing tables, and controls the boundaries between broadcast domains.
网络硬件设备构成了现代通信系统的骨干。网卡提供设备加入网络的物理和数据链路接口,并使用MAC地址对帧进行寻址。交换机通过在局域网内学习并维护MAC地址表来智能转发帧,减少冲突并提高效率。路由器连接不同网络,使用IP地址和路由表转发数据包,并控制广播域之间的边界。
Each device performs a distinct and complementary function, and a clear understanding of their differences is essential for any student of computer science aiming to master the CIE A-Level networking syllabus.
每种设备执行着不同且互补的功能,清晰理解它们之间的区别,对于任何旨在掌握CIE A-Level网络考纲的计算机科学学生而言都至关重要。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)

或截图后用「扫一扫 → 相册」选择本图