How does a router work?

A router is a layer 3 network device. The hub works on the first layer ( the physical layer) and has no intelligent processing capabilities. When the current of one port is passed to the hub, it simply transmits the current to other ports, and does not care whether the computers connected to other ports receive these data. . The switch works at the second layer  the data link layer), which is smarter than the hub. For it, the data on the network is the collection of MAC addresses, and it can distinguish the source MAC address and destination MAC address in the frame. , so a connection can be established between any two ports, but the switch does not know the IP address, it only knows the MAC address. The router works at the third layer ( the network layer), it is more “smarter” than the switch, it can understand the IP address in the data, if it receives a data packet, it checks the destination network address in the packet to determine whether the destination address of the packet exists in the current routing table (that is, whether the router knows the path to the destination network). If the destination address of the packet is found to be the same as the network address connected to an interface of the router, the data will be forwarded to the corresponding interface immediately; if the destination address of the packet is found not to be directly connected to its own network segment, the router will check its own routing table. Find the interface corresponding to the destination network of the packet, and forward it from the corresponding interface; if the network address recorded in the routing table does not match the destination address of the packet, it will be forwarded to the default interface according to the router configuration. If the default interface is not configured The following will return the ICMP information that the destination address is unreachable to the user.

Post time: Sep-29-2022