CS 168 Fall 2024
Project 2:Distance-Vector Routing
In this project,you will write a distance-vector routing protocol.We have provided simulator code that you can use to visualize your protocol in action.
Lectures needed for this project:Lecture 6(Routing States),Lecture 7 (Distance-Vector Protocols).
You can work on this project alone,or with one partner.You can keep the same partner from Project 1,or choose a different partner.Reminder: Our course policies page has a collaboration policy that youmust follow.
Setup
Python Installation
This project has been tested to work on Python 3.8.(It probably works on newer versions of Python as well,but use at your own risk.)
If you run python3 --version or python --version in your terminal and you see output of the form. python 3.8.*, you're all set.
Starter Code
Download a copy of the starter code here.
We recommend making frequent backups of your code.Some parts of the project will require you to modify code that you wrote earlier,and you might want to revert your changes to start over from an earlier save point.
You should only edit dv router.py.There are comments clearly indicating the places where you should fill in code.
Guidelines:
·Don't modify any other files. ·Don't add any new files.
·Don't add any imports.
·Don't edit any code outside the sections indicated by the comments.
·Don't add any hard-coded global variables.
·Adding helper methods is fine (and encouraged in the last part).
·In general,if we haven't told you to use something,you probably don't need it.Our goal is not to trick you!
In your terminal,use cd to navigate to the cs168-fa24-proj2-routing/simulator directory.All of
the Python commands should be run from this directory.
New Spec
Note:This spec has been rewritten for Fall 2024 to be clearer and provide a few extra hints.It may contain bugs.
If you would like to work off the previous version of the spec,you can find ithere.
Project Overview
This project is split into 3 sections,with a total of 10 stages across all sections.
Each stage has its own unit tests,provided to you locally.Your grade will be determined only by these unit tests (no hidden tests).
To run a unit test,run this command,replacing 5 with the number of the stage you want to test:
python3 dv_unit_tests.py 5
Warning:Stage 10 is a good deal longer than the other stages,so plan accordingly
Warm-Up Example:Hub
Some assumptions before we get started:
·In this project,your code will find routes between hosts.You don't need to find routes to other routers.
·In this project.our forwarding tables will map destinations to numbered physical ports,instead of next-hops.For example,a row of the table might say:“Packets destined for h1 should be sent out of port 1.”
To get you started,we've provided an implementation of a hub in examples/hub.py.The hub is a network device that takes any incoming packet,and forwards that packet out of all its ports (except the port the packet came from).
Let's run the simulator on a linear topology with three hosts:
python3 simulator.py --start --default-switch-type=examples.hub topos.linear--n=3
You can now access the visualizer at http://127.0.0.1:4444 in your browser.You should see the hosts and routers displayed against a purple background.
Now,let's make host h1 send a ping packet to host h3.You can either type in the Python terminal:
h1.ping(h3)
Or,you can send the ping from the visualizer by:(1)clicking h1 and pressing A,(2) clicking h3 and pressing B,and (3)pressing p to send the ping from A to B.
You should see the"ping"packet sent from h1 to h3.Then,you should see the reply
“pong”packet sent from h3 to h1.You should also see both packets delivered to h2,even though h2 isn't the recipient.This behavior. is expected,because the hub floods packets everywhere.
You can also observe what's going on by reading the log messages printed to the Python terminal (you can ignore the TTL field,you won't touch it in this project).
WARNING:user:h2:NOT FOR ME:h3 ttl:17>s1,s2,h2
DEBUG:user:h3:rx:h3 &
334



被折叠的 条评论
为什么被折叠?



