Networking Primer – Part 5.3: Network Layer – IP Routing

Previous: Networking Primer – Part 5.2: Network Layer – DNS and DHCP

Up until this point, all of the layers, addresses and other attributes we have discussed have conceptually existed inside either the source or destination node.  We now need a mechanism for physically moving the data from point A and B.  While it is possible and would provide a very simple solution to delivering data, having a single connection between each source and destination node isn’t feasible.  This might be appropriate for a test system in a lab where we could use a cross-over cable to connect two computers together, but we would face insurmountable challenges if we tried to connect the billions of devices in the world together with one-to-one connections.  We need to split down our global network into smaller interconnect pieces and it is at this point we introduce additional devices outside of the nodes that will be responsible for routing the data between source and destination. These additional devices are very aptly named “Routers”.

In reality the internet is a huge complex and organic network that spans the globe like a gigantic spiderweb. While it would be interesting to dig into the internet in great depth, we’ll stay with our theme of simplicity.

Map of The Internet

Map of the Entire Internet 2014 – Source :

The Default Gateway

In most small to medium-sized environments there will be a single router that is responsible for taking packets destined for external nodes and routing them accordingly. If the source and destination nodes are inside the same network, then there is no need for a router to be involved as the nodes will usually be connected to the same physical media, have access to the same broadcast domain and can communicate directly.  If the destination node is outside of my network, my source node will automatically send it to my Default Gateway, which is the router that will forward it on towards the external destination.

A Router is essentially just another computer that sits on its own IP address in the network. Rather than having a server or desktop operating system installed, it has a stripped down specialised operating that is optimised for the processes required for routing.  If you look underneath the CLI (command line interface) for the device, you will find that the operating system is most likely a descendant of UNIX or Linux, that has been tailored for this specific purpose.  Traditionally, these devices were built on custom hardware, with custom chipsets designed to perform with rapid speed in mind. This is something that is changing. With the continued exponential performance increases in commodity x86 hardware, the cost/benefit ratio of using custom hardware versus decoupled software backed by commodity x86 servers no longer stacks up in custom hardware’s favour. I’ll address this in more depth in future posts.

The nodes in our network are aware of the default gateway, as they the default gateway address is either configured manually or provided by the DHCP server at network configuration time.  On Windows, the Default Gateway can be identified using the IPCONFIG command:

Default Gateway Highlight

When the default gateway receives our packet, it examines the destination IP address, performs a lookup in it’s routing table to find where to send it and forwards the packet onward to the next router in the journey.  It’s important to note here that the Router might not necessary know the final router’s destination address, it simply knows the address of the next hop or step to take.  The same process happens at each decision point (router) in the journey, until the packet finally reaches it’s end destination. This being the router that is responsible for (has authority over) the network where the destination node is hosted.

How do Routers Know Where to Route?

While it is possible to manually edit the routing table by adding static routes for the next hop of known destinations, routers are thankfully much more intelligent. There are a number of protocols which routers can implement, so that they may automatically discover and share route information. This makes networks very flexible and also able to adapt quickly to change. These protocols are sub-divided into two groups, IGPs (Interior Gateway Protocols) and EGPs (Exterior Gateway Protocols).  IGPs are used in larger environments where an organisation might have multiple routers and many nodes with multiple geographical or logical segmentations. One such protocol is RIP (Routing Information Protocol). EGPs are used at the border between autonomous systems (i.e. at the gateway between networks that are controlled by different entities). BGP (Border Gateway Protocol) is an example of an EGP.

Additional Tags

It is worth mentioning at this point that in addition to simple packet forwarding, modern routers also give us some extra functionality. One area where we can leverage the router is to enforce a certain level of service. We are able to flag each packet with a priority, this comes in the form of a DSCP (Differentiated Service Code Point) tag that we can place in the IP packet header. This can be used by routers that support QoS (Quality of Service) operations to prioritize packets. By default, higher priority packets will be sent first, and lower one’s queued in buffer space until there is bandwidth available to send them. If the buffer capacity fills, the router will simply discard lower priority packets that won’t fit in the buffer. This might sound like a very bad thing, but that’s where TCP would step in for important packets and resend them when the notification is received from the destination that packets haven’t arrived.

The Pirate Ship: In our pirate scenario, we’ll say that the Post Master in the mailroom of my office is my Default Router.  If I wanted to send my Lego package to another room in the building, I wouldn’t bother the Post Master, I’d simply use a different mechanism to get it to the other room which we’ll discuss in future posts. In this instance, I do want to send the package to an external address so the first point it will reach is the Post Master. Before sending the package to him, I have put some additional information on it, in the form of a marking that says “1st Class”. This would be analogous in the IP world of applying QoS tags to ensure the packet receives the appropriate level of service.

He reads the marking and ensure’s the package is dealt with before other lower priority packages. He knows that it needs to be posted at the local Post Office and sends his mailroom assistant on his bicycle to do this immediately. The local post office receives the package, examines the destination address and performs another routing action. As it’s going from Manchester to London, the next hop for the package is to send it to the North West UK Distribution Centre (NWUKDC). It’s placed in a van and sent the same day. Packages aren’t delivered directly from NWUKDC to locations in the South East. They are bulk transported via truck to the South East equivalent Distribution Centre, SEUKDC. From there my package is routed and sent by van to the local London Post office and then by Post Man to Rich’s office door. At each point in the journey the package is examined and sent to the next hop.

Rich’s room will now receive the package from his Postmaster, and he’ll unwrap it accordingly. This will happen for each piece of the ship and as it arrives, it will be reassembled into the full original form.

Next: Networking Primer – Part 6.1: Data Link Layer, Ethernet and MAC