Comment on How does data sent over the internet know where to go?

<- View Parent
Atemu@lemmy.ml ⁨3⁩ ⁨months⁩ ago

Your home router probably has no clue where that is, so it goes to its upstream router and asks if they know, this process repeats until one figures it out and you get a route.

That’s not how that works. The router merely sends the packet to the next directly connected router.

Let’s take a simplified example:

If you were in the middle of bumfuck nowhere, USA and wanted to send a packet to Kyouto, Japan, your router would send the packet to another router it’s connected to on the west coast. From your router’s perspective, that’s it; it just sends it over and never “thinks” about that packet again.
The router on the west coast receives the packet, looks at the headers, sees that its supposed to go to Japan and sends it over a link to Hawaii.
The router in Hawaii again looks at the packet, sees that it’s supposed to go to Japan and sends it over its link to Toukyou.
The router in Toukyou then sends it over its link to Kyouto and it’ll be locally routed further to the exact host from there but you get the idea.

This is generally how IP routing works; always one hop to the next.

What I haven’t explained is how your router knows that it can reach Kyouto via the west coast or how the west coast knows that it can reach Kyouto via Hawaii.
This is where routing protocols come in. You can look up how exactly these work in detail but what’s important is their purpose: Build “map” of the internet which you can look at to tell which way to send a packet at each intersection depending on its destination.

In operation, each router then simply looks at the one intersection it represents on the “map” and can then decide which way (link) to send each individual packet over.
The “map” (routing table) is continuously updated as conditions change.

Never at any point do routers establish a fixed route from one point to another or anything resembling a connection; the internet protocol is explicitly connectionless.

source
Sort:hotnewtop