A router makes it possible for devices to connect to the internet and share data. If you connect to the WiFi at home, in the office, or even at a coffee shop, you are using a router. A router passes information between one or more computer networks. It acts as a gateway, sitting between an internet connection harnessed by a modem, and a local network that devices use to communicate.
Once a unit of data or packet arrives at a router, the router identifies the packet’s destination and calculates the best way for it to get there. Kind of like a GPS, a router will compare the destination against a routing table or a set of rules for forwarding data and determine the best path of “hops” in the network for it to get there. The router also keeps track of which internet traffic goes to which device on a network. This is what prevents your emails or web searches from showing up on a coworker’s computer instead of your own. Routers can be physical, standalone devices, or virtual in which case the router is a software instance.
There can be different types of routers. But most of the routers do the function of passing data between Local Area Networks and Wide Area Networks. While LAN is specified as a small or local geographic region, WAN is spread across a large area and network of a vast geographic region. For the connection of a LAN to the internet or a WAN, a router needs to communicate with another device called a modem. And for that it can be done in two ways: wired and wireless router connections. Other than the wired and wireless types of routers, there are many other kinds of routers for specific functions like a core router, edge router, virtual router, etc.
*Must Read : The 7 Best Android Browsers of 2022
How Does the Router Work?
As you might be aware, bits are a form of language for machines and packets are a series of these bits that traverse the network. The mechanism via which these packets travel across the network is organized thanks to internet protocol, which is a set of common rules, structures, and descriptions. The more amount of information to be transmitted, the more amount of bits that need to be sent and more packets to be formed.
Now, what is so specific within an IP packet that allows routers to understand which way to route the information as bits?
Every device sending and receiving IP packets has its own unique address called simply, IP address. The aim of an IP address is very similar to a postal address – it locates the sender and receiver within the network.
How does a router know where to route the packet?
Routers have ports or more precisely interfaces that are interfacing with other network devices. Interfaces connect the links that are used in packet forwarding. Links can be cable, fiber, or even wireless.
When a packet is coming on an interface, the router needs to know which interface it has to use to send out the packet. The router checks this against the routing table which has entries related to each known destination. Each routing entry stores the destination address and address of the next device on the path called the next hop device. Now having the next hop address, the router can determine the outgoing interface and send the packet!