SlideShare a Scribd company logo
1 / 61
EL-5244
MininetBasics
Eueung Mulyana
https://telematika.org/remark/mininet
CodeLabs | Attribution-ShareAlike CC BY-SA
Outline
Introduction
Getting Started
MiniNAM
OpenFlow Tutorial
POX Controller
2 / 61
Mininet 2.2.2 on Ubuntu 14.04 LTS - 64 bit, o cial VM | POX 0.2.0
(carp) | OVS (Open vSwitch) 2.0.2
VirtualBox 5.2.6 on Ubuntu Xenial 16.04.3. Ref: [Mininet VM Images]
3 / 61
Introduction
4 / 61
Mininet provides a virtual test bed and development environment for SDN 5 / 61
6 / 61
Mininet enables
Rapid prototyping of software-de ned networks
Complex topology testing without the need to
wire up a physical network
Multiple concurrent developers to work
independently on the same topology
7 / 61
Mininet networks run real code including
standard Unix/Linux network applications as well
as the real Linux kernel and network stack.
Mininet provides an extensible Python API for
network creation and experimentations.
Ref: MININET - Open Networking Foundation
Getting Started
8 / 61
9 / 61
Mininet
Setup
Using Pre-Made VM
Download a Mininet VM Image
Import the Image (eg. into VirtualBox)
Con gure Access (eg. port forwarding or host-only
networking)
Run the VM
Access via SSH with Remote Display Forwarding Enabled
Note: in the o cial Mininet VM image version 2.2.2, there is possibly a con guration bug
if you're using VirtualBox. See comments by isams1 in this thread. So don't use host-only
networking to access the VM.
Import Appliance 10 / 61
Import Appliance 11 / 61
Con gure Access
12 / 61
Con gure Access - Port Forwarding
13 / 61
Con gure Access - Port Forwarding
14 / 61
Run the VM 15 / 61
Access via SSH 16 / 61
Test 17 / 61
Test - Wireshark 18 / 61
19 / 61
Check
$ ssh -Y -l mininet -p 2222 localhost
mininet@mininet-vm:~$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.ori
mininet@mininet-vm:~$ sudo sed -i 's/http://us.archive.ubuntu.com/ubuntu//http://kambing.u
mininet@mininet-vm:~$ sudo apt-get update
mininet@mininet-vm:~$ sudo apt-get install tree
mininet@mininet-vm:~$ tree -L 1
.
|-- install-mininet-vm.sh
|-- loxigen
|-- mininet
|-- oflops
|-- oftest
|-- openflow
|-- pox
20 / 61
Check
mininet@mininet-vm:~/mininet$ tree -L 2 -d
.
|-- bin
|-- build
| |-- bdist.linux-x86_64
| |-- lib.linux-x86_64-2.7
| |-- scripts-2.7
|-- custom
|-- debian
| |-- source
|-- dist
|-- doc
|-- examples
| |-- test
|-- mininet
| |-- examples -> ../examples
| |-- test
|-- mininet.egg-info
|-- util
|-- kbuild
|-- nox-patches
|-- openflow-patches
|-- sch_htb-ofbuf
|-- vm
mininet@mininet-vm:~/mininet/examples$ ll
total 364
drwxrwxr-x 3 mininet mininet 4096 Mar 21 2017 ./
drwxrwxr-x 13 mininet mininet 4096 Mar 21 2017 ../
-rw-rw-r-- 1 mininet mininet 4965 Mar 21 2017 README.md
-rw-rw-r-- 1 mininet mininet 48 Mar 21 2017 __init__.py
-rwxrwxr-x 1 mininet mininet 1074 Mar 21 2017 baresshd.py*
-rwxrwxr-x 1 mininet mininet 2310 Mar 21 2017 bind.py*
-rwxrwxr-x 1 mininet mininet 33427 Mar 21 2017 cluster.py*
-rwxrwxr-x 1 mininet mininet 501 Mar 21 2017 clusterSanity.py*
-rw-rw-r-- 1 mininet mininet 3875 Mar 21 2017 clustercli.py
-rwxrwxr-x 1 mininet mininet 639 Mar 21 2017 clusterdemo.py*
-rwxrwxr-x 1 mininet mininet 15612 Mar 21 2017 consoles.py*
-rwxrwxr-x 1 mininet mininet 1061 Mar 21 2017 controllers.py*
-rwxrwxr-x 1 mininet mininet 1612 Mar 21 2017 controllers2.py*
-rwxrwxr-x 1 mininet mininet 4967 Mar 21 2017 controlnet.py*
-rwxrwxr-x 1 mininet mininet 3725 Mar 21 2017 cpu.py*
-rwxrwxr-x 1 mininet mininet 960 Mar 21 2017 emptynet.py*
-rwxrwxr-x 1 mininet mininet 1549 Mar 21 2017 hwintf.py*
-rwxrwxr-x 1 mininet mininet 1320 Mar 21 2017 intfoptions.py*
-rwxrwxr-x 1 mininet mininet 2034 Mar 21 2017 limit.py*
-rwxrwxr-x 1 mininet mininet 4062 Mar 21 2017 linearbandwidth.py*
-rwxrwxr-x 1 mininet mininet 2826 Mar 21 2017 linuxrouter.py*
-rwxrwxr-x 1 mininet mininet 154479 Mar 21 2017 miniedit.py*
-rwxrwxr-x 1 mininet mininet 4198 Mar 21 2017 mobility.py*
-rwxrwxr-x 1 mininet mininet 834 Mar 21 2017 multilink.py*
-rwxrwxr-x 1 mininet mininet 2235 Mar 21 2017 multiping.py*
-rwxrwxr-x 1 mininet mininet 2469 Mar 21 2017 multipoll.py*
-rwxrwxr-x 1 mininet mininet 1049 Mar 21 2017 multitest.py*
-rwxrwxr-x 1 mininet mininet 550 Mar 21 2017 nat.py*
-rwxrwxr-x 1 mininet mininet 1948 Mar 21 2017 natnet.py*
-rwxrwxr-x 1 mininet mininet 2330 Mar 21 2017 numberedports.py*
-rwxrwxr-x 1 mininet mininet 1023 Mar 21 2017 popen.py*
-rwxrwxr-x 1 mininet mininet 932 Mar 21 2017 popenpoll.py*
-rwxrwxr-x 1 mininet mininet 2032 Mar 21 2017 scratchnet.py*
-rwxrwxr-x 1 mininet mininet 2455 Mar 21 2017 scratchnetuser.py*
-rwxrwxr-x 1 mininet mininet 1888 Mar 21 2017 simpleperf.py*
-rwxrwxr-x 1 mininet mininet 3040 Mar 21 2017 sshd.py*
drwxrwxr-x 2 mininet mininet 4096 Mar 21 2017 test/
-rwxrwxr-x 1 mininet mininet 522 Mar 21 2017 tree1024.py*
-rwxrwxr-x 1 mininet mininet 950 Mar 21 2017 treeping64.py*
-rwxrwxr-x 1 mininet mininet 3679 Mar 21 2017 vlanhost.py*
21 / 61
Check
22 / 61
Notes
Mininet
Walkthrough
$ sudo mn [--topo=minimal]
$ sudo mn --test pingpair
$ sudo mn --test iperf
$ sudo mn --link tc,bw=10,delay=10ms
$ sudo mn --test pingall --topo single,3
$ sudo mn --test pingall --topo mytopo --custom ~/mininet/custom/topo-2sw-2host.py
$ sudo mn --mac
mininet> h1 ping -c10 h2
mininet> pingall
mininet> h1 python -m SimpleHTTPServer 80 &
mininet> h2 wget -O - h1
mininet> iperf
mininet> link s1 h1 down
mininet> link s1 h1 up
$ sudo ~/mininet/examples/sshd.py
Ref: Mininet Walkthrough - Mininet
23 / 61
Notes
Mininet Sample
Work ow
# Creating a Network
$ sudo mn --switch ovs --controller ref --topo tree,depth=2,fanout=8 --test pingall
# Interacting with a Network
mininet> h2 ping h3
mininet> h2 python -m SimpleHTTPServer 80 >& /tmp/http.log &
mininet> h3 wget -O - h2
# Customizing a Network
from mininet.net import Mininet
from mininet.topolib import TreeTopo
tree4 = TreeTopo(depth=2,fanout=2)
net = Mininet(topo=tree4)
net.start()
h1, h4 = net.hosts[0], net.hosts[3]
print h1.cmd('ping -c1 %s' % h4.IP())
net.stop()
Ref: Mininet Sample Work ow - Mininet
MiniNAM
24 / 61
25 / 61
MiniNAM
A utility that provides real-time animation of any network
created by the Mininet emulator.
MiniNAM includes all the components required to initiate,
visualize and modify Mininet network ows in real-time.
MiniNAM provides a graphical user interface that allows
dynamic modi cation of preferences and packet lters: a
user can view selective ows with options to color code
packets based on packet type and/or nodes (hosts).
Ref: MiniNAM | University College Cork
26 / 61
Setup
$ ssh -Y -l mininet -p 2222 localhost
$ sudo apt-get install git python-imaging python-imaging-tk
$ git clone https://github.com/uccmisl/MiniNAM.git
mininet@mininet-vm:~/MiniNAM$ tree
.
|-- conf.config
|-- Examples
| |-- LoadBalancer
| | |-- install.sh
| | |-- MiniNAM.py
| | |-- paping
| | |-- README.md
| |-- NAT
| | |-- badNAT.py
| | |-- conf.config
| | |-- goodNAT.py
| | |-- MiniNAM.py
| | |-- README.md
| |-- Routing
| |-- MiniNAM.py
| |-- README.md
| |-- simple_switch_13.py
| |-- simple_switch_stp_13.py
| |-- spanning_tree.py
|-- LICENSE
|-- MiniNAM.py
|-- README.md
mininet@mininet-vm:~/MiniNAM$ sudo python MiniNAM.py
MiniNAM | h1 ping -c2 h2
27 / 61
OpenFlow Tutorial
28 / 61
sudo mn --topo single,3 --mac --switch ovsk --controller remote 29 / 61
sudo python ~/MiniNAM/MiniNAM.py ... | controller & wireshark issues 30 / 61
31 / 61
Manual Flow
Entry
mininet@mininet-vm:~$ sudo ovs-ofctl dump-flows s1
NXST_FLOW reply (xid=0x4):
mininet> h1 ping -c3 h2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
From 10.0.0.1 icmp_seq=1 Destination Host Unreachable
...
mininet@mininet-vm:~$ sudo ovs-ofctl add-flow s1 in_port=1,actions=output:2
mininet@mininet-vm:~$ sudo ovs-ofctl add-flow s1 in_port=2,actions=output:1
mininet@mininet-vm:~$ sudo ovs-ofctl dump-flows s1
NXST_FLOW reply (xid=0x4):
cookie=0x0, duration=25.666s, table=0, n_packets=0, n_bytes=0, idle_age=25, in_port=1 actions=o
cookie=0x0, duration=11.374s, table=0, n_packets=0, n_bytes=0, idle_age=11, in_port=2 actions=o
mininet> h1 ping -c3 h2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.979 ms
...
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.099/0.402/0.979/0.408 ms
sudo wireshark & 32 / 61
Capture Interfaces - Loopback 33 / 61
34 / 61
Starting
Controller
OF Reference
Controller
$ controller ptcp: &
# Issue: controller must first be run, before mininet
# Could be an issue related with the image
$ controller ptcp: &
$ sudo mn --topo single,3 --mac --switch ovsk --controller remote
# clean up arp
mininet> h1 ip -s -s neigh flush all
mininet> h2 ip -s -s neigh flush all
# in case, there's still flow entries
mininet@mininet-vm:~$ sudo ovs-ofctl del-flows s1
mininet> h1 ping -c1 h2
Filter - of 35 / 61
Inspect Packet 36 / 61
Inspect Packet 37 / 61
of and not (of10.echo_request.type or of10.echo_reply.type) 38 / 61
OF Packets Captured After : h1 ping -c1 h2 39 / 61
40 / 61
h1 ping -c1 h2
41 / 61
Flow Entries
mininet> dpctl dump-flows
mininet@mininet-vm:~$ sudo ovs-ofctl dump-flows s1
NXST_FLOW reply (xid=0x4):
cookie=0x0, duration=25.373s, table=0, n_packets=1, n_bytes=42, idle_timeout=60, idle_age=25, p
cookie=0x0, duration=30.373s, table=0, n_packets=1, n_bytes=42, idle_timeout=60, idle_age=30, p
cookie=0x0, duration=25.374s, table=0, n_packets=1, n_bytes=42, idle_timeout=60, idle_age=25, p
cookie=0x0, duration=30.371s, table=0, n_packets=1, n_bytes=98, idle_timeout=60, idle_age=30, p
cookie=0x0, duration=30.37s, table=0, n_packets=1, n_bytes=98, idle_timeout=60, idle_age=30, pr
mininet@mininet-vm:~$ sudo ovs-ofctl dump-flows s1
NXST_FLOW reply (xid=0x4):
42 / 61
Benchmark
kernel- vs. user-
space
mininet> iperf
+++ Iperf: testing TCP bandwidth between h1 and h3
+++ Results: ['27.5 Gbits/sec', '27.6 Gbits/sec']
mininet> exit
mininet@mininet-vm:~$ sudo mn --topo single,3 --controller remote --switch user
mininet> iperf
+++ Iperf: testing TCP bandwidth between h1 and h3
+++ Results: ['658 Mbits/sec', '659 Mbits/sec']
# Notes user-space:
mininet> sh ovs-ofctl dump-flows s1
ovs-ofctl: s1 is not a bridge or a socket
Notes
My personal notes with previous versions of Mininet. Some are not tested yet with the current
version.
43 / 61
44 / 61
Notes
mininet> xterm h1 h2 h3
h1# tcpdump -ne -i h1-eth0
mininet>1 h1 ping -c1 h2
mininet>1 h1 arp -na
# deprecated??
$ sudo ovs-controller --verbose ptcp:& #
$ sudo controller ptcp:& #
$ sudo ovs-controller --hub ptcp:& # --noflow --normal --verbose
$ sudo ovs-controller --hub --verbose ptcp:&
$ sudo ovs-controller --noflow --verbose ptcp:&
45 / 61
Notes
# IP-Source-Address-Based Rule --> may need Reset
$ sudo ovs-ofctl del-flows s1
$ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,dl_type=0x0800,nw_src=10.0.0.1,acti
$ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,dl_type=0x0800,nw_src=10.0.0.2,acti
# IP-Dest-Address-Based Rule --> may need Reset
$ sudo ovs-ofctl del-flows s1
$ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,ip,nw_dst=10.0.0.3,actions=output:3
$ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,ip,nw_dst=10.0.0.2,actions=output:2
$ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,ip,nw_dst=10.0.0.1,actions=output:1
$ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,arp,actions=NORMAL
# Alternatives
$ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,dl_type=0x0806,actions=FLOOD
$ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,dl_type=0x0806,actions=ALL
$ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,dl_type=0x0800,nw_proto=1,actions=N
$ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,icmp,nw_dst=10.0.0.2,actions=output
# NORMAL sends packet to non-openflow function of switch - not all switch
# sudo ovs-ofctl del-flows s1 in_port=1
# sudo ovs-ofctl del-flows s1 dl_type=0x0800
46 / 61
Notes
47 / 61
Notes
POX Controller
48 / 61
49 / 61
POXController
POX is a Python-based SDN controller
platform geared towards research and
education.
POX provides a framework for
communicating with SDN switches using
either the OpenFlow or OVSDB protocol.
Developers can use POX to create an SDN
controller using the Python programming
language. Ref: [brianlinkletter ]
50 / 61
POX Controller
Files
mininet@mininet-vm:~/pox/pox/misc$ ll
total 76
drwxrwxr-x 3 mininet mininet 4096 Mar 21 2017 ./
drwxrwxr-x 15 mininet mininet 4096 Mar 21 2017 ../
-rw-rw-r-- 1 mininet mininet 689 Mar 21 2017 __init__.py
-rw-rw-r-- 1 mininet mininet 1240 Mar 21 2017 cbench.py
-rw-rw-r-- 1 mininet mininet 1079 Mar 21 2017 full_payload.py
-rw-rw-r-- 1 mininet mininet 5214 Mar 21 2017 gephi_topo.py
-rw-rw-r-- 1 mininet mininet 10251 Mar 21 2017 ip_loadbalancer.py
-rw-rw-r-- 1 mininet mininet 3794 Mar 21 2017 mac_blocker.py
-rw-rw-r-- 1 mininet mininet 14375 Mar 21 2017 nat.py
-rw-rw-r-- 1 mininet mininet 4582 Mar 21 2017 of_tutorial.py
-rw-rw-r-- 1 mininet mininet 2096 Mar 21 2017 pidfile.py
drwxrwxr-x 2 mininet mininet 4096 Mar 21 2017 telnetd/
mininet@mininet-vm:~/pox/pox/forwarding$ ll
total 96
drwxrwxr-x 2 mininet mininet 4096 Mar 21 2017 ./
drwxrwxr-x 15 mininet mininet 4096 Mar 21 2017 ../
-rw-rw-r-- 1 mininet mininet 651 Mar 21 2017 __init__.py
-rw-rw-r-- 1 mininet mininet 1092 Mar 21 2017 hub.py
-rw-rw-r-- 1 mininet mininet 4426 Mar 21 2017 l2_flowvisor.py
-rw-rw-r-- 1 mininet mininet 6692 Mar 21 2017 l2_learning.py
-rw-rw-r-- 1 mininet mininet 15558 Mar 21 2017 l2_multi.py
-rw-rw-r-- 1 mininet mininet 4324 Mar 21 2017 l2_nx.py
-rw-rw-r-- 1 mininet mininet 2105 Mar 21 2017 l2_nx_self_learning.py
-rw-rw-r-- 1 mininet mininet 2882 Mar 21 2017 l2_pairs.py
-rw-rw-r-- 1 mininet mininet 12330 Mar 21 2017 l3_learning.py
-rw-rw-r-- 1 mininet mininet 14102 Mar 21 2017 topo_proactive.py
from pox.core import core
import pox.openflow.libopenflow_01 as of
log = core.getLogger()
#============
class Tutorial (object):
#-------------------------------
def __init__ (self, connection):
self.connection = connection
connection.addListeners(self)
self.mac_to_port = {}
#-------------------------------
def resend_packet (self, packet_in, out_port):
msg = of.ofp_packet_out()
msg.data = packet_in
action = of.ofp_action_output(port = out_port)
msg.actions.append(action)
self.connection.send(msg)
#-------------------------------
def act_like_hub (self, packet, packet_in):
self.resend_packet(packet_in, of.OFPP_ALL)
#-------------------------------
def act_like_switch (self, packet, packet_in):
#-------------------------------
def _handle_PacketIn (self, event):
packet = event.parsed # This is the parsed packet data.
if not packet.parsed:
log.warning("Ignoring incomplete packet")
return
packet_in = event.ofp # The actual ofp_packet_in message.
self.act_like_hub(packet, packet_in)
#self.act_like_switch(packet, packet_in)
#============
def launch ():
def start_switch (event):
log.debug("Controlling %s" % (event.connection,))
Tutorial(event.connection)
core.openflow.addListenerByName("ConnectionUp", start_switch)
51 / 61
of_tutorial.py
52 / 61
POX Controller
Hub Behavior
mininet@mininet-vm:~/pox$ ./pox.py log.level --DEBUG misc.of_tutorial
POX 0.2.0 (carp) / Copyright 2011-2013 James McCauley, et al.
DEBUG:core:POX 0.2.0 (carp) going up...
DEBUG:core:Running on CPython (2.7.6/Oct 26 2016 20:30:19)
DEBUG:core:Platform is Linux-4.2.0-27-generic-x86_64-with-Ubuntu-14.04-trusty
INFO:core:POX 0.2.0 (carp) is up.
DEBUG:openflow.of_01:Listening on 0.0.0.0:6633
INFO:openflow.of_01:[None 1] closed
INFO:openflow.of_01:[00-00-00-00-00-01 2] connected
DEBUG:misc.of_tutorial:Controlling [00-00-00-00-00-01 2]
$ sudo mn --topo single,3 --mac --switch ovsk --controller remote
mininet> xterm h1 h2 h3
h1# tcpdump -XX -n -i h1-eth0 > h1.txt &
h2# tcpdump -XX -n -i h2-eth0 > h2.txt
h3# tcpdump -XX -n -i h3-eth0 > h3.txt
h1# ping -c1 10.0.0.2
53 / 61
POX Controller
Hub Behavior
mininet@mininet-vm:~$ cat h1.txt
16:33:33.273970 ARP, Request who-has 10.0.0.2 tell 10.0.0.1, length 28
16:33:33.305723 ARP, Reply 10.0.0.2 is-at 00:00:00:00:00:02, length 28
16:33:33.305730 IP 10.0.0.1 > 10.0.0.2: ICMP echo request, id 4108, seq 1, length 64
16:33:33.306899 IP 10.0.0.2 > 10.0.0.1: ICMP echo reply, id 4108, seq 1, length 64
16:33:38.356385 ARP, Request who-has 10.0.0.1 tell 10.0.0.2, length 28
16:33:38.356425 ARP, Reply 10.0.0.1 is-at 00:00:00:00:00:01, length 28
mininet@mininet-vm:~$ cat h2.txt
16:33:33.305056 ARP, Request who-has 10.0.0.2 tell 10.0.0.1, length 28
16:33:33.305079 ARP, Reply 10.0.0.2 is-at 00:00:00:00:00:02, length 28
16:33:33.306329 IP 10.0.0.1 > 10.0.0.2: ICMP echo request, id 4108, seq 1, length 64
16:33:33.306344 IP 10.0.0.2 > 10.0.0.1: ICMP echo reply, id 4108, seq 1, length 64
16:33:38.317451 ARP, Request who-has 10.0.0.1 tell 10.0.0.2, length 28
16:33:38.359253 ARP, Reply 10.0.0.1 is-at 00:00:00:00:00:01, length 28
mininet@mininet-vm:~$ cat h3.txt
16:33:33.305054 ARP, Request who-has 10.0.0.2 tell 10.0.0.1, length 28
16:33:33.305722 ARP, Reply 10.0.0.2 is-at 00:00:00:00:00:02, length 28
16:33:33.306328 IP 10.0.0.1 > 10.0.0.2: ICMP echo request, id 4108, seq 1, length 64
16:33:33.306898 IP 10.0.0.2 > 10.0.0.1: ICMP echo reply, id 4108, seq 1, length 64
16:33:38.356378 ARP, Request who-has 10.0.0.1 tell 10.0.0.2, length 28
16:33:38.359247 ARP, Reply 10.0.0.1 is-at 00:00:00:00:00:01, length 28
54 / 61
POX Controller
Hub Behavior
h1# ping -c1 10.0.0.5
mininet@mininet-vm:~$ cat h1.txt
16:45:33.285777 ARP, Request who-has 10.0.0.5 tell 10.0.0.1, length 28
16:45:34.285666 ARP, Request who-has 10.0.0.5 tell 10.0.0.1, length 28
16:45:35.285632 ARP, Request who-has 10.0.0.5 tell 10.0.0.1, length 28
mininet@mininet-vm:~$ cat h3.txt
16:45:33.335877 ARP, Request who-has 10.0.0.5 tell 10.0.0.1, length 28
16:45:34.310252 ARP, Request who-has 10.0.0.5 tell 10.0.0.1, length 28
16:45:35.287537 ARP, Request who-has 10.0.0.5 tell 10.0.0.1, length 28
mininet@mininet-vm:~$ cat h2.txt
16:45:33.335881 ARP, Request who-has 10.0.0.5 tell 10.0.0.1, length 28
16:45:34.310257 ARP, Request who-has 10.0.0.5 tell 10.0.0.1, length 28
16:45:35.287542 ARP, Request who-has 10.0.0.5 tell 10.0.0.1, length 28
Packets Captured After : h1 ping -c1 10.0.0.2 55 / 61
Packets Captured After : h1 ping -c1 10.0.0.5 56 / 61
57 / 61
POX Controller
Hub Behavior
mininet> sh ovs-ofctl dump-flows s1
NXST_FLOW reply (xid=0x4):
mininet> pingpair
h1 -> h2
h2 -> h1
+++ Results: 0% dropped (2/2 received)
mininet> pingall
+++ Ping: testing ping reachability
h1 -> h2 h3
h2 -> h1 h3
h3 -> h1 h2
+++ Results: 0% dropped (6/6 received)
mininet> iperf
+++ Iperf: testing TCP bandwidth between h1 and h3
+++ Results: ['19.0 Mbits/sec', '20.3 Mbits/sec']
mininet@mininet-vm:~$ sudo python MiniNAM/MiniNAM.py --topo single,3 --mac --switch ovsk --contr
def act_like_switch (self, packet, packet_in):
self.mac_to_port[packet.src] = packet_in.in_port
if packet.dst in self.mac_to_port:
print("Packet sent to Control Plane")
self.resend_packet(packet_in,
self.mac_to_port[packet.dst])
# log.debug("Installing flow...")
msg = of.ofp_flow_mod()
msg.match.dl_dst = packet.dst
# msg.match = of.ofp_match.from_packet(packet)
msg.actions.append(of.ofp_action_output(port=self.mac_to_port[packet.dst]))
self.connection.send(msg)
else:
self.resend_packet(packet_in, of.OFPP_ALL)
58 / 61
of_tutorial.py
Refs/Resources
59 / 61
Refs/Resources
1. Learn Development Tools - mininet/open ow-tutorial Wiki
2. Create a Learning Switch - mininet/open ow-tutorial Wiki
3. MININET - Open Networking Foundation
4. MiniNAM | University College Cork
5. uccmisl/MiniNAM: A Network Animator for Visualizing Real-Time Packet Flows in Mininet
6. FAQ - mininet/mininet Wiki
7. Learn Development Tools - mininet/open ow-tutorial Wiki
8. Create a Learning Switch - mininet/open ow-tutorial Wiki
60 / 61
61 / 61
ENDEueung Mulyana
https://telematika.org/remark/mininet
CodeLabs | Attribution-ShareAlike CC BY-SA

More Related Content

PDF
Mininet introduction
Vipin Gupta
 
PPTX
Les Vpn
medalaa
 
PPTX
Linux and DNS Server
Prabhakar Thota
 
PPT
IIS
Giritharan V
 
PPTX
Mininet demo
Momina Masood
 
PDF
Administration des services réseaux
Fethi Kiwa
 
PDF
JANOG43 Forefront of SRv6, Open Source Implementations
Kentaro Ebisawa
 
PPTX
Protocole ARP/RARP
Hayder Gallas
 
Mininet introduction
Vipin Gupta
 
Les Vpn
medalaa
 
Linux and DNS Server
Prabhakar Thota
 
Mininet demo
Momina Masood
 
Administration des services réseaux
Fethi Kiwa
 
JANOG43 Forefront of SRv6, Open Source Implementations
Kentaro Ebisawa
 
Protocole ARP/RARP
Hayder Gallas
 

What's hot (20)

PPTX
Apache web server
Rishabh Bahukhandi
 
PDF
Cours linux complet
aubin82
 
PPTX
HSRP ccna
MohamedJafar5
 
PDF
Alphorm.com Formation Hacking et Sécurité, l'essentiel
Alphorm
 
PPTX
IPv6 DHCP
Irsandi Hasan
 
PPTX
Dns presentation
Anurag Pandey
 
