In this assignment, you are going to implement the core functionalities of an Ethernet learning switch using the Switchyard framework. An Ethernet switch is a layer 2 device that uses packet switching to receive, process and forward frames to other devices (end hosts, other switches) in the network. A switch has a set of interfaces (ports) through which it sends/receives Ethernet frames. When Ethernet frames arrive on any port, the switch process the header of the frame to obtain information about the destination host. If the switch knows that the host is reachable through one of its ports, it sends out the frame from the appropriate output port. If it does not know where the host is, it floods the frame out of all ports except the input port.
Your task is to implement the logic of a switch. As it is described in the last paragraph of the "Ethernet Learning Switch Operation" section, your switch will also handle the frames that are intended for itself and the frames whose Ethernet destination address is the broadcast address FF:FF:FF:FF:FF:FF
.
In addition to these, you will also implement three different mechanisms to purge the outdated/stale entries from the forwarding table. This will allow your learning switch to adapt to changes in the network topology.
These mechanisms are:
-
Remove an entry from the forwarding table after 10 seconds have elapsed.
-
Remove the least recently used (LRU) entry from the forwarding table. For this functionality assume that your table can only hold 5 entries at a time. If a new entry comes and your table is full, you will remove the entry that has not been matched with a Ethernet frame destination address for the longest time.
-
Remove the entry that has the least traffic volume. For this functionality assume that your table can only hold 5 entries at a time. Traffic volume for an entry is the number of frames that the switch received where
Destination MAC address == MAC address of entry
.
You will implement these mechanisms in three separate Python files. The core functionalities that are explained above will be the same for these implementations.
Warning
Please carefully read the FAQ section, for more specific details regarding the implementations
In these tasks, you will write the code to implement the core logic in an Ethernet learning switch using the Switchyard framework. Besides using Switchyard for developing and testing your switch, you can deploy it in Mininet to test it in a "live" setting. The code you'll need to add for the simplest version of this exercise should be less than 20 lines (and possibly quite a bit less depending on exactly how you write the code). There are extensions to the basic learning switch that could add quite a bit more code.
Note
The sentences marked with ✅ are related to the content of your report. Please pay attention.
Initiate your project with our template.
Start with the basic learning switch.
Implement timeouts based on the previous task.
Implement LRU rule replacement algorithm based on Task 2.
Implement least traffic volume rule replacement algorithm based on Task 2.
We will provide a template of your lab assignment report here. You need to submit the report in your repository named <学号><姓名>_lab_2
. The format of your report can be Microsoft Doc or PDF. An example is 123456789拾佰仟_lab_2.pdf
.
To submit your work, you need to do the following things.
-
Modify your code and complete your report.
-
When you have done your work, put your report and code in the folder
lab_2
then commit them. Tag the commit named<学号/lab_2>
which you want to submit. An example is123456789/lab_2
. Finally your project will look likeswitchyard/ ├─docs/ ├─.../ m ├─lab_2/ + │ ├─123456789拾佰仟_lab_2.pdf m │ ├─myswitch.py m │ ├─myswitch_to.py m │ ├─myswitch_lru.py m │ ├─myswitch_traffic.py │ ├─... m │ └─start_mininet.py ├─.gitignore └─...
[!WARNING] The file names in your submission have to exactly match the file names above. Otherwise, you will lose points!
-
Submit your work by pushing your local repository to your remote repository with your tags by running the command
git push origin --tags
.[!WARNING] Only commit your source code to your local repository. If there are some generated files that are not source code, ignore them by adding them in the file
.gitignore
.