This lecture - 2 fundamental datagram routing algorithms: 1) Link-state routing 2) Distance-vector routing Both routing protocols assume that each router knows: a) the address of each neighbor b) the cost of reaching each neighbor Both protocols allow each router to find the next hop to each every destination in the network by the shortest path, by exchanging routing information with only its neighbors: link-state routing - a node tells every other node in the network its distance to its neighbors. distance-vector routing - a node tells its neighbors its distance to every other node in the network. Both routing protocols are distributed in the above sense. 1) Ideas for Link-state routing a) distribute the whole network topology and the cost of each link to all the routers b) each router independently computes optimal paths to every destination c) If each router sees the same cost for each link and uses the same algorithm to compute the best path, the routes are guaranteed to be loop free. Thus, 2 key components in link-state routing: A) Topology dissemination - a way to distribute knowledge of the network topology to every router in the network B) Shortest paths computation - a way to compute shortest paths from a router to every other router given the topology A) each router creates a set of link-state packets (LSPs) describing its links. An LSP contains the router's ID, the neighbor's ID, and the cost of the link to that neighbor. A router then sends a copy of every LSP to every other router using controlled flooding: when a router receives a new LSP, it stores a copy of the LSP in an LSP database, and forwards the LSP to every interface other than the one on which it arrived. With this method, an LSP is never transferred over the same link twice in the same direction. B) Dijkstra's shortest-path algorithm (1959) - each router knowing the cost of each link in the network computes the shortest path from itself to every other node in the network. Key ideas - each router performs the following: - maintain a set of nodes, P, for which the shortest path has already been determined. Every node outside P must be reached by a path from a node already in P. - for every node n outside P that can be reached by a one-hop path from a node already in P, choose the shortest of these as the path to n. - node n can now be added to P - continue this fashion until we have the shortest path to all the nodes in the network. More precisely, define two sets P and T, where P is defined above and T is the set of nodes to which we are considering shortest paths. Initially, P is set to the originating router and T to null. The algorithm repeats the following steps: 1) For the node just added to P, add each of its neighbors n to T such that a) if n is not in T, add it, labeling it with the cost to reach it through p and its parent as p, b) if n is already in T and the path to n through p has a lower cost, then remove the earlier instance of n and add the new instance labeled with the cost to reach it through p and its parent as p. 2) Pick the node n that has the smallest cost in T and, if it is not already in P, add it to P. If T is empty, we are done. Algorithm Complexity - proportional to n^2, can be reduced to O(E log n), where E is the number of links. Give an example here.