PPTX
Room 1 - 7 - Lê Quốc Đạt - Upgrading network of Openstack to SDN with Tungste...
Vietnam Open Infrastructure User Group
 
PPTX
Vxlan deep dive session rev0.5 final
KwonSun Bae
 
PPTX
SIP over TLS
Hossein Yavari
 
PPT
Ns 2 Network Simulator An Introduction
Jaipur National University, Jaipur, Rajasthan, India
 
PPTX
VXLAN Practice Guide
Prasenjit Sarkar
 
PPT
Linux history & features
Rohit Kumar
 
PDF
DNS Attacks
Himanshu Prabhakar
 
PPTX
OVN 設定サンプル | OVN config example 2015/12/27
Kentaro Ebisawa
 
PDF
Alphorm.com Formation Hacking et Sécurité 2020 (4of4) : Attaques AD et Web
Alphorm
 
PPT
CCNA PPT
Reetesh Gupta
 
PDF
OpenStack & Ansible で実現する自動化
Hideki Saito
 
PDF
Introduction to OpenFlow
Joel W. King
 
PDF
Virtualized network with openvswitch
Sim Janghoon
 
PPTX
DNS Security
inbroker
 
Apache web server
Rishabh Bahukhandi
 
Cours linux complet
aubin82
 
HSRP ccna
MohamedJafar5
 
