Transcript 00:00 the following content is provided under 00:01 a Creative Commons license your support 00:04 will help MIT OpenCourseWare continue to 00:06 offer high quality educational resources 00:08 for free 00:09 to make a donation or view additional 00:12 materials from hundreds of MIT courses 00:14 visit MIT opencourseware at ocw.mit.edu 00:27 okay so today we're going to continue 00:29 talking about multi-hop networks and in 00:32 particular I'm going to talk about a 00:34 fairly fundamental problem in multi 00:37 health networks called network routing 00:39 and that's the topic for today and for 00:42 threw through most of half of next week 00:45 and today this week we'll talk about 00:48 network routing in networks where there 00:50 are no failures so you know in real 00:53 networks of course things fail packets 00:55 get dropped nodes may fail switches may 00:57 fail links may fail we'll just worry 00:59 about the case when there are no 01:00 failures for this week next week we'll 01:03 add some more complexity and talk about 01:05 how we deal with failures so the 01:07 abstract problem is pretty simple you 01:09 have a set of nodes in the network and 01:11 there's some network topology 01:26 and every source in the network you know 01:29 you have sources and you have 01:30 destinations loads in the network and 01:32 they wish to send packets to each other 01:35 and we're going to decompose this 01:37 problem these endpoints which actually 01:42 want you to want to communicate with 01:43 each other as we've already talked about 01:45 do so by sending packets via switches 01:48 and the problem we're going to worry 01:51 about is what happens inside the network 01:55 in these switches the switches solved 02:00 the following problem if things work 02:02 correctly and if things work well when a 02:05 switch receives a packet with the 02:08 destination address specifying that that 02:10 packet has to be sent to a particular 02:12 named destination in the network the 02:14 switch figures are how to ship that 02:17 packet it figures out whether to send it 02:19 along I need a better topology here it's 02:22 sugarstar this switch for example 02:23 figures out whether a package should go 02:25 along that link or this link or this 02:27 link or this link or that link given any 02:30 packet that receives and every switch in 02:32 the network performs this task 02:37 now when a switch gets a packet and the 02:40 packet has the destination address in it 02:42 what the switch does is some sort of a 02:45 lookup it looks up that destination in 02:50 some sort of a table and that table 02:52 maintains information about which of the 02:55 links to use in sending that packet 02:59 toward the destination and this step is 03:02 called forwarding 03:10 packets are forwarded by switches 03:14 technically packets aren't routed 03:16 everybody says packet routing and I say 03:18 too but it's important to realize 03:20 packets aren't drought at packets are 03:22 forwarded the fumbling process is pretty 03:25 straightforward at slow speeds you get a 03:28 packet you take the destination you look 03:30 up that packet in a table and that table 03:33 tells you what you do with the packet 03:35 which link to use routing is the problem 03:39 that the switch is solved of 03:41 constructing these tables so forwarding 03:44 is simply look up in a table and the 03:50 table is called the routing table 03:54 sometimes it's also called the 03:56 forwarding table and there's a technical 03:57 difference between them that's not that 03:59 important for us so forwarding is the 04:01 process of looking up the destination in 04:06 the routing table routing is the 04:08 distributed process the algorithm that's 04:10 used or the protocol that's used to 04:12 build up these routing tables so it's 04:14 the construction process how to 04:17 construct these routing tables at each 04:20 switch in the network 04:24 that's done in the background that's 04:25 usually done in software switches that 04:28 high-speeds involve a fair amount of 04:30 hardware routing itself is usually done 04:32 in software and so a typical switch you 04:37 know has a lot of different processing 04:39 elements in it a lot of those processing 04:41 elements are high speed hardware that 04:43 deals with the process of forwarding and 04:44 then you have software sitting on the 04:46 side where all of the complexity is and 04:49 all that complexity deals with all sorts 04:52 of complicated rules that you have to 04:54 come up with in order to decide how to 04:56 construct these routing tables and we're 04:58 going to talk about the world's simplest 04:59 networks today where and you'll find 05:02 that even that's reasonably 05:03 sophisticated and complicated so just 05:06 for concreteness an example of a picture 05:09 of a topology is like this and for 05:12 reasons that will become apparent as we 05:13 talk this through will model the network 05:16 as a set of nodes and a set of links and 05:18 so far there's nothing new about this 05:20 but will model links as having the cost 05:23 and this cost might reflect for example 05:26 the delay or latency to send a packet 05:29 along that link the cost might reflect 05:31 the real dollar cost of shipping data 05:34 along links internet service providers 05:37 might charge different amounts of money 05:38 for different types of data for example 05:39 well the cost might just reflect your 05:42 own internal preferences as to which 05:45 links you might prefer based on whatever 05:47 concerns maybe some links are slow and 05:49 some links are fast maybe they're higher 05:50 speed link slower speed links that cost 05:52 more or less etc so these costs are 05:55 abstract numbers and we'll just assume 05:57 that we're interested in finding minimum 05:59 cost paths between senders and receivers 06:02 so every switch solves the problem of 06:05 finding the minimum cost path to a 06:07 destination where the cost along a path 06:10 is simply the sum of the costs along the 06:12 links on that path this is just standard 06:15 shortest path routing will use shortest 06:18 paths even though we don't mean 06:19 literally the shortest number of hops 06:21 but the minimum cost path and where that 06:23 distinction is important between the 06:25 number of hops and the cost etc we'll 06:27 five so if there aren't cable looks 06:31 something like this in fact it looks 06:33 like this 06:34 there's destination every switch has 06:36 this so this is an example of a round 06:38 table at load B node B maintains all the 06:41 destinations in the network and we're 06:43 dealing with small networks so far in 06:44 our class so we'll just assume that 06:46 every node in the network has a unique 06:48 name or a unique address and that the 06:52 destination that the routing tables 06:53 contain an entry for every destination 06:55 in the network so the arm table has 06:57 three columns it's a database with three 07:00 columns and every switch in the network 07:02 or a node I'm going to use the word node 07:03 and switch interchangeably every switch 07:05 or node in the network has one of these 07:06 if the network is working correctly so 07:09 if there aren't protocol that what does 07:10 this job every node comes up with its 07:12 own version of this table there's a 07:14 destination there's the link you need to 07:16 use that is the next hop if you get a 07:19 packet to this destination what link 07:22 would you use and a cost so in this 07:24 table if node B or switch B received a 07:27 packet destined for destination a it 07:31 would use link l1 each link is named 07:34 locally so B would have its own l0 l2 07:36 and l1 you know your own computer has a 07:38 bunch of links if you do I don't know 07:41 how what the command is in Windows but 07:42 in all other sensible platforms if you 07:44 do I have conveyed you can you can get I 07:46 think it's called IP config under 07:48 windows but you can actually see a list 07:49 of links so switches have many many many 07:51 links and so you'll find for example for 07:54 destination a you use link l1 the cost 07:56 is 18 in fact you'll see here that when 07:59 when B receives a packet for a it 08:01 doesn't use the direct link because the 08:03 direct link has a cost of 19 whereas 08:05 going through l1 this link has the cost 08:08 of 11 and if it believes if B believes 08:11 that this the path toward a along this 08:14 link has a cost of elemental 7 is 18 08:16 that's what it thinks and therefore it 08:17 would use that link 08:21 okay it's very simple now routing is the 08:24 process by which these different nodes 08:26 talk to each other and build up these 08:27 tables when I say a route to a 08:31 destination I mean this I mean the route 08:35 to a destination at a switch or at a 08:37 node is the link that that destination 08:40 would use to send packets to the 08:42 destination this is important 08:45 technically for us because otherwise we 08:47 will get all tangled up getting confused 08:49 between routes and paths okay for the 08:53 purposes of our discussion a route is 08:54 the next hop link is the link that 08:56 you're going to use to get to the 08:57 destination the path is a sequence of 08:59 links so I don't want people telling me 09:02 that the route from B to E is whatever 09:06 ever it is BCE I'd like people to tell 09:09 me that the route act destiny node B to 09:11 destination e is l1 or if you wish to be 09:15 clear you can say it's link l1 which 09:17 takes it to the next hop see the path 09:20 from B to E might be BCE okay 09:26 all right so that's what the routing 09:28 table structure looks like and we're 09:30 interested in minimum cost our paths to 09:33 go from places to places so you know 09:36 normally traditionally we sit around and 09:38 try to now dive into protocols but I 09:40 think here what we're going to do is 09:42 since our notes are also nice and 09:44 written up I actually don't have to tell 09:46 you everything that's there so what 09:47 we're actually going to do is something 09:48 we call the routing game which is an 09:52 experiment in social networking like 09:55 what it means is that each of you or 09:57 some of you will act as nodes and start 10:00 computing routes to different 10:02 destinations okay so that's what this 10:04 game is going to be so what I have in my 10:06 hand is 40 slips of paper and I hope 10:10 there are 40 people here 40 slips of 10:12 paper and each of these paper slips of 10:16 paper has some information that looks 10:18 like this it says you are node X and 10:25 you're connected to nodes Y Z W etc okay 10:28 and there's a set of rules that I will 10:31 go through in a minute first of all 10:35 these were all in perfect order so I 10:36 need to shuffle them a few times 10:37 carefully without losing them 10:39 I think persi diaconis is famous 10:42 probabilistic said that you got to do 10:43 the seven times okay so what I'm going 10:49 to do is I'm gonna pass this around 10:51 there's no bag here the bag is 10:53 cumbersome so what I'd like you to do 10:55 actually I'll put it in the envelope and 10:56 pass it around just kind of close your 10:57 eyes or something don't look at the 10:59 number and just pick one up and don't 11:00 look at it until I tell you okay so we 11:03 start here and just pass it around I'd 11:05 like you know 40 different people to 11:07 have them you don't you don't have to 11:09 feel compelled to take it but just pass 11:10 it around and try to do it quickly 11:12 because I'd like that to happen faster 11:14 than the time it's going to take for us 11:16 to compute these routes so why don't you 11:18 just pick one sheet of paper up and just 11:20 pass it around please 11:21 okay so though you know I picked seven 11:24 minutes sometimes works a little faster 11:27 than seven the best that the class is 11:28 down is about five minutes and sometimes 11:30 last term they did it very quickly but 11:33 they got it wrong so 11:35 I don't think that counts but I've been 11:37 told that they've tried this experiment 11:38 Berkeley has taken usually more than 11:40 seven minutes and I figure MIT students 11:42 are smarter so let's see if you can do 11:44 it faster than seven minutes now your 11:48 job is to find a path from a source node 11:50 to a destination or as quickly as 11:52 possible okay and I mean as a bonus if 11:58 you actually find the path with the 11:59 minimum number of hops that's even 12:00 better but we'll take any pack now 12:04 there's some rules here 12:10 now there are some rules here so you may 12:12 not actually kind of get up and run 12:14 around and try to you know do things 12:16 that a normal network switch wouldn't do 12:18 so you're allowed to stay in one place 12:20 and what you're actually allowed to do 12:23 is you're not allowed to pass your sheet 12:24 of paper to other people because you 12:26 know you have information about yourself 12:27 and that piece tells you who your 12:29 neighbors are the numbers of your 12:30 neighbors so you can't actually kind of 12:32 copy the Ascend your piece of paper to 12:34 other nodes that's not allowed and don't 12:36 don't let people copy what's on your 12:37 sheet of paper now here's some things 12:40 you can do you can read them ask your 12:43 friends for advice you can shout to 12:45 other participants we're allowing you to 12:47 you know yell and scream but do so in a 12:49 way that's somewhat civilized and you 12:52 know if you can wish that you didn't 12:53 pick up a slip or pick up a slip or 12:55 whatever but you know try to act 12:56 generally I mean this class is recorded 12:58 so you know what you say might be heard 13:00 now if you get to sleep a slip there's 13:03 some ground rules you can't cheat like 13:05 you know we're not dealing with security 13:06 here's where a node that's 17 and 13:08 connected to 27 and 29 tells people that 13:11 it's 14 I mean you don't want that it's 13:12 hard enough to do when you tell the 13:14 truth so don't cheat this you know 13:16 there's probably a variant of this we 13:18 can come up with where some fraction of 13:19 the nodes they're adversarial and then 13:21 you can see if this stuff even works but 13:23 right now don't cheat if you've got a 13:25 slip you kind of have to really try to 13:27 participate in whatever protocol you 13:29 come up with and this experiment has no 13:31 human subjects approval 13:34 okay so it does um who has the envelope 13:39 is it empty oh my goodness at seven 13:42 minutes already 13:43 let's okay well when the envelope gets 13:50 empty we can start this thing so we 13:53 should try to move it along 13:54 is everyone clear on the rules what 13:57 you're trying to do is to find a path 13:58 between a node that the source node 14:01 which was numbered one and the 14:02 destination node enough that was number 14:04 forty the source and the destination 14:05 know who they each are and then we'll 14:07 just gonna wait this is the easiest 14:09 lecture to prepare for because I just 14:10 have to keep quiet 14:11 for a few minutes okay and if things all 14:15 work out or things don't work whatever 14:16 it is I'm assuming that you'll come up 14:18 with some variant of the reasonable 14:19 routing protocol and odds are it will be 14:22 a variant of one of the ones we're going 14:23 to study you know the general hero's 14:26 suggest if something was a reasonable 14:27 idea which is you go and you know you 14:29 you do one you tell you you know you 14:32 pick one neighbor and you go through but 14:34 you get stuck in a loop and then the 14:35 idea is you come back to where you start 14:37 and then you go through the next and 14:38 that principle could work but you gotta 14:41 remember a lot of stuff and tends to 14:43 make mistakes in fact you know this was 14:45 an easy Network where every node had one 14:46 two or three neighbors I mean as a few 14:48 with more but most of them had a small 14:49 number of neighbors what you guys were 14:51 going after was a sort of better plan 14:53 which is everybody yells out the 14:54 neighbors and the day as yell out their 14:55 neighbors and their neighbors and so 14:57 forth and that particular protocol has a 14:58 nice name to it it's called link state 15:00 routing where you broadcast and flood 15:04 your own neighbor information okay 15:07 that's the second of the two protocols 15:09 we're going to study what you were 15:11 trying to go after was a link state 15:12 routing 15:14 now the first protocol we're gonna study 15:18 has a different name to it it's called 15:20 distance vector re 15:25 and these are the two routing protocols 15:28 we're going to study almost all routing 15:31 protocols and practice are variants of 15:32 either a vector protocol or one of these 15:35 link-state protocols there's lots of 15:36 variants but these cover and there's 15:39 hundreds of routing protocols but these 15:41 cover the main concepts so let me tell 15:45 you how this is our distance vector 15:47 protocol or how the vector protocols 15:49 works they're a little different from 15:51 the kind of approach you were going 15:53 after in solving this problem had you 15:56 gone after an approach where you started 15:59 at the destination at 40 and 40 simply 16:03 said I'm 40 and then the neighbors next 16:08 to 40 then said I'm connected to 40 to 16:11 get to 40 come through me and the cost 16:14 is let's say whatever the cost of their 16:16 link to 40 is right then now initially 16:20 nodes only knew about themselves but now 16:23 you have a destination and you have a 16:24 set of nodes connected to the 16:25 destination let's call these nodes let's 16:30 just say n1 n2 and n3 16:35 initially the only thing that D says is 16:38 I'm D and it says back to its neighbors 16:41 along these links the same has a name to 16:47 it it's in it's an advertisement now 16:53 when anyone hears about destination D it 16:56 can do the same thing to its neighbors 17:01 so let's say these are n4 and n5 here 17:06 what n1 can do is to say that to get to 17:09 D let's imagine that this cost here is 6 17:12 so D says I'm D and the cost to get to 17:15 me is 0 because I'm D n1 says here's 17:20 that and it says I'm n1 that's true but 17:23 to get to D come through me and the cost 17:26 is 6 so it now puts out advertisements 17:28 along these links but it says D : 6 6 6 17:38 where 6 is the cost of that link 17:42 and now let's imagine that you know 17:44 these other links have cost so let's say 17:45 this link has a cost of eight this link 17:47 has a cost of two let's say this link 17:50 has a cost of 9 so the link cost is 17:57 eight the link cost is nine and the link 17:59 cost is two and let's say for a minute 18:01 here that this cost of this link is 18:03 there now n1 advertises to everybody 18:07 saying to get 2d the cost is six to get 18:11 2d the cost to six and they get to get 18:13 2d the cost of six each of those guys 18:15 when they get this information now know 18:18 that they can get a route to destination 18:23 D because now and for now is that if it 18:26 used this link to get 2d the cost would 18:29 be six plus the cost of that link so 18:33 it's 14 so it would have a routing table 18:35 entry that says D is a cost 14 and of 18:39 course the routing table entry would 18:40 have an entry saying this is the link 18:42 that it should use similarly n5 here 18:47 would take destination D and say that 18:52 the cost to destination D is 9 plus the 18:55 advertisement which was 6 and so it 18:57 would say D is 15 and n 2 which 19:02 previously had her out today which was 19:04 this link that cost 10 would look at 19:07 this new advertisement coming in here 19:09 saying that the cost on this from n1 is 19:13 6 add that cost to the cost of the link 19:16 which is 2 and have now a different way 19:20 to get to D whose cost is 8 and compared 19:23 that cost against the cost a previously 19:24 held to the destination D and because 19:27 we're interested in minimum cost routing 19:29 8 smaller than 10 so n 2 would 19:32 previously which had previously had a 19:34 cost to destination D of 10 would throw 19:37 that route out 19:38 replace it with a route the destination 19:41 D going along this link with the cost of 19:44 now eight which is smaller than ten and 19:48 this process just continues through as 19:50 it goes along so you might end up in a 19:53 situation quite easily as we just went 19:55 through here well let's say n 3 will 19:56 connected to n 5 if this link had a cost 19:59 of 1 in this link at a cost of 4 what 20:01 would eventually happen is that n 5 20:03 which ended up with the cost of 15 to go 20:06 like that would when it here's an 20:07 advertisement from this node replace 20:09 that route with a cost of 4 and use this 20:12 link as its route to get to get the 20:15 destination D and this process just 20:16 continues until everybody has initially 20:19 some route to D and then if the process 20:22 continues a little bit longer everybody 20:24 will have a minimum cost route to D this 20:28 step where nodes evaluate an 20:31 advertisement that they hear about a 20:34 destination against their current route 20:36 and the current cost to the destination 20:38 and replace it if they end up finding a 20:43 route with smaller cost or an 20:45 advertisement with smaller cost when you 20:48 the cost you have to compare is the cost 20:50 of the advertisement plus the cost of 20:52 the link along which that advertisement 20:54 came and you compare that cost against 20:56 the cost of the route you already hold 20:58 if it's smaller you replace it that 21:01 algorithm is called the bellman-ford 21:03 algorithm 21:04 and you might have seen centralized 21:07 implementations of shortest path routing 21:10 using this algorithm and if you have it 21:13 actually turns out it's a little less 21:14 efficient than other algorithm another 21:16 one we'll study called Dijkstra's if 21:18 you're doing it centralized but it's 21:19 very very elegant elegant for 21:21 distributed computation because the 21:24 routes to different destinations are 21:26 being computed in a completely 21:27 distributed way these nodes far away 21:30 here have no idea what the network 21:32 topology looks like they couldn't even 21:34 reconstruct the network topology the 21:35 best they could do is to find their own 21:37 way to get you know their link to use 21:39 the only information they have is what 21:41 they hear from their neighbors but yet 21:43 they're able to find an answer because 21:45 all they have to do is to listen to all 21:47 their neighbors and among the set of 21:50 neighbors pick that neighbor whose 21:54 advertise cost plus the cost of the link 21:56 to that neighbor is minimum across all 21:58 of the neighbors so the computation 22:01 that's being done is a very simple 22:03 computation very elegant computation 22:04 which is the main over all of the 22:07 neighbors of the link cost lij plus the 22:11 advertised cost from j where the minimum 22:15 has gone over all are all j where j is 22:17 the set of neighbors so you minimize 22:23 over the set of the neighbors each node 22:25 I does this you minimize over the set of 22:26 neighbors J of I the link cost from I to 22:30 J plus the advertised past to 22:33 destination D of J and take the minimum 22:37 cost that's the minimum cost and then 22:39 you take the link corresponding to that 22:41 neighbor and that's the route that you 22:42 use 22:46 now this algorithm gets more complicated 22:48 and tricky to argue that it's correct 22:50 when there are failures but today there 22:51 are no failures there's some other 22:56 wrinkles in the algorithm which is I 22:57 mentioned that you know what are the 23:00 conditions under which a link node 23:02 changes its route to a destination so I 23:06 went through one rule I I mentioned a 23:09 rule that said if the current copy if 23:11 the current route to the destination 23:12 does not exist in which case the cost is 23:15 assumed to be infinity or if the current 23:19 cost to the destination is smaller than 23:22 the cost of the advertisement plus the 23:24 cost of the link along which the 23:25 advertisement came then you replace the 23:28 route to the destination but there's 23:31 actually one other condition under which 23:32 you should replace the route to the 23:33 destination 23:42 if it's equal well technically you don't 23:44 have to replace it you still have a good 23:45 pad right 23:46 you could replace it but it doesn't 23:48 matter there might be a case where you 23:50 have to replace the link the route when 23:53 and when in fact the cost increases 23:57 there might be a case where you hear a 24:00 you you have a current cost to the 24:02 destination and some current route to 24:05 the destination and you hear an 24:06 advertisement and you take that 24:07 advertisement and you add the link cost 24:09 and you find a bigger number and you 24:10 might sometimes have to replace it yes 24:23 right it could be that what's going on 24:25 here is that the cost to the destination 24:28 you know a link I might I previously 24:30 told you that my cost to the destination 24:32 is 17 and now I've changed my mind I 24:34 tell you that it's actually 19 and I 24:36 could change my mind for a variety of 24:37 reasons usually having to do with 24:38 failure so I guess this is a little bit 24:40 of a cheating question because I told 24:41 you there's no failures but it could be 24:43 that perhaps you know the cost of a link 24:47 changed because it became more expensive 24:48 or something like that and that's the 24:50 only subtle case you have to worry about 24:52 where a cost of only the advertisement 24:54 could could increase and if that cost 24:57 increases along your current route like 25:00 you think that the route to the 25:01 destination is 17 the cost is 17 but in 25:04 fact it turns out to be you know 24 25:06 that's the time when you have to change 25:08 your entry in the routing table you have 25:09 to change the cost associated with it 25:11 but otherwise it's basically that's the 25:14 algorithm and it's summarized over in 25:17 this in the stable I in this chart here 25:19 and I've gone through pretty much all of 25:21 it does anyone have any questions 25:29 no questions 25:32 how long does it take before every node 25:36 in the network actually before I get to 25:38 that the reason it's called a vector 25:39 protocol is I showed you a picture for 25:42 one destination but in fact each switch 25:45 or each node does it for all 25:46 destinations so the general form of a 25:49 distance vector advertisement looks like 25:54 this it has a destination destination 1 25:58 : cost one destination to Poland cost to 26:04 destination 3 : cost 3 and so forth for 26:07 all the destinations to which you have a 26:09 cost and initially when you start you 26:12 don't know about all of any of the other 26:13 nodes if you have a route to some 26:15 destination in general then there's some 26:17 cost associated with it if you know 26:19 about a destination but have no route to 26:21 it 26:21 the cost is infinity it'll turn out next 26:24 week will find that the value of 26:26 infinity in this network has to be 26:27 pretty small but that's because the 26:30 sarvam is not the world's best algorithm 26:32 for big networks and I'll explain why 26:34 infinity has to be a small number but 26:37 theoretically we can assume it's 26:39 infinite 26:40 the reason it's called a vector protocol 26:43 is because the advertisements are a 26:45 vector of this destination cost tuples 26:47 and so you send these tuples around and 26:50 this is a vector of these tuples and 26:51 hence this is called a vector protocol 26:53 it really should be called cost vector 26:55 protocol but initially they ran this 26:57 thing where all of the links had cost of 26:59 one where and therefore they were 27:00 minimizing distance and the name stuck 27:02 but if we wanted to be perfectly precise 27:05 we would say cost vector but then no one 27:06 else in the world would understand what 27:08 you meant so we say distance vector okay 27:11 any questions all right how long does it 27:15 take before every node in the network 27:17 for some destination how long does it 27:19 take before every node in the network 27:20 has a route to that destination where by 27:24 how long I mean how many advertisement 27:26 cycles do you have to go through how 27:28 many how many of these advertisements 27:30 like initially let's say that the way 27:32 our world is going to work is initially 27:33 every node advertises its own 27:36 advertisement to itself then at the next 27:38 time step every node advertises their 27:40 arts that it knows about and then it 27:42 does that periodically so let's say that 27:44 every T seconds a node sends out an 27:47 advertisement where an advertisement 27:48 basically contains this tuple of this 27:51 the spec vector of tuples for all of the 27:53 destination it knows about right so let 27:56 me explain this protocol again and then 27:57 I'll ask you the question the protocol 28:00 is very simple every T seconds 28:08 what what the nodes doing is looking at 28:10 two columns in the thriving table it's 28:12 looking at the destination column and 28:14 the cost column and it's just taking 28:16 that information out and it sends out an 28:18 advertisement the distance okay every T 28:24 seconds how long does it take now let's 28:27 focus on one destination D some 28:30 destination D in the network and you 28:31 have some network how long does it take 28:33 before every node has some route to the 28:36 destination yes up to the number of 28:43 edges in my network all right so let's 28:48 say you have a network that looks like 28:49 this 28:55 how long does it take before every node 28:57 has a route to destination be there for 29:03 well I'm asking for an answer that holds 29:06 for all networks not for sure in the 29:10 worst case it could well yes in the 29:16 absolute worst case it is true that 29:17 it'll always take time smaller than the 29:20 number of edges in the network but you 29:21 can come up with a much better bound so 29:23 let's try to come up yes sir longest 29:29 length chain so that's not completely to 29:32 the longest what kind of longest length 29:33 because you could have a really so 29:35 another counter example let's say that I 29:37 have this network the longest length 29:40 chain is 1 2 3 4 5 6 but yet you guys 29:44 just told me that in one shot you get 29:45 the answer so you have to clarify what 29:49 you meant a little bit you're almost 29:50 right 29:53 I said find a path or find a route not 30:02 the best route how long does it take to 30:06 find a route and network you said this 30:07 almost the longest path but it's not 30:10 quite the longest path it's the longest 30:11 something bad yes 30:14 the longest shortest path that is the 30:17 longest path with the minimum number of 30:19 the longest path when you compute the 30:21 longest overall paths with a minimum 30:22 number of hops between one place to 30:24 another that's also called the diameter 30:25 of the network okay yes yes okay all 30:31 right now that's the time it takes a 30:33 multiply by T and I might be off by one 30:35 you know it's one minus that minus one 30:37 actually it's not it is the number of 30:39 hops along the longest shortest path now 30:43 how long does it take to find the 30:47 minimum cost path - there - to some 30:51 destination D at all of the nodes 30:58 what 31:01 three times no that's that's true that 31:03 you can find it within that oh that's 31:04 too long so I'm gonna come back to this 31:08 question it's probably answered in my in 31:10 one of the chilla too in chapter 18 I 31:14 think but we'll come back to that next 31:15 time it'll become a little bit clearer 31:16 but you should think about it there's a 31:18 nice succinct answer to this question 31:19 and generally speaking in every quiz 31:21 there's some variant of this question so 31:23 you know it's not explicit but there's 31:25 some story that looked wise if yes you 31:27 have an answer 31:27 oh you do okay I'll come back to that 31:30 question next time but yes yeah I can go 31:36 over that so let's say you have here 31:47 you look at this destination beam and 31:50 you look at from every node what's the 31:53 path with the smallest number of hops 31:55 number of hops not cost path with the 31:57 smallest number of hops to get to that 31:59 destination right so this guy it's one 32:02 two three four this guy it's one two 32:05 three etc whatever that biggest number 32:08 is multiplied by T is the answer that's 32:12 how long it takes before every node here 32:15 some pack but it's not quite the right 32:17 answer for the best path because as you 32:19 saw in this example here it took us one 32:23 step before n to God a proud to the 32:25 destination but it took us two time 32:27 steps before it got its best route to 32:30 the destination and the reason was that 32:31 has something to do with the length of 32:33 the minimum cost path right because in 32:37 this case the length of the minimum cost 32:38 path is two plus six eight it took two 32:40 hops which is different from the length 32:43 of some shortest hop path which was one 32:45 half so if I look at this picture and to 32:47 here's about some route to the 32:49 destination in the first advertisement 32:51 but then to find its best route to the 32:53 destination requires us to actually wait 32:56 around until we find this two plus six 32:59 path which took two hops so it's a 33:01 little longer but it's not like 33:03 enormously long it's just a little bit 33:04 longer and the answer of course depends 33:07 on in the worst case it could be quite 33:08 long but it depends on the number of 33:11 hops along the minimum cost path and if 33:14 you minimize that quantity you find the 33:16 answer to the question how long does it 33:19 take before every node finds the minimum 33:20 cost path to the destination 33:22 okay is that clear any questions about 33:26 distance-vector crystal fear okay we'll 33:33 see when the lab comes around 33:35 it is crystal everybody really really 33:38 does well in the slide in these labs 33:39 it's a lot of fun hacking the stuff up 33:41 so your Olympic medals and you'll 33:44 actually look at all sorts of failures 33:45 and it'll just be sometimes miraculous 33:48 that it actually works even when you 33:49 didn't consider some failure cases okay 33:52 now I'm going to talk about link state 33:53 routing and this is the routing protocol 33:56 that you guys were sort of attempting to 33:57 implement attempting to come up with 34:00 this is a radically different approach 34:03 from the vector protocols in a vector 34:06 protocol everybody advertises for each 34:09 destination a vector of tuples where 34:12 it's the destination and the cost in a 34:15 link state protocol we don't do that the 34:17 link state protocol 34:18 does not compute in a distributed way in 34:21 a link state protocol every node just 34:22 says I am node 17 and I am connected to 34:25 1645 and 44 and the cost of my link to 34:29 16 is 7 the cost of my link to 45 is 34:32 something and the cost of my link to 34:35 this other neighbor that I have is 34:37 something else 34:37 so every node advertises what I've shown 34:40 up on the slide every node advertises a 34:43 neighbor it's immediate neighbor and the 34:46 link cost to that neighbor okay in 34:50 addition in each of these link state 34:52 advertisements there is a sequence 34:54 number the sequence number starts at 34:56 some initial value like say zero and 34:58 every time one of these link-state 35:01 advertisements is sent and that's done 35:03 periodically as well every T seconds 35:04 every time you send a link state 35:06 advertisement you increment the sequence 35:08 number by one 35:09 now here's the key step the key step 35:13 here is that when a node receives if I 35:18 receive a link state advertisement from 35:20 you I just send that to my neighbors and 35:23 then my neighbors will send it to their 35:26 neighbors and so on so it's a very this 35:28 nice flooding protocol every node sends 35:31 out its link state advertisement and 35:33 every neighbor that receives it 35:36 processes that and then turns around and 35:38 ships it to their neighbors and they do 35:41 the same thing to their neighbors and so 35:42 forth now when this flooding process 35:45 completes and every node is originating 35:47 its own link-state advertisements so 35:49 you're telling them you know your 35:51 neighbors who you're connected to she's 35:52 telling her neighbors who she's 35:54 connected to and we all do that and 35:56 we're all doing this in parallel it's 35:58 all happening at the same time and all 35:59 our neighbors are rebroadcasting this 36:01 and eventually every nodes going to get 36:04 one or more copies of every link state 36:07 advertisement which means that every 36:09 node can now construct an entire map of 36:10 the network every node can construct 36:13 this entire graph and once they 36:15 construct that graph every node can 36:17 implement some shortest path routing 36:19 protocol to compute the paths over that 36:21 graph this is very different from the 36:23 previous protocol in vector routing 36:25 protocols the nodes actually have no 36:27 idea what the topology of the network is 36:29 all they know is and they trust what the 36:31 neighbors tell them here every node has 36:34 complete knowledge under the basic model 36:37 every node has complete knowledge of the 36:38 overall network topology so let me show 36:42 this by example 36:44 become completely clear so let's imagine 36:46 that this is what the network looks like 36:48 and you start I'm going to show you a 36:51 picture of no death no deaf originates 36:55 its initial link-state advertisements a 36:57 day Iseman it increments the sequence 36:59 number by one and it says I am connected 37:02 to G with no G with a cost of eight and 37:06 the node C with a cost of two and it 37:08 spits it out to its neighbors each of 37:10 those neighbors turns around and does 37:11 the same thing you rebroadcast a 37:14 link-state advertisement along the links 37:16 that you're connected to and they 37:19 rebroadcast it and so forth and 37:20 eventually be get said and he broadcasts 37:22 it too though it was completely useless 37:23 to do so well not completely packets are 37:27 lost it's pretty useful anyway when this 37:30 flooding completes which takes you know 37:32 some number of steps every node now has 37:35 at least one if no packets are lost 37:37 every node has a bunch of copies of this 37:39 link state advertisement if packets can 37:41 get lost as long as the loss rates are 37:43 not you know enormous every node might 37:46 have one copy of a link state 37:48 advertisement and now every node 37:50 originates its own link-state 37:51 advertisements and therefore they end up 37:53 with a map of the network by the way why 37:56 do we have the sequence number in the 37:58 link state advertisement 38:03 yes 38:13 yes that is one of the two reasons why 38:17 you have it that's actually the second 38:18 reason the main reason you have and 38:20 that's a valid reason but the main 38:21 reason you have it is that if si gets a 38:24 link-state advertisement originating 38:26 from F with sequence number 17 and then 38:29 eventually C is also going to get D 38:31 rebroadcasting that link-state 38:33 advertisements ends it this way but F 38:35 also sends it this way and that goes up 38:37 here and that comes down here and then D 38:39 rebroadcast said C needs a way of 38:41 telling whether this link-state 38:42 advertisement is new or old right and 38:45 the way it tells if it's new or old is 38:47 it considers the link-state 38:49 advertisements bigger than the last 38:52 sequence number it received from that 38:54 origin so now every note has a map of 38:58 the network and now we run this 39:00 integration step where we actually take 39:02 this map of the network and we find 39:04 shortest paths to the network I need a 39:06 show of hands how many people know how 39:07 Dijkstra's algorithm works from how many 39:09 people don't know how it works all right 39:12 what I'm going to do is it's described 39:14 very well in the notes we've talked 39:15 about in recitation tomorrow but I'm 39:16 going to show it by example and then 39:18 we'll come back to this again on Monday 39:20 but I'm going to tell you this now 39:21 because you kind of need it for the lab 39:23 and it is just that very well in the 39:25 readings and we'll do it in recitation 39:26 as well so here's how it works let's 39:29 imagine we want to find paths from a to 39:31 all of the other nodes in the network 39:33 now initially a doesn't know paths to 39:36 anyone except for itself but what a nose 39:38 is this map of the network and what is 39:40 trying to do is to find routes to all 39:42 the other destinations the way does that 39:45 is it keeps building up in non 39:48 decreasing order of the cost of the 39:50 minimum cost path to the destination it 39:52 starts building up information about the 39:54 routes to the different destination so 39:56 initially it looks 39:57 the stable and it says it's connected to 39:59 C and it's connected to B with a cost of 40:01 six so what it does is it says all right 40:03 among all of the people out here I'm 40:05 going to pull in the person with the 40:08 minimum that minimum cost path and it 40:10 might pick in this case it might just 40:13 pick the node C because between C and B 40:15 it doesn't matter which one it takes now 40:17 the cost to all of the other guys is 40:19 considered to be infinity so it has 40:23 costs of six and six so it pulls in one 40:25 of them by without loss of generality it 40:27 just picks one of them and now it has 40:29 cost to both of them and it says that 40:31 the route from a itself at a the route 40:34 to see is this link what it then does is 40:38 it goes and looks at all of the 40:39 neighbors connected to a and C and in 40:41 fact it only has to look at the New 40:42 Nordic pulled in and it has to adjust 40:44 the cost of the minimum cost path to the 40:47 destination that's connected to that in 40:49 this case it adjusts from infinity it 40:52 brings down the cost to be to 13 because 40:54 it knows that it can get to C is 6 6 40:56 plus 7 is 13 similarly it does that for 40:59 e at 10 and then it does that to F at 8 41:02 so now it has costs of 66.6 is already 41:07 in 6 13 10 and 8 and infinity so now it 41:11 has to decide what node to pull in next 41:12 and it pulls in the node with the 41:15 minimum cost among the costs that you 41:17 have so far and that's this node over 41:19 here so it pulls that in if my wireless 41:23 works there we go and then once it pulls 41:26 that in it adjusts the route to that to 41:28 be the green link and then it goes ahead 41:30 and looks at the neighbors of B and it 41:33 adjusts the shortest path cost in this 41:35 case that 13 now becomes 11 because 6 41:38 plus 5 going through B is shorter than 6 41:40 plus 7 going through C 41:42 and now it repeats it pulls down the 41:44 minimum the minimum of this case is 8 it 41:46 pulls in F makes that be the route to F 41:49 now the route to F is not that link the 41:51 route to F is in fact this link at the 41:54 routing table but it knows that because 41:56 it knows that F is connected to C and 41:58 therefore the route to F is equal to the 42:00 route to the parent which is C's 42:02 therefore in the throttle table entry it 42:04 makes the route to FB that link which is 42:06 exactly the link to C so that's the 42:08 subtlety you have to keep in mind when 42:10 you implement this stuff in the lab it 42:12 goes ahead and adjust that to 16 it now 42:14 pulls the minimum which will be 10 and 42:17 then adjusts the cost of the guys 42:20 connected to it so D becomes D changes 42:23 to 10 and then it now goes ahead and 42:26 pulls the minimum in in this case it's 42:27 12 its D with a cost of 10 that's the 42:32 link to use and that link there for the 42:35 route to D is the same as there are two 42:36 e there are two E's the same as there 42:38 are two C which is that link and now you 42:40 finally conclude the algorithm by 42:42 getting that last node here so I'm going 42:47 to stop here that was Dijkstra's 42:48 algorithm and the two routing protocols 42:50 we will pick it up in recitation