(This article is written for my classmates.)
As everyone knows, the internet is extremely big and it seamlessly connects every people, in the world. But there’s one question: how can the internet knows where to pass the data around? The answer to this problem is the router. The router, by definition, is a device that forwards data between computer networks. To understand what a router actually does, we need to have a basic understanding to the structures of the internet.
The internet is composed of many small networks joining together to form a large network. Different large networks then joining together to form the internet. You may see from the picture above, one of these small networks are called an Local Area Network (LAN) and they join up to form an Wide Area Network (WAN). When you need to connect to another computer (typically a server), your request needs to be sent to the server which may not be in the same LAN as you are in. Therefore, we need someone to help passing the data to another network. This is what a router does.
So, a router is needed to decide where should the data should go before it gets to the final destination. Inside a router, there will have a routing table containing all the information needed to determine the next destination of the data. The next destination may be another router (the data still not reach the target’s network) or the target. The router will determine the shortest path to the destination by the information given in the routing table. Usually, the routing table is configured by the ISP and is exchanged with other connecting routers via the Border Gateway Protocol (BGP).
(the traceroute to my webserver from my home)
There is a tool called traceroute to track the routers passed when you try to send data to a target. Usually, the router’s geographical location is revealed from its hostname. As seen in the diagram, the data passes through 10 routers before it reached the destination and my webserver is in Canada, as reflected by the hostnames of router 8 & 9.
But what about the routers we use in our home? Setting up that is only plugging in cables and switching that on without touching something like routing tables! Actually, these kind of home routers consists of different components fused together, typically a combination of router, hub and/or a wireless access point. These kind of home routers have a predefined routing table that routes all data to your ISP’s routers and the network inside the router is not publicly exposed.