This repository is a lab for NCTU course "Introduction to Computer Networks 2018".
In this lab, we are going to write a Python program with Ryu SDN framework to build a simple software-defined network and compare the different between two forwarding rules.
- Learn how to build a simple software-defined networking with Ryu SDN framework
- Learn how to add forwarding rule into each OpenFlow switch
TODO:
- How to run your program?
- What is the meaning of the executing command (both Mininet and Ryu controller)?
- Show the screenshot of using iPerf command in Mininet (both
SimpleController.py
andcontroller.py
)
- open 2 terminals( t1 & t2 )
- first run SimpleTopo.py / topo.py in t1 by "mn --custom SimpleTopo.py / topo.py --topo topo -link tc --controller remote"
- then run SimpleController.py / controller.py in t2 by "ryu-manager SimpleController.py / controller.py --observe-links"
- use iperf command in t1 and get result
- leave t1 first, then leave t2
- --custom .py: read custom classes or params from .py file(s)
- --topo linear/minimal/reversed/single/torus/tree: linear=LinearTopo, torus=TorusTopo, tree=TreeTopo, single=SingleSwitchTopo, reversed=SingleSwitchReversedTopo, minimal=MinimalTopo
- -link default/ovs/tc: default=Link ovs=OVSLink tc=TCLink
- --controller default/none/nox/ovsc/ref/remote/ryu: ovsc=OVSController, none=NullController, remote=RemoteController, default=DefaultController, nox=NOX, ryu=Ryu, ref=Controller
- -c : clean up
-
ryu-manager: ryu-manager is the executable for Ryu applications. ryu-manager loads Ryu applications and run it.
-
--observe-links: observe link discovery events.
TODO:
- Describe how you finish this work in detail
- Environment Setup
- clone initial repository from github and login to container by SSH
- run Mininet with OvS's controller ( to support topos )
- Example of Ryu SDN
- open 2 terminals(t1 & t2 )and both login to container
- both change directory to /src/
- first run SimpleTopo.py in t1 by "mn --custom SimpleTopo.py --topo topo -link tc --controller remote"
- then run SimpleController.py in t2 by "ryu-manager SimpleController.py --observe-links"
- Mininet Topology
- duplicate SimpleTopo.py and change it name to topo.py by " cp SimpleTopo.py topo.py"
- change s1-s2 & s1-s3 & s2-s3 's bandwidth, delay, loss rate as follow
- go to task 5
- Ryu Controller
- duplicate SimpleController.py and change it name to controller.py by " cp SimpleController.py controller.py"
- modify switch_features_handler(self, ev) part as follow rules
- go to task 5
- Measurement
for task 3(SimpleController):
- first run topo.py in t1 by "mn --custom topo.py --topo topo -link tc --controller remote"
- then run SimpleController.py in t2 by "ryu-manager SimpleController.py --observe-links"
- use iperf commands in t1:
h1 iperf -s -u -i 1 -p 5566 > ./out/result1 &
h2 iperf -c 10.0.0.1 -u -i 1 -p 5566 - then get result 1 (leave RYU controller)
for task 4(controller):
- first run topo.py in t1 by "mn --custom topo.py --topo topo -link tc --controller remote"
- then run controller.py in t2 by "ryu-manager controller.py --observe-links"
- use iperf commands in t1:
h1 iperf -s -u -i 1 -p 5566 > ./out/result2 &
h2 iperf -c 10.0.0.1 -u -i 1 -p 5566 - then get result 2 (leave RYU controller)
TODO:
- Answer the following questions
-
Describe the difference between packet-in and packet-out in detail.
packet-in: 由switch發出,請求controller
packet-out: 由controller發出,告知switch將packet導致對應主機 -
What is “table-miss” in SDN?
假如一個封包在Flow Table裡?有發現能夠匹配成功的Flow Entry,這就是一次"Table Miss"。
至於發生Table Miss後的動作取決于此Flow Table的配置:
1)直接丟棄,2)繼續轉發給後面的Flow Table,3)封裝成 packet-in 消息送給Remote Controller。 -
Why is "
(app_manager.RyuApp)
" adding after the declaration of class incontroller.py
?
讓class繼承 app_manager.RyuApp。 app_manager.RyuApp是Ryu應用程式的基礎類別 -
Explain the following code in
controller.py
.@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
@set_ev_cls(ev_cls, dispatchers=none) 是一個用於將方法註冊成 Ryu 事件處理器的一個修飾器,被修飾的方法將會成為一個事件處理器。
ev_cls 表示想要被該 Ryu 應用程式接收的事件類別。
dispatchers 則表示了該事件處理器將會在哪些談判階段(negotiation phases) 去接收此一類型的事件
MAIN_DISPATCHER: 接收 Switch-features 訊息以及 傳送 set-config 訊息
-
What is the meaning of “datapath” in
controller.py
?
the switch in the topology using OpenFlow -
Why need to set "
ip_proto=17
" in the flow entry?
定義該封包資料區使用的協定,17 代表UDP -
Compare the differences between the iPerf results of
SimpleController.py
andcontroller.py
in detail.
Simple: 10sec 1.21MB 1.01 Mb/s 0.005ms 32/893(3.6%)
control: 10sec 1.23MB 1.03Mb/s 0.006ms 18/893(2%) -
Which forwarding rule is better? Why?
lost: simplecontroller > controller
controller is better.
TODO:
- Please add your references in the following
- Ryu SDN
- Python
- Others
TODO:
- Please replace "
YOUR_NAME
" and "YOUR_GITHUB_LINK
" into yours
GNU GENERAL PUBLIC LICENSE Version 3