1

So I have been reading a bit about networking, and I am a bit confused about what exactly happens after domain name resolutions.

Lets say I do a get request to "some.website.com". First, my request goes to my ISP; my ISP then checks in their cached DNS; The request goes all the way to the root server; the name server, the A records ... (I may have messed up some steps in the DNS, I am still learning, but I got the general idea their). Finally, the name is resolved. We have found the IP for the site to be x.x.x.x. What happens then? How does my computer and x.x.x.x know how to talk to each other? If I use a human messengers analogy, I would tell a person to go get me a package, and I would give him the address of the location and a map (he probably already have one).

When it comes to the computers, the address would be the IP. Knowing the IP, however, doesn't exactly tell me where to find that computer (how to get to it?) or does it? So my question is after the IP is found, how do the two computers find a route to communicate to each other? what is the analogy for the map?

I have a guess, so what I would imagine is, my computer would ask my ISP, if he knows anyone with x.x.x.x IP, my ISP does the same with other connected devices and then the devices do the same until they are an ending node (have no more connection except the one they are talking to) or x.x.x.x themselves. If they are an ending node, the path taken to reach their would be considered a failure, but if they lead to x.x.x.x then they will be considered as a possible way to communicate with my computer. Out of those possible paths the shortest would be the one that found x.x.x.x first and that would be used until a node in between breaks.But this sounds a very slow algorithm and one that would get even get slower as more nodes are added to the system. (Is this close to the right way or very far?)

1
  • Removed the off-topic request for resources. – Ron Maupin Apr 8 at 19:57
1

How does my computer and x.x.x.x know how to talk to each other?

They don't really. But they know who to ask.

Routing is a collective effort. Most routers gateways only know a small number of other routes and gateways. Only few routers need to know all routes.

A greatly simplified view:

  • Your computer sees by the destination IP that the destination is remote, so a gateway is required. It only knows your edge router as the default gateway, so the packet goes there.
  • Your edge router just has a single default route to your ISP, so the packet continues there.
  • Now, your ISP router has knows all the route and a number of gateways. It selects the best one and forwards the packet there.
  • The routing process continues until the destination is reached. The gateways on the last hops usually only need to know very few routes again.

These are all the mechanisms required. The reverse path works pretty much the same way.

In practice, there are a few more routers involved and a packet often doesn't just go from the source ISP to the destination one but may cross a few others (carriers). Your ISP likely uses more than a single core router and there may be multiple routers in your network as well.

3
  • Thanks, the kind of "my level" answer I was looking for, just one more quick question? How does a gateway go about choosing the next best router. If ip's were geographical information i would assume they would choose the one closest to them in the direction of the destination, but how is this done in this case? – EHM Apr 8 at 20:45
  • 1
    @EHM "If ip's were geographical information i would assume they would choose the one closest to them in the direction of the destination, but how is this done in this case?" Not geographical, but based on the routing table. In almost all cases, there is a single path to a destination network in the router's forwarding table. – Ron Maupin Apr 8 at 23:37
  • @EHM A router uses its routing table to choose the next hop. The routing table is sorted by prefix length (more specific routes have a longer prefix) and entries may additional use metrics, cost or logical distance values. Common prefixes include 0.0.0.0/0 for the default route (most unspecific, matches everything) or 192.168.0.0./24 for a locally attached, private network. – Zac67 Apr 9 at 6:21
2

How does my computer and x.x.x.x know how to talk to each other? If I use a human messengers analogy, I would tell a person to go get me a package, and I would give him the address of the location and a map (he probably already have one).

Exactly, an IP packet has both the source and destination IP addresses on it, much like the envelope of a letter.

You host will compare the destination IP address to its configured network to see if the destination is local. If so, it creates a frame containing the IP packet destined directly to the local destination. If the destination IP address is on a different network, it creates a frame destined to its configured gateway (router). Then it sends the frame out the network interface.

A router will strip off the frame, inspect the destination IP address on the packet, compare it to its routing table, and forward it creating a new frame for the next interface network, or drop it if no routing table match is found. The same thing happens at each router hop until the destination network, where the destination host gets the packet.

The destination host gets the source address from the packet header and uses that as the destination for any reply.

2
  • "...compare it to its routing table, and forward it...", how does it know to which next interface to send to from the routing table? I don't exactly know what that is but I would assume it is a big list. How can you tell which address in the table will lead to a dead end and which one to the destination ip. – EHM Apr 8 at 20:49
  • The routing table gives the next hop address, and the next hop will be on a network directly attached to an interface, so it knows which interface to use. – Ron Maupin Apr 8 at 21:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.