On the osi seven-layer model, the switch works on the second layer and the router works on the third layer. However, with the development of technology, some switches integrate some third-level routing functions, called Layer 3 switches. Let’s analyze the differences between standard switches and routers:
In the simplest terms, the way the switch looks for a computer is by looking up the mac address, which is done by a unique identification number inherent in your network card.
· The router looks for a computer through the ip address, which is to first number your computer, send you an ip, and then identify you through this ip. That is to say, the switch at the second layer is not designed to work. Protocol and network address (ip) allocation
In fact, the word exchange first appeared in the telephone system, especially the exchange of voice signals between two different telephones. The equipment that completes the work is the telephone exchange. So in terms of the intention, the exchange is just a technical concept, that is, the completion of the signal is forwarded from the device entrance to the exit. Therefore, all devices that are consistent with this definition can be referred to as switching devices. Thus, “exchange” is a broad term that, when used to describe a device on the second layer of a data network, actually refers to a bridge device; and when it is used to describe the third layer of the data network. When referring to a device, it refers to a routing device. The Ethernet switch we often talk about is actually a multi-port Layer 2 network device based on bridge technology, which provides a low latency, low overhead path for data frames to be forwarded from one port to another.
The router is a packet switching device (or network layer relay device) in the network layer of the OSI protocol model. The basic function of the router is to transmit data (IP packets) to the correct network, including:
- Forwarding of IP datagrams, including routing and transmission of datagrams;
- Subnet isolation to suppress broadcast storms;
- Maintain the routing table and exchange routing information with other routers. This is the basis for IP packet forwarding.
- Error handling of IP datagrams and simple congestion control;
- Implement filtering and accounting of IP datagrams.
The main differences between routers and switches are reflected in the following aspects:
(1) different levels of work
The original switch was at the data link layer of the OSI/RM open architecture, the second layer, and the router was designed to work at the network layer of the OSI model. Since the switch works in the second layer (data link layer) of OSI, its working principle is relatively simple, and the router works in the third layer (network layer) of OSI, which can get more protocol information, and the router can make Smarter forwarding decisions.
(2) The data is based on different objects
The switch uses the physical address or MAC address to determine the destination address for forwarding data. The router uses the ID number (ie IP address) of the different network to determine the address for data forwarding. The IP address is implemented in software and describes the network where the device is located. Sometimes the addresses of these Layer 3 are also called protocol addresses or network addresses. The MAC address is usually provided by the hardware, distributed by the network card manufacturer, and has been solidified into the network card, which is generally unchangeable. IP addresses are usually assigned automatically by the network administrator or the system.
(3) The traditional switch can only divide the collision domain and cannot divide the broadcast domain; the router can split the broadcast domain.
The network segments connected by the switch still belong to the same broadcast domain. Broadcast packets are transmitted on all network segments connected to the switch. In some cases, communication congestion and security holes are caused. The network segments connected to the router are assigned to different broadcast domains, and the broadcast data does not pass through the router. Although the switch above the third layer has the VLAN function, the broadcast domain can also be divided, but the sub-broadcast domains cannot communicate with each other, and communication between them still requires a router.
(4) The router provides a firewall service
The router only forwards packets of a specific address, does not transmit packet transmissions that do not support routing protocols, and transmits unknown unknown network packets, thereby preventing broadcast storms.
Switches are generally used for LAN-WAN connections. Switches are attributed to bridges and are data link layer devices. Some switches can also implement Layer 3 switching. The router is used for the connection between the WAN and the WAN, and can solve the forwarding packet between the heterosexual networks and acts on the network layer. They simply accept the incoming packet from one line and then forward it to the other. These two lines may belong to different networks and adopt different protocols. In comparison, the function of the router is stronger than that of the switch, but the speed is relatively slow and expensive. The Layer 3 switch has the ability to forward packets at the line rate and has good control functions of the router, so it can be widely used.