# start the ryu-manager
# Gui topology with controller
$ cd ~
$ ryu-manager --verbose ryu/ryu/app/gui_topology/gui_topology.py ryu/ryu/app/simple_switch_13.py
# start the mininet
$ sudo mn --mac --switch ovs,protocols=OpenFlow13 --controller remote
📌 Open http://127.0.0.1:8080 in browser, then you can see the Topology
Topo_style | Description | Sample |
---|---|---|
minimal (default) |
Minimal topology with two hosts and one switch |
sudo mn |
linear |
Linear topology of k switches, with one host per switch. |
sudo mn --topo linear,k |
reversed |
Single switch connected to k hosts, with reversed ports. |
sudo mn --topo reversed,k |
single |
Single switch connected to k hosts. |
sudo mn --topo single,k |
tree |
Topology for a tree network with a given depth and fanout. |
sudo mn --topo tree,n,k |
torus |
2-D Torus topology |
sudo mn --topo torus,n,k |
◽ task2_topo.py
from mininet.topo import Topo
from mininet.link import TCLink
class MyTopo(Topo):
def __init__(self):
Topo.__init__(self)
h1 = self.addHost("h1")
h2 = self.addHost("h2")
h3 = self.addHost("h3")
h4 = self.addHost("h4")
s1 = self.addSwitch("s1")
s2 = self.addSwitch("s2")
self.addLink(h1,s1)
self.addLink(h2,s1)
self.addLink(h3,s1)
self.addLink(s1,s2)
self.addLink(h4,s2)
topos = {"mytopo":(lambda : MyTopo())}
# start the ryu-manager
# with controller (simple_switch_13.py)
$ cd ~
$ ryu-manager --verbose ryu/ryu/app/gui_topology/gui_topology.py ryu/ryu/app/simple_switch_13.py
# start the mininet
$ cd ~
$ sudo mn --custom network_slice/experiment_2/task2_topo.py --topo mytopo --mac --switch ovs,protocols=OpenFlow13 --controller remote
📌 Open http://127.0.0.1:8080 🔗 in browser, then you can see the Topology
# start the ryu-manager
$ ryu-manager --verbose ryu/ryu/app/simple_switch_13.py
# mininet
$ sudo mn --topo single,4 --mac --switch ovs,protocols=OpenFlow13 --controller remote
Modify the flowentrys that make h1 and h4 can't ping each other
# show the s1 flowentry
$ sudo ovs-ofctl -O OpenFlow13 dump-flows s1
$ sudo ovs-ofctl -O OpenFlow13 mod-flows s1 "table=0, priority=1, in_port="s1-eth4", dl_src=00:00:00:00:00:04, dl_dst=00:00:00:00:00:01, actions=drop"
# mod the flow meets the match to set action=drop
$ sudo ovs-ofctl -O OpenFlow13 mod-flows s1 "table=0, priority=1, in_port="s1-eth1", dl_src=00:00:00:00:00:01, dl_dst=00:00:00:00:00:04, actions=drop"
# mod the flow meets the match to set action=drop
h1 -> h2 h3 x
h2 -> h1 h3 h4
h3 -> h1 h2 h4
h4 -> x h2 h3
◽ task3_topo.py
from mininet.topo import Topo
from mininet.link import TCLink
class MyTopo(Topo):
def __init__(self):
Topo.__init__(self)
h1 = self.addHost("h1")
h2 = self.addHost("h2")
h3 = self.addHost("h3")
h4 = self.addHost("h4")
s1 = self.addSwitch("s1")
s2 = self.addSwitch("s2")
s3 = self.addSwitch("s3")
s4 = self.addSwitch("s4")
self.addLink(s1,h1)
self.addLink(s1,s2)
self.addLink(s2,s4)
self.addLink(s4,h3)
self.addLink(s1,h2)
self.addLink(s1,s3)
self.addLink(s4,s3)
self.addLink(s4,h4)
topos = {"mytopo":(lambda : MyTopo())}
# start the ryu-manager
$ ryu-manager --verbose ryu/ryu/app/ofctl_rest.py
# start the mininet
$ sudo mn --custom network_slice/experiment_2/task3_topo.py --topo mytopo --mac --switch ovs,protocols=OpenFlow13 --controller remote
h1 -> x h3 x
h2 -> x x h4
h3 -> h1 x x
h4 -> x h2 x
🔑 Add the all flowentrys for s1, s2, s3, s4
$ sudo ovs-ofctl -O OpenFlow13 add-flow s1 in_port=1,actions=output:2
$ sudo ovs-ofctl -O OpenFlow13 add-flow s1 in_port=2,actions=output:1
$ sudo ovs-ofctl -O OpenFlow13 add-flow s1 in_port=3,actions=output:4
$ sudo ovs-ofctl -O OpenFlow13 add-flow s1 in_port=4,actions=output:3
$ sudo ovs-ofctl -O OpenFlow13 add-flow s2 in_port=1,actions=output:2
$ sudo ovs-ofctl -O OpenFlow13 add-flow s2 in_port=2,actions=output:1
$ sudo ovs-ofctl -O OpenFlow13 add-flow s3 in_port=1,actions=output:2
$ sudo ovs-ofctl -O OpenFlow13 add-flow s3 in_port=2,actions=output:1
$ sudo ovs-ofctl -O OpenFlow13 add-flow s4 in_port=1,actions=output:2
$ sudo ovs-ofctl -O OpenFlow13 add-flow s4 in_port=2,actions=output:1
$ sudo ovs-ofctl -O OpenFlow13 add-flow s4 in_port=3,actions=output:4
$ sudo ovs-ofctl -O OpenFlow13 add-flow s4 in_port=4,actions=output:3
📌 🔗 Notice the OVS version and Linux kernel version when using meter
# start the ryu-manager
$ ryu-manager --verbose ryu/ryu/app/simple_switch_13.py
# start the mininet
$ sudo mn --custom network_slice/experiment_2/task2_topo.py --topo mytopo --mac --switch ovs,protocols=OpenFlow13 --controller remote
$ sudo ovs-vsctl set bridge s1 datapath_type=netdev
$ sudo ovs-vsctl set bridge s2 datapath_type=netdev
# open Xterm for h1 h2 h3 h4 in mininet
$ xterm h1 h2 h3 h4
📌 When datapath_type
is set to netdev
, the datapath is converted from Kernel mode
to Userspace mode
, datapath receives the packet arrives, the packet will be checked and the packet will be discarded if the check fails.
This is why in many cases, after datapath_type=netdev
, the hosts can be ping through, but the iperf
cannot be used to measure bandwidth. Need to turn off tx-checksumming
.
# turn off the tx-checksumming
$ ethtool -K h4-eth0 tx off
$ iperf -s
# turn off the tx-checksumming
$ ethtool -K h1-eth0 tx off
$ iperf -c 10.0.0.4
# turn off the tx-checksumming
$ ethtool -K h2-eth0 tx off
$ iperf -c 10.0.0.4
# turn off the tx-checksumming
$ ethtool -K h3-eth0 tx off
$ iperf -c 10.0.0.4
# add meter
$ sudo ovs-ofctl -O OpenFlow13 add-meter s1 meter=1,kbps,band=type=drop,rate=5000
# 5000 kbps = 5 Mbps
# show meters
$ sudo ovs-ofctl -O OpenFlow13 dump-meters s1
# show flowentrys in terminal
$ sudo ovs-ofctl -O OpenFlow13 dump-flows s1
# modify the flowentry meet the match, set action into meter then outport
$ sudo ovs-ofctl -O OpenFlow13 mod-flows s1 "table=0, priority=1, in_port="s1-eth1", dl_src=00:00:00:00:00:01, dl_dst=00:00:00:00:00:04, actions=meter:1,output:"s1-eth4""
# check the different
$ iperf -c 10.0.0.4
# delete meter
$ sudo ovs-ofctl -O OpenFlow13 del-meter s1 meter=1
◽ task4_topo.py
from mininet.topo import Topo
from mininet.link import TCLink
class MyTopo(Topo):
def __init__(self):
Topo.__init__(self)
h1 = self.addHost("h1")
h2 = self.addHost("h2")
h3 = self.addHost("h3")
s1 = self.addSwitch("s1")
s2 = self.addSwitch("s2")
s3 = self.addSwitch("s3")
self.addLink(h1,s1,cls=TCLink,bw=100) # bw=Mbps
self.addLink(h2,s2,cls=TCLink,bw=100)
self.addLink(h3,s3,cls=TCLink,bw=100)
self.addLink(s1,s2,cls=TCLink,bw=10)
self.addLink(s1,s3,cls=TCLink,bw=100)
self.addLink(s2,s3,cls=TCLink,bw=100)
topos = {"mytopo":(lambda : MyTopo())}
🔗 Mininet config function source code
# start the ryu-manager
$ ryu-manager --verbose ryu/ryu/app/ofctl_rest.py
# start the mininet
$ sudo mn --custom network_slice/experiment_2/task4_topo.py --topo mytopo --mac --switch ovs,protocols=OpenFlow13 --controller remote
🔑 Add flowentrys to s1, s2, s3
$ sudo ovs-ofctl -O OpenFlow13 add-flow s1 table=0,in_port=1,actions=output:3
# in s1, from port1(h1) to port3(s3)
$ sudo ovs-ofctl -O OpenFlow13 add-flow s1 table=0,in_port=3,actions=output:1
# in s1, from port3(s2) to port1(h1)
$ sudo ovs-ofctl -O OpenFlow13 add-flow s2 table=0,in_port=1,actions=output:3
# in s2, from port1(h2) to port3(s3)
$ sudo ovs-ofctl -O OpenFlow13 add-flow s2 table=0,in_port=3,actions=output:1
# in s2, from port3(s3) to port1(h2)
$ sudo ovs-ofctl -O OpenFlow13 add-flow s3 table=0,in_port=3,actions=output:2
# in s3, from port3(s2) to port2(s1)
$ sudo ovs-ofctl -O OpenFlow13 add-flow s3 table=0,in_port=2,actions=output:3
# in s3, from port2(s1) to port3(s2)
# open Xterm for h1 h2 in mininet
$ xterm h1 h2
# open iperf
$ iperf -s
# open iperf
$ iperf -c 10.0.0.1 -i 2
📌 Transmission Bandwidth between h1 and h2 does not restrict in 10Mbps.