Alphorm.com Formation Hacking et Sécurité, l'essentiel
Alphorm
 
IPv6 DHCP
Irsandi Hasan
 
Dns presentation
Anurag Pandey
 
Room 1 - 7 - Lê Quốc Đạt - Upgrading network of Openstack to SDN with Tungste...
Vietnam Open Infrastructure User Group
 
Vxlan deep dive session rev0.5 final
KwonSun Bae
 
SIP over TLS
Hossein Yavari
 
Ns 2 Network Simulator An Introduction
Jaipur National University, Jaipur, Rajasthan, India
 
VXLAN Practice Guide
Prasenjit Sarkar
 
Linux history & features
Rohit Kumar
 
DNS Attacks
Himanshu Prabhakar
 
OVN 設定サンプル | OVN config example 2015/12/27
Kentaro Ebisawa
 
Alphorm.com Formation Hacking et Sécurité 2020 (4of4) : Attaques AD et Web
Alphorm
 
CCNA PPT
Reetesh Gupta
 
OpenStack & Ansible で実現する自動化
Hideki Saito
 
Introduction to OpenFlow
Joel W. King
 
Virtualized network with openvswitch
Sim Janghoon
 
DNS Security
inbroker
 
Ad

Similar to Mininet Basics (20)

PDF
Open stack pike-devstack-tutorial
Eueung Mulyana
 
DOCX
SDN Training - Open daylight installation + example with mininet
SAMeh Zaghloul
 
PDF
Functional Operations (Functional Programming at Comcast Labs Connect)
Susan Potter
 
PPTX
Virtual Networking (1) (1).pptx
KrishnaMishra386849
 
ODP
LSA2 - 02 Namespaces
Marian Marinov
 
PDF
DCEU 18: Tips and Tricks of the Docker Captains
Docker, Inc.
 
PDF
C&C Botnet Factory
Nullbyte Security Conference
 
PPTX
Great Hiroshima with Python 170830
Takuya Nishimoto
 
PPTX
Couch to OpenStack: Neutron (Quantum) - August 13, 2013 Featuring Sean Winn
Trevor Roberts Jr.
 
PDF
Developing MIPS Exploits to Hack Routers
Onur Alanbel
 
PDF
Sandboxing WebKitGTK (GUADEC 2019)
Igalia
 
PDF
FPC for the Masses (SANSFire Edition)
Xavier Mertens
 
PDF
FPC for the Masses - CoRIIN 2018
Xavier Mertens
 
