Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Lets say I am connecting to 64.34.119.12. How does the network know where to send the traffic?

I know there are chucks of IP addresses given to ISPs, but how does the internet manage getting the traffic from anywhere in the world to the correct destination network and IP address?

share|improve this question

closed as not constructive by John Gardeniers, Greg Askew, HopelessN00b, mulaz, gWaldo Aug 20 '12 at 18:28

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

    
You can start reading at en.wikipedia.org/wiki/Routing#Multiple_agents. –  Shi Aug 19 '12 at 21:03

3 Answers 3

There are two basic scenarios-

1.) End host / stub network (i.e. edge of the internet) - These entities know that a packet is either delivered locally or is sent to a default gateway. This determination is made by the IP address of the transmitting device and its subnet mask.

2.) Router with full view/default-free - A router receiving full routes (generally via BGP) has a database of publicly routed subnets. Your 64.34.119.x network may be part of a larger summary route. The router in question finds the shortest match (i.e. longest subnet masks) between the destination of the packet and these locally received subnets. This route will have a corresponding next-hop - the next router to which the packet must be sent. This next-hop router performs the same look-up and forwarding, and so on, until the packet reaches a router with said subnet locally connected (most likely something like #1).

Note that there is little or no knowledge of the intervening network(s) between the transmitter and the receiver. Each routing device knows only the next-hop to reach a given destination.

share|improve this answer

Every host has a routing table. It contains subnets, with network numbers and netmasks, and interfaces. For instance (simplified):

0.0.0.0/0     eth0  via 172.16.1.1
172.16.1.0/24 eth0  local
10.0.0.0/8    eth1  local
127.0.0.0/8   lo    local

The most specific one is used. So, for instance, the host 172.16.1.2 is on the 172.16.1.0/24 subnet, so the routing table tells us to just send it out eth0.

If it was 10.0.1.2, it would be on 10.0.0.0/8, so we would send it locally on eth1 (and not via a gateway, either).

If we were connecting to 4.2.2.1, the routing table has no route more specific than the default route (0.0.0.0/0), so it sends it out via the default gateway (172.16.1.1), which in turn will pass it on using its routing table (this is called a hop). Eventually, a router will be found that has a local route for 4.2.2.1, and then the packet will reach its destination.

That is a simplification, but it's basically how it works.

The network doesn't itself know or really do anything; hosts and routers do all the work ;)

On a router, the routing table is usually generated by using a routing protocol (such as BGP, or cisco's EIGRP) to discover adjacent routers, and the most efficient path is found by adding a metric (cost) to each route, so that the most specific route with the lowest cost is selected to pass the packet through.

If the packet ends up in a loop, or hits a dead end (gets routed to a router that has nowhere to send it), the packet will be dropped, and an ICMP failure message will sometimes be returned to you.

share|improve this answer

Essentially your packets are stamped with the source/ destination IP address and then wrapped in Layer 2 Frame data (Hardware addresses, etc). If your workstation does not have a route in it's routing table for the destination network (try typing route print in a windows workstation's cmd prompt to view the routing table), the packets will be sent to the default gateway set on the workstation. Note that the frame will use the MAC address of the gateway interface for the destination MAC. If no gateway is set, the packets/frames are dropped at the workstation.

The gateway (router) will receive the frame and see that the destination MAC is it's MAC and then read the packet data. It will look at the source and destination IP address and then look for a match for the destination IP network in it's routing table. There will be directly connected routes (networks to which the routers is directly connected), or remote routes.

If there is a match to a local network, the router will wrap the packet with new Frame data (source/ destination hardware addresses) and will send it out the associated interface for that network. The router will use the source MAC of the sending interface, and the destination MAC of the destination IP. If the router doesn't know the MAC address for the destination's IP, it will use ARP to learn it. The destination host would receive the frame, see the destination MAC is it's own, and then see that the packet destination IP is it's own and process the rest of the packet data.

If there match to a remote network, the router will wrap the packet with new Frame data and send it out associated interface for that network. The router will use the source MAC of the sending interface, and the destination MAC of the next hop router defined in the remote route. The matched remote network could be specifically defined (static), dynamically learned (routing protocols like RIP, OSPF, EIGRP, ISIS), or could be a "default route" (essentially setting a default gateway for the router). Any traffic destined for a network in the routing table would be sent to the destination IP defined in the default route. In this case, this process will continue to repeat until a router receives the packet that has a local route to the destination IP's network. At that point, the process for a local route above is used.

One key point to note in all this is that the source/ destination IP addresses do not change throughout this process, unless NAT is used. The Layer 2 frame data is what is changed at each hop.

If you want to get an idea of the routers that your packet hits before reaching the destination, you can use the tracert 64.34.119.12 on windows, or traceroute 64.34.119.12 on a linux box. Although, keep in mind that not all routers will respond with their information.

share|improve this answer

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