Routers are one of the most important devices in any computer network. By definition, it is used to connect multiple networks and act as an interface between the networks. They also serve as bridges, which allow all individual messages inside a network to reach their destination paths quickly and accurately without wasting precious bandwidth.
Routers connect traffic from one source in a network to another. Routers allow traffic to be directed according to predetermined rules and make filtering possible. These routing functions help reduce congestion and lag caused by voluminous traffic while enhancing network security.
Routers can be either internal or external devices depending on their location within the network. An internal router works right within your LAN while an external router sits outside your LAN usually at the point where it connects to another LAN or wide area network (WAN). In addition, you can find two types of external routers: the gateway router and remote access server/router.
What are the two main functions routers perform in a network?
The two main functions a router performs in a network are:
- The transferring of data packets between networks.
- To direct traffic to the right network interface card for further routing within the destination computer or device being connected to.
For example, when you type an Internet address into your browser and hit enter, your computer sends a packet of information through your modem to your Internet Service Provider’s (ISP) router. The router takes that information and looks at the destination address, let’s say google.com. Then, it gets a list of all of its available connections for reaching google.com. It looks through them and chooses the best one from the pool which is usually the fastest or the cheapest route. It sends the packet through that connection and then gets information back from it, where it should send the request next.
Now, let’s say you’re on Comcast and you want to visit google.com. You type in http://www.google.com/. Your computer sends that IP address to your modem which sends a signal out onto the cable to your ISP’s router. Your modem then receives an acknowledgement from the connection and sends it over to you. So at this point, your computer will be expecting a packet of information with all of google.com’s website content on it from that router.
The router in turn takes the packet from Google and looks at its destination address. It then looks at the next-hop in its routing table, which is your modem’s connection to the ISP. So it sends the packet through that. Your modem receives the packet and hands it off to you. You are now looking at google.com.
Now let’s say you want to visit http://www.facebook.com/ instead. That’s easy, you just type it in like before. But then the computer is going to send that request packet to your ISP’s router which will do all of the same stuff as before but send it to a different connection within its network. The router will choose a different path for efficient routing. For example, let’s say Facebook has a deal with your ISP and the router knows that if it sends packets to the connection that heads to Facebook’s servers, then it will be able to save money.
So when you type in http://www.facebook.com/, the router looks at facebook.com’s IP address and sees that it is directly connected to another network. Therefore, it sends the packet straight to it, and then it sends a confirmation back to you. Now you have Facebook loaded up in your browser!
What if you typed in google.com and instead of loading up Google with your IP address, it tried to connect locally by asking all of the connected devices around on your network? The router would look at its routing table, see that it was connected to a local network, and send the packet directly to your computer. Your computer doesn’t have an internet connection at this point though, so the packet would go nowhere. The router would then resend the packet through its default gateway, which is usually your modem, onto its ISP’s network as before.
Types of Routing
To understand further how a router works, it’s important to first understand the different types of routers and their functions in networks.
1) Source Routing – This function allows routers to route source addresses of IP packets from a particular host or network to its next hop, which is typically the exit point on an internetwork. For example, when an internal host wants to send packets outside the corporate LAN for access via another router, this feature makes sure that packets from an unknown external address will be routed back into the internal network via another gateway before exiting the LAN. While source routing was used more frequently by commercial systems in WAN environments as part of security measures such as firewalls, it is now rarely used.
2) Filtering/Forwarding – Routers forward packets using rules called forwarding information base (FIB). These rules are created by software and hardware depending on how you operate them. While the router works primarily at Layer 3 of the OSI reference model, which is also known as the Network layer, they can also be configured to work at higher layers of the OSI model such as Transport or Session layers. A common example for Router filtering/forwarding would be firewall configuration where a router is configured with rules that allow only certain hosts to access the Internet.
3) Routing Information Protocol (RIP) – This protocol implements an internal gateway host, which functions as a server by keeping track of all routers in an internetwork and then sending them routing updates periodically. RIP was first developed for IP networks but has since been extended to be used in other networks such as AppleTalk.
4) Address Resolution Protocol (ARP) – This protocol is used by hosts that connect on a LAN to determine the Ethernet addresses of hosts whose IP addresses are not available. The process involves broadcasting ARP request packets on the network and waiting until someone responds with an ARP reply packet containing the requested information, which will then be stored in a local cache for later use.
5) Open Shortest Path First (OSPF)/Enhanced Interior Gateway Routing Protocol (EIGRP)- These two protocols control how routers exchange their routing information across a network or area that is identified by the network’s area ID. They are both based on link-state routing protocols, which means each router within that area must know about other routers, including their location and physical links they use to reach one another.
6) Inter-Area Routing – This is a newer version of OSPF used in large internetworks and combines the advantages of an Internet Protocol (IP)-based network with those of OSI connectionless network services while also overcoming their limitations. The main advantage it offers is a solution for IP packet delivery problems over extended networks where the source host cannot always depend on receiving the acknowledgement packets when sending data due to issues such as delayed timeouts or congestion. For this reason, you need only one protocol running throughout your network to deliver data from one end of the internetwork to the other.
7) Multi-Protocol Label Switching (MPLS)-MPLS is a functional label switching and routing protocol that determines how packets are routed through an MPLS tunnel. It handles and controls traffic based on its priority label rather than using any specific routing table information. Packets with different labels are directly switched by router hardware modules instead of being routed via CPU processing, which allows routers to forward IP packets much faster.
What is the difference between a router and a switch?
Routers, also known as gateways, are devices that forward data packets to another specified network. These devices can process the data based on information in the packet such as destination IP address. Routers do not typically forward broadcasts or multicasts. A switch is a device that only forwards packets to intended recipients on its port. The switch does not read the information in the packet like a router but instead filters it by learning MAC addresses via Address Resolution Protocol (ARP). When an unknown device sends out an ARP request for its own MAC address, the switch will respond with its MAC address. If both sender and receiver are on this same Ethernet LAN segment, then no other forwarding action is required.
A good analogy of a router and switch is to imagine sending an email from one office (router) to another (switch). If the sender puts the wrong address or no address at all in the ‘to’ field then it will be returned with an error message. When a router receives a packet with invalid information such as destination IP address, it processes this information and sends back an ICMP Destination Unreachable-Host unreachable. This is like when someone puts just a room number instead of the full address on an envelope and it gets returned to him/her. The router normally has multiple NIC ports that can connect different networks, such as Ethernet LAN segments. So if someone wants to send a packet to a certain device he/she has two options:
- Send it directly to that device if the devices are connected via a shared network.
- Use the router as a gateway and send it to that desired destination’s MAC address, which is associated with the IP address.
Routers are more reliable when compared to switches because routers can process data while switches just forward packets based on MAC addresses learned from ARP.
While switches do not perform any type of processing on data like routing does, they can support multi-VLAN functionality by filtering and forwarding traffic from one VLAN domain to another. For example, in an office building where there are multiple offices in different areas but all using the same switch for internet access. The switch can be configured to send data packets from one VLAN domain to another based on IP address or any other information in the packet.
In summary, routers are used to transfer information between different networks while switches forward traffic only between devices connected to its ports. As a result, switches do not process data like routing does but instead only forwards it based on MAC addresses learned by Address Resolution Protocol (ARP). Understanding these concepts will help every network administrator install and maintain the infrastructure more efficiently.