Csep-561-Lec-4

L3 Addressing, Subnets, and Verification

Why are link layer addresses important?

  • They let you define who is who and where messages should go.
    How do devices get their link layer addresses?
  • Manufacturers register with a Central Registry
  • They must be unique in a given L2 LAN at the factory.
  • Alternatively, just assign randomly, since MAC is 48 bits and we're not expecting a large number of devices on a single L2 net.
    Importantly, there's no structure to these local device-level addresses.

Why do we need L3 (Network Layer)?

A global scale L2 network runs into problems quickly:

  • Given that local addresses have no structure, switch routing tables would get huge.
  • Recall L2 falls back to broadcast/flood on unknown destinations, this would be absurd on the internet scale.
  • Lack of traffic control (aside from SDN)
  • Lack of heterogeneity: need to be able to route over virtual circuit and datagram networks, etc.

Routing is a network wide decision of how to get packets from source to destination

Forwarding is the actual packet forward done at the individual switch level.

L3 via IPv4

  • Mistakes corrected in IPv6:
  • Checksum over TTL
  • Every router needs to compute the checksum to bump the TTL
  • Fragmentation
  • Tip: when dealing with A.B.C.D, convert it to binary! It's meaning is usually as a bit mask, and it's hard to reason about in decimal.
  • L-bit Prefixes are what allows IP to scale past L2.

Classless Inter-Domain Routing (CIDR)

Modern network uses classless IP prefixes:

  • notated as "IP address / length"
  • IP addr: lowest address in the prefix
  • length: how long the prefix is
  • don't have to align on byte boundary
  • typically A.B.C.D is written decimal, but it is 4 8-bit sections.
  • E.g. 128.13.0.0/16 is equivalent to
  • 10000000 . 00001101 . xxxxxxxx . xxxxxxxx
  • E.g. 18.31.0.0/24 is
  • 0010010 . 00011111 . 00000000 . xxxxxxxx
  • E.g. 64.14.64.0/18 is
  • 01000000 . 00001110 . 01xxxxxx . xxxxxxxx
  • Note the longer prefix length, the more specific the address is.

So, we scale in L3 by forwarding based on prefix. E.g.
|Prefix | Next Hop |
|-|-|
| 192.24.0.0/18 | D |
| 192.24.12.0/22 | B |
This obviously reduces the size of the forwarding table by orders of magnitude.
Note that prefixes in the table can overlap; in this case, the switch forwards the packet based on the longest matching prefix. This combines hierarchy with flexibility. For an example, note that the table above is equivalent to
|Prefix | Next Hop |
|-|-|
| 192.00011000.00xxxxxx.xxxxxxxx | D |
| 192.00011000.000011xx.xxxxxxxx | B |

  • So, 192.24.6.0 == 192.00011000.00000110.00000000 doesn't match B so it goes to D.
  • While 192.24.14.32 == 192.00011000.00001110.00010000 does match B, and goes there since it's the more specific, longer prefix.

Back in the day, changing the forwarding table to not be a simple lookup was concerning. But these days, we can do longest matching prefix really quickly in hardware, so it's fine.

So within a given network, hosts use this prefixing methodology as well. If an IP matches the local network prefix, they send it to them directly within their (L2) network. If it doesn't match network prefix, send it to the gateway/router to get it to the broader internet. Local host forwarding table:
|Prefix | Next Hop |
|-|-|
| My network prefix | Send directly to IP |
| 0.0.0.0/0 | Send to gateway router |

  • Notice the default route of all zeroes that catches all IP addresses.

Hierarchical Routing

We use this prefix idea to split the internet into regions. I.e. use an entire prefix to send to region west or the EU, etc. This might result in some individual routes being less efficient, but ultimately compacts the forwarding table and speeds up processing the packets.

  • This does result in asymmetric routes from A->B vs B->A.

You can scale this by adjusting the size of IP prefixes

  • subnets: Split a broader prefix into more specific "subnets"
  • aggregation: Join more specific prefixes into a broader one (done by ISP)

Routers can change prefix lengths dynamically as needed, without affecting hosts.