Multi-layer routing

by: burt rosenberg
at: university of miami

Classic A, B, C networking

In what is commonly known as TCP/IP there is a two-level routing scheme,

  1. Network delivery, on level 3.
  2. Local delivery, on level 2
The division between local and network, for classic state-full addressing is implicit in the bit pattern of the most significant bits of the 32 bit IP address. There are two reserved hosts. The "all one's" host means broadcast. All hosts on the network are to consider themselves the destination for this address. An example in class B would be 129.171.255.255.

The "all zero's" host means network. No host on the network is to consider themselves the destination of this address, and it refers to the network, not to any hosts. An example in class B would be 129.171.0.0.

      Most significant 4 bits of IP address    Numerical range
   
           +-----+-----+-----+-----+
Class A    |  0  |  x  |  x  |  x  |           0.0.0.0 to 127.255.255.255
           +-----+-----+-----+-----+
    
           +-----+-----+-----+-----+
Class B    |  1  |  0  |  x  |  x  |           128.0.0.0 to 191.255.255.255
           +-----+-----+-----+-----+ 
    
           +-----+-----+-----+-----+
Class C    |  1  |  1  |  0  |  x  |           192.0.0.0 to 223.255.255.255
           +-----+-----+-----+-----+   

Local delivery

When the source and destination IP's on a packet agree on the network part, the packet is given to the L2 for direct delivery to the destination.

L2 has its own means. For ethernet, the packet is (in principle but not in practice) broadcast with a header giving the source and destination MAC addresses. All hosts listen, and the host with matching MAC as the destination accepts the packet.

The translation from IP address to MAC is done with ARP, the Address Resolution Protocol. ARP is a glue software that fits in both L2 and L3 in the networking stack. It broadcasts a WHO-HAS on L2 with the IP address sought, and hopes to get an IS-AT response, with the MAC of the corresponding IP. It is the owner of the IP that generally makes this response, but proxy-arp and other supplicants can do so instead.

Network delivery

When the source and destination IP's on a packet do not agree on the network part, the packet is routed by L2 in the direction of the destination network. A gateway is a host on multiple L2 networks. It can receive a packet on one of these L2 networks and resend it on the other. An route is a sequence of gateways, the first on the same L2 network as the source, the last on the same L2 network as the destination, that are, in the sequence they appear, connected by an L2 network.
                        *---------- L3 Routing ------------*
                       |                 |                 |                                                             
  [Source Host]    [Gateway]         [Gateway]         [Gateway]   [Destination Host]
       |             |   |             |   |             |   |             |
       *-----L2------*   *-----L2------*   *-----L2------*   *-----L2------*

All delivery is made by L2, and L2 deliveries can only be made between machines that have the same IP network. So the default gateway must have multiple IP addresses, one on each L3 network it serves. This is called being multi-homed.

The gateways run routing protocols such as RIP or OSPF, to learn network routes. The endpoint hosts do not run these, protocols and are instead given the IP address of a default gateway, either by hand configuring the host (generally only servers) or by an automatic network configuration protocol such as DHCP.

☞ The IP address that appears in the IP header is always that of the ultimate source host and destination host!

The IP addresses of the gateways are used by the ARP system to get L2 address, for use in the hop-by-hop L2 framing, and are not put into the IP header. The gateway understands why it is receiving L2 frames destined for it, but when the L2 header is removed, the L3 header shows the packet is not destined for it. It knows it has received this packet for the purpose of forwarding.

Autonomous Systems

There is a third layer called the Autonomous System, or AS. That is an ISP, and it handles a collection of networks. The AS is more of an administrative division, and does not appear in the technical specifications of IP.

An AS is a collection of IP networks. Between networks in the same AS an interior routing protocol is used, such as RIP or OSPF. AS's communicate through their exit and entry gateways, and these run special exterior routing protocols such as BGP.

The purpose of an exterior routing protocol is not next hop, as is interior routing protocols. The AS route is a sequence of AS's, starting with the AS in which lies the network of the source host, and ending with the AS in which lies the network of the destination host; and all pairwise AS's in the sequence are connected by the AS gateways. This allows for routing decisions based on commercial contracts (how network operators get paid), or government policy (prevent packets from leaving the national boundary).

If a packet is in transit across the AS, it routes from the entry of the AS to the exit of the AS by the interior routing. It then hops from the exit of one AS to the entry of the next. Eventually it is in the AS of the destination host and is delivered by the interior routing.

There are tools such as the Telia Looking Glass to query for AS routes, to lookup by host in which AS it lies, or to list AS's. The University of Miami, MIAMI-EDU, is AS 4511 on this list.

CIDR: Classless Interdomain Routing, and Subnetting

The A, B, C system of network classification is old. The new system uses what I will class slash addressing (my terminology, caveat emptor). With slash addressing the number of high order bits in the network part is explicitly stated, after a "/", spoken as "slash", hence the name.

An old class A is "slash 8", and written e.g. 10.1.0.1/8. An old class B is "slash 16", and class C is "slash 24". But other numbers are possible. You can cook up something halfway between a B and C with 20 bits of network and 12 bits of host. The slash number must be provided, it is no long possible to infer it from the address.

While the wastefulness of classic address was an issue, the major reason to introduce CIDR was to help routing software to agregate routes, making for small routing tables. If an ISP was allocated 4 class B's agreeing on the top 14 bits but not the top 16, it can advertise one /14 network rather than four /16's.

In this way CIDR is related to the idea of subnet routing. In subnet routing the "classic" host part is divided into high order bits of the sub-net and low order bits of the net. Below is an example of how this might work for the address 129.171.34.4, a University of Miami IP address, assigned to the math address block.


phantom.math.miami.edu.	3600	IN	A	129.171.34.4


        +---------+---------+---------+---------+
        |   129   |   171   |   34    |   4     |
        +---------+---------+---------+---------+   
        
        |*--- classic B ---*|*-- classic host--*|
        
        |                   |*-s/net-*|*- host-*|
        
        |*--- /24 as if a class C ---*|*- host-*|
                             
   

In the above examples, the UM 129.171.0.0 address is a classical B, with 16 bits of host. Internal to the university, rather than a local delivery on the last 16 bits, the gateways continue to route on the next 8 bits, treating the address internally as if it were a class C. Externally, only a single route destination needs be known. In CIDR notation, 129.171.0.0/16. Internally there is the benefit of routing along an internal backbone as a 129.171.0.0/24, with the third octet providing the gateway destination. In this case, 34 for math. The octet 32 was reserved for the backbone itself.

The subnet, as well as CIDR, do not need to follow an 8, 16, 24 pattern, A /20 CIDR network can be subnetted as a /26 with 6 bits subnet and 6 bits host, for example.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

Author: Burton Rosenberg
Created: February 17, 2021
Last Update: February 18, 2021