- TCP/IP and IPX Routing Tutorial
Classed IP Addressing and the Use of ARP
Consider a small internalnetwork consisting of one Ethernet segment and three nodes. The IP network number of this Ethernet segment is 200.1.2. The host numbers for A, B, and C are 1, 2, and 3 respectively. These are Class C addresses, and therefore allow for up to 254 nodes on this network segment.
Each of these nodes have corresponding Ethernet addresses, which are six bytes long. They are normally written in hexadecimal form separated by dashes (02-FE-87-4A-8C-A9 for example).
In the diagram above and subsequent diagrams, we have emphasized the network number portion of the IP address by showing it in red.
Suppose that A wanted to send ato C for the first time, and that it knows C’s IP address. To send this packet over Ethernet, A would need to know C’s Ethernet address. The Address Resolution Protocol (ARP) is used for the dynamic discovery of these addresses .
ARP keeps an internal table of IP address and corresponding Ethernet address. When A attempts to send the IPdestined to C, the ARP module does a lookup in its table on C’s IP address and will discover no entry. ARP will then broadcast a special request packet over the Ethernet segment, which all nodes will receive. If the receiving node has the specified IP address, which in this case is C, it will return its Ethernet address in a reply packet back to A. Once A receives this reply packet, it updates its table and uses the Ethernet address to direct A’s packet to C. ARP table entries may be stored statically in some cases, or it keeps entries in its table until they are “stale” in which case they are flushed.
Consider now two separate Ethernet networks that are joined by a PC, C, acting as an IP router (for instance, if you have two Ethernet segments on your server).
Device C is acting as a router between these two networks. A router is a device that chooses different paths for the network packets, based on the addressing of the IP frame it is handling. Different routes connect to different networks. The router will have more than one address as each route is part of a different network.
Since there are two separate Ethernet segments, each network has its own Class C network number. This is necessary because the router must know which network interface to use to reach a specific node, and each interface is assigned a network number. If A wants to send ato E, it must first send it to C who can then forward the packet to E. This is accomplished by having A use C’s Ethernet address, but E’s IP address. C will receive a packet destined to E and will then forward it using E’s Ethernet address. These Ethernet addresses are obtained using ARP as described earlier.
If E was assigned the same network number as A, 200.1.2, A would then try to reach E in the same way it reached C in the previous example – by sending an ARP request and hoping for a reply. However, because E is on a different physical wire, it will never see the ARP request and so thecannot be delivered. By specifying that E is on a different network, the IP module in A will know that E cannot be reached without having it forwarded by some node on the same network as A.
Direct vs. Indirect Routing
Direct routing was observed in the first example when A communicated with C. It is also used in the last example for A to communicate with B. If thedoes not need to be forwarded, i.e. both the source and destination addresses have the same network number, direct routing is used.
Indirect routing is used when the network numbers of the source and destination do not match. This is the case where themust be forwarded by a node that knows how to reach the destination (a router).
In the last example, A wanted to send ato E. For A to know how to reach E, it must be given routing information that tells it who to send the packet to in order to reach E. This special node is the “ ” or router between the two networks. A Unix-style method for adding a routing entry to A is:
route add [destination_ip]  [metric]
Where the metric value is the number of hops to the destination. In this case,
route add 22.214.171.124 126.96.36.199 1
will tell A to use C as theto reach E. Similarly, for E to reach A,
route add 188.8.131.52 184.108.40.206 1
will be used to tell E to use C as theto reach A. It is necessary that C have two IP addresses – one for each network interface. This way, A knows from C’s IP address that it is on its own network, and similarly for E. Within C, the routing module will know from the network number of each interface which one to use for forwarding IP packets.
In most cases it will not be necessary to manually add this routing entry. It would normally be sufficient to set up C as the defaultfor all other nodes on both networks. The default gateway is the IP address of the machine to send all packets to that are not destined to a node on the directly-connected network. The routing table in the default gateway will be set up to forward the packets properly, which will be discussed in detail later.
Static vs. Dynamic Routing
Static routing is performed using a preconfigured routing table which remains in effect indefinitely, unless it is changed manually by the user. This is the most basic form of routing, and it usually requires that all machines have statically configured addresses, and definitely requires that all machines remain on their respective networks. Otherwise, the user must manually alter the routing tables on one or more machines to reflect the change in network topology or addressing. Usually at least one static entry exists for the network interface, and is normally created automatically when the interface is configured.
Dynamic routing uses special routing informationto automatically update the routing table with routes known by peer routers. These protocols are grouped according to whether they are Interior Protocols (IGPs) or Exterior Gateway Protocols. Interior gateway protocols are used to distribute routing information inside of an Autonomous System (AS). An AS is a set of routers inside the domain administered by one authority. Examples of interior gateway protocols are OSPF and RIP. Exterior gateway protocols are used for inter-AS routing, so that each AS may be aware of how to reach others throughout the Internet. Examples of exterior gateway protocols are EGP and BGP. See RFC 1716  for more information on IP router operations.
WANPIPE® is a network interface, and does not actually route packets according to IP address, or maintain IP routing information.routing between interfaces is accomplished by the protocol stack, which can send IP based dynamic routing over WANPIPE®. The information and protocols needed for dynamic routing are handled by the protocol stack, and not at the WANPIPE® level. In practice, it is almost always better to use explicit static routing table entries rather than relying on dynamic routing.