What is routing?

The English name of the router is Router, which is “the tool to find the way”. Looking for what way? Find the way between various network nodes.

In other words, the router is like a transit station for express delivery. Packages will pass through one transit station and be sent from far away places to your neighborhood. The same is true for data packets.

A router is a hardware device that connects two networks. It undertakes the path-finding function and is the gate of the network. Therefore, the router is also called a gateway device (Gateway).

routing table

Routers, like switches, also have their own notebooks. This routing table records the routes to each network node, and records data sources, corresponding routing entries, and next hops.

The routing table is equivalent to the navigation of the router. The router only needs to follow the instructions of the routing table. Of course, the premise is that there is a routing entry matching the destination IP address of the packet in the routing table. The routing table will be updated periodically, and it will also be updated when the network topology changes, so there is no need to worry about going the wrong way.

The process of sending and receiving data packets by a router

When a router sends and receives packets, it will first check the routing table. If there is a match in the routing table, it will send the packet to the next hop. If there is no match, the packet is simply dropped and the host is told that the destination is unreachable.

Direct connection, static routing, dynamic routing

There are many sources for obtaining routing entries, such as direct connection, static routing and dynamic routing.

Direct connection, that is, the direct neighbor of the router. The router will know the neighbors by itself, and then record them.

Of course, you can also manually add the path to the destination network segment to the router, that is, a static route, which is suitable for scenarios with a relatively small network scale. But when the network topology changes, or the scale increases, the cost of configuration and maintenance will be high.

At this time, it is necessary to combine dynamic routing and let the router learn in a dynamic way. In large networks, this combination of dynamic and static routing is often used for deployment.

three-level addressing

Do you still remember the “two-layer addressing” explained in the last issue? Layer 2 addressing means that the switch performs addressing at the physical layer based on the MAC address.

Layer 3 addressing means that routers perform addressing at the network layer based on IP addresses.

Router Layer 3 Addressing Process

When the host wants to send data, it will first check whether the destination is on the same network segment as itself, and if it is on the same network segment, the switch will be forwarded at Layer 2.

As shown in the figure below, if PC1 wants to send data to PC2, it will be done through the switch.

If it is not in the same network segment, the host will send the data packet to its own router, and the router will query its own routing table according to the destination IP. If there is a matching entry, it will be handed over to the next hop, and if not, it will be discarded.

As shown in the figure below, PC1 wants to send data to PC3, and finds that PC3 is not in the same network segment as itself, it will send the data packet to router A, and then forward it to router B -> C according to the entry in the routing table, and finally pass through switch C Served on PC3.

wayfinding principle

Since the router is responsible for finding the way, which road leads to Rome, which road is the closest?

Source: Giphy

By default, route queries follow the longest match principle, that is, the longer and more accurate the mask, the router will choose that route first.

Then consider the path cost, such as bandwidth, administrative distance, metric, etc. That is, how much time and money it will take to go down this road. The vast majority of data communication behaviors are bidirectional. When considering traffic, you must also pay attention to the round-trip of traffic. If you go from this road, you have to come back from this road. When you come back, there is no way. This is not enough.

The behavior of routing query is hop-by-hop, and each router along the way to the target network must have routing information about the target network segment. Simply put, every time a packet passes through a router, the router tells it who the next hop is and which direction to go.

How to choose a router?

Several factors can be considered in router selection: bandwidth requirements/forwarding performance, number of ports, and number of machines.

For example, if you have gigabit broadband at home, the router must be a gigabit router, and it must also meet the performance of gigabit NAT forwarding. By the way, the optical modem provided by the operator has its own routing function. If there is no special requirement, it is generally enough for ordinary families.

In general home scenarios, routing ports are not used much and can be supplemented by switches. In most commercial scenarios, 4-12 ports are enough. If there are more, I believe that most enterprises will choose Layer 3 switches.

The capacity of the machine is a very important indicator. We generally consider concurrent users and the user’s business type.

Take UniFi’s gateway device as an example: USG can reach 100 concurrent, which is enough for ordinary households or small and micro enterprises; USG-Pro-4 can reach 1000 concurrent devices, which can basically meet the needs of small and medium-sized enterprises; if there are more For high demand, UDM-Pro can be used.

Editor: Huang Fei

Leave a Reply

Your email address will not be published.