The Internet: Routing Algorithms
The Internet: Routing Algorithms
Being stuck in traffic is squarely on the list of things that Anna Kendrick would rather do than spend a summer in Ohio…but not by much. Sure, that highway might be the shortest route, but the hours of pain spent listening to the same songs cycle through the radio station as you move a foot an hour? That can't be the best way to get home. Sometimes you have to wind your way through indirect side-roads to actually get anywhere.
Routers—the machines that send your information across the web—get this too (minus the show tunes, of course).
With the responsibility of sending billions of peoples’ information between computers on their tiny metal frames, routers need to rely on a specific type of algorithm (a set of steps that go from a start state to an end state) to get the job done. Those algorithms are called—wait for it—routing algorithms to figure out the best path to get from one computer to another. Usually, that best path is going to be the cheapest path in terms of the number of pit stops (or "hops") to other routers it takes to get to the right router.
Global Routing
In global routing and link state algorithms, the routers start by all exchanging IP addresses with nearby routers through a super-special packet handshake. Once they know all the nearby addresses, routers will send "echo packets" to determine how long it takes to send data to any other router they know, and then gossip about the time difference to all the other routers so that everyone knows how well the network is doing.
Once all those relative distances are found, the routers use another algorithm (like the Dijkstra shortest path algorithm) to figure out which routers to hop from to get to the destination router the fastest.
Decentralized Routing
Then there's decentralized routing or distance vector algorithms. Those work a bit differently. In this case, if the routers were people (which we've been claiming for the last few paragraphs, TBH) the routers with these algorithms are the Type A, spreadsheet-loving people who make great accountants. Every single router on the network takes their best route findings and makes a table out of all the data.
In order to figure out best distances, the routers first mark their tables with the "weight" of the paths (a number determining how easy or hard it is to take that path) to their directly connected neighbors. Once they've got those numbers, they pass along their tables to their neighbors, who send back their routing tables. When enough routers do that, every router can fill in the weight across every path on the network.
Wow, that's making our head spin.
This system sounds like the perfect utopia for the list-makers, right? In a small system, sure, but in a big one involving millions of routers, that's a lot of information to hold at once. Instead, you'll need something more like hierarchical routing, which keeps routers from needing to build up information between all routers on the network. In this kind of algorithm, the network combines routers into larger groups and uses the distance vector algorithm to figure out the weights of paths between bigger regions.
It's like when you want to mail your pen pal Sabina in Azerbaijan a banana because…maybe you think Azerbaijan doesn't have bananas, or something like that. When the Post Office looks at it, they're probably going to say,
- "Will this banana even be edible by the time it gets to Sabina?"
- "Azerbaijan. That's in Asia."
They aren't going to try and find Sabina right away because they're too far away from her to know exactly where she lives. Instead, they'll send it to Asia, or maybe to the Baltic States. Once it's there, someone else can figure out the exact city or town, and then Sabina's exact address. The banana might be brown, but it'll get to her with some regionalization of points.
The same thing happens with routers. Instead of looking for a router in a haystack, they'll regionalize to find about where the file needs to go before splitting hairs about the exact router it needs to end up at.
Routers inside specific regions just have to keep tables with the weights of paths between themselves. All of those routers then just need a single given path to each neighboring region instead of every other individual router.
How do you like them bananas?