Monday, June 9, 2008

The Post Offices of the Networks

So, we now know that data is sent in packets and that the destination and source address is written in the headers.

In a normal worldly scenario, what happens to the letter which you had dropped in the mail box? It goes to your area post-office, there based on the destination address it is sent to either the City post office or if the destination address is within the area of the same post-office, it is delivered. In real world, we have a hierarchy of post-offices. City Post offices cover lot of area post offfices. Country post offices are used for sending international mails etc. Same structure is used for receiving the letter too. First it is delivered to the city post office, from where it is delivered to the area post office and finally those soothing words reach you.
Computer networks are similar. Just replace post-offices by what are called routers. And the basic operation is pretty much similar. The packet which you sent first reaches a router which is in-charge of your local area ( called Local Area Network or LAN ) . The router will decide where it should send the packet based on the destination address. Your LAN router will send it to either another router in the same hierarchy or to a router which is one level up in hierarchy. The interconection of these routers is what is referred to as the network topology, and these may vary based on the requirements.

So, lets get to some nitty-gritties now,some tech details. If it gets too geeky somewhere, apologies for that are tendered now itself :)
When a packet reaches a router, we have said that it decides where to send it based on the destination address. Just exactly how does it do that? The answer lies in what is called a routing table. Each router has a routing table. These routing table contains the information which is required to know where to send the packet. Each router is basically a machine with several network interfaces. A typical routing table entry looks like:
Destination Address Mask Gateway METRIC INTERFACE
Based on the Destination address, router decides what thru what interface should the packet be sent out. The information of which interface to send it out is equivalent to the information where to deliver the packet. Coz, once you decide the interface, you put the packet on-wire on that interface .If normal conditions prevail, then there will be something at the other end of the wire. So, whether you say that I have to send the packet to router B or that I have to send it out via interface IF1 ( which is connected to router B), you mean the same thing. In networking terminology, router B is called the nexthop and IF1 is called the outgoing interface.
So thats that about routing tables. Now, you will say: Hold your horses. Before you carry on, who will explain what do the other fields mean. Now, dont blame me for making it geeky. These are the meaning of the entries:
Destination Address and MASK together determine what is called the Destination Prefix. They define what is called a subnet. Destination Prefix and subnets are just a simple concept of aggregating toghether computers which are in the same network hierarchy. For eg, the state name can be considered as a network prefix. The letters destined for any city in the state have the same state name, thereby enabling post offices to send the packet to the correct state.
GATEWAY is simply the IP address of router B. METRIC is a admin-configurable value assigned to the link (wire) connecting our router to router B.
The above was the basics of the routing table. But any information will not appear by itself. SO, the next logical question is: Who Put it there ?

No comments: