How does a router know where to send a packet next?
The Problem Which path should packets take from A to B? A B R2 R R4 R3 C D 2
The Internet forwards packets hop-by-hop Data IP Address Next-hop A R B R4 C R4 D R4 B A B R2 IP Address Next-hop A A B R2 C R3 D R3 R R4 R3 C IP Address Next-hop A R3 B B C R3 D R3 D 3
It s not always obvious Which path should packets take from A to B? A R5 R2 B R6 5 5 R R4 R3 C D 4
How do the routers know how to populate the forwarding table? 5
Here are four common ways. Flooding: Every router sends every arriving packet to every neighbor 2. Source Routing: End host adds a list of routers to visit along the way 3. Static Entries: If the network owner knows, then simply write the entries into the table. 4. Routers talk to each other and construct forwarding tables using a clever algorithm 6
Find the shortest path from to 40 6 7 32 2 3 4 5 6 7 8 5 4 3 2 0 9 8 9 20 2 22 23 24 3 30 29 28 27 26 25 33 34 35 36 37 38 39 40 7
What if each link has a cost? 8
Cost = +4+4+2 = Cost = 4+9 = 3 4 4 4 A B C D E 5 2 9 5 Expensive link : It might be very long. e.g. a link from Europe to USA. Or it might be very busy. e.g. it connects to Google or CNN. Or it may be very slow. e.g. Mb/s instead of Gb/s. F G 2 H 9
A distributed algorithm to find the lowest cost spanning tree CS44, Stanford University 0
Find lowest cost path from A to H 4 4 A B C D 4 5 E 9 2 F 5 9 G 5 H 2 2 Remember the lowest cost we have heard, and the next hop to reach H. Tell our neighbors the lowest cost we know to reach H. Round #
Find lowest cost path from A to H 4 4 3 6 2 4 2 5 5 F G 5 9 9 A B C D E H 2 2 Round #2 2
Find lowest cost path from A to H 4 4 3 6 2 4 2 5 5 F G 5 9 9 A B C D E H 2 2 Round #3 3
Find lowest cost path from A to H 4 4 3 6 2 4 2 5 5 F G 4 5 9 9 A B C D E H 2 2 Round #3 4
Find lowest cost path from A to H 7 4 4 3 6 2 4 2 5 5 F G 4 5 9 9 A B C D E H 2 2 Round #3 5
Find lowest cost path from A to H 7 4 4 3 6 2 4 2 5 5 F G 4 5 9 9 A B C D E H 2 2 Round #4 6
Find lowest cost path from A to H 4 4 7 3 5 6 2 4 2 5 5 F G 4 5 9 9 A B C D E H 2 2 Round #5 7
Find lowest cost path from A to H 4 4 6 7 5 6 2 4 2 5 5 F G 4 5 9 9 A B C D E H 2 2 Round #5 8
Find lowest cost path from A to H Known as the Bellman-Ford Distance Vector Algorithm 6 5 A B C 2 D E 4 9 2 F 9 G 2 H 2 Questions. How do we know we finished? 2. In general, what is the maximum number of steps the algorithm needs to complete? 3. How do we turn this into a distributed algorithm between the routers? 4. What happens when the topology changes? 9
A more complicated topology CS44, Stanford University 20
Find the lowest cost path from to 2 24 4 27 6 25 8 5 7 4 7 9 6 8 0 28 3 7 32 26 5 7 4 30 2 6 9 6 20 2 3 4 2 2 23 22 8 0 3 3 5 29 3 2 2 Router 4 tells its neighbors: I can reach 2 with a cost of 5 2
Solution 7 6 5 24 4 27 6 25 8 5 7 4 7 9 6 8 0 28 3 7 32 26 5 7 8 4 30 2 6 4 8 9 6 28 8 9 7 20 7 2 6 2 3 7 3 4 2 2 5 23 4 5 4 22 8 0 3 3 5 29 3 3 2 7 2 2 Cost = 22 and so on! 22
A second algorithm 23
Dijkstra s shortest path first algorithm (An example of a Link State Algorithm ). Exchange link state: A router floods to every other router the state of links connected to it. - Periodically - When link state changes 2. Run Dijkstra s algorithm: Each router independently runs Dijkstra s shortest path first algorithm. Each router runs an algorithm to find the lowest cost spanning tree to reach every other router. CS44, Stanford University 24
Find lowest cost path from H to every router 4 4 A B C D 4 5 E 2 F 9 G 5 H 2 Every router learns the topology from the flooded link-state 25
Find lowest cost path from H to every router 4 4 A B C D 4 5 E 2 F 9 G 5 H 2 Add path of cost Add path of cost 2 Add path of cost 2 D C D G H G H G H 26
Find lowest cost path from H to every router 4 4 A B C D 4 5 E 2 F 9 G 5 H 2 C Add path of cost 4 D B Add path of cost 5 C D F G H F G H.. 27
How to find the lowest cost tree manually 4 4 A B C D 4 5 E 2 F 9 G 5 H 2 0 2 3 4 5 6 7 Shortest Path Set Candidate Set Add H DEFG G 28
Dijkstra s Algorithm Questions:. How long does the algorithm take to run? 2. What happens when link costs change, or when routers/links fail? CS44, Stanford University 29
Dijkstra s algorithm in practice Dijkstra s algorithm is an example of a Link State algorithm. - Link state is known by every router. - Each router finds the shortest path spanning tree to every other router. It is the basis of OSPF (Open Shortest Path First), a very widely used routing protocol. CS44, Stanford University 30
Another view of Dijkstra CS44, Stanford University 3
R 3 A 4 4 4 R 4 2 R 2 R 3 R 5 3 4 B 2 CS44, Stanford University 32
A R R 4 R 2 R 3 R 5 B CS44, Stanford University 33
A R 3 4 4 4 R 2 R 3 R 4 R 5 4 2 3 2 CS44, Stanford University B 34
Routing between Autonomous Systems The Border Gateway Protocol (BGP) CS44, Stanford University 35
All organizations (Autonomous Systems) use the same algorithm to talk to each other CENIC Internet2 Stanford University Cambridge University 36
AS (Autonomous System) numbers nickm> traceroute -q www.cam.ac.uk nickm> whois -h whois.cymru.com 62.40.24.98 traceroute to www.cam.ac.uk (3..50.25), 30 hops max, 40 byte packets csmx-west-rtr.sunet (7.64.74.2) 8.567 ms 2 dc-svl-rtr-vl8.sunet (7.64.255.204) 0.334 ms 3 dc-svl-agg4--stanford-00ge.cenic.net (37.64.23.44).04 ms 7 et-4-0-0.4079.sdn-sw.lasv.net.internet2.edu (62.252.70.28) 4.320 ms 4 internet2.mx.lon.uk.geant.net (62.40.24.44) 44.085 ms 5 janet-gw.mx.lon.uk.geant.net (62.40.24.98) 44.552 ms 24 primary.admin.cam.ac.uk (3..50.25) 50.353 ms [Querying whois.cymru.com] [whois.cymru.com] AS IP AS Name 20965 62.40.24.98 GEANT The GEANT IP Service, GB 2320 62.40.24.98 GEANT_IAS_VRF, EU CS44, Stanford University 37
38
Border Gateway Protocol (BGP) BGP neighbors ( peers ) establish a TCP connection. BGP is not a link-state or a distance-vector routing protocol. Instead, BGP uses what is called a Path vector. For each prefix, a BGP router advertises a path of AS s to reach it. This is the path vector Example of path vector advertisement: The network 7.64/6 can be reached via the path {AS, AS5, AS3} When a link/router fails, the path vector is withdrawn 39
Border Gateway Protocol (BGP) The network 7.64/6 can be reached via the path {AS, AS5, AS3} Paths with loops are detected locally and ignored. Local policies pick the preferred path among all advertised paths. 40
Current Version BGP Version 4 or BGP-4 Described in RFC 427 (2006) Used by the Internet since 994 Used to connect all Border Gateways in the Internet Used internally in some very large private networks, such as data-centers 4
Customers and Providers provider provider customer IP traffic customer Customer pays provider to carry its packets. 42
Customer-Provider Hierarchy provider customer IP traffic 43
The Peering Relationship peer provider traffic allowed peer customer traffic NOT allowed Peers provide transit between their respective customers Peers do not provide transit between peers Peers (typically) do not exchange $$$ So how does traffic from the left side reach the right side? 44
Tier Providers A tier network is a transit-free network that peers with every other tier network Tier Tier Tier Tier Examples: AT&T, CenturyLink, Level 3, Deutsche Telekom, Tata, Verizon, CS44, Stanford University 45
Tier Tier Tier peer provider traffic allowed peer customer traffic NOT allowed Peers provide transit between their respective customers Peers do not provide transit between peers Peers (typically) do not exchange $$$ 46
BGP Messages Open : Establish a BGP session. Keep Alive : Handshake at regular intervals. Notification : Shuts down a peering session. Update : Announcing new routes or withdrawing previously announced routes. BGP announcement = prefix + path attributes Path attributes Include: next hop, AS Path, local preference, Multi-exit discriminator, Used to select among multiple options for paths. 47
BGP Route Selection Summary Highest Local Preference Enforce relationships E.g. prefer customer routes over peer routes Shortest ASPATH Lowest MED i-bgp < e-bgp Lowest IGP cost to BGP egress Lowest router ID Traffic Engineering Throw up hands and break ties 48
AS Path Selection AS 29 AS 755 AS 239 AS 2654 AS 708 AS 634 35.207.0.0/6 AS 3549 Prefix Originated 49
AS Path Selection 35.207.0.0/6 AS Path = 755 239 708 634 AS 29 35.207.0.0/6 AS Path = 239 708 634 AS 755 35.207.0.0/6 AS Path = 29 755 239 708 634 AS 239 35.207.0.0/6 AS Path = 708 634 Pick preferred AS path AS 2654 35.207.0.0/6 AS Path = 634 AS 634 35.207.0.0/6 AS 708 35.207.0.0/6 AS Path = 708 634 35.207.0.0/6 AS Path = 3549 708 634 AS 3549 Prefix Originated 50
So Many Choices peer provider peer customer AS 4 Frank s Internet Barn AS 3 AS 2 Which route should Frank pick to 3.3.0.0/6? AS 3.3.0.0/6 5
Summary of BGP All AS s in the Internet must connect using BGP-4. BGP-4 is a path vector algorithm, allowing loops to be detected easily. BGP-4 has a rich and complex interface to let AS s choose a local, private policy. Each AS decides a local policy for traffic engineering, security and any private preferences. CS44, Stanford University 52
Thank you! CS44, Stanford University 53
If there is time. CS44, Stanford University 54
Multicast routing in the Internet 55
Multicast A B C D R R 2 R 4 R 6 R 5 R 7 R 3 R 8 E X 56
Multicast A B C D R R 2 R 4 R 6 R 5 R 7 R 3 R 8 E X 57
Techniques and Principles Multicast - Reverse Path Broadcast (RPB) and Pruning - One versus multiple trees Practice - IGMP group management - DVMRP the first multicast routing protocol - PIM protocol independent multicast CS44, Stanford University 58
Reverse Path Broadcast (RPB) aka Reverse Path Forwarding (RPF) A B C D R R 2 R 4 R 6 R 5 R 7 R 3 R 8 E X CS44, Stanford University 59
RPB + Pruning. Packets delivered loop-free to every end host. 2. Routers with no interested hosts send prune messages towards source. 3. Resulting tree is the minimum cost spanning tree from source to the set of interested hosts. CS44, Stanford University 60
One tree versus several trees? A B C D R R 2 R 4 R 6 R 5 R 7 R 3 R 8 E X 6
Addresses and joining a group IPv4: Class D addresses are set aside for multicast. IGMP (Internet group management protocol) - Between host and directly attached router. - Hosts ask to receive packets belonging to a particular multicast group. - Routers periodically poll hosts to ask which groups they want. - If no reply, membership times out (soft-state). CS44, Stanford University 62
Multicast in practice Multicast used less than originally expected - Most communication is individualized (e.g. time shifting) - Early implementations were inefficient - Today, used for some IP TV and fast dissemination - Some application-layer multicast routing used Some interesting questions - How to make multicast reliable? - How to implement flow-control? - How to support different rates for different end users? - How to secure a multicast conversation? 63