Network Routing

Avocado Aun
7 min readMay 21, 2020

We are better together

Where do I go next?

Introduction

This is not a story about relationship advice. But do you believe in Long Distance Relationship?

Well, thanks to the Internet; I do. You see, we can talks to anyone across the globe in seconds on the Internet despite being physically distanced. If you ask me, this is better than having someone next to you but is emotionally distanced. Under the hood, the Internet works because network routers are constantly working hard to forward our data (as packets) across the world.

So, what is the Internet? — in one line:

Internet is ‘a collection of routers connecting multiple networks together’ — Avocado, 2020

No. We can’t really touch it, we can’t really see it; but it just works (we call this the networking magic). You get a router from your ISP, connect your devices to it, and boom: Welcome to the Internet. If there is a profile picture for the Internet; I bet it will looks like this:

The Internet — the white dots represents routers that are connecting multiple networks

But does it really always just works?

For routers to communicate, route packets and synchronize with one another; they are several things that need to be configured. These configurations are transparent to end users; so that your iPhone can immediately connects to the WiFi without needing to configure your Access Point first. Routers configuration is mostly done by the network administrators for the core routers. Meanwhile, the home’s router is normally preconfigured by the ISP. So, routers do work out of the box (if pre-configured) but most of the time we want to get into it for further customization. In this story, we will outline the intuition of routing over several posts and then we show an example of how to configure a Cisco routers using command lines.

The Intuition of Network and Routing

Why are routers needed? — All the nodes on the Internet has an IP address. The IP address is used by machines to identify each other on the network uniquely. For host_A in LAN1 to talk to host_B in LAN2; the need router as the middleman to forwards their packets to the destination network. Router is a layer-3 network device; which deals with IP addresses.

To understand why we need routers, first we need to understand the concepts of networks. A computer network (also called LAN) is a collection of devices that connect to the same router. In your home; your mobile phone, smart TV, laptop all connects to the same router provided by your ISP — this formed the home network. In your office; your workstation, your printer, your projector all connects to the same office router — this formed the campus network or the enterprise network. The figure below shows four LANs and their respective network address.

Every network has one unique network address. This address made the network to be globally reachable from the other networks. For anyone in LAN1 to talk to LAN3; the edge router in LAN1 needs to know how to get to the edge router in LAN3 (routers are not shown in the figure).

The concept of Inter-Network Packet Forwarding

Let’s take a detour and think about how your parcels reach you when you shop online. Says, we bought a new Bose soundbar from Amazon. We need to provide name, shipping address and phone number for Amazon to ship the soundbar. The shipping job is assigned to DHL (because Tom Cruise works there). To ship this soundbar to our door; the courier company first check the area code of our address in the sorting hub. Then, the parcels are allocated to different riders that is in-charged of different delivery location. If the shipping address is in another country; the parcel would have to transit to the destination country on flight. On arrival, this parcel is ‘forwarded’ to the local courier company who is responsible for the last-mile delivery; which is to ship this parcel to your door based on your house address and number. Voila!

Surprisingly, network routing works in somewhat similar ways to the ‘logistic delivery system’ we’ve just discussed. We can simply imagine the ‘parcel’ as the ‘network packet’; the ‘area code’ as the ‘network address’ and the ‘courier’ as the ‘router’.

Router as the Middleman in between the Networks

Consider the simple network with 2 LANs. The network on the left (LAN1) has the NET_addr of 192.168.1.0/24; the network on the right (LAN2) has NET_addr of 10.10.1.0/24.

Enlarge to see the network clearly

Suppose that PC1 in LAN1 talks to PC2 in LAN2. For the packets to go from LAN1 to LAN2; they need router as the middleman to forward this packet. To do so, the router first needs to know where is PC2 located at (in other words, what is the network address of LAN2?).

PC1 (192.168.1.1) → Router → PC2(10.10.1.1)

When PC1 builds this packet; it use its own IP as the sourceIP and PC2 IP as the destination IP. The packet header looks like this:

The steps to send this packet from PC1 → PC2 is shown here:

(1) PC1 first checks if the destination is in the same LAN? Well, PC2 is not in the same LAN. So, PC1 would forward this packet to its router.

(2) When the packet arrived at the router, the router check the destination IP of the packet. Then, router calculate the network address of this IP. The destIP is 10.10.1.1; so the router calculates the network address as 10.10.1.0/24.

(3) The router check its routing table to find out how to reach PC2’s network; at the network address of 10.10.1.0/24. It found out that it should send the packet out to the link on the right based on the routing table.

(4) If there are other routers in between the path, these routers (core routers on the Internet) will continue forwarding this packet based on their respective routing table using the best path until this packet finally reaches the router of LAN2 (where PC2 is in it). So, we can trust that network packets would eventually find their way to the destination based on routers and routing protocols.

(5) When the packet arrived at LAN2’s router, it forwards the packet to the switch and switch continue to forward it back to PC2 based on the switch’s MAC table. In this case, LAN1 and LAN2 is connected to the same router. So, the router simply take a packet from one port and forwards it out to another port.

Here’s a video to illustrates what happens when PC1 pings PC2.

Note: in the example network, there is only 1 router connecting two LANs. We called this ‘directly connected’ networks. At this stage, no routing configuration is needed yet.

When is router needed?

One of the scariest message you can find on the machine sounds like this — ‘you are connected to the network, but no Internet’. This means that all your devices connected to the LAN can still communicate among each other within the LAN; but they can’t talk to anyone else on other networks (the Internet). So, now you know that you can still project your iPhone to your Smart TV even without the Internet? — that’s because your iPhone use the AirPlay2 protocol to stream the data to the TV through the router within the same LAN (not needing the Internet here).

So, do we always need a router? — the short answer is YES; because most servers of your favourite apps are located somewhere on the Internet. But if you are planning to isolate yourself in quest to find yourself; then you probably don’t need a router. Here’s a technical example showing us when a router is needed.

The first network (below) shows PC1 and PC2 having the same network address; in this case, we only need a switch to connect them.

The second network (below) shows the same PC1 and PC2; but this time they have different network address. Here, we need a router to connect them.

To recap, routing is just an act of forwarding packets from one hop to another, progressively until the packet reaches the edge router of the destination network. Just like the basketball players passing the ball from players to players before finally dunking it to the net.

Now that we’ve learnt about why we need routers on the Internet; next, we will find out when do we need routing, and if so, how can we configure routing on the routers.

Click on these links to get routed to other related stories on routing

Part 2: When to configure Routing?

Part 3: Distance Vector vs Link State Routing Protocols

Part 4: Static Routing vs Dynamic Routing

Part 5: Understanding Routing Table

Part 6: Configuring Simple Static Route

Part 7: Configuring Complex Static Route

Part 8: Configuring Dynamic Route (RIPv1)

Part 9: Configuring Default Route

--

--

Avocado Aun

I’m just a little boy, lost in the tech world. But remember, love is a riddle, and life with tech is more amazing than ever