Router addressing principle
路由器是一种三层设备,
是使用IP地址寻址,
实现从源IP到达目标IP地址的端到端的服务,
其工作原理如下:
01
第一步
The First Step
1、路由器接收到数据包,提取目标IP地址及子网掩码计算目标网络地址;
The router receives the data packet, extracts the target IP address and subnet mask, and calculates the target network address;
02
第二步
The Second Step
2、根据目标网络地址查找路由表,如果找到目标网络地址就按照相应的出口发送到下一个路由器;
The routing table is searched according to the destination network address. If the destination network address is found, it is sent to the next router according to the corresponding exit;
03
第三步
The Third Step
3、如果没有找到,就看一下有没有默认路由,如果有就按照默认路由的出口发送给下一个路由器;
If not, check whether there is a default route. If there is, send it to the next router according to the exit of the default route;
04
第四步
The Fourth Step
4、如果没有找到就给源IP发送一个出错ICMP数据包表明没法传递该数据包;
If not, send an error ICMP packet to the source IP, indicating that the packet cannot be delivered;
05
第五步
The Fifth Step
5、如果是直连路由就按照第二层MAC地址发送给目标站点。
If it is a direct connection route, it will be sent to the target site according to the MAC address of the second layer.