This paper is participating in theNetwork protocols must be known and must be known”Essay campaign

From primitive tribes to the modern world, this article explains how routers find their way.

Router pathfinding

So, where does the routing information come from?

Host gateway

Run the route command to view the routing table of the host

# routeDestination Gateway Genmask Flags Metric Ref Use Iface default 9.134.64.1 0.0.0.0ug 0 0 0 eth1 9.0.0.0 9.134.64.1 255.0.0.0ug 0 0 0 eth1Copy the code

You can see that the gateway address here is 9.134.64.1, that is, the router will find the route through this IP address.

There are two main ways to configure a router.

  • Static configuration: Manually configure router routes
  • Dynamic algorithm: Calculates the route through the dynamic algorithm of the network
    • Dynamic algorithms are aware of networks
    • The complexity of the algorithm will increase the burden of the network
    • There can be turbulence and problems of consistency

Distance vectoralgorithm

Distance vector algorithm is one of the simplest routing algorithms in network layer.

Routers forward their entire routing table, which is a distance vector table, to neighboring routers. Each record records:

  • Destination router
  • distance
    • The shortest distance to the destination
  • Path through
    • Pathfinding is possible if the path is recorded, but not possible otherwise
    • How to jump from one to the other

A neighbor

Routers can use IP broadcast addresses to exchange information with their neighbors

  • Broadcast every 30 secondsUpdate your routing table
    • The broadcast address of the IP layer is 255.255.255.255.
  • In this way, neighbors can exchange messages every 30 seconds

Swap and learn

As shown in the figure, three nodes exchange information with their neighbors:

There are three nodes R0,R1 and R2 in the figure

  • Neighbors of R0 have R1,R2, and R0 get a distance vector like this [(R1, 1),(R2, 1)].
  • R0 tells R1 its distance direction meter
  • R1 is advertised with a new route (R2, 1), which does not exist in the routing table of this node. At this time, the local system adds this new route to obtain (R2, 2).
  • R2 in the same way

Similarly, R3,R4, and R5 exchange information in the same way

When the two subnets are connected, R0 and R3 are connected, as shown below:

Soon, R0 and R3 exchange information as adjacent nodes

  • Then the distance vector of R0 becomes [(R1, 1),(R2, 1),(R3, 1),(R4, 2),(R5, 2)].
    • Note that for the sake of simplicity, the exact path is not drawn
    • The path of R4, 2 is R3, which actually records R4, 2, R3.
  • R0 and R1By exchanging information, R1 updates its distance vector and obtains the global topology
    • (R0, R3, 2)
    • (R4, 3, R0 | R3), R0 | R3 said through the path, first after R0 again after arrived in R4 R3
  • R0 and R2 continue to exchange information, and R2 updates its distance vector and also gets the global topology
  • Same thing with R3’s original subnet

Choose a smaller distance

Suppose another router R6 is added at this time, and R6 is connected to R4 first, as shown in the left side of the figure below:

For R0:

  • R0 distance vector a new record (R6, 3, R3 | R4), said to the path the R6, first through the R3 and R4.

Then, suppose that a link is also added between R6 and R1, as shown on the right side of the figure above.

  • After two intervals, R0 gets itself from R1 to R6 can pass through R1 with a hop count of 2
  • This route has a shorter distance than route 3 currently in use
  • In this case, the existing route to that destination in the routing table is replaced with a new route that passes through the node that sent the routing information
  • The distance vector of R0 updates the record of R6 to (R6,2,R1).

R6,2,R1) will be selected after the host passes through R0 router to R6. This is how the host is routed.

Possible problems

At the beginning, although the dynamic algorithm can spontaneously perceive the network, it may have some problems, such as increasing the burden of the network. Moreover, in the distance vector algorithm, the most serious problem is turbulence and consistency.

turmoil

An example of turbulence, as you can see below,

If I break this link from R0 to R3, at this point if R0 needs to go to R5,

  • The distance between R0 and R5 before the break was 2, and it was forwarded by R3
  • When it disconnects from R3, R0 loses its route to R5
  • R0 may lose messages from R5 for a period of time until R6 tells R1, which then tells R0, with a delay of about 1 minute.
  • But after two exchange information, and can be found (R5, 5, R1 | R6 | R4 | R3), a distance of 5.

This sudden loss of contact is turbulence.

consistency

  • Hop count a lot

Here, at the extreme, there are 14 routers between R0 and R1,

  • Messages are exchanged once in 30s
  • R0If I leave,R1It takes 15*30s or 7.5 minutes to feel it
    • That’s how long it’s going to take.

It can be seen that

  • information-exchangingintervalThe longer it goes, the less consistent it gets
    • However, if the interval is too short, it will cause greater network burden.
  • The more hops,consistencyThe worse.
    • Consistency means that a message or event is synchronized across the network
  • So the general rule is that the maximum hop count is 15

conclusion

If the maximum number of hops specified in RIP is 15 or more, the destination network is considered unreachable. The root cause is that if the hop count becomes larger, consistency and volatility will increase, making the network almost unusable. Like the example above.

  • Therefore, distance vector algorithm is only suitable for small networks.

  • In large network environments, OSPF can solve the problem perfectly.