You are on page 1of 17

Mininet, Remote Controller & Custom Topology

SDN Research Group MNIT(SARGAM)

November 14, 2016

SDN Research Group MNIT(SARGAM) Mininet, Remote Controller & Custom Topology November 14, 2016 1 / 17
Installation of mininet

install git
I sudo apt-get install git

Download the mininet code from github


I git clone git://github.com/mininet/mininet
I cd mininet
I git tag
I git checkout -b 2.2.1 2.2.1
I cd ..
I mininet/util/install.sh -a

SDN Research Group MNIT(SARGAM) Mininet, Remote Controller & Custom Topology November 14, 2016 2 / 17
Example:SDN Working

Controllers with some modules

5 6

2 3 8 9

4 7
1 10MBps s2 10MBps 10

h2 h3

s1 s4
100MBps 100MBps

h1 h4

s3

SDN Research Group MNIT(SARGAM) Mininet, Remote Controller & Custom Topology November 14, 2016 3 / 17
SDN Controller

Controller Duties
I check link, port status(LLDP,BBDP)
I listen events from switchs(e.g. PacketIn, FlowRemoved)
I parse incoming packet
I push flowtable entry
I can get statistics(e.g. timers)

SDN Research Group MNIT(SARGAM) Mininet, Remote Controller & Custom Topology November 14, 2016 4 / 17
Open Vswitch Controller

Default Controller
I sudo mn
I Default Controller:ovs-controller
I Source: /home/oftest/tools/ovs-ctl/ovs-ctl.py

Limitation
I Only supports 16 switches
I will not work with a network that has loops in it

Available Options
I NOX(python), POX(python), Ryu(python), OpenDaylight(java),
Floodlight(java), ...

SDN Research Group MNIT(SARGAM) Mininet, Remote Controller & Custom Topology November 14, 2016 5 / 17
Installation of Remote controller(POX)

Download the POX code from the POX repository on github


I git clone http://github.com/noxrepo/pox

Run POX Controller with mininet


I $ sudo mn - -controller=remote,ip=127.0.0.1,port=6633
I pox$ ./pox.py log.level - -DEBUG forwarding.hub

SDN Research Group MNIT(SARGAM) Mininet, Remote Controller & Custom Topology November 14, 2016 6 / 17
Example:Remote Controller

SDN Research Group MNIT(SARGAM) Mininet, Remote Controller & Custom Topology November 14, 2016 7 / 17
Example:Remote Controller

SDN Research Group MNIT(SARGAM) Mininet, Remote Controller & Custom Topology November 14, 2016 8 / 17
Example:Remote Controller

SDN Research Group MNIT(SARGAM) Mininet, Remote Controller & Custom Topology November 14, 2016 9 / 17
Understand the Code of POX module
Switch as a HUB
1
2 from pox . c o r e i m p o r t c o r e
3 i m p o r t pox . o p e n f l o w . l i b o p e n f l o w 0 1 a s o f
4 from pox . l i b . u t i l i m p o r t d p i d T o S t r
5
6 log = core . getLogger ()
7
8
9 def handle ConnectionUp ( event ) :
10 msg = o f . o f p f l o w m o d ( )
11 msg . a c t i o n s . append ( o f . o f p a c t i o n o u t p u t ( p o r t = o f .
OFPP FLOOD) )
12 e v e n t . c o n n e c t i o n . s e n d ( msg )
13 l o g . i n f o ( ” H u b i f y i n g %s ” , d p i d T o S t r ( e v e n t . d p i d ) )
14
15 def launch () :
16 c o r e . openflow . addListenerByName ( ” ConnectionUp ” ,
handle ConnectionUp )
17
SDN Research Group MNIT(SARGAM) Mininet, Remote Controller & Custom Topology November 14, 2016 10 / 17
Create Custom Topology
/home/mininet/custom/topo-2sw-2host.py
1 from m i n i n e t . t o p o i m p o r t Topo
2
3 c l a s s MyTopo ( Topo ) :
4
5 def init ( self ):
6 # I n i t i a l i z e topology
7 Topo . init ( self )
8 # Add h o s t s and s w i t c h e s
9 l e f t H o s t = s e l f . addHost ( ’ h1 ’ )
10 r i g h t H o s t = s e l f . addHost ( ’ h2 ’ )
11 l e f t S w i t c h = s e l f . addSwitch ( ’ s3 ’ )
12 r i g h t S w i t c h = s e l f . addSwitch ( ’ s4 ’ )
13 # Add l i n k s
14 s e l f . addLink ( l e f t H o s t , l e f t S w i t c h )
15 s e l f . addLink ( l e f t S w i t c h , r i g h t S w i t c h )
16 s e l f . addLink ( rightSwitch , r i g h t H o s t )
17
18 t o p o s = { ’ mytopo ’ : ( lambda : MyTopo ( ) ) }
SDN Research Group MNIT(SARGAM) Mininet, Remote Controller & Custom Topology November 14, 2016 11 / 17
Mininet & Custom Topology

Run Custom Topology with Mininet


I sudo mn - -custom mininet/custom/topo-2sw-2host.py –topo mytopo

SDN Research Group MNIT(SARGAM) Mininet, Remote Controller & Custom Topology November 14, 2016 12 / 17
Mininet, Custom Topology & Remote Controller

Run Custom Topology, Remote Controller with Mininet


I sudo mn - -controller=remote,ip=127.0.0.1,port=6633 - -custom
mininet/custom/topo-2sw-2host.py - -topo mytopo
I pox$ ./pox.py log.level - -DEBUG forwarding.hub

SDN Research Group MNIT(SARGAM) Mininet, Remote Controller & Custom Topology November 14, 2016 13 / 17
Understand the Code of POX module
Switch as a
1
2 from pox . c o r e i m p o r t c o r e
3 i m p o r t pox . o p e n f l o w . l i b o p e n f l o w 0 1 a s o f
4 from pox . l i b . u t i l i m p o r t d p i d T o S t r
5
6 log = core . getLogger ()
7
8
9 def handle ConnectionUp ( event ) :
10 msg = o f . o f p f l o w m o d ( )
11 msg . a c t i o n s . append ( o f . o f p a c t i o n o u t p u t ( p o r t = o f .
OFPP FLOOD) )
12 e v e n t . c o n n e c t i o n . s e n d ( msg )
13 l o g . i n f o ( ” H u b i f y i n g %s ” , d p i d T o S t r ( e v e n t . d p i d ) )
14
15 def launch () :
16 c o r e . openflow . addListenerByName ( ” ConnectionUp ” ,
handle ConnectionUp )
17
SDN Research Group MNIT(SARGAM) Mininet, Remote Controller & Custom Topology November 14, 2016 14 / 17
Writing Controller Module

Run Remote Controller with Mininet


I sudo mn - -controller=remote,ip=127.0.0.1,port=6633
I Created Topology H1==S1==H2

Write a Controller Module

SDN Research Group MNIT(SARGAM) Mininet, Remote Controller & Custom Topology November 14, 2016 15 / 17
Mininet, Custom Topology & Remote Controller with
Custom Module

Controllers with some modules

10MBps s2 10MBps

h2 h3

s1 s4
100MBps 100MBps

h1 h4

s3

Run Custom Topology, Remote Controller with Mininet


SDN Research Group MNIT(SARGAM) Mininet, Remote Controller & Custom Topology November 14, 2016 16 / 17
THANK YOU

SDN Research Group MNIT(SARGAM) Mininet, Remote Controller & Custom Topology November 14, 2016 17 / 17

You might also like