What is a Router?
A Router, much like a switch, is a piece of network hardware that 'routes' data across networks and the internet, hence its name. It is responsible for sending packets of data across a network, it does this by forwarding the packets between multiple routers using a routing protocol. Generally, a router is connected to multiple data lines, and when a router receives inbound data, it reads the header of the data packet. This contains the ultimate destination of the data, and then using a routing table, calculates the best route for the packet to take based on the information stored in its routing table. This occurs at every router between the original sender and the destination router.
The most common type of router is the Small Office/Home Office (SOHO) router, typically used by Internet Service Providers (ISP's) to connect homes and businesses to the internet. Additionally, although a router is a physical hardware device, it does have a range of software capabilities, these are mainly what define a router compared to a switch. Routers are a Layer 3 (Network layer) device, this refers to the Open Systems Interconnection (OSI) model. In the OSI model, this is the layer in which packet forwarding takes place, with the layer itself helping to forward data packets through millions of routers globally. While the OSI model is a fine and detailed structure it isn't followed to a tee, but generally routes forward data using the processes of Layer 3.
What is a routing table?
Every router uses an internal routing table to learn of other devices on a network or the internet, these are referred to as destinations. When data is sent from a router, it doesn't get sent directly from the sender to the receiver, instead routers use a data forwarding method by where each data packet is forwarded on from router to router. When the data reaches a router, it reads the embedded network information about the data stored in the header and from this learns of its ultimate destination. As mentioned routers simply forward data on, the router will then analyse its routing table and chooses which router will be the most direct or efficient router to move the data towards its destination. This process is repeated until the data eventually reaches its destination. Routers constantly share location information with each other, this helps to build the routing tables with new routes as well as identify destinations which routers cannot see. Routers have a limited range at which they can see other routers ('see' means directly communicate with, past a certain distance routers know of another routers location but must interact with it via another router located somewhere between them). Routers utilise this information and can forward data along a route, knowing that a router is in a certain location, even though it cannot see it. Using this, the initial router that has sent the data can relatively choose an efficient route.