# Lecture 9 Outline

1. Introduction
• Today: Link-state and distance-vector routing.
• Neither of these routing protocols is used to route across the entire Internet; let's find out why.
2. Routing Protocols in General
• Goal: For every node X, after the routing protocol is run, X's routing table should contain a *minimum-cost route* to every other reachable node.
• Route vs. path:
• Path = Full path packets will travel.
• Route = First hop of that path. Node really only needs to know the first hop.
• Link costs can represent many things: Delay, congestion, etc. Sometimes all link costs are just 1, so that the min-cost paths are the paths with the fewest hops.
• Once a routing table is set up, when a switch gets a packet, it can check the packet header for the destination address, look that address up in its routing table, and add the packet to the queue for that outgoing link.
3. Distributed Routing Protocols
• Scale better than centralized ones.
• Three steps:
• Nodes learn about their neighbors via the HELLO protocol.
• Nodes determine minimum-cost routes.
• HELLO protocol lets nodes discover link/node failures.
• Main idea: Through advertisements, nodes disseminate information about the topology of the graph to all other nodes. Once all nodes have that information, they can run a shortest-path algorithm.
• Each node sends advertisements to their neighbors, who forward to their neighbors, who forward to their neighbors, ... I.e., advertisements are flooded.
• After flooding, each node should have a complete map of the network (except in the case of very specific, very rare sequences of advertisement loss). Nodes use this map to run Dijkstra's shortest path algorithm.
• Here's one way to do Dijkstra's algorithm, slightly different from the example I did in class (below, we assume that all nodes are initially known; you can make this a nodes-need-tobe-discovered based implementation with a few small changes).
• In each step of Dijkstra's algorithm, we keep track of W, the set of nodes we haven't processed yet. Initially, W is all nodes in the network.
• We also keep track of the current costs and routes to all of the nodes. Initially:

routing_table [self] = Self; routing_table [anyone else] = ?
cost_table [self] = 0; cost_table [anyone else] = infinity

• While W is not empty:

• u = the node in W we have the minimum cost to so far
• Remove u from W
• For every neighbor v of u:
`d = cost_table [u] + cost (u, v) if d < cost_table [v]   cost_table [v] = d   routing_table [v] = routing_table [u]`
• Good things: Flooding makes link-state extremely robust to failure. Very unlikely that a node will miss so many advertisements that it has an incorrect view of the network.
5. Distance-vector Routing
• In link-state, nodes calculate full shortest paths. They really only need the route (first-hop) to a destination. Let's exploit that.
• Integrate step: When node X receives an advertisement from its neighbor Y, this advertisement will be a list of [(dst, cost)] pairs. Each cost represents Y's cost to dst.
• For each (dst, cost) in the advertisement, X needs to check for two things:

• If X is already using Y to get to dst, update the cost information (remember, costs can change!).
• If X is not already using Y to get to dst, see if Y could provide a better path; if so, update the routing and cost information.