• head_banner

The difference between a switch and a router

(1) From the appearance, we distinguish between the two

Switches usually have more ports and look cumbersome.

The router’s ports are much smaller and the volume is much smaller.

In fact, the picture on the right is not a real router but integrates the function of the router. In addition to the function of the switch (the LAN port is used as the port of the switch, the WAN is the port used to connect to the external network), and the two The antenna is the wireless AP access point (which is commonly referred to as wireless local area network wifi).

(2) Different working levels:

The original switch worked at the ** data link layer of the OSI open system interconnection model, ** which is the second layer

The router works at the network layer of the OSI model, which is the third layer

Because of this, the principle of the switch is relatively simple. Generally, hardware circuits are used to realize the forwarding of data frames.

The router works at the network layer and shoulders the important task of network interconnection. To implement more complex protocols and have more intelligent forwarding decision-making functions, it generally runs an operating system in the router to implement complex routing algorithms, and is more inclined to software implementation. Its function.

(3) The data forwarding objects are different:

The switch forwards data frames based on the MAC address

The router forwards IP datagrams/packets based on the IP address.

The data frame encapsulates the frame header (source MAC and destination MAC, etc.) and frame tail (CRC check. Code) on the basis of IP data packets/packets. As for the MAC address and IP address, you may not understand why two addresses are needed. In fact, the IP address determines the final data packet to reach a certain host, and the MAC address determines which one the next hop will interact with. A device (usually a router or a host). Moreover, the IP address is realized by software, which can describe the network where the host is located, and the MAC address is realized by hardware. Each network card will solidify the world’s only MAC address in the ROM of the network card when it leaves the factory, so the MAC address cannot It is modified, but the IP address can be configured and modified by the network administrator.

(4) “Division of labor” is different

​ The switch is mainly used to build a local area network, and the router is responsible for connecting the host to the external network. Multiple hosts can be connected to the switch through a network cable. At this time, the LAN is established, and data can be sent to other hosts in the LAN. For example, the LAN software such as Feiqiu we use forwards data to other hosts through the switch. However, the LAN established by the switch cannot access the external network (that is, the Internet). At this time, a router is needed to “open the door to the wonderful world outside” for us. All the hosts on the LAN use the private network IP, so it must The external network can be accessed only after the router is converted into an IP of the public network.

(5) Conflict domain and broadcast domain

The switch divides the conflict domain, but does not divide the broadcast domain, while the router divides the broadcast domain. The network segments connected by the switch still belong to the same broadcast domain, and broadcast data packets will be transmitted on all network segments connected by the switch. In this case, it will cause broadcast storms and security vulnerabilities. The network segment connected to the router will be assigned an unreachable broadcast domain, and the router will not forward broadcast data. It should be noted that the unicast data packet will be uniquely sent to the target host by the switch in the local area network, and other hosts will not receive the data. This is different from the original hub. The arrival time of the data is determined by the forwarding rate of the switch. The switch will forward the broadcast data to all hosts in the LAN.

The last thing to note is that routers generally have the function of a firewall, which can selectively filter some network data packets. Some routers now have the function of a switch (as shown on the right in the figure above), and some switches have the function of a router, which are called Layer 3 switches and are widely used. In comparison, routers have more powerful functions than switches, but they are also slower and more expensive. Layer 3 switches have both the linear forwarding capability of switches and the good routing functions of routers, so they are widely used.


Post time: Nov-26-2021