lab 4 dynamic routing cs144 review session 5 october 30, 2009 samir selman
TRANSCRIPT
![Page 1: Lab 4 Dynamic Routing CS144 Review Session 5 October 30, 2009 Samir Selman](https://reader033.vdocument.in/reader033/viewer/2022042505/56649d8e5503460f94a76b1e/html5/thumbnails/1.jpg)
Lab 4Dynamic Routing
CS144 Review Session 5October 30, 2009
Samir Selman
![Page 2: Lab 4 Dynamic Routing CS144 Review Session 5 October 30, 2009 Samir Selman](https://reader033.vdocument.in/reader033/viewer/2022042505/56649d8e5503460f94a76b1e/html5/thumbnails/2.jpg)
Announcements
• Lab 4 : Due in 2 weeks (Thurs ,Nov 12)• Lab 3 : Due Yesterday• For those of you submitting late, contact us
before your deadline if you need an additional extension. Tell us:– Where you are– How much more time you need
![Page 3: Lab 4 Dynamic Routing CS144 Review Session 5 October 30, 2009 Samir Selman](https://reader033.vdocument.in/reader033/viewer/2022042505/56649d8e5503460f94a76b1e/html5/thumbnails/3.jpg)
Routing
• Static Routing (Implemented Lab 3)• Dynamic Routing:– Unicast Routing:• Interior Gateway Protocols (RIP, OSPF, IS-IS)• Exterior Gateway Protocols (BGP)
– Multicast Routing• Examples: Multicast OSPF (MOSPF) , Multicast
BGP(MBGP)
• This Lab will cover RIP
![Page 4: Lab 4 Dynamic Routing CS144 Review Session 5 October 30, 2009 Samir Selman](https://reader033.vdocument.in/reader033/viewer/2022042505/56649d8e5503460f94a76b1e/html5/thumbnails/4.jpg)
Routing
![Page 5: Lab 4 Dynamic Routing CS144 Review Session 5 October 30, 2009 Samir Selman](https://reader033.vdocument.in/reader033/viewer/2022042505/56649d8e5503460f94a76b1e/html5/thumbnails/5.jpg)
Routing Information Protocol(RIP)
• RIP:– Routing Protocol based on Bellman-Ford, Distance Vector
algorithm.– Intra-domain routing algorithm or interior gateway
protocol (IGP)– Cost is usually hop count– Limitations:
• The protocol is limited to networks whose longest path is 15 hops• The protocol depends upon "counting to infinity" to resolve
certain unusual situations• The protocol uses fixed "metrics" to compare alternative routes
![Page 6: Lab 4 Dynamic Routing CS144 Review Session 5 October 30, 2009 Samir Selman](https://reader033.vdocument.in/reader033/viewer/2022042505/56649d8e5503460f94a76b1e/html5/thumbnails/6.jpg)
RIP-Lab4: Implementation
• Lab 4 is just a subset of RIP• Want you to focus on the RIP part of the
router => Supplied you with ‘dr’ binary• Binary relies on API implemented in a shared
library to handle dynamic routing. You should implement this library.
• Write code in dr_api.h and dr_api.c
![Page 7: Lab 4 Dynamic Routing CS144 Review Session 5 October 30, 2009 Samir Selman](https://reader033.vdocument.in/reader033/viewer/2022042505/56649d8e5503460f94a76b1e/html5/thumbnails/7.jpg)
RIP-Lab4
• Each Router has a forwarding table containing an entry for every destination network.
• Forwarding table Entry: (Dest Network, Cost, Next-hop, Time Stamp).– Dest Network: Represented by a network address and
a network mask (X.X.X.X / Y)– Cost: Sum of link costs to reach destination.– Next-hop: IPv4 address of next router along the path to
destination– Time Stamp: Used to timeout routing entries
![Page 8: Lab 4 Dynamic Routing CS144 Review Session 5 October 30, 2009 Samir Selman](https://reader033.vdocument.in/reader033/viewer/2022042505/56649d8e5503460f94a76b1e/html5/thumbnails/8.jpg)
RIP-Lab4: RIP Packet Format
• RIP packet:
• Command: Indicates whether packet is request or response– Request: Asks that a router sends all or part of its routing table. (For
this Lab you don’t need to worry about RIP Requests)
– Response: Either unsolicited routing update or a response to request.
• Version: RIP version used. Lab 4 uses RIP V2• AFI: Address family used. (AF_INET)• Route Tag: Not used in this lab (replaced by pad)
![Page 9: Lab 4 Dynamic Routing CS144 Review Session 5 October 30, 2009 Samir Selman](https://reader033.vdocument.in/reader033/viewer/2022042505/56649d8e5503460f94a76b1e/html5/thumbnails/9.jpg)
RIP-Lab4: RIP Packet Format
• RIP packet:
• Network address: IP address for the entry• Subnet Mask: Contains subnet mask for the entry• Next Hop: Indicates IP address of the next hop to which
packets for the entry is forwarded.• Metric: Indicates how many hops(routers) have been
traversed in the trip to the destination. (16=unreachable)
![Page 10: Lab 4 Dynamic Routing CS144 Review Session 5 October 30, 2009 Samir Selman](https://reader033.vdocument.in/reader033/viewer/2022042505/56649d8e5503460f94a76b1e/html5/thumbnails/10.jpg)
RIP-Lab4: Periodic Updates
• Send routing updates:– At regular intervals (periodic)– When a router changes the metric to a route (Triggered
Updates)
• Every 10 sec send RIP reply message to all neighbors containing complete routing table
• Triggered update when an interface goes down or cost of a local interface changes.
![Page 11: Lab 4 Dynamic Routing CS144 Review Session 5 October 30, 2009 Samir Selman](https://reader033.vdocument.in/reader033/viewer/2022042505/56649d8e5503460f94a76b1e/html5/thumbnails/11.jpg)
RIP-Lab4: Route Timeouts
• Dynamic Route:– Route learned from a neighboring router– Have a Timestamp field per entry– When receive an update, a router sets the entry Timestamp value
to the current time.– Periodically check if entries expired (current time – updatetime > 20
sec.– If an entry expires => set the Cost = INFINITY
• Local Route:– Directly Connected Networks– Invalid TTL= -1– Next_hop_ip = 0
![Page 12: Lab 4 Dynamic Routing CS144 Review Session 5 October 30, 2009 Samir Selman](https://reader033.vdocument.in/reader033/viewer/2022042505/56649d8e5503460f94a76b1e/html5/thumbnails/12.jpg)
RIP-Lab4: Routing Loops
• Split Horizon with Poisoned Reverse– Prevent a loop from occurring between two nodes– Advertise information back to source with cost INFINITY.– What about loops with more than 2 nodes. eq: A -> B, B ->
C, C -> A ?• Cannot stop such a loop using split horizon.• This loop will only be resolved when the metric reaches infinity
and the network involved is then declared unreachable• Speed up process using triggered update.
![Page 13: Lab 4 Dynamic Routing CS144 Review Session 5 October 30, 2009 Samir Selman](https://reader033.vdocument.in/reader033/viewer/2022042505/56649d8e5503460f94a76b1e/html5/thumbnails/13.jpg)
RIP-Lab4: Routing Loops
![Page 14: Lab 4 Dynamic Routing CS144 Review Session 5 October 30, 2009 Samir Selman](https://reader033.vdocument.in/reader033/viewer/2022042505/56649d8e5503460f94a76b1e/html5/thumbnails/14.jpg)
RIP-Lab4: Code
• You should only touch the safe_ methods (threading handled already for you)
• Routing table entry/** a single entry in the routing table */typedef struct route_t { uint32_t subnet; /* destination subnet which this route is for */ uint32_t mask; /* mask associated with this route */ uint32_t next_hop_ip; /* next hop on on this route */ uint32_t outgoing_intf; /* interface to use to send packets on this route */ uint32_t cost; struct timeval last_updated;
int is_garbage; /* boolean which notes whether this entry is garbage */
route_t* next; /* pointer to the next route in a linked-list */} route_t;
![Page 15: Lab 4 Dynamic Routing CS144 Review Session 5 October 30, 2009 Samir Selman](https://reader033.vdocument.in/reader033/viewer/2022042505/56649d8e5503460f94a76b1e/html5/thumbnails/15.jpg)
RIP-Lab4: Code
• safe_dr_get_next_hop(ip): Called when router needs to know how to route a packet. Returns which interface packet should be sent out and IP address of next hop.
• safe_dr_handle_packet: Method called when router receives a dynamic routing packet.
• safe_dr_handle_periodic(): Method called periodically by the router.
• safe_dr_interface_changed: When interface goes up or down or upon a change in direct link cost
• dr_init: Used to initialize any internal data structures.
![Page 16: Lab 4 Dynamic Routing CS144 Review Session 5 October 30, 2009 Samir Selman](https://reader033.vdocument.in/reader033/viewer/2022042505/56649d8e5503460f94a76b1e/html5/thumbnails/16.jpg)
RIP-Lab4: Running the Lab
• First start the lvns server– ./lvns -t simple.topo
• If the server is running on the same machine as the dr instance, then you can start a router which takes control of a node named "dr1" like this: – ./dr -v dr1
• If you are running dr from a separate location you'll want to specify the server‘s address and port explicitly: – ./dr -v dr1 -s myth5.stanford.edu -p 9999
![Page 17: Lab 4 Dynamic Routing CS144 Review Session 5 October 30, 2009 Samir Selman](https://reader033.vdocument.in/reader033/viewer/2022042505/56649d8e5503460f94a76b1e/html5/thumbnails/17.jpg)