How do IP packets know what hoops/servers to go through to reach the intended recipient’s IP?

414 views

How do IP packets know what hoops/servers to go through to reach the intended recipient’s IP?

In: 2

6 Answers

Anonymous 0 Comments

Each device that forwards IP packets has tables containing subnet routes to a “next hop”. With the growth of the Internet, tables are now millions of routes. Each time a packet hits a router its referred to as a hop. Routers will keep referring to their routing tables until the destination is the last hop. Routers learn routes by talking to each other and distributing the information to each other about what networks/IPs they have destinations for. There are complex routing protocols in place to figure out which neighbor router is the next hop.

Anonymous 0 Comments

There are multiple protocols that decide this. I may be going too deep on this one. If so, apologies.

This is a pretty deep subject once you get down to the fine details. Much of the Network+ is about answering this question on different networks. Almost all answers are “in most cases”.

LANs tend to work by having a switch find out which computers have which IP addresses and also what their hardware MAC is (typically built into a network card). Once they know, everything sent to them with a particular IP address is sent to that MAC and only that MAC.

Next getting out of the LAN typically works by IP address. A router is told explicitly, “Only this list of IPs is on your network” via a process known as subnetting. A computer that wants to reach the Internet is told the router’s IP address when it is set up to connect to the Internet. It sends a packet to the “default gateway”, and the router at that gateway says, “Oh, this isn’t one of mine”, and sends it out into the larger network. This can be a fairly small network that is broken up into smaller networks, a large network, or even the Internet. There may be several layers of routers until you route all the way out of your company’s network.

Typically, at this point, you are now on the Internet. You are likely on a very big network belonging to an Internet Service Provider. These providers have a variety of protocols that they might use. If the IP address is one that they control, they know where to send your packet, but if they do not, they do know which other networks the packet should go to. Their internal protocols then tell them what route to take, whatever they use.

At the edge of the network you have connections to other networks, the totality of which is the Internet. These networks are huge, but they talk, and they know things like, “Massive ISP X has addresses between A and B. I can see that this packet has an IP address between A and B, so I will send it to Massive ISP X.”

This is oversimplified quite a bit, and possibly a bit inaccurate in some details, but that should give you a general idea. If you want to know in more depth, you are probably looking at an entire course to get a networking certification such as the Network+.

Edited to note at the top that this might be TMI.

Anonymous 0 Comments

They don’t. IP packets don’t “know” anything. The data in it has information of where it’s from and where it’s instructed to go. This comes from routing tables the host machine knows because a router told it so. Once it reaches the router, the router reframes the packet to to tell it where it *thinks* it should go. So on and so forth.

And I think your question is based on thinking a packet stays the same. It doesn’t. What routers do is strip part of it and add parts to get it to the next hop it needs to go. If it doesn’t know where to go, it asks it’s own network if they know and then pass it forward. Again, the cycle repeats.

If no one knows, that’s why you get error messages. There wasn’t a route or something along the way said “NOPE!”

Look up Layer 2 and Layer 3 networking for a more detailed explanation.

Anonymous 0 Comments

The same way your mailman knows how to get a letter from your house to your friends house across the country.

Your mailman (router/modem) picks the letter up and takes it to the facility he works for (a router between you and your ISP). The facility (another router between you and your ISP) reads the address and says “well that’s not an address I can deliver to, so I’m going to send it to this other facility (your ISP) that knows more addresses than I do”. The other facility (your ISP) gets it and says “Oh, I can’t deliver that address, but I can send it to this other facility (routers between your ISP and your friends ISP) that can get it to that address”. Repeat until it arrives at the local mail facility (your friends ISP) near your friend, who then puts it on a truck for one of their mailmen to deliver.

Anonymous 0 Comments

Routers have routes.
Your router at home has 2 routes.
“send everything that belongs to your own subnet to your own subnet”
And
“send everything else to your ISPs router” (default route)

The first router from your ISP (directly connected to yours) will probably know much more routes and know the routes to your neighbors directly. However if it doesn’t have a route to the destination IP it will use its default route again.

Good example is a physical trip with public transport.

Visit someone in your street? No worries, hop in the bus and leave it on the next stop. Bus driver will know that destination.

Vistit someone in your city? Hop in the bus. Bus driver does not know your destination, so you end up at the central bus station.
There you get the information to use a different bus to get to your destination.

Visit someone in a suburb in a different country?
Bus->train->plane->train->bus

And yes, you actually benefit from living next to an airport.

Anonymous 0 Comments

On the lowest levels, “hierarchical” routing is used. Computers, that are connected to the same router, get IP addresses with the same top digits and only differ in lower digits. So if the router sees, that the top digits don’t match – it knows that the destination is not in “his department” and sends it to a superior router. If the digits match – then it just walks the list of subordinate IPs, until there is a match.

On the highest level, a different approach is used. All top routers have a list of other top routers. They also have a map of the Internet, which tells how those top routers are connected to each other, the speed of the connection, etc. They first pick a router that is servicing the destination (by comparing the top digits of IP with a list), then they use a map to plot the best path, and then send.

The map of the Internet is updated automatically. When a new top router joins, it announces itself to the neighbors. The neighbors then tell their neighbors, and so on. When some router disconnects, its neighbors notice and report to others.