Mininet + NS3 for SDN and WIFI simulations


Example 3:

h1( links0 ( AP + open vswitch)--wired link--h3(

h2 ( link--



1.      Open the vm.

2.      Login with name: mininet and password: mininet

3.      Change to graphical mode: startx

4.      Open a terminal

5.     Go to the directory containing ns3: cd ns-allinone-3.17/ns-3.17

6.      Run sudo ./waf shell in order to let the ns3 set appropriate environment variables.

7.     Run the

import rlcompleter

import readline


import time


from import Mininet

from mininet.node import Node, Switch

from import Link, Intf

from mininet.log import setLogLevel, info

from mininet.cli import CLI


import mininet.ns3

from mininet.ns3 import WIFISegment

from mininet.node import OVSController

from import TCLink


readline.parse_and_bind("tab: complete")


if __name__ == '__main__':

    setLogLevel( 'info' )


    net = Mininet( controller=OVSController )

    c0 = net.addController( 'c0' )


    info( '*** Adding hosts\n' )

    h1 = net.addHost( 'h1', ip='' )

    h2 = net.addHost( 'h2', ip='' )

    h3 = net.addHost( 'h3', ip='' )


    info( '*** Adding switch\n' )

    s0 = net.addSwitch( 's0' )

    s0.listenPort = 6634


    s0.start( [c0] )

    linkopts=dict( bw=100, delay='1ms', loss=0 )

    TCLink( s0, h3, **linkopts )


    #net.hosts.append( s0 )

    net.hosts.append( h1 )

    net.hosts.append( h2 )


    wifi = WIFISegment()


    wifi.addAp( s0 )

    wifi.addSta( h1 )

    wifi.addSta( h2 )







8. use the dpctl to set that when the packets from h2, the packets will be dropped (go to an unexisting port)


Dr. Chih-Heng Ke

Department of Computer Science and Information Engineering, National Quemoy University, Kinmen, Taiwan