The header of the datagram received by the person extracts the destination Internet Protocol Address D.
First determine whether it is a direct delivery. Check the networks directly connected to the router one by one: use the subnet mask and D of each network to “AND” bit by bit to see if the result matches the corresponding network address. If it matches, the packet is directly delivered (of course, D needs to be converted into a physical address, and the datagram is packaged into a frame and sent out), and the forwarding task is over. Otherwise, it is an indirect delivery, execute (3)
Indirect delivery: If there is a specific host route with destination address D in the routing table, the datagram is sent to the next-hop router specified in the routing table, otherwise
Execute (4). There is no specific host route with destination address D in the general routing table: for each row in the routing table (destination network address, subnet mask, next hop address), use the subnet mask and D in it bit-by-bit “AND” (AND operation), the result is N. If N matches the destination network address of the row, the datagram is sent to the next hop router indicated at the beginning of the row; otherwise, execute (5)
No default route: If there is a default route in the routing table, send the datagram to the default route specified in the routing table; otherwise, execute (6).
Report a forwarding packet error.