Network Hardware - Routers and ARP
Routers
A router works much like a bridge to connect different networks together. However, a router is a great deal more intelligent and operates at the third layer of the OSI 7 layer model - the network layer. Recall that bridges operate at the data link layer. This means that bridges understand physical network addresses; i.e. MAC addresses. Routers can further inspect data packets to determine logical network addresses. The precise nature of a logical network address depends on the network protocols your network uses. Today, we most commonly use IP addresses for logical network addressing. Essentially, all this means is that a logical address, such as an IP address, can be mapped to a physical (MAC) address.
Let's take an example of an TCP/IP network:

Note that unlike the example illustrated in the discussion of bridges, this example depicts two separate IP networks (essentially two separate LANs) separated by a router, not simply two different segments of the same IP network.
(As a quick aside, all you need to know is that each node has a logical IP address, represented as a 32 bit number. Furthermore, each node has a subnetmask, which is also a 32 bit number. Each individual node must have a unique IP address. However, the value of the node's subnetmask defines whether the node is in the same IP network as another node. This is discussed in the IP addresses and subnetting section.)
Let's say that the IP address of Node 1 is 10.0.0.101 and it wants to talk to Node 2 which has an IP address of 10.0.0.102. So, Node 1 packages up the data it wishes to send to Node 2 in a packet which contains the source and destination IP addresses. However, Ethernet doesn't understand IP addresses, only MAC addresses. So, what actually happens is that Node 1 sends out a broadcast across the entire local network, saying "Hello. Who has an IP address of 10.0.0.102?"
This is called an ARP request, where ARP stands for address resolution protocol. A broadcast is achieved by sending out a frame with a destination MAC address of FF:FF:FF:FF:FF:FF, i.e. all bits set to 1.
All the nodes will receive this message, and all but Node 2 will discard the message. Node 2 receives the messages and recognises that it has the IP address matching that in the request. It then stores the source MAC address in that request, together with the source IP address in a table called its ARP cache. It then sends a response, an ARP reply, back to Node 1 (by specifying the MAC address of Node 1 in the response), saying "Hello, I have the IP address 10.0.0.102."
Node 1 receives this response, and stores the MAC address of Node 2 against the IP address of Node 2 in its own ARP cache. Subsequently, any messages destined for Node 2 from Node 1 can be addressed directly, by specifying the MAC address in the frame header.
But what happens when Node 1 tries to communicate with Node 3 which is in a different IP network? Let's say the IP address of Node 3 is 192.168.0.1. Node 1 looks at the destination IP address and determines that Node 3 must be on a different subnet. Thus, instead of sending an ARP request to determine the destination MAC address of Node 3, it instead sends a request to determine the destination MAC address of the local router (the default gateway), by specifying the router's IP address instead. (This assumes that Node 1 does not already have an entry for the router in its ARP cache.) All nodes except the router will discard this request.
Upon receiving an ARP response from the router, Node 1 stores the MAC address of the router against its IP address in its own ARP cache. Now things get more interesting. Node 1 still wishes to send data to Node 3, and it has the IP address of Node 3 but not its MAC address. So, Node 1 sends the data with Node 3's IP address, but with the MAC address of the router. The router then receives this data and can determine the MAC address of Node 3 by performing its own ARP request. Once the router has the MAC address of Node 3 (and thus stores the MAC address against the IP address in its routing table), it can modify the frame that was sent to it by Node 1. It modifies the destination MAC address in the frame to that of Node 3, and then forwards the frame onto Network 2. When Node 3 receives the frame, it believes it has come straight from Node 1.
Routers can actually do a lot more than this. Given multiple possibilities for reaching a destination (e.g. acrosss several different router permutations), routers have complex algorithms that allow them to permit the most efficient, or indeed, cost effective route. However, a discussion of how routers do this is beyond the scope of this section.
What's next
The next section takes a look at Broadband.
| Just Too Good Last updated: June, 2006 (DJL) |
Drop me a line