500 likes | 959 Views
4. 1 Introduction 4.2 Virtual circuit and datagram networks 4.3 What’s inside a router 4.4 IP: Internet Protocol Datagram format IPv4 addressing ICMP IPv6. 4.5 Routing algorithms Link state Distance Vector Hierarchical routing 4.6 Routing in the Internet RIP OSPF BGP
E N D
4. 1 Introduction 4.2 Virtual circuit and datagram networks 4.3 What’s inside a router 4.4 IP: Internet Protocol Datagram format IPv4 addressing ICMP IPv6 4.5 Routing algorithms Link state Distance Vector Hierarchical routing 4.6 Routing in the Internet RIP OSPF BGP 4.7 Broadcast and multicast routing Chapter 4: Network Layer
routing algorithm local forwarding table header value output link 0100 0101 0111 1001 3 2 2 1 value in arriving packet’s header 1 0111 2 3 Interplay between routing, forwarding There is a difference between routing and forwarding • Forwarding • Forwarding is the act of taking a packet from an input interface and sending a packet out on an output interface. • This requires using the destination address and looking in the forwarding table to determine the next-hop (= output interface) • Routing • The act of generating forwarding tables
B C E A D Vertices: A, B, C, D, E Edges: (A,B), (B,C), (C,D), (C,E), (E,D) Graph Abstraction Abstraction: a model (i.e., some aspects of the real system are missing or only approximated) and a generalization (i.e., it can represent other things beside the original object) • Graphs have two components • Vertices (nodes) • Edges (links) • Graph abstraction • IP Networks: Routers are vertices and links are edges • WWW: Web pages are vertices and “hot links” are edges • Social networks: people are vertices and relationships are edges • Zillions of other graph abstractions • This means that techniques from graph theory can be applied • Graph theory is a part of discrete mathematics • Other important theoretical areas include probability (stochastic processes and quueing theory), optimization, and algortihms
An example of a directed graph with weighted edges 2 2 B C E 1 3 5 A D 3 All of these types of graphs are important in networking Types of Graphs • Directed graphs v.s. undirected graphs • In directed graphs, edges have direction • In undirected graphs, edges are bidirectional • Graphs with weighted edges • Graphs with weighted vertices
2 2 B C E 2 2 1 1 5 5 3 5 5 A D 3 Graphs • Edge weights can represent • Bit-rate • Give an example where bit-rates are asymmetric • DSL, Comcast • E.g., comcast has 16Mbps download and 768kbps upload • Delay • Congestion • Security/robustness • Cost • Service provides may charge per bit • Abstract cost representing several of the above • Node weights can represent • Remaining battery power • Security/robustness • (Graph theory focuses more on weighted vertices than weighted edges. But graphs with weighted edges can be transformed into similar graphs with weighted vertices.)
Concepts from Graph Theory • A graph is connected if it is possible to reach any node from any node. • If the graph is directed, then the movement between nodes must follow the direction of the edge • K-connected: a graph is k-edge-connected if it remains connected when k-1 edges are removed. • K-connected is an important concept for robustness. • Least cost/hop path • If each edge has the same cost, then a least cost path is the same as the least hop path • Find the least hop path between A and E • Find the least cost path between A and E • Routing is usually concerned with finding least cost paths. • Diameter of a graph is the maximum length of all least hop paths • What is the diameter of the graph below • The degree of a vertex = the number of edges emanating from vertex • In networking, the out-degree is the number of output interfaces and the in-degree is the number of input interfaces • In social networks, the degree is the number of “friends” a vertex has • In the web, the out-degree of a page is the number of links a page has • In the web, the in-degree of a page is the number of other pages that have links to the page • Degree can be used to measure importance • Max-flow • If edge weights are the capacities of edges, then what is the maximum flow can be sent from one node to another? • What is the maximum flow from A to E 2 2 B C E 1 3 5 A D 3
Global information: all routers have complete topology and link cost info link state routing algorithms have global information OSPF and ISIS are examples of link-state routing protocols OLSR is a link state protocol for ad hoc wireless networks Local information: router knows physically-connected neighbors, link costs to neighbors iterative process of computation, exchange of info with neighbors distance vector algorithms use local information RIP is an example of a distance vector routing protocol RIP and distance vector routing is not widely used Routing with Global or Local Topology Information Distance vector: Pros • Routers only need to get information from their neighbors • Low overhead (in theory) Cons • However, an iterative scheme is required, which might require many iterations before convergence • It might take a long time for the routing to converge • In the meantime, there might be loops • Will a pkt remain in a loop forever? • Loops can cause congestion • Excessive overhead to achieve timely convergence Link state: Cons • Overhead is required to ensure that all routers have • An up-to-date “picture” of the topology • Have a consistent “picture” of the topology • Otherwise loops can occur Pros • Routes can be immediately computed, there is no problems with convergence
Static or dynamic Static: routes change only when manually changed Dynamic: routes change when the topology changes periodic update in response to link cost changes Adaptive Route change even when the topology remains constant, but e.g., when the traffic changes. Adaptive routing is rarely used in the internet It is used in some the Philadelphia mesh network What should be optimized when find routes Nothing, just get packets to the destination E.g., the pkt follows a random path Least cost paths where cost is The number of hops Total energy (in wireless transmission and receptions require energy) Maximum remaining battery Congestion total congestion along the path worst-case congestion End-to-end Delay Money Probability of arrival at destination Administrative cost The network administrator adjust the cost so that several of the above are represented in the cost. Types of Routing Algorithms
4. 1 Introduction 4.2 Virtual circuit and datagram networks 4.3 What’s inside a router 4.4 IP: Internet Protocol Datagram format IPv4 addressing ICMP IPv6 4.5 Routing algorithms Link state Distance Vector Hierarchical routing 4.6 Routing in the Internet RIP OSPF BGP Chapter 4: Network Layer
Three tasks must be accomplished Determine the link state hello messages so that bidirectionality is determined Exchange/flood topology information Link state flooding Link state database synchronization Compute routes Dijkstra’s algorithm – a fast way to compute least cost paths A Link-State Routing Algorithm e.g., OSPF (open shortest path first (open, because anyone can use it, as oppose to ISIS which belongs to cisco))
Determining Link State - Hello • A link is “up” if it is bi-directional • If a router hears a hello from a router, then the link is known to be unidirectional. • The hello packet contains a list of neighboring routers that have recently sent hello packets. • A router should send a hello every 10 seconds • If a router has not heard a hello from a neighboring router in 40 seconds, then it removes the router from the list of routers that have recently sent hello packets.
Link State Generation and Flooding • Link state announcement generation • A router will generate is own link state announcement (LSA) within 30 minutes • or when link change is detected and flood it to all its neighbors. • The LSA contains the state of the ability to communicate with all its neighbors • i.e., link is up or down • No information such as congestion is used in OSPF • Flooding • LSA exchanges between routers are reliable • When an LSA is received, an ACK is sent. • The router resends the LSA until either an ACK is received or the link is no longer bidirectional. • Since exchanges are reliable, LSA flooding is reliable • Routers don’t flood to routers that sent the LSA, but to all others. • Routers only flood if the LSA is new • If a router gets a “new” LSA, then it floods it to its neighbors. • LSAs are stored in a LSA database • Sequence numbers are used to determine if a received LSA is newer than the one in the database • How could the LSA be in the database be newer than the one that was received? • An LSA in a router is replaced when a “newer” one is received. • So updating the link state database implies that the LSA is sent to all neighbors (except the one that sent it) Aside: we’ve seen sequence numbers in all three layers so far (there are in MAC layer as well)
Database sync • After a link comes up, the database must synchronized. • After receiving a hello with the router in the recently heard list, the router sends a datebase seq number. (this acts as a hello to make the link fully bidirectional • The routers exchange link state announcement headers only. (Each LSA contains the list of links from a single router and a sequence number). • Each router then requests LSAs it does not have. • These LSA are then flooding to neighbors in the usual way. • Note, that usually a router will only generate its own LSAs • But when a link comes up, its neighbor will generate LSAs from its database that are announcing links besides its own links • These generated LSAs will be flooded by the neighbor router. • Of course, if the neighbors of the just-up router have already received these LSAs, they will not propagation the LSAs • But, these LSAs are new to some neighbors, they will be propagated. This can happen when the network is partitioned. • If a router did not generate the LSAs in this way, it would take 30 minutes for the network to stabilize after a un-partitioning (i.e., when a router comes up so that the network switches from partitioned to unpartitioned)
Sequence numbers • When a router crashes and reboots, how does it know which seq. num to use? If it uses 0x00000 and other routers in the network still have LSA from this router, then the other routers will ignore its LSAs. • note, a router will only use a link if it has up-to-date LSAs from routers on both ends • So, if a router receives its own LSA, but with a larger seq num, it will increase its own seq no. • It should receive its own LSA during synchronization 1.2.1.2 1.2.1.3 Originator: 1.2.1.2 Seq num: 0x00000000 link: to: 1.2.1.3; 1.2.3.5…
B B>A, although, the number A > the number B B A 0x00000 B>A A 0xFFFFF B A In this case, we don’t know if A >B In 1981, the original ARPA net tried such an approach (without CRC or checksum). Transmission errors lead to three different sequence numbers being generated. They had to reboot! S1 • An update with seq num=S1 arrives – so update LS database • An update with seq num=S2 arrives, so update the Ls database • An Update with seq num=S# arrives, so update LS databass, • Then back to 1… S3 S2 Sequence numbers • When a router crashes and reboots, how does it know which seq. num to use? If it uses 0x00000 and other routers in the network still have LSA from this router, then the other routers will ignore its LSAs. • note, a router will only use a link if it has up-to-date LSAs from routers on both ends • So, if a router receives its own LSA, but with a larger seq num, it will increase its own seq no. • It should receive its own LSA during synchronization • What about wrap around? • You could take an circular approach • B>A if (A+X)%0xfffff = B and (B+Y)%0xfffff = A, and X<Y.
OSPF uses 0x8000001 as the smallest seq num and 0x7fffffff as the largest. No wrap around permitted. To reset the seq num to 0x800001, the router must clear the LSA from the other routers. LSAs will not be accepted faster than once per 5 seconds. So wrap around will not occur for 600 years. But what if an attacker is able to put in an incorrect LSA. OSPF has some authentication of LSAs What if there are multiple failures that require updates closer than 5 seconds. If faster than 5 sec was permitted, then an attacker or a faulty link could generate a large number of LSAs and cause routing problems Also, the seq num could reach 0x7FFFFFFF in which case the router would have to be brought offline for a little while OSPF Sequence numbers
LS Age (timeout) • A router will generate a LSA every 30 minutes • If the LS Age reaches 1 hour, the LSA is removed from all databases. • However, it is important that all routers remove the LSA together (why?) • Routers must have a consistent view of the network • But, if an LSA has not been generated, then perhaps the router is down, in which case the router on the other side should have generated a LSA declaring the link is down. • But if the network is partitioned, then no such LSA is generated. • To remove the LSA, an LSA is flooded with LS age=1 hour.
LS Age (timeout) • A router will generate a LSA every 30 minutes • If the LS Age reaches 1 hour, the LSA is removed from the database. • However, it is important that all routers remove the LSA together (why?) • Routers must have a consistent view of the network • But, if an LSA has not been generated, then perhaps the router is down, in which case the router on the other side should have generated a LSA declaring the link is down. • But if the network is partitioned, then no such LSA is generated. • To remove the LSA, an LSA is flooded with LS age=1 hour. • If a router goes down, the other routers will not remove the LSA from this router for an hour. • Would this lead to routing problems? • No, the routing will only use links that are advertised by both routers. • If a router wants to remove its LSAs, then it can flood an LSA with LS Age = MaxAge (1 hour). • This will delete the LSAs. • But, if this real LS ages are not close to 1 hour, then an LSA with age=max-age can only be generated by the originating router. Originator: 1.2.1.2 Seq num: 0x80000001 link: to: 1.2.1.3; 1.2.3.5… Originator: 1.2.1.2 Seq num: 0x80000001 link: to: 1.2.1.3; 1.2.3.5…
LS Age (timeout) • A router will generate a LSA every 30 minutes • If the LS Age reaches 1 hour, the LSA is removed from the database. • However, it is important that all routers remove the LSA together (why?) • Routers must have a consistent view of the network • But, if an LSA has not been generated, then perhaps the router is down, in which case the router on the other side should have generated a LSA declaring the link is down. • But if the network is partitioned, then no such LSA is generated. • To remove the LSA, an LSA is flooded with LS age=1 hour. • If a router goes down, the other routers will not remove the LSA from this router for an hour. • Would this lead to routing problems? • No, the routing will only use links that are advertised by both routers. • If a router wants to remove its LSAs, then it can flood an LSA with LS Age = MaxAge (1 hour). • This will delete the LSAs. • But, if this real LS ages are not close to 1 hour, then an LSA with age=max-age can only be generated by the originating router. Originator: 1.2.1.2 Seq num: 0x80000001 link: to: 1.2.1.3; 1.2.3.5… Originator: 1.2.1.2 Seq num: 0x80000001 link: to: 1.2.1.3; 1.2.3.5… Originator: 1.2.1.2 Seq num: 0x0…017 Age: 60min
OSPF • For each Neighbor • If TimeSinceLastHello>10 sec • Send hello • If TimeSinceLastLSAWasGenerated > 30 minutes • Generate new LSA • Flood new LSA • If received an LSA • ACK LSA • Check if LSA is a new LSA • If LSA AGE == MaxLSA Age and LSA is in LSA data base, then delete LSA and flood LSA to neighbors (except the one that sent the LSA) • If LSA is new, then put LSA into LSA database, increment LSA age and flood to neighbors. If topology has changed, recompute forwarding table • Else (I.e., not new), quietly discard LSA • For each LSA in database • Check if LSA Age is greater than 60 minutes • If LSA age is greater than 60 minutes, generate a copy of the LSA but with the LSA Age=MaxAge. Flood this LSA and delete LSA • On reboot or upon rediscovery of a neighbor, exchange link state databases and flood any required LSA from the exchange • Consider a link that is brought up so the network is no longer partitioned • When computing the forwarding table, only links that are advertised by both ends are used.
See other slides Dijkstra’s Algorithm
4. 1 Introduction 4.2 Virtual circuit and datagram networks 4.3 What’s inside a router 4.4 IP: Internet Protocol Datagram format IPv4 addressing ICMP IPv6 4.5 Routing algorithms Link state Distance Vector Hierarchical routing 4.6 Routing in the Internet RIP OSPF BGP 4.7 Broadcast and multicast routing Chapter 4: Network Layer
c(B,C)=2 B C c(A,B)=1 c(C,F)=1 c(C,D)=6 c(B,E)=6 A F c(E,F)=2 c(A,D)=12 D E c(D,E)=1 Dynamic Programming Bellman-Ford Equation (dynamic programming) Dynamic programming is one of the major achievements in the 20th century Objective: find the least cost path between two vertices in a graph Approach 1: list all possible paths and select the smallest one Drawback: Too many possible paths. The number of paths grows exponentially with the number of vertices
Then we must have D(i,j) = min { c(i,k) + D(k,j) } k neighbors of i c(B,C)=2 B C c(A,B)=1 c(C,F)=1 c(C,D)=6 c(B,E)=6 F c(E,F)=2 c(A,D)=12 D E c(D,E)=1 Dynamic Programming Bellman-Ford Equation (dynamic programming) Dynamic programming is one of the major achievements in the 20th century Objective: find the least cost path between two vertices in a graph. Approach 2: Dynamic programming • Let D(i,j) be the end-to-end cost from vertex i to vertex j. • Let c(i,j) be the edge cost along the edge from vertex i to vertex j. D(B,F)=3 D(C,F)=1 What is D(A,F)? A’s neighbors are B and D. D(A,F) = min{ c(A,B)+D(B,F), c(A,D)+D(D,F) } D(A,F) = min{ 1 + 3, 12+3} D(A,F) = min{4, 15} = 4 D(F,F)=0 A D(A,F)=? D(E,F)=2 D(D,F)=3 Assume: c(i,j)=c(j,i)
D(n+1,i,j) = min { c(i,k) + D(n,k,j) } Let k neighbors of i Then D(i,j) = min { c(i,k) + D(k,j) } k neighbors of i Dynamic Programming • Let c(i,j) be the edge cost along the edge from vertex i to vertex j. • Let D(n,i,j) be the estimate of end-to-end cost from vertex i to vertex j at the nth iteration. Then limnD(n,i,j) exists (i.e., the above converges) Let D(i,j) := limnD(n,i,j)
Then D(i,j) = min { c(i,k) + D(k,j) } k neighbors of i D(n+1,i,j) = min { c(i,k) + D(n,k,j) } Let k neighbors of i 2 B C 1 1 6 24 A F 6 2 2 D E Dynamic Programming Let c(i,j) be the edge cost along the edge from vertex i to vertex j. Let D(i,j) := limnD(n,i,j) Initialization: n=0 D(0,C,F) = D(0,B,F) = D(0,A,F) = D(0,F,F)=0 1 D(0,E,F) = D(0,D,F) =
Then D(i,j) = min { c(i,k) + D(k,j) } k neighbors of i D(n+1,i,j) = min { c(i,k) + D(n,k,j) } Let k neighbors of i 2 B C 1 1 6 24 A F 6 2 2 D E Dynamic Programming Let c(i,j) be the edge cost along the edge from vertex i to vertex j. Let D(i,j) := limnD(n,i,j) Iteration 1: n=1 D(0,C,F) = D(1,C,F) = min{c(C,B)+D(0,B,F), c(C,D)+D(0,D,F) c(C,F)+D(0,f,F)} = min{ 2 + , 6 + , 1 + 0} = 1 D(0,B,F) = D(1,B,F) = min{c(B,A)+D(0,A,F), c(B,C)+D(0,C,F)} = min{ 1 + , 2 + } = D(0,A,F) = D(1,A,F) = min{c(A,B)+D(0,B,F), c(A,D)+D(0,D,F), c(A,E)+D(0,E,F) c(A,F)+D(0,F,F)} = min{ 1 + , 2 + , 6 + , 24 + 0} = 24 D(0,F,F)=0 D(1,F,F)=0 1 D(0,E,F) = D(1,E,F) = min{c(E,A)+D(0,A,F), c(E,D)+D(0,D,F), c(E,F)+D(0,F,F)} = min{ 6 + , 1 + , 2 + 0 } = 2 D(0,D,F) = D(1,D,E) = min{c(D,A)+D(0,A,F), c(D,C)+D(0,C,F), c(D,E)+D(0,E,F)} = min{ 2 + , 6 + , 1 + } =
Then D(i,j) = min { c(i,k) + D(k,j) } k neighbors of i D(n+1,i,j) = min { c(i,k) + D(n,k,j) } Let k neighbors of i 2 B C 1 1 6 24 A F 6 2 2 D E Dynamic Programming Let c(i,j) be the edge cost along the edge from vertex i to vertex j. Let D(i,j) := limnD(n,i,j) Iteration 2: n=2 D(1,C,F) = 1 D(2,C,F) = min{c(C,B)+D(1,B,F), c(C,D)+D(1,D,F) c(C,F)+D(1,f,F)} = min{ 2 + , 6 + , 1 + 0} = 1 D(1,B,F) = D(2,B,F) = min{c(B,A)+D(1,A,F), c(B,C)+D(1,C,F)} = min{ 1 + 24, 2 + 1} = 3 D(1,A,F) = 24 D(2,A,F) = min{c(A,B)+D(1,B,F), c(A,D)+D(1,D,F), c(A,E)+D(1,E,F) c(A,F)+D(1,F,F)} = min{ 1 + , 2 + , 6 + 2, 24 + 0} = 8 D(0,F,F)=0 D(1,F,F)=0 D(2,F,F)=0 1 D(1,E,F) = 2 D(2,E,F) = min{c(E,A)+D(1,A,F), c(E,D)+D(1,D,F), c(E,F)+D(1,F,F)} = min{ 6 + 24, 1 + , 2 + 0 } = 2 D(1,D,F) = D(2,D,E) = min{c(D,A)+D(2,A,F), c(D,C)+D(2,C,F), c(D,E)+D(2,E,F)} = min{ 2 + 24, 6 + 1, 1 + 2} = 3
Then D(i,j) = min { c(i,k) + D(k,j) } k neighbors of i D(n+1,i,j) = min { c(i,k) + D(n,k,j) } Let k neighbors of i 2 B C 1 1 6 24 A F 6 2 2 D E Dynamic Programming Let c(i,j) be the edge cost along the edge from vertex i to vertex j. Let D(i,j) := limnD(n,i,j) Iteration 3: n=3 D(2,C,F) = 1 D(3,C,F) = min{c(C,B)+D(2,B,F), c(C,D)+D(2,D,F) c(C,F)+D(2,f,F)} = min{ 2 + 3, 6 + 3, 1 + 0} = 1 D(2,B,F) = 3 D(3,B,F) = min{c(B,A)+D(2,A,F), c(B,C)+D(2,C,F)} = min{ 1 + 8, 2 + 1} = 3 D(2,A,F) = 8 D(3,A,F) = min{c(A,B)+D(2,B,F), c(A,D)+D(2,D,F), c(A,E)+D(2,E,F) c(A,F)+D(2,F,F)} = min{ 1 + 3, 2 + 3, 6 + 2, 24 + 0} = 4 D(0,F,F)=0 D(1,F,F)=0 D(2,F,F)=0 D(3,F,F)=0 1 D(2,E,F) = 2 D(3,E,F) = min{c(E,A)+D(2,A,F), c(E,D)+D(2,D,F), c(E,F)+D(2,F,F)} = min{ 6 + 8, 1 + 3, 2 + 0 } = 2 D(2,D,F) = 3 D(3,D,E) = min{c(D,A)+D(2,A,F), c(D,C)+D(2,C,F), c(D,E)+D(2,E,F)} = min{ 2 + 8, 6 + 1, 1 + 2} = 3
Then D(i,j) = min { c(i,k) + D(k,j) } k neighbors of i D(n+1,i,j) = min { c(i,k) + D(n,k,j) } Let k neighbors of i 2 B C 1 1 6 24 A F 6 2 2 D E Dynamic Programming Let c(i,j) be the edge cost along the edge from vertex i to vertex j. Let D(i,j) := limnD(n,i,j) Iteration 4: n=4 D(3,C,F) = 1 D(4,C,F) = min{c(C,B)+D(3,B,F), c(C,D)+D(3,D,F) c(C,F)+D(3,f,F)} = min{ 2 + 3, 6 + 3, 1 + 0} = 1 D(3,B,F) = 3 D(4,B,F) = min{c(B,A)+D(3,A,F), c(B,C)+D(3,C,F)} = min{ 1 + 8, 2 + 1} = 3 D(3,A,F) = 8 D(4,A,F) = min{c(A,B)+D(3,B,F), c(A,D)+D(3,D,F), c(A,E)+D(3,E,F) c(A,F)+D(3,F,F)} = min{ 1 + 3, 2 + 3, 6 + 2, 24 + 0} = 4 D(0,F,F)=0 D(1,F,F)=0 D(2,F,F)=0 D(3,F,F)=0 1 D(3,E,F) = 2 D(4,E,F) = min{c(E,A)+D(3,A,F), c(E,D)+D(3,D,F), c(E,F)+D(3,F,F)} = min{ 6 + 8, 1 + 3, 2 + 0 } = 2 D(3,D,F) = 3 D(4,D,E) = min{c(D,A)+D(3,A,F), c(D,C)+D(3,C,F), c(D,E)+D(3,E,F)} = min{ 2 + 8, 6 + 1, 1 + 2} = 3 Nothing changed, so done!
Then D(i,j) = min { c(i,k) + D(k,j) } k neighbors of i D(n+1,i,j) = min { c(i,k) + D(n,k,j) } Let k neighbors of i 2 B C 1 1 6 24 A F 6 2 2 D E Dynamic Programming Let c(i,j) be the edge cost along the edge from vertex i to vertex j. Let D(i,j) := limnD(n,i,j) Iteration 4: n=4 D(0,B,F) = 3 D(1,B,F) = min 4+1, 2+1 = 3 D(2,B,F) = min 4+1, 5+2 = 5 D(3,B,F) = 5 D(4,B,F) = min 7+2,5+1 = 6 D(5,B,F) = 6 D(6,B,F) = min 5+1, 8+2 = 6 D(0,C,F) = 1 D(1,C,F) = min D(B,F)+c(C,B), D(D,F)+c(C,D) = min( 3+2, 3+6)= min(5,9) = 5 D(2,C,F) = 5 D(3,C,F) = min(5+2, 6+3) = 7 D(4,C,F) = 7 D(5,C,F) = 6+2,6+3=8 D(6,C,F) = 8 D(0,A,F) = 4 D(1,A,F) = 4 D(2,A,F) = 4 D(3,A,F) = min 5+1, 3+2,2+6, 24)=5 D(4,A,F) = 5 D(5,A,F) = min 6+1,3+2,6+2,24 = 5 D(0,F,F)=0 D(1,F,F)=0 D(2,F,F)=0 D(3,F,F)=0 1 D(0,E,F) = 2 D(1,E,F) = 2 D(2,E,F) = 2 D(2,E,F) = 2 D(0,D,F) = 3 D(1,D,f) = 3 D(2,D,F) = 3 D(3,D,F) = 3
Iterative, asynchronous: each local iteration caused by: local link cost change (hello messages) DV update message from neighbor Distributed: each node notifies neighbors only when its DV changes Each node: wait for (change in local link cost from hello msg or msg from neighbor) recompute estimates if DV to any dest has changed, notify neighbors Distance Vector Algorithm
1 4 1 50 x z y Distance Vector: link cost changes Link cost changes: • node detects local link cost change • updates routing info, recalculates distance vector • if DV changes, notify neighbors At time t0, y detects the link-cost change, updates its DV, and informs its neighbors. “good news travels fast” At time t1, z receives the update from y and updates its table. It computes a new least cost to x and sends its neighbors its DV. At time t2, y receives z’s update and updates its distance table. y’s least costs do not change and hence y does not send any message to z.
Need more examples of what happends when top changes, like in final examine
Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B C D E A B C D E A B C D E A B C D E C C C D E B B C D D A B C C C D D D D E A B B B B 3 2 1 0 1 2 1 0 1 2 4 3 2 1 0 0 1 2 3 4 1 0 1 2 3 Distance Vector: Bad news travels slowly 1 1 1 1 B C D A E
Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B C D E A B C D E A B C D E A B C D E B B C D D D D D D E A B C C C C C C D E A B B B B 3 2 1 0 1 0 1 2 3 4 4 3 2 1 0 1 0 1 2 3 2 1 0 1 2 Distance Vector: Bad news travels slowly link break 1 1 1 B C D A E Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 4 A B C D E A B C C C 1 0 1 2 3 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D 2 1 0 1 2 C min{2+1, +0} ? 3 ?
Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B C D E A B C D E A B C D E A B C D E D D D D E C C C D E B B C D D A B B B B A B C C C 3 2 1 0 1 4 3 2 1 0 2 1 0 1 2 0 1 2 3 4 1 0 1 2 3 Distance Vector: Bad news travels slowly link break 1 1 1 B C D A E Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 4 A B C D E A B C C C 1 0 1 2 3 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D 2 1 0 1 2 C 3 Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 4 A B C D E A B C C C 1 0 1 2 3 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D 2 1 0 1 3 min{3+1, 3+1} C
Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B C D E A B C D E A B C D E A B C D E B B C D D A B B B B C C C D E D D D D E A B C C C 0 1 2 3 4 4 3 2 1 0 3 2 1 0 1 2 1 0 1 2 1 0 1 2 3 Distance Vector: Bad news travels slowly link break 1 1 1 B C D A E Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 4 A B C D E A B C C C 1 0 1 2 3 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D 2 1 0 1 2 C 3 Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 4 A B C D E A B C C C 1 0 1 2 3 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D 2 1 0 1 3 C 4 Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 4 A B C D E A B C C C 1 0 1 2 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D 2 1 0 1 min{4+1, 4+1} min{4+1, +1} 4 C
Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B C D E A B C D E A B C D E A B C D E C C C D E A B C C C B B C D D D D D D E A B B B B 0 1 2 3 4 4 3 2 1 0 3 2 1 0 1 1 0 1 2 3 2 1 0 1 2 Distance Vector: Bad news travels slowly link break 1 1 1 B C D A E Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 4 A B C D E A B C C C 1 0 1 2 3 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D 2 1 0 1 2 C 3 Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 4 A B C D E A B C C C 1 0 1 2 3 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D 2 1 0 1 3 C 4 Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 4 A B C D E A B C C C 1 0 1 2 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D 2 1 0 1 5 4 C 5 Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 A B C D E A B C C C 1 0 1 2 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D 2 1 0 1 5+1 5 C min{5+1, 5+1} 5
Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B C D E A B C D E A B C D E A B C D E A B C C C A B B B B B B C D D D D D D E C C C D E 1 0 1 2 3 4 3 2 1 0 2 1 0 1 2 0 1 2 3 4 3 2 1 0 1 Distance Vector: Bad news travels slowly link break 1 1 1 B C D A E Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 4 A B C D E A B C C C 1 0 1 2 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D 2 1 0 1 5 4 C 5 Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 A B C D E A B C C C 1 0 1 2 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D 2 1 0 1 6 C min{6+1, 6+1} 6 min{6+1, +1}
Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B C D E A B C D E A B C D E A B C D E D D D D E C C C D E B B C D D A B B B B A B C C C 0 1 2 3 4 4 3 2 1 0 1 0 1 2 3 2 1 0 1 2 3 2 1 0 1 Distance Vector: Bad news travels slowly link break 1 1 1 B C D A E Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 4 A B C D E A B C C C 1 0 1 2 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D 2 1 0 1 5 4 C 5 Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 A B C D E A B C C C 1 0 1 2 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D 2 1 0 1 6 C 7 6 7 Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 A B C D E A B C C C 1 0 1 2 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D 2 1 0 1 8 5 C 5 8
Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B C D E A B C D E A B C D E A B C D E A B C C C A B B B B B B C D D D D D D E C C C D E 2 1 0 1 48 1 0 1 2 49 0 1 2 3 48 3 2 1 0 49 4 3 2 1 0 Distance Vector: Bad news travels slowly 50 link break 1 1 1 B C D A E Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B or E 0 1 2 3 50 A B C D E A B C C C 1 0 1 2 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D 2 1 0 1 49 50 C 49 Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B or E 0 1 2 3 A B C D E A B C C C or A 1 0 1 2 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D 2 1 0 1 50 C 51 50 51 Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B E 0 1 2 3 A B C D E A B C C C or A 1 0 1 2 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D or B 2 1 0 1 50 51 C 51 52 Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B E 0 1 2 3 A B C D E A B C C A 1 0 1 2 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D orB 2 1 0 1 50 51 C 53 52
Distance Vector: Bad news travels slowly Poisoned reverse: • If Z routes through Y to get to X : • Z tells Y its (Z’s) distance to X is infinite (so Y won’t route to X via Z) • will this completely solve count to infinity problem? • No, there are cases where it will not
Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B C D E A B C D E A B C D E A B C D E C C C D E A B C C C B B C D D D D D D E A B B B B 0 1 2 3 4 4 3 2 1 0 3 2 1 0 1 1 0 1 2 3 2 1 0 1 2 Distance Vector: Bad news travels slowly link break 1 1 1 B C D A E Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 4 A B C D E A B C C C 1 0 1 2 3 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D 2 1 0 1 2 - inf Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 4 A B C D E A B C C C 1 0 1 2 3 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D - 2 1 0 1 -inf - inf Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 4 A B C D E A B C C - 1 0 1 2 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D - 2 1 0 1 inf inf - inf Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B - 0 1 2 3 A B C D E A B C C - 1 0 1 2 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D - 2 1 0 1 inf inf - inf inf
Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B C D E A B C D E A B C D E A B C D E C C C D E A B C C C B B C D D D D D D E A B B B B 0 1 2 3 4 4 3 2 1 0 3 2 1 0 1 1 0 1 2 3 2 1 0 1 2 Distance Vector: Bad news travels slowly link break 1 1 1 B C D A E Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 4 A B C D E A B C C C 1 0 1 2 3 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D D 2 1 0 1 2 - inf Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 4 A B C D E A B C C C 1 0 1 2 3 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D - 2 1 0 1 -inf - inf Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B B 0 1 2 3 4 A B C D E A B C C - 1 0 1 2 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D - 2 1 0 1 inf inf - inf Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B B B - 0 1 2 3 A B C D E A B C C - 1 0 1 2 0 A B C D E C C C D 3 2 1 0 A B C D E D D D D E A B C D E B B C D - 2 1 0 1 inf inf - inf inf
After convergence, is distance vector loop-free? • Proof by contradiction • What does this mean? • Suppose that there is a loop between routers A and B • What does it mean when B is the next hop from A? • D(A,T) = min c(A,k) + D(k,T) = c(A,B) + D(B,T) • What does it mean when A is the next hop from B? • D(B,T) = min c(B,k) + D(k,T) = c(B,A) + D(A,T) • Plug D(A,T) from the first eq into the second • D(B,T) = c(B,A)+c(A,B)+D(B,T) • 0=c(B,A)+c(A,B) • As long as link costs are > 0 , loops are not possible • In dijkstra, link cost of zero is ok, but cost can’t be less than zero. • What is the least cost path when the cost is negative?
Convergence time? • Assuming • C = 1 (least hop) • Initial cost=0 or infinite • How many steps until a node N hops away from the destination convergence? Answer: N • Proof by induction • let T be the destination • Let A be one hop from T. • Then the optimal path from A to T is A->T • A learns this route after one iteration • Let B be M hops from T and have converged in M steps • Let C be M+1 hops from T and let B be a neighbor of C • Note that if C is M+1 hops from T, then it must have a neighbor that is M hops from T • Claim: C will converge in at most M+1 steps • After M steps, B has the correct cost • In the next step, C gets this cost, and this cost will never increase or decrease • Since the maximum length path has length N, it will take at most N steps
Message complexity LS: with n nodes, E links, O(nE) msgs sent DV: exchange between neighbors only convergence time varies Speed of Convergence LS: O(n2) algorithm requires O(nE) msgs If link cost vary, may have oscillations DV: convergence time varies may be routing loops count-to-infinity problem Robustness: what happens if router malfunctions? LS: node can advertise incorrect link cost each node computes only its own table DV: DV node can advertise incorrect path cost each node’s table used by others error propagate thru network Comparison of LS and DV algorithms
4. 1 Introduction 4.2 Virtual circuit and datagram networks 4.3 What’s inside a router 4.4 IP: Internet Protocol Datagram format IPv4 addressing ICMP IPv6 4.5 Routing algorithms Link state Distance Vector Hierarchical routing 4.6 Routing in the Internet RIP OSPF BGP 4.7 Broadcast and multicast routing Chapter 4: Network Layer
Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost Dest. Next hop Cost A B C D E A B C D E A B C D E A B C D E A B C D E A B C D E A B C D E B B C D D C C C D E C C C D E D D D D E A B B B B A B C C C A B C C C 4 3 2 1 0 3 2 1 0 1 3 2 1 0 1 1 0 1 2 3 1 0 1 2 3 0 1 2 3 4 2 1 0 1 2 Distance Vector: Bad news travels slowly 1 1 1 B C D A E Dest. Next hop Cost C c 0 B initial Dest. Next hop Cost Make a new table before sending a hello Dest. Next hop Cost A B C D E B B C B B 2 1 0 3 C c 0 + 4 D After processing D After processing B Dest. Next hop Cost Dest. Next hop Cost A B C D E B B C D D 2 1 0 1 A B C D E B B C B B 2 1 0 3 + New table 2 4 3 loops