Working principle of the router
We know that the router is used to connect to different network segments or networks. In a local area network, if you do not need to communicate with an external network, each of the workstations of the internal network can identify other nodes, which can be transmitted through the switches. It is basically not on the router to memory the Node MAC address of the local area network. The router identifies the method of different networks by identifying the network ID number of different networks, so in order to ensure the success of the route, each network must have a unique network number. The router is to identify another network, first to identify is the network ID of the router IP address of the other network, see if it is consistent with the network ID number in the destination node address. If it is of course sent to the router of this network, after receiving the message sent by the network, it is sent to the host ID number in the IP address included in the packet. In one node, then send it directly.
In order to clearly explain the working principle of the router, we now assume that there is such a simple network. Suppose one of the network segments network ID number is "A", there are 4 terminal devices in the same network segment, and each device of this network segment is assumed to be: A1, A2, A3, and A4. A router connected to this segment is used to connect to other network segments, the router connected to the port IP address of the A network segment is A5. The same router is connected to another network segment as a B network segment. The network ID number of this network segment is "B", which is set to: B1, B2, B3, B4, which is also connected to the IP address of the router port of the B network segment we set to B5, the structure is shown in Figure 1.
figure 1
In such a simple network, there are two different network segments, and if the A1 user in the A network segment wants to send a data to B network segment, there is a router very simple.
First, the A1 user is ready to send the transmitted data and send packets, and send all nodes of the same network segment through the hub or switch broadcast in the form of a data frame (the hub is taking the broadcast mode, and the switch cannot recognize this address. Take a broadcast mode), the router after listening to the data frame sent by A1, analyzing the IP address information of the destination node (the router is always analyzed after obtaining the packet). It is not known that the data frame is not received, and the network ID number of the receiving node is similar to the network ID number of the B5 port according to its routing table analysis, and the A5 port of the router directly transmits the data frame. Give the router B5 port. The B5 port determines the final destination node B2 according to the host ID number in the destination node IP address information in the data frame, and then transmits the data to the node B2. Such a complete data frame is completed, and the data is also correct and successfully reaches the destination node.
Of course, it is actually a very simple network, and the function of the router cannot be fundamentally reflected. Generally, a network will connect to other network segments or networks at the same time, just like Figure 2, A, B , C, D four networks are connected together via the router.
figure 2
Now let's take a look at how the router is in the network environment in Figure 2 to exert its route, data forwarding. We also need to assume that there are not many IP address assignments of all network users, Figure 2 has been marked. The steps of signal delivery are as follows:
Step 1: User A1 Sends the address C3 of the destination user C3, along with the data information in the form of a data frame to broadcast all nodes in the same network in the form of a network, when the router A5 port detects this address, Analysis learns that the originator node is not this network segment, it requires routing forwarding, receives the data frame.
Step 2: After receiving the data frame of the user A1, the router A port is received, first remove the IP address of the destination user C3, and calculate the best path to the user C3 according to the routing table. Because the network ID number of the C3 is known from the analysis, the C5 port directly to the router directly to the router is the best passage of the signal transmission. Step 3: The router's C5 port retrieves the IP address of the destination user C3, finds the host ID number in the IP address of the C3. If there is a switch in the network, you can send it to the switch, and it is found according to the MAC address table. Specific network node position; if there is no switch device, the data frame is sent directly to the user C3 according to the host ID in its IP address, so a complete data communication forwarding process is also completed.
It can be seen from the above, regardless of the network, the workforce work is in such steps, so the working principle of the entire router is similar. Of course, in the actual network, it is much more complicated in Figure 2, and the actual steps are not as simple as the above, but the total process is like this.