The main role of a Router is to route data traffic towards its destination. To do this the router needs to keep track of where on the network different destinations are located. When the router receives traffic it will try to forward the traffic towards the destination.
A home router often performs very simple routing tasks. It simply doesn’t have many possible paths to choose from when it wants to forward traffic. It knows that a single local LAN network exists on the inside of the router. Thus every other network must be available on the outside internet. So unless the traffic is being sent to the local LAN, the router can safely assume that the traffic needs to be forwarded to the internet.
When two computers on the inside LAN are talking to each other, then the home router can pass the traffic on directly between those computers. But if a computer on the LAN tries to browse to a web page on the Internet, then the router must forward the traffic. It does so by sending the traffic through its WAN port towards the ISP. Once the traffic arrives at the ISP, their more powerful routers will take over responsibility for forwarding the traffic towards its destination.
The internet relies on routers and agreements
The internet is more or less just a bunch of routers that are interconnected with each other. Each internet service provider owns and operates their own set of routers. These routers all perform basically the same type of routing as a home router does, although they are typically much more powerful.
An ISP might operate a number of routers that connect end users to the internet. These routers are normally connected to even more powerful routers at central locations, where network traffic can be aggregated and handled more easily.
A core principle of the internet is that these different ISP’s want to be able to exchange traffic with one another. There are thousands of ISP’s over the world. Some ISP’s operate just locally. Others are international and operate global computer networks. But none of them can reach every customer on the internet by themselves. The ISP’s have to cooperate.
For that reason, ISP’s form agreements between each other. They agree to interconnect their networks and to exchange data traffic with one another. Some ISP’s choose to connect to just a handful of other ISP’s. Others might connect with tens or even hundreds of other ISP’s. This lets traffic from a customer who is connected to one ISP reach the web server of a company that uses another ISP on the opposite side of the world.
So the Internet isn’t really much more than a lot of interconnected routers which are owned by different ISP’s. A company that wants to run a web server will contact their ISP and ask for an Internet connection. They will then connect their web server to that internet connection. This is very similar to how home users lease internet connections from their local ISP to connect to the internet. What makes it all work are the interconnections between those internet service providers.
By understanding more about your home network you will also gain some understanding about how the Internet as a whole works. It’s basically the same thing, just on a larger scale!
Computers use IP addresses when they need to communicate with each other. IP addresses could be somewhat compared to what street addresses are used for in real life. Imagine a person who wants to send a letter to a friend. The sender must know the street address of the recipient and print it down on an envelope. Then the letter is put inside of the envelope.
The sender doesn’t have to know exactly where the recipient is located. The sender just has to knows the exact address of the recipient. A mailman will pick up the letter and bring it to a main sorting office once the letter has been dropped off at a post box.
The postal service will then take over responsibility for transporting the letter closer and closer to the recipient, until it is delivered to the correct address. The sender is effectively delegating responsibility for handling the letter to the postal service. The postal service in turn will transport the letter to its final destination through its chain of delivery.
In the picture below you can see that different parts of the address on the envelope have different importance at various stages of the delivery process. The bold part of the address is probably the most significant part of the address at each step of the delivery process.
How a letter is forwarded towards its destination
At the first post office the address on the envelope is investigated to see where the letter is being sent. If the recipient is far away, or perhaps even in another country, then the letter will first be sent to another central post office closer to the recipient.
The first sorting central might not even know exactly where the destination street address is located. But that is fine, because they don’t actually need to know! They just have to figure out which general direction the letter should be sent toward. At this stage of the delivery process the letter just needs to be sent closer towards its destination. It needs to end up in the correct country, region or city.
This process might be repeated one or multiple times. But the detailed address information gets increasingly important as the letter gets closer to its final destination. When the letter eventually ends up in a main sorting office in the right city, that sorting office will have to give the letter to the correct mail delivery office based on the postal code. Finally the letter is handed over to a mailman who knows exactly where the final destination is. That mailman delivers the letter to the recipient.
Routing is similar to post delivery
The mail sorting offices in the example above are represented in the world of computer networks by routers. A home router that is sending out traffic to the Internet doesn’t have to know exactly where www.homenethowto.com is located. All it needs to know is that the general direction it needs to send the traffic towards is the outside Internet connection. Because that is where all networks except for the inside LAN network are located.
Then the task of sending the traffic towards the destination is delegated to the ISP router that the home router is connected to. The ISP router will also look at the traffic without knowing exactly where the destination is. But it will have more detailed knowledge than the home router. ISP routers might also have multiple possible paths to choose from when it wants to forward network traffic. The same destination could often be reached via different paths across the internet.
The computer traffic is sent or routed over the Internet closer and closer to its destination via various ISPs’ routers. Each router will look at the destination address of the traffic and will decide how the traffic should be forwarded. As the network traffic closes in on the destination the routers will have more detailed knowledge about where the destination is located. Eventually the traffic will end up at a router that has a direct connection to the destination, which could be a web server or similar. That last router in the chain will then deliver the traffic to the web server.