Router
A router is a device that forwards data packets between computer networks. This creates an overlay internetwork, as a router are connected to and more data lines from different networks. When a data packet comes in one of the lines, the router reads the address information in the packet to determine its ulti Mate destination. Then, using information-routing table or routing policy, it directs the packet to the next network on its Journey. Routers perform the "traffic directing" functions on the Internet.
Routers that connect customers to the Internet are called Edge router. Routers that are only responsible for passing data to and from other routers, such as the ISP's network, are called core routers.
In addition to the function of the switch, the router has the route table as the basis for transmitting the packet, and chooses the best path in the path with many choices. In addition, the network can connect more than two different network segments, while the exchanger can only connect two. and has the function of IP sharing, such as: distinguish which packets are to be transmitted to the WAN, or only on the LAN.
Switch
A network switch (sometimes known as a switching hub) is a computer networking device, is used to connect devices Toge Ther on a computer network by performing a form of packet switching. A switch is a multi-port network bridge, processes and forwards data at the Data Link layer (Layer 2) of the OSI model .
802.1X Network access control
The switch works on the second layer of the OSI Reference Model, the data link layer. The CPU inside the switch learns its MAC address through the ARP protocol and saves it as an ARP table when each port is successfully connected. In future communications, packets destined for that MAC address will be sent only to their corresponding port, not all ports. Therefore, the switch can be used to divide the data link layer broadcast , namely the conflict domain, but it cannot divide the network layer broadcast, namely broadcast domain.
Switches are widely used in two-layer network switching. The mid-range managed switches also feature VLAN partitioning, port auto-negotiation, MAC access control lists, and a command-line interface or graphical interface console for network administrators to adjust parameters
Layer three switches can handle the third layer of Network layer protocol, which is used to connect different network segments and create a direct connection between two network segments through query learning for the default gateway.
Layer three switches have a certain "routing" capability, but can only be used for interconnection between the same type of LAN subnet. In this way, the layer three switch can identify the packet with the MAC address as the two layer switch, or the weaker route forwarding between the two LAN subnets as the traditional router does, and its route forwarding is not the routing table maintained by the software, but the forwarding is handled by the dedicated ASIC chip;
Difference
The difference between switches and routers is not limited to the following points (the switches and routers here are regular models):
1. Both work at different levels of the OSI model
The switch works on the second layer of data link layer, and the router works on the third layer of the network layer. The network layer provides more protocol information, which makes it easier for routers to make more intelligent forwarding choices.
2. Different objects on which the two are forwarded
The switch is based on MAC address recognition to implement encapsulating packet forwarding. The router is based on the network ID number (IP address). The MAC is generally cured in the NIC and cannot be changed. The IP address can be set and assigned by the system or network administrator.
3. The difference between the domains in which the broadcast packets are forwarded
Networks connected by switches belong to the same broadcast domain, and broadcast packets propagate across all segments of the network. The network segments connected to the routers are partitioned into different broadcast domains, and broadcast packets are propagated only within their broadcast domains and cannot penetrate the routers. This seed mesh isolation feature of routers can prevent broadcast storms to some extent.