Tuesday, March 31, 2020

Static Routing

When two hosts on the same LAN want to communicate, it is quite straightforward for them to find each other: simply send out an ARP message, get the other host's MAC address, and be done with it.  But when the second host is not local, things become a little complicated.

In order to get two or more LANs to communicate with each other or one another, there needs to be an intermediary router.  The purpose of the router is to know the topology of multiple networks.  When you want your host to communicate with a host on another network, your machine will set the destination IP as the host on the other network, but the destination MAC address will be for the router.  This allows the router to receive the packet and examine the destination IP, and since it knows that IP is on the other network, it will forward the packet.


The router must know what networks are plugged into it.  This information is called a "routing table".  When the router is manually informed about what paths it can take, the table is called static, thus the term "static routing".  Once routes are plugged into the routing table by the network administrator manually, they do not get changed until the next administrator comes back and changes them.

Routing tables:
Routing tables are lists of network addresses, netmasks, and destination interfaces.  Let us consider the below diagram in our example.



When a packet arrives at a router that has a routing table like this, it will go through the list of routes and apply each netmask to the destination IP address.  If the resulting network address is equal to the network address in the table, the router knows to forward the packet on to that interface.

Let us say that from Node N1, you run the command:

# scp /export/home/bigfile.tar N9:/export/home

The router receives a packet on Port 7 with the destination IP address set to N9.  Assume that the IP address of N9 is 10.145.75.53   .  The first table entry has the netmask 255.255.254.0  .  When this netmask is applied to 10.145.75.53, the result is not 10.145.75.0  so the router moves on to the second entry.  Like the first table entry, this route has the netmask 255.255.254.0  .  The router will apply this to 10.145.75.53 and find that the resulting network address is not 10.145.75.0  .  So the router moves to the third entry in the routing table.  This route has the netmask 255.255.254.0  .  The router will apply this to 10.145.75.53 and find that the resulting network address is equal to 10.145.75.0  .  So now the appropriate route is found.  The packet is forwarded through Port 31 to the switch that is on the 10.145.75.0 network.

Run a traceroute and see the results:
N1: / >
N1: / > traceroute N9
traceroute to N9 (10.145.75.53), 30 hops max, 40 byte packets
 1  router.us.company.com (10.145.71.1)  0.567 ms  0.362 ms  0.341 ms
 2  N9.us.company.com (10.145.75.53)  0.268 ms  0.174 ms  0.170 ms
N1: / >
N1: / >


If a packet arrives at the router and does not match the first four routes (in our example), it will match the default case.  In our diagram routing table, this will cause the packet to be forwarded to Port 49.  This will probably be a gateway/uplink to the company corporate network.

Limitations of Static Routing:
Static routing is useful when we have only a handful of networks that need to communicate with one another and they are not going to change often.

There are limitations to this technique of manually updating the routing table.  You are required to update all of your routers with the new information whenever you make a network change.  Although this is usually easy to do in a small network, there is room for human error.  Furthermore, as your network grows and more routes get added, it is very likely that the routing table will get complicated to manage this way.

A second significant limitation is that the time it takes the router to process a packet is almost proportional to the number of routes present.  With only three or four routes it is not a problem.  But as you start getting into dozens of routes, the overhead becomes apparent.

In view of the above limitations it is best to use static routes only in small networks.

No comments:

Post a Comment