Before introducing the network layer protocol, I forgot to introduce a very important point of knowledge: IP routing.
Once said that if the IP address of the two communication parties is not within the same subnet, then the two to communicate, the packet needs to go through the router forwarding, may have to go through multiple routers to reach the receiver. So how does the router work? In fact, the core point is that the router has a routing table, which includes the following types of information:
1. Destination IP Address: It can be either a full host address or a network address.
2. The IP address of the next-hop router refers to a router on a direct-attached network.
3. Logo. One of the flags indicates whether the destination IP is the host address or the network address, and the other flag indicates if the next-hop router is a true next-hop router or a direct-attached network interface.
The steps for IP routing are as follows:
1. Search for the destination address in the routing table, and if present, send the IP packet directly to that address, otherwise go to 2.
2. Search the destination network corresponding subnet address, if present, then send to the subnet number corresponding to the next hop address, otherwise go 3.
3. The network number corresponding to the search destination network, if present, is sent to the network number corresponding to the scare-hop router, otherwise turn 4.
4. Find the default route and forward it if it is present, or discard it.
Therefore, the routing table includes dynamic routing control and static route control, obviously, dynamic routing strategy can be adaptively adjusted, but the cost is large. It also includes the Internal Gateway Protocol IGP (including the famous Rip and OSPF) and the External Network Management Protocol EGP (based on the Dijkstra algorithm). While the static route control is when the interface is configured, the route table entry is generated by default and can be generated or deleted by means of the route instruction. It is less expensive, but not adaptable to network changes.
Some views on the TCP/IP protocol: IP Routing