PDF
26.1.7 lab snort and firewall rules
Freddy Buenaño
 
PDF
DPDK in Containers Hands-on Lab
Michelle Holley
 
PDF
Laporan Praktikum Keamanan Siber - Tugas 4 -Kelas C - Kelompok 3.pdf
IGedeArieYogantaraSu
 
PDF
Docker containers : introduction
rinnocente
 
PDF
IoT: Internet of Things with Python
Lelio Campanile
 
PDF
Raspberry home server
Massimiliano Perrone
 
PDF
Package Management via Spack on SJTU π Supercomputer
Jianwen Wei
 
Open stack pike-devstack-tutorial
Eueung Mulyana
 
SDN Training - Open daylight installation + example with mininet
SAMeh Zaghloul
 
Functional Operations (Functional Programming at Comcast Labs Connect)
Susan Potter
 
Virtual Networking (1) (1).pptx
KrishnaMishra386849
 
LSA2 - 02 Namespaces
Marian Marinov
 
DCEU 18: Tips and Tricks of the Docker Captains
Docker, Inc.
 
C&C Botnet Factory
Nullbyte Security Conference
 
Great Hiroshima with Python 170830
Takuya Nishimoto
 
Couch to OpenStack: Neutron (Quantum) - August 13, 2013 Featuring Sean Winn
Trevor Roberts Jr.
 
Developing MIPS Exploits to Hack Routers
Onur Alanbel
 
Sandboxing WebKitGTK (GUADEC 2019)
Igalia
 
FPC for the Masses (SANSFire Edition)
Xavier Mertens
 
FPC for the Masses - CoRIIN 2018
Xavier Mertens
 
26.1.7 lab snort and firewall rules
Freddy Buenaño
 
DPDK in Containers Hands-on Lab
Michelle Holley
 
Laporan Praktikum Keamanan Siber - Tugas 4 -Kelas C - Kelompok 3.pdf
IGedeArieYogantaraSu
 
Docker containers : introduction
rinnocente
 
IoT: Internet of Things with Python
Lelio Campanile
 
Raspberry home server
Massimiliano Perrone
 
Package Management via Spack on SJTU π Supercomputer
Jianwen Wei
 
Ad

More from Eueung Mulyana (20)

PDF
FGD Big Data
Eueung Mulyana
 
PDF
Hyper-Connectivity and Data Proliferation - Ecosystem Perspective
Eueung Mulyana
 
PDF
Industry 4.0 And Beyond The A.I* For Surviving A Tech-Accelerated World
Eueung Mulyana
 
PDF
Blockchain Introduction
Eueung Mulyana
 
PDF
Bringing Automation to the Classroom: A ChatOps-Based Approach
Eueung Mulyana
 
PDF
FinTech & Cryptocurrency Introduction
Eueung Mulyana
 
PDF
Open Source Networking Overview
Eueung Mulyana
 
PDF
ONOS SDN Controller - Clustering Tests & Experiments
Eueung Mulyana
 
PDF
Basic onos-tutorial
Eueung Mulyana
 
PDF
ONOS SDN Controller - Introduction
Eueung Mulyana
 
PDF
OpenDaylight SDN Controller - Introduction
Eueung Mulyana
 
PDF
Android Programming Basics
Eueung Mulyana
 
PDF
Cloud Computing: Overview and Examples
Eueung Mulyana
 
PDF
selected input/output - sensors and actuators
Eueung Mulyana
 
PDF
Connected Things, IoT and 5G
Eueung Mulyana
 
PDF
Connectivity for Local Sensors and Actuators Using nRF24L01+
Eueung Mulyana
 
PDF
NodeMCU with Blynk and Firebase
Eueung Mulyana
 
PDF
Trends and Enablers - Connected Services and Cloud Computing
Eueung Mulyana
 
PDF
Digital Ecosystems - Connected Services and Cloud Computing
Eueung Mulyana
 
PDF
Services Convergence - Connected Services and Cloud Computing
Eueung Mulyana
 
FGD Big Data
Eueung Mulyana
 
Hyper-Connectivity and Data Proliferation - Ecosystem Perspective
Eueung Mulyana
 
Industry 4.0 And Beyond The A.I* For Surviving A Tech-Accelerated World
Eueung Mulyana
 
Blockchain Introduction
Eueung Mulyana
 
Bringing Automation to the Classroom: A ChatOps-Based Approach
Eueung Mulyana
 
FinTech & Cryptocurrency Introduction
Eueung Mulyana
 
Open Source Networking Overview
Eueung Mulyana
 
ONOS SDN Controller - Clustering Tests & Experiments
Eueung Mulyana
 
Basic onos-tutorial
Eueung Mulyana
 
ONOS SDN Controller - Introduction
Eueung Mulyana
 
OpenDaylight SDN Controller - Introduction
Eueung Mulyana
 
Android Programming Basics
Eueung Mulyana
 
Cloud Computing: Overview and Examples
Eueung Mulyana
 
selected input/output - sensors and actuators
Eueung Mulyana
 
Connected Things, IoT and 5G
Eueung Mulyana
 
Connectivity for Local Sensors and Actuators Using nRF24L01+
Eueung Mulyana
 
NodeMCU with Blynk and Firebase
Eueung Mulyana
 
Trends and Enablers - Connected Services and Cloud Computing
Eueung Mulyana
 
Digital Ecosystems - Connected Services and Cloud Computing
Eueung Mulyana
 
Services Convergence - Connected Services and Cloud Computing
Eueung Mulyana
 

Recently uploaded (20)

PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
Doc9.....................................
SofiaCollazos
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 

Mininet Basics

  • 1. 1 / 61 EL-5244 MininetBasics Eueung Mulyana https://telematika.org/remark/mininet CodeLabs | Attribution-ShareAlike CC BY-SA
  • 3. Mininet 2.2.2 on Ubuntu 14.04 LTS - 64 bit, o cial VM | POX 0.2.0 (carp) | OVS (Open vSwitch) 2.0.2 VirtualBox 5.2.6 on Ubuntu Xenial 16.04.3. Ref: [Mininet VM Images] 3 / 61
  • 5. Mininet provides a virtual test bed and development environment for SDN 5 / 61
  • 6. 6 / 61 Mininet enables Rapid prototyping of software-de ned networks Complex topology testing without the need to wire up a physical network Multiple concurrent developers to work independently on the same topology
  • 7. 7 / 61 Mininet networks run real code including standard Unix/Linux network applications as well as the real Linux kernel and network stack. Mininet provides an extensible Python API for network creation and experimentations. Ref: MININET - Open Networking Foundation
  • 9. 9 / 61 Mininet Setup Using Pre-Made VM Download a Mininet VM Image Import the Image (eg. into VirtualBox) Con gure Access (eg. port forwarding or host-only networking) Run the VM Access via SSH with Remote Display Forwarding Enabled Note: in the o cial Mininet VM image version 2.2.2, there is possibly a con guration bug if you're using VirtualBox. See comments by isams1 in this thread. So don't use host-only networking to access the VM.
  • 13. Con gure Access - Port Forwarding 13 / 61
  • 14. Con gure Access - Port Forwarding 14 / 61
  • 15. Run the VM 15 / 61
  • 16. Access via SSH 16 / 61
  • 17. Test 17 / 61
  • 18. Test - Wireshark 18 / 61
  • 19. 19 / 61 Check $ ssh -Y -l mininet -p 2222 localhost mininet@mininet-vm:~$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.ori mininet@mininet-vm:~$ sudo sed -i 's/http://us.archive.ubuntu.com/ubuntu//http://kambing.u mininet@mininet-vm:~$ sudo apt-get update mininet@mininet-vm:~$ sudo apt-get install tree mininet@mininet-vm:~$ tree -L 1 . |-- install-mininet-vm.sh |-- loxigen |-- mininet |-- oflops |-- oftest |-- openflow |-- pox
  • 20. 20 / 61 Check mininet@mininet-vm:~/mininet$ tree -L 2 -d . |-- bin |-- build | |-- bdist.linux-x86_64 | |-- lib.linux-x86_64-2.7 | |-- scripts-2.7 |-- custom |-- debian | |-- source |-- dist |-- doc |-- examples | |-- test |-- mininet | |-- examples -> ../examples | |-- test |-- mininet.egg-info |-- util |-- kbuild |-- nox-patches |-- openflow-patches |-- sch_htb-ofbuf |-- vm
  • 21. mininet@mininet-vm:~/mininet/examples$ ll total 364 drwxrwxr-x 3 mininet mininet 4096 Mar 21 2017 ./ drwxrwxr-x 13 mininet mininet 4096 Mar 21 2017 ../ -rw-rw-r-- 1 mininet mininet 4965 Mar 21 2017 README.md -rw-rw-r-- 1 mininet mininet 48 Mar 21 2017 __init__.py -rwxrwxr-x 1 mininet mininet 1074 Mar 21 2017 baresshd.py* -rwxrwxr-x 1 mininet mininet 2310 Mar 21 2017 bind.py* -rwxrwxr-x 1 mininet mininet 33427 Mar 21 2017 cluster.py* -rwxrwxr-x 1 mininet mininet 501 Mar 21 2017 clusterSanity.py* -rw-rw-r-- 1 mininet mininet 3875 Mar 21 2017 clustercli.py -rwxrwxr-x 1 mininet mininet 639 Mar 21 2017 clusterdemo.py* -rwxrwxr-x 1 mininet mininet 15612 Mar 21 2017 consoles.py* -rwxrwxr-x 1 mininet mininet 1061 Mar 21 2017 controllers.py* -rwxrwxr-x 1 mininet mininet 1612 Mar 21 2017 controllers2.py* -rwxrwxr-x 1 mininet mininet 4967 Mar 21 2017 controlnet.py* -rwxrwxr-x 1 mininet mininet 3725 Mar 21 2017 cpu.py* -rwxrwxr-x 1 mininet mininet 960 Mar 21 2017 emptynet.py* -rwxrwxr-x 1 mininet mininet 1549 Mar 21 2017 hwintf.py* -rwxrwxr-x 1 mininet mininet 1320 Mar 21 2017 intfoptions.py* -rwxrwxr-x 1 mininet mininet 2034 Mar 21 2017 limit.py* -rwxrwxr-x 1 mininet mininet 4062 Mar 21 2017 linearbandwidth.py* -rwxrwxr-x 1 mininet mininet 2826 Mar 21 2017 linuxrouter.py* -rwxrwxr-x 1 mininet mininet 154479 Mar 21 2017 miniedit.py* -rwxrwxr-x 1 mininet mininet 4198 Mar 21 2017 mobility.py* -rwxrwxr-x 1 mininet mininet 834 Mar 21 2017 multilink.py* -rwxrwxr-x 1 mininet mininet 2235 Mar 21 2017 multiping.py* -rwxrwxr-x 1 mininet mininet 2469 Mar 21 2017 multipoll.py* -rwxrwxr-x 1 mininet mininet 1049 Mar 21 2017 multitest.py* -rwxrwxr-x 1 mininet mininet 550 Mar 21 2017 nat.py* -rwxrwxr-x 1 mininet mininet 1948 Mar 21 2017 natnet.py* -rwxrwxr-x 1 mininet mininet 2330 Mar 21 2017 numberedports.py* -rwxrwxr-x 1 mininet mininet 1023 Mar 21 2017 popen.py* -rwxrwxr-x 1 mininet mininet 932 Mar 21 2017 popenpoll.py* -rwxrwxr-x 1 mininet mininet 2032 Mar 21 2017 scratchnet.py* -rwxrwxr-x 1 mininet mininet 2455 Mar 21 2017 scratchnetuser.py* -rwxrwxr-x 1 mininet mininet 1888 Mar 21 2017 simpleperf.py* -rwxrwxr-x 1 mininet mininet 3040 Mar 21 2017 sshd.py* drwxrwxr-x 2 mininet mininet 4096 Mar 21 2017 test/ -rwxrwxr-x 1 mininet mininet 522 Mar 21 2017 tree1024.py* -rwxrwxr-x 1 mininet mininet 950 Mar 21 2017 treeping64.py* -rwxrwxr-x 1 mininet mininet 3679 Mar 21 2017 vlanhost.py* 21 / 61 Check
  • 22. 22 / 61 Notes Mininet Walkthrough $ sudo mn [--topo=minimal] $ sudo mn --test pingpair $ sudo mn --test iperf $ sudo mn --link tc,bw=10,delay=10ms $ sudo mn --test pingall --topo single,3 $ sudo mn --test pingall --topo mytopo --custom ~/mininet/custom/topo-2sw-2host.py $ sudo mn --mac mininet> h1 ping -c10 h2 mininet> pingall mininet> h1 python -m SimpleHTTPServer 80 & mininet> h2 wget -O - h1 mininet> iperf mininet> link s1 h1 down mininet> link s1 h1 up $ sudo ~/mininet/examples/sshd.py Ref: Mininet Walkthrough - Mininet
  • 23. 23 / 61 Notes Mininet Sample Work ow # Creating a Network $ sudo mn --switch ovs --controller ref --topo tree,depth=2,fanout=8 --test pingall # Interacting with a Network mininet> h2 ping h3 mininet> h2 python -m SimpleHTTPServer 80 >& /tmp/http.log & mininet> h3 wget -O - h2 # Customizing a Network from mininet.net import Mininet from mininet.topolib import TreeTopo tree4 = TreeTopo(depth=2,fanout=2) net = Mininet(topo=tree4) net.start() h1, h4 = net.hosts[0], net.hosts[3] print h1.cmd('ping -c1 %s' % h4.IP()) net.stop() Ref: Mininet Sample Work ow - Mininet
  • 25. 25 / 61 MiniNAM A utility that provides real-time animation of any network created by the Mininet emulator. MiniNAM includes all the components required to initiate, visualize and modify Mininet network ows in real-time. MiniNAM provides a graphical user interface that allows dynamic modi cation of preferences and packet lters: a user can view selective ows with options to color code packets based on packet type and/or nodes (hosts). Ref: MiniNAM | University College Cork
  • 26. 26 / 61 Setup $ ssh -Y -l mininet -p 2222 localhost $ sudo apt-get install git python-imaging python-imaging-tk $ git clone https://github.com/uccmisl/MiniNAM.git mininet@mininet-vm:~/MiniNAM$ tree . |-- conf.config |-- Examples | |-- LoadBalancer | | |-- install.sh | | |-- MiniNAM.py | | |-- paping | | |-- README.md | |-- NAT | | |-- badNAT.py | | |-- conf.config | | |-- goodNAT.py | | |-- MiniNAM.py | | |-- README.md | |-- Routing | |-- MiniNAM.py | |-- README.md | |-- simple_switch_13.py | |-- simple_switch_stp_13.py | |-- spanning_tree.py |-- LICENSE |-- MiniNAM.py |-- README.md mininet@mininet-vm:~/MiniNAM$ sudo python MiniNAM.py
  • 27. MiniNAM | h1 ping -c2 h2 27 / 61
  • 29. sudo mn --topo single,3 --mac --switch ovsk --controller remote 29 / 61
  • 30. sudo python ~/MiniNAM/MiniNAM.py ... | controller & wireshark issues 30 / 61
  • 31. 31 / 61 Manual Flow Entry mininet@mininet-vm:~$ sudo ovs-ofctl dump-flows s1 NXST_FLOW reply (xid=0x4): mininet> h1 ping -c3 h2 PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data. From 10.0.0.1 icmp_seq=1 Destination Host Unreachable ... mininet@mininet-vm:~$ sudo ovs-ofctl add-flow s1 in_port=1,actions=output:2 mininet@mininet-vm:~$ sudo ovs-ofctl add-flow s1 in_port=2,actions=output:1 mininet@mininet-vm:~$ sudo ovs-ofctl dump-flows s1 NXST_FLOW reply (xid=0x4): cookie=0x0, duration=25.666s, table=0, n_packets=0, n_bytes=0, idle_age=25, in_port=1 actions=o cookie=0x0, duration=11.374s, table=0, n_packets=0, n_bytes=0, idle_age=11, in_port=2 actions=o mininet> h1 ping -c3 h2 PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data. 64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.979 ms ... 3 packets transmitted, 3 received, 0% packet loss, time 2003ms rtt min/avg/max/mdev = 0.099/0.402/0.979/0.408 ms
  • 32. sudo wireshark & 32 / 61
  • 33. Capture Interfaces - Loopback 33 / 61
  • 34. 34 / 61 Starting Controller OF Reference Controller $ controller ptcp: & # Issue: controller must first be run, before mininet # Could be an issue related with the image $ controller ptcp: & $ sudo mn --topo single,3 --mac --switch ovsk --controller remote # clean up arp mininet> h1 ip -s -s neigh flush all mininet> h2 ip -s -s neigh flush all # in case, there's still flow entries mininet@mininet-vm:~$ sudo ovs-ofctl del-flows s1 mininet> h1 ping -c1 h2
  • 35. Filter - of 35 / 61
  • 38. of and not (of10.echo_request.type or of10.echo_reply.type) 38 / 61
  • 39. OF Packets Captured After : h1 ping -c1 h2 39 / 61
  • 40. 40 / 61 h1 ping -c1 h2
  • 41. 41 / 61 Flow Entries mininet> dpctl dump-flows mininet@mininet-vm:~$ sudo ovs-ofctl dump-flows s1 NXST_FLOW reply (xid=0x4): cookie=0x0, duration=25.373s, table=0, n_packets=1, n_bytes=42, idle_timeout=60, idle_age=25, p cookie=0x0, duration=30.373s, table=0, n_packets=1, n_bytes=42, idle_timeout=60, idle_age=30, p cookie=0x0, duration=25.374s, table=0, n_packets=1, n_bytes=42, idle_timeout=60, idle_age=25, p cookie=0x0, duration=30.371s, table=0, n_packets=1, n_bytes=98, idle_timeout=60, idle_age=30, p cookie=0x0, duration=30.37s, table=0, n_packets=1, n_bytes=98, idle_timeout=60, idle_age=30, pr mininet@mininet-vm:~$ sudo ovs-ofctl dump-flows s1 NXST_FLOW reply (xid=0x4):
  • 42. 42 / 61 Benchmark kernel- vs. user- space mininet> iperf +++ Iperf: testing TCP bandwidth between h1 and h3 +++ Results: ['27.5 Gbits/sec', '27.6 Gbits/sec'] mininet> exit mininet@mininet-vm:~$ sudo mn --topo single,3 --controller remote --switch user mininet> iperf +++ Iperf: testing TCP bandwidth between h1 and h3 +++ Results: ['658 Mbits/sec', '659 Mbits/sec'] # Notes user-space: mininet> sh ovs-ofctl dump-flows s1 ovs-ofctl: s1 is not a bridge or a socket
  • 43. Notes My personal notes with previous versions of Mininet. Some are not tested yet with the current version. 43 / 61
  • 44. 44 / 61 Notes mininet> xterm h1 h2 h3 h1# tcpdump -ne -i h1-eth0 mininet>1 h1 ping -c1 h2 mininet>1 h1 arp -na # deprecated?? $ sudo ovs-controller --verbose ptcp:& # $ sudo controller ptcp:& # $ sudo ovs-controller --hub ptcp:& # --noflow --normal --verbose $ sudo ovs-controller --hub --verbose ptcp:& $ sudo ovs-controller --noflow --verbose ptcp:&
  • 45. 45 / 61 Notes # IP-Source-Address-Based Rule --> may need Reset $ sudo ovs-ofctl del-flows s1 $ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,dl_type=0x0800,nw_src=10.0.0.1,acti $ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,dl_type=0x0800,nw_src=10.0.0.2,acti # IP-Dest-Address-Based Rule --> may need Reset $ sudo ovs-ofctl del-flows s1 $ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,ip,nw_dst=10.0.0.3,actions=output:3 $ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,ip,nw_dst=10.0.0.2,actions=output:2 $ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,ip,nw_dst=10.0.0.1,actions=output:1 $ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,arp,actions=NORMAL # Alternatives $ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,dl_type=0x0806,actions=FLOOD $ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,dl_type=0x0806,actions=ALL $ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,dl_type=0x0800,nw_proto=1,actions=N $ sudo ovs-ofctl add-flow s1 idle_timeout=600,priority=33001,icmp,nw_dst=10.0.0.2,actions=output # NORMAL sends packet to non-openflow function of switch - not all switch # sudo ovs-ofctl del-flows s1 in_port=1 # sudo ovs-ofctl del-flows s1 dl_type=0x0800
  • 49. 49 / 61 POXController POX is a Python-based SDN controller platform geared towards research and education. POX provides a framework for communicating with SDN switches using either the OpenFlow or OVSDB protocol. Developers can use POX to create an SDN controller using the Python programming language. Ref: [brianlinkletter ]
  • 50. 50 / 61 POX Controller Files mininet@mininet-vm:~/pox/pox/misc$ ll total 76 drwxrwxr-x 3 mininet mininet 4096 Mar 21 2017 ./ drwxrwxr-x 15 mininet mininet 4096 Mar 21 2017 ../ -rw-rw-r-- 1 mininet mininet 689 Mar 21 2017 __init__.py -rw-rw-r-- 1 mininet mininet 1240 Mar 21 2017 cbench.py -rw-rw-r-- 1 mininet mininet 1079 Mar 21 2017 full_payload.py -rw-rw-r-- 1 mininet mininet 5214 Mar 21 2017 gephi_topo.py -rw-rw-r-- 1 mininet mininet 10251 Mar 21 2017 ip_loadbalancer.py -rw-rw-r-- 1 mininet mininet 3794 Mar 21 2017 mac_blocker.py -rw-rw-r-- 1 mininet mininet 14375 Mar 21 2017 nat.py -rw-rw-r-- 1 mininet mininet 4582 Mar 21 2017 of_tutorial.py -rw-rw-r-- 1 mininet mininet 2096 Mar 21 2017 pidfile.py drwxrwxr-x 2 mininet mininet 4096 Mar 21 2017 telnetd/ mininet@mininet-vm:~/pox/pox/forwarding$ ll total 96 drwxrwxr-x 2 mininet mininet 4096 Mar 21 2017 ./ drwxrwxr-x 15 mininet mininet 4096 Mar 21 2017 ../ -rw-rw-r-- 1 mininet mininet 651 Mar 21 2017 __init__.py -rw-rw-r-- 1 mininet mininet 1092 Mar 21 2017 hub.py -rw-rw-r-- 1 mininet mininet 4426 Mar 21 2017 l2_flowvisor.py -rw-rw-r-- 1 mininet mininet 6692 Mar 21 2017 l2_learning.py -rw-rw-r-- 1 mininet mininet 15558 Mar 21 2017 l2_multi.py -rw-rw-r-- 1 mininet mininet 4324 Mar 21 2017 l2_nx.py -rw-rw-r-- 1 mininet mininet 2105 Mar 21 2017 l2_nx_self_learning.py -rw-rw-r-- 1 mininet mininet 2882 Mar 21 2017 l2_pairs.py -rw-rw-r-- 1 mininet mininet 12330 Mar 21 2017 l3_learning.py -rw-rw-r-- 1 mininet mininet 14102 Mar 21 2017 topo_proactive.py
  • 51. from pox.core import core import pox.openflow.libopenflow_01 as of log = core.getLogger() #============ class Tutorial (object): #------------------------------- def __init__ (self, connection): self.connection = connection connection.addListeners(self) self.mac_to_port = {} #------------------------------- def resend_packet (self, packet_in, out_port): msg = of.ofp_packet_out() msg.data = packet_in action = of.ofp_action_output(port = out_port) msg.actions.append(action) self.connection.send(msg) #------------------------------- def act_like_hub (self, packet, packet_in): self.resend_packet(packet_in, of.OFPP_ALL) #------------------------------- def act_like_switch (self, packet, packet_in): #------------------------------- def _handle_PacketIn (self, event): packet = event.parsed # This is the parsed packet data. if not packet.parsed: log.warning("Ignoring incomplete packet") return packet_in = event.ofp # The actual ofp_packet_in message. self.act_like_hub(packet, packet_in) #self.act_like_switch(packet, packet_in) #============ def launch (): def start_switch (event): log.debug("Controlling %s" % (event.connection,)) Tutorial(event.connection) core.openflow.addListenerByName("ConnectionUp", start_switch) 51 / 61 of_tutorial.py
  • 52. 52 / 61 POX Controller Hub Behavior mininet@mininet-vm:~/pox$ ./pox.py log.level --DEBUG misc.of_tutorial POX 0.2.0 (carp) / Copyright 2011-2013 James McCauley, et al. DEBUG:core:POX 0.2.0 (carp) going up... DEBUG:core:Running on CPython (2.7.6/Oct 26 2016 20:30:19) DEBUG:core:Platform is Linux-4.2.0-27-generic-x86_64-with-Ubuntu-14.04-trusty INFO:core:POX 0.2.0 (carp) is up. DEBUG:openflow.of_01:Listening on 0.0.0.0:6633 INFO:openflow.of_01:[None 1] closed INFO:openflow.of_01:[00-00-00-00-00-01 2] connected DEBUG:misc.of_tutorial:Controlling [00-00-00-00-00-01 2] $ sudo mn --topo single,3 --mac --switch ovsk --controller remote mininet> xterm h1 h2 h3 h1# tcpdump -XX -n -i h1-eth0 > h1.txt & h2# tcpdump -XX -n -i h2-eth0 > h2.txt h3# tcpdump -XX -n -i h3-eth0 > h3.txt h1# ping -c1 10.0.0.2
  • 53. 53 / 61 POX Controller Hub Behavior mininet@mininet-vm:~$ cat h1.txt 16:33:33.273970 ARP, Request who-has 10.0.0.2 tell 10.0.0.1, length 28 16:33:33.305723 ARP, Reply 10.0.0.2 is-at 00:00:00:00:00:02, length 28 16:33:33.305730 IP 10.0.0.1 > 10.0.0.2: ICMP echo request, id 4108, seq 1, length 64 16:33:33.306899 IP 10.0.0.2 > 10.0.0.1: ICMP echo reply, id 4108, seq 1, length 64 16:33:38.356385 ARP, Request who-has 10.0.0.1 tell 10.0.0.2, length 28 16:33:38.356425 ARP, Reply 10.0.0.1 is-at 00:00:00:00:00:01, length 28 mininet@mininet-vm:~$ cat h2.txt 16:33:33.305056 ARP, Request who-has 10.0.0.2 tell 10.0.0.1, length 28 16:33:33.305079 ARP, Reply 10.0.0.2 is-at 00:00:00:00:00:02, length 28 16:33:33.306329 IP 10.0.0.1 > 10.0.0.2: ICMP echo request, id 4108, seq 1, length 64 16:33:33.306344 IP 10.0.0.2 > 10.0.0.1: ICMP echo reply, id 4108, seq 1, length 64 16:33:38.317451 ARP, Request who-has 10.0.0.1 tell 10.0.0.2, length 28 16:33:38.359253 ARP, Reply 10.0.0.1 is-at 00:00:00:00:00:01, length 28 mininet@mininet-vm:~$ cat h3.txt 16:33:33.305054 ARP, Request who-has 10.0.0.2 tell 10.0.0.1, length 28 16:33:33.305722 ARP, Reply 10.0.0.2 is-at 00:00:00:00:00:02, length 28 16:33:33.306328 IP 10.0.0.1 > 10.0.0.2: ICMP echo request, id 4108, seq 1, length 64 16:33:33.306898 IP 10.0.0.2 > 10.0.0.1: ICMP echo reply, id 4108, seq 1, length 64 16:33:38.356378 ARP, Request who-has 10.0.0.1 tell 10.0.0.2, length 28 16:33:38.359247 ARP, Reply 10.0.0.1 is-at 00:00:00:00:00:01, length 28
  • 54. 54 / 61 POX Controller Hub Behavior h1# ping -c1 10.0.0.5 mininet@mininet-vm:~$ cat h1.txt 16:45:33.285777 ARP, Request who-has 10.0.0.5 tell 10.0.0.1, length 28 16:45:34.285666 ARP, Request who-has 10.0.0.5 tell 10.0.0.1, length 28 16:45:35.285632 ARP, Request who-has 10.0.0.5 tell 10.0.0.1, length 28 mininet@mininet-vm:~$ cat h3.txt 16:45:33.335877 ARP, Request who-has 10.0.0.5 tell 10.0.0.1, length 28 16:45:34.310252 ARP, Request who-has 10.0.0.5 tell 10.0.0.1, length 28 16:45:35.287537 ARP, Request who-has 10.0.0.5 tell 10.0.0.1, length 28 mininet@mininet-vm:~$ cat h2.txt 16:45:33.335881 ARP, Request who-has 10.0.0.5 tell 10.0.0.1, length 28 16:45:34.310257 ARP, Request who-has 10.0.0.5 tell 10.0.0.1, length 28 16:45:35.287542 ARP, Request who-has 10.0.0.5 tell 10.0.0.1, length 28
  • 55. Packets Captured After : h1 ping -c1 10.0.0.2 55 / 61
  • 56. Packets Captured After : h1 ping -c1 10.0.0.5 56 / 61
  • 57. 57 / 61 POX Controller Hub Behavior mininet> sh ovs-ofctl dump-flows s1 NXST_FLOW reply (xid=0x4): mininet> pingpair h1 -> h2 h2 -> h1 +++ Results: 0% dropped (2/2 received) mininet> pingall +++ Ping: testing ping reachability h1 -> h2 h3 h2 -> h1 h3 h3 -> h1 h2 +++ Results: 0% dropped (6/6 received) mininet> iperf +++ Iperf: testing TCP bandwidth between h1 and h3 +++ Results: ['19.0 Mbits/sec', '20.3 Mbits/sec'] mininet@mininet-vm:~$ sudo python MiniNAM/MiniNAM.py --topo single,3 --mac --switch ovsk --contr
  • 58. def act_like_switch (self, packet, packet_in): self.mac_to_port[packet.src] = packet_in.in_port if packet.dst in self.mac_to_port: print("Packet sent to Control Plane") self.resend_packet(packet_in, self.mac_to_port[packet.dst]) # log.debug("Installing flow...") msg = of.ofp_flow_mod() msg.match.dl_dst = packet.dst # msg.match = of.ofp_match.from_packet(packet) msg.actions.append(of.ofp_action_output(port=self.mac_to_port[packet.dst])) self.connection.send(msg) else: self.resend_packet(packet_in, of.OFPP_ALL) 58 / 61 of_tutorial.py
  • 60. Refs/Resources 1. Learn Development Tools - mininet/open ow-tutorial Wiki 2. Create a Learning Switch - mininet/open ow-tutorial Wiki 3. MININET - Open Networking Foundation 4. MiniNAM | University College Cork 5. uccmisl/MiniNAM: A Network Animator for Visualizing Real-Time Packet Flows in Mininet 6. FAQ - mininet/mininet Wiki 7. Learn Development Tools - mininet/open ow-tutorial Wiki 8. Create a Learning Switch - mininet/open ow-tutorial Wiki 60 / 61
  • 61. 61 / 61 ENDEueung Mulyana https://telematika.org/remark/mininet CodeLabs | Attribution-ShareAlike CC BY-SA