Traditional switches have evolved from bridges and belong to the second layer of OSI, the data link layer device. It is addressed according to the MAC address, routing is selected through the station table, and the establishment and maintenance of the station table is automatically performed by the switch. The router belongs to the OSI layer 3, the network layer device, which is addressed according to the IP address and generated by the routing table routing protocol. The biggest advantage of the switch is fast. Because the switch only needs to identify the MAC address in the frame, it is simple to generate the selective forwarding port according to the MAC address, which is convenient for the ASIC to implement, so the forwarding speed is extremely high. But the working mechanism of the switch also brings some problems.
1. Loop: According to the switch address learning and station table establishment algorithm, loops are not allowed between switches. Once a loop exists, the spanning tree algorithm must be started to block the port that generated the loop. The router's routing protocol does not have this problem. There can be multiple paths between routers to balance the load and improve reliability.
2. Load concentration: There can only be one path between switches, so that information is concentrated on one communication link and cannot be dynamically allocated to balance the load. The router's routing protocol algorithm can avoid this. The OSPF routing protocol algorithm can not only generate multiple routes, but also select different optimal routes for different network applications.
3. Broadcast Control: The switch can only narrow down the collision domain, not the broadcast domain. The entire switched network is a large broadcast domain, and broadcast messages are scattered throughout the switched network. The router can isolate the broadcast domain, and broadcast packets cannot continue to be broadcast through the router.
4. Subnetting: The switch can only recognize the MAC address. The MAC address is a physical address and has a flat address structure, so the subnet cannot be divided according to the MAC address. The router recognizes the IP address, and the IP address is assigned by the network administrator. It is a logical address and the IP address has a hierarchical structure. It is divided into a network number and a host number, which can be conveniently used for subnetting. The main function of the router is to use Connect to different networks.