IP Routing OverviewThree main Steps
-Routing – find the outgoing interface
-Switching – move the packet between interfaces
-Encapsulation- Build the layer 2 header
Regardless of what you’re running the router will always go through a three step process internally when it’s moving packets between interfaces.
First, when a router receives an IP packet, it’s going to look at the destination address to find the outgoing interface.
This is the routing processes job. (RIB or CEF or FIB) – once the decision is made of where to send the packet it, it’s out of the routing processes hands.
The second of this three step process is the switching path – where the router actually moves the packet between the interfaces.
Note: there is separation between the routing process and the switching process. The switching process is controlled by the CEF or fast switching process, this is where you could define load-balancing, etc. Also where the router has use its general CPU to move traffic between interfaces or where we use the forwarding table globally or line card/ port.
Third – the encapsulation process. This is where the router will actually build the layer 2 header. Then main diff between L2 switching process and L3 – for a layer 3 routing process is - for a layer 3 router we are rebuilding the L2 encapsulation in a hop by hop basis. This process allows a packet to be received from a Frame interface and then forward to a Ethernet interface.
All devices L3 and above will be rebuilding the L2 header on a hop-by-hop basis.
The routing process:
-Find the longest match
When the router receives an L3 packet, it first looks at what is the destination address. It will then do a lookup against the routing table of the forwarding table to find the most number of BITS in common, and the destination of the packet.
EX: route for network 220.127.116.11
# s hip route
18.104.22.168/24 – Router will choose this path because it’s the longest match. The most number of Bits in common for routing entry and also destination
Note: For the longest match – a /32 host route would be the longest as compare to the default route – the last ditch effort.
Note: This is also independent of the AD distance or the metric
Recurse the to the outgoing interface.
What’s the outgoing interface and next hop value associated with the route.
Note: if the router has to look-up the destination more than one time this is a recursive lookup.
Once the routing process has made its decision on the longest match and the outgoing interface, the process is done.
The packet is then sent to the switching process whose job is to move the packet over to the next or exit interface.
Multiple longest matches:
If there’s multiple longest matches for a destination – the router needs to choose which to use. It can also use some sort of load balancing mechanism.
Where do the same lonest matches come from?
-Same protocol (EX: EIGRP)
--choose the lowest metric - this will be used if the same longest matches are coming from the same routing protocols.
Different protocols (ex: EIGRP to OSPF)
-choose lowest administrative distance. – This will be used if the longest match is coming from different routing protocols.
1.Connected Link – distance = 0. Router will ALWAYS prefer this – there’s no way to preempt a connected link for ANY destination.
2.Static route – Distance = 1
3.EIGRP Summary Route – Distance = 5 (IP summary add at the link level of a router)
4.EIGRP – Distance = 90
5. OSPF – Distance – 110
6. RIP – Distance – 120
7. EIGRP External routes – Distance = 170
EBGP – distance = 20
iBGP – distance – 200
So a manually configured static router – will always be preferred over any Dynamically learned info.
From an external routing perspective, the router will always prefer any external BGP derived route VS any IGP’s
Note: If you’re learning the route from BGP it means the route is not part of your own autonomous system. If it was part of your own AS – the route should be learned from your own IGP.
The switching process:
Moves the packet between interfaces.
-process, fast, CEF, etc.
-where load balancing occurs.
# ip cef
# (no) ip route-cache (turns the process on or off for on the interface level)
# (no) ip mroute-cache (for multicast switching)
#sh ip interface
#sh ip cef (address) (detail)
#Sh ip cef exact-route (source) (Destination) – can be useful for load distribution based on multiple interface, helps find the outgoing interface. If routing protocol is offering two equal cost paths.
CEF Switching should be the default switching on most all platforms. CEF is preferred because it has a faster internal lookup process.
CEF lookups are deterministic – CEF internally divides its lookups into 4 different tables. Based on the hierarchy of the IP Addressing (IPv4). This is because IPv4 has four different octets - Octets A.B.C.D.
Within the scope of the CEF process there is an internal data structure that represents each Octet.
Octet A: there is 255 child entries that go from 1 – 255. And so on for each Octet.
What this means from a CEF table’s point of view when trying to figure the outgoing interface – the process has to do 4 individual lookups under each Octet and each child object.
The CEF process the table is always pre-calculated – the cache is built from the routing protocols and longest match information. Note: the CEF or FIB table on larger scale gear like the 6500 – the table actually runs on the line card level. This means that there’s no need to forward to the routing process of SUP, it can be immediately sent and doesn’t need to reference the central copy of the CEF table.
# sh ip cache
R1#sh ip cache
IP routing cache 0 entries, 0 bytes
0 adds, 0 invalidates, 0 refcounts
Minimum invalidation interval 2 seconds, maximum interval 5 seconds,
quiet interval 3 seconds, threshold 0 requests
Invalidation rate 0 in last second, 0 in last 3 seconds
Last full cache invalidation occurred 00:26:33 ago
R1#sh ip cef
Prefix Next Hop Interface
0.0.0.0/0 drop Null0 (default route handler entry)
Process Switching – the entire lookup is done all at once based on a Top down perspective. Depends on how many entries in the routing table / order they’re configured in – has to look though all entries and this happens on a per packet basis.
Fast switching – once the router has found the outgoing interface, it keeps a caching table (route cache)that has the interface mappings. This is driven by the data plane because we don’t have an entry until a packet is sent to a particular destination.
Note: The router will Process switch (process uses the routers Local CPU) locally originated or locally destined traffic. Any transit traffic (packets coming in one interface and going out another) these packets will go to the CEF process by default.
The encapsulation Process:
Build the layer 2 header
Multipoint interfaces require L3 to L2 resolution. Router will ALWAYS have to do an L2 to L3 resolution.
-Ethernet # sh harp
-Frame Relay #Sh frame-relay map
Point to point interfaces, PPP sub interfaces, PPP or HDLC links, etc. Do not have to go through the L2 to L3 link, this because the same L2 address is used for every destination reachable out the link.
Note: By definition PPP is a point to point protocol.
Routing to a Next-Hop:
When you route to a next hop value, this means the router doesn’t know the outgoing interface to s destination.
If the router cannot find a next-hop, that means the route cannot be installed in the forwarding table. Once the router finds the next-hop interface it will need to do a layer 3 to Layer 2 resolution on the next-hop value.
Recurse to the interface –
If multipoint, resolve L2 address of next-hop
# ip route 10.0.0.0 255.0.0.0 22.214.171.124
-find interface for 126.96.36.199
-if multipoint, find L2 address of 188.8.131.52
Routing to a Multipoint interface
-recursion not required
-resolve L2 address for final destination
-ip route 10.0.0.0 255.0.0.0 Fastherthernet 0/0
- find layer 2 address of 10.0.0.1
Note: In this case he router doesn’t need to do a lookup because it already knows the exit interface is FA0/0. What it does not know is what is the L2 neighbor on the link – this is not a good idea for Multipoint interfaces.
Routing to a Point-to-Point interface
-recursion NOT required
L2 resolution not required
EX: ip route 10.0.0.0 255.0.0.0 Serial 0/0.1
Note: You should only point a route to an interface on a P2P link. Because not Recursion or L2 lookup is required for this type link.