# Computer Network Lab2
## Mininet installation guide
:::info
I suggest installing Mininet on Ubuntu. If your computer's operating system is not Ubuntu, you can install it using a virtual machine.
:::
### Install Mininet
```
# update package information
$ sudo apt update
# install Mininet
$ sudo apt install mininet
# Verify Mininet installation
$ sudo mn --test pingall
```
If the installation is successful, you should see output similar to the following:
```
*** Ping: testing ping reachability
h1 -> h2 X
h1 -> h3 X
h2 -> h1 X
h2 -> h3 X
h3 -> h1 X
h3 -> h2 X
*** Results: 100% dropped (0/12 received)
```
### Install Ryu controller
:::danger
Mininet supports various different controllers, but for this assignment, please use the Ryu Controller.
:::
```
# update package information
$ sudo apt update
# install Ryu Controller
$ sudo apt install ryu
# retrieve the version information of the Ryu Controller
# You can use this method to verify if Ryu Controller has been successfully installed
$ ryu-manager --version
# View the location of the ryu-manager
$ sudo find / -name ryu-manager 2>/dev/null
```
:::success
If your Ryu Controller is successfully installed, you will see a path similar to "/home/zack/.local/bin/ryu-manager".
:::
```
# Run the Ryu Controller
$ "your ryu-manager path" ryu.app.simple_switch
# e.g.
$ /home/zack/.local/bin/ryu-manager ryu.app.simple_switch
```
:::info
In this assignment, we require the Ryu Controller to control OpenFlow switches, and it needs to run simultaneously when conducting Mininet simulations.
:::
### Install Iperf
```
# update package information
$ sudo apt update
# install Iperf
$ sudo apt install iperf
# retrieve the version information of Iperf
$ iperf --version
```
## Lab2 Implementation (50%)
:::info
You need to download the folder named "Lab2.zip" on e3.
This assignment should be written using Python3.
:::
### Implementation Content
In this assignment, you are required to use the Mininet simulator to accomplish the following tasks:
#### 1. Generate Topology (10%):
Please create a network topology that includes hosts, switches, and their connections as follows.
Hosts: h1, h2, h3, h4, h5, h6, h7, h8, h9
Switches: s1, s2, s3, s4, s5, s6
Controller: c1, a Ryu controller
Links:
h1 connected to s1
h2 connected to s1
s1 connected to s2
s2 connected to h3
s2 connected to s3
s3 connected to h4
s3 connected to h5
s1 connected to s4
s4 connected to h6
s4 connected to s5
s5 connected to h7
s5 connected to s6
s6 connected to h8
s6 connected to h9
#### 2. Set up iperf sessions (10%):
Set up four different iperf sessions, each with different source and destination hosts, as well as bandwidth limits. The specifications are as follows.
The conversations from h1 to h2 have a bandwidth limit of 5 Mbps.
The conversations from h1 to h3 have a bandwidth limit of 10 Mbps.
The conversations from h4 to h5 have a bandwidth limit of 15 Mbps.
The conversations from h6 to h8 have a bandwidth limit of 20 Mbps.
#### 3. "runIperf" function (30%)
Write the "runIperf" function, which must include the following functionalities.
(1) Set up and start the iperf server.
(2) Construct and execute the iperf client command.
(3) Detect if there are any cases exceeding the set value; if so, terminate the iperf processes on the server and client.
### result
Your execution result should resemble the following image.

## Report(50%)
1. Take a screenshot of the code in three sections of your Lab2 Implementation Content. (15%)
2. Please provide a line-by-line explanation of how your "runIperf function" is written.(35%)
## Submission
1. Submission deadline: 2024/01/04 (Thu.) 11:59 a.m.
2. Please compress the source code and report into a zip file.
3. The zip file should be named "Lab2_StudentId_Name.zip".
e.g. "Lab2__311551176_林書宇.zip"
:::danger
Do not plagiarize. If you are found plagiarism, you will get "0 point"!
:::