Example #1
0
def topology():

    "Create a network."
    net = Mininet( controller=RemoteController, link=TCLink, switch=OVSKernelSwitch )
    sta = []

    print "*** Creating nodes"
    for n in range(10):
	sta.append(n)
	sta[n] = net.addStation( 'sta%s' % (n+1), wlans=2, mac='00:00:00:00:00:%s' % (n+1), ip='192.168.0.%s/24' % (n+1) )
    phyap1 = net.addPhysicalBaseStation( 'phyap1', ssid= 'SBRC16-MininetWiFi', mode= 'g', channel= '1', position='50,115,0', wlan='wlan11' )
    sta11 = net.addStation( 'sta11', ip='10.0.0.111/8', position='120,200,0')
    ap2 = net.addBaseStation( 'ap2', ssid= 'ap2', mode= 'g', channel= '11', position='100,175,0' )
    ap3 = net.addBaseStation( 'ap3', ssid= 'ap3', mode= 'g', channel= '6', position='150,50,0' )
    ap4 = net.addBaseStation( 'ap4', ssid= 'ap4', mode= 'g', channel= '1', position='175,150,0' )
    c1 = net.addController( 'c1', controller=Controller, port=6653 )
    root = Node( 'root', inNamespace=False )

    print "*** Creating links"
    for station in sta:
        net.addMesh(station, ssid='meshNet')

    """uncomment to plot graph"""
    net.plotGraph(max_x=240, max_y=240)

    """Routing"""
    net.meshRouting('custom')

    """Seed"""
    net.seed(20)

    print "*** Associating and Creating links"
    net.addLink(phyap1, ap2)
    net.addLink(ap2, ap3)
    net.addLink(ap3, ap4)

    print "*** Starting network"
    net.build()

    c1.start()
    phyap1.start( [c1] )
    ap2.start( [c1] )
    ap3.start( [c1] )
    ap4.start( [c1] )

    ip = 201
    for station in sta:
        station.cmd('ifconfig %s-wlan1 10.0.0.%s/8' % (station, ip))
        ip+=1

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
    net.startMobility(startTime=0, model='RandomWalk', max_x=200, max_y=220, min_v=0.1, max_v=0.2)

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' )
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
    sta2 = net.addStation( 'sta2', wlans=2, ip='10.0.0.3/8' )
    sta3 = net.addStation( 'sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8' )
    sta4 = net.addStation( 'sta4', wlans=2, ip='10.0.0.5/8' )
    sta5 = net.addStation( 'sta5', mac='00:00:00:00:00:06', ip='10.0.0.6/8' )
    sta6 = net.addStation( 'sta6', wlans=2,ip='10.0.0.7/8' )

    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid1', mode= 'g', channel= '1', position='30,30,0', range= 30)
    ap2 = net.addBaseStation( 'ap2', ssid= 'new-ssid2', mode= 'g', channel= '2', position='60,30,0', range= 40 )
    ap3 = net.addBaseStation( 'ap3', ssid= 'new-ssid3', mode= 'g', channel= '3', position='30,50,0', range= 35 )
    ap4 = net.addBaseStation( 'ap4', ssid= 'new-ssid4', mode= 'g', channel= '4', position='60,50,0', range= 45 )
    c1 = net.addController( 'c1', controller=Controller )


    print "*** Associating and Creating links"
    net.addLink(ap1, ap2)
    net.addLink(ap1, ap3)
    net.addLink(ap1, ap4)
    net.addLink(ap2, ap3)
    net.addLink(ap2, ap4)
    net.addLink(ap3, ap4)

    net.addLink(ap1, h1)
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)
    net.addLink(ap2, sta3)
    net.addLink(ap3, sta4)
    net.addLink(ap4, sta5)
    net.addLink(ap4, sta6)
    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )
    ap2.start( [c1] )
    ap3.start( [c1] )
    ap4.start( [c1] )
    
    net.seed(10)

    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    net.startMobility(startTime=0, model='RandomWayPoint', max_x=60, max_y=60, min_v=0.1, max_v=0.5, AC='ssf')

   

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
def topology():
    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', wlans=2, ip='10.0.0.2/8' )
    h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' )
    h2 = net.addHost( 'h2', mac='00:00:00:00:00:11', ip='10.0.0.11/8' )
    ap1 = net.addBaseStation( 'ap1', ssid='ssid_ap1', mode= 'g', channel=6, position='70,25,0' )
    ap2 = net.addBaseStation( 'ap2', ssid='ssid_ap2', mode= 'g', channel=1, position='30,25,0' )
    ap3 = net.addBaseStation( 'ap3', ssid='ssid_ap3', mode= 'g', channel=11, position='110,25,0' )
    s4 = net.addSwitch( 's4', mac='00:00:00:00:00:10' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** Associating and Creating links"
    net.addLink(ap1, s4)
    net.addLink(ap2, s4)
    net.addLink(ap3, s4)
    net.addLink(s4, h1)
    net.addLink(s4, h2)

    sta1.cmd('modprobe bonding mode=3')
    sta1.cmd('ip link add bond0 type bond')
    sta1.cmd('ip link set bond0 address 02:01:02:03:04:08')
    sta1.cmd('ip link set sta1-wlan0 down')
    sta1.cmd('ip link set sta1-wlan0 address 00:00:00:00:00:11')
    sta1.cmd('ip link set sta1-wlan0 master bond0')
    sta1.cmd('ip link set sta1-wlan1 down')
    sta1.cmd('ip link set sta1-wlan1 address 00:00:00:00:00:12')
    sta1.cmd('ip link set sta1-wlan1 master bond0')
    sta1.cmd('ip addr add 10.0.0.10/8 dev bond0')
    sta1.cmd('ip link set bond0 up')

    print "*** Starting network"
    net.build()
    c1.start()
    s4.start( [c1] )
    ap1.start( [c1] )
    ap2.start( [c1] )
    ap3.start( [c1] )

    sta1.cmd('ip addr del 10.0.0.2/8 dev sta1-wlan0')
    os.system('ovs-ofctl add-flow s4 actions=normal')

    """seed"""
    net.seed(12)

    """uncomment to plot graph"""
    net.plotGraph(max_x=140, max_y=140)
    
    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWaypoint, GaussMarkov ***"
    net.startMobility(startTime=0, model='RandomDirection', max_x=120, max_y=50, min_v=0.4, max_v=0.6)

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
def topology():
    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8' )
    sta3 = net.addStation( 'sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8' )
    sta4 = net.addStation( 'sta4', mac='00:00:00:00:00:05', ip='10.0.0.5/8' )
    sta5 = net.addStation( 'sta5', mac='00:00:00:00:00:06', ip='10.0.0.6/8' )
    sta6 = net.addStation( 'sta6', mac='00:00:00:00:00:07', ip='10.0.0.7/8' )
    sta7 = net.addStation( 'sta7', mac='00:00:00:00:00:08', ip='10.0.0.8/8' )
    sta8 = net.addStation( 'sta8', mac='00:00:00:00:00:09', ip='10.0.0.9/8' )
    sta9 = net.addStation( 'sta9', mac='00:00:00:00:00:10', ip='10.0.0.10/8' )
    sta10 = net.addStation( 'sta10', mac='00:00:00:00:00:11', ip='10.0.0.11/8' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid1', mode= 'g', channel= '1', position='50,50,0' )
    ap2 = net.addBaseStation( 'ap2', ssid= 'new-ssid2', mode= 'g', channel= '1', position='70,50,0', range=30 ) #range: set the AP range
    ap3 = net.addBaseStation( 'ap3', ssid= 'new-ssid3', mode= 'g', channel= '1', position='90,50,0' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** Associating and Creating links"
    net.addLink(ap1, ap2)
    net.addLink(ap2, ap3)
    
    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )
    ap2.start( [c1] )
    ap3.start( [c1] )
    
    """uncomment to plot graph"""
    net.plotGraph(max_x=120, max_y=120)

    """association control"""
    net.associationControl('ssf')

    """Seed"""
    net.seed(1) 

    """ *** Available models: 
                RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov
	*** Association Control (AC) - mechanism that optimizes the use of the APs:
                llf (Least-Loaded-First)
                ssf (Strongest-Signal-First)"""
    net.startMobility(startTime=0, model='RandomWayPoint', max_x=120, max_y=120, min_v=0.3, max_v=0.5)
   
    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Example #5
0
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    car1 = net.addVehicle( 'car1', wlans=2, mac='00:00:00:00:00:01', ip='10.0.0.1/8', min_speed=1, max_speed=5 )
    car2 = net.addVehicle( 'car2', wlans=2, mac='00:00:00:00:00:02', ip='10.0.0.2/8', min_speed=5, max_speed=10 )
    car3 = net.addVehicle( 'car3', mac='00:00:00:00:00:03', ip='10.0.0.3/8', min_speed=10, max_speed=15 )
    car4 = net.addVehicle( 'car4', mac='00:00:00:00:00:04', ip='10.0.0.4/8', min_speed=15, max_speed=20 )
    car5 = net.addVehicle( 'car5', mac='00:00:00:00:00:05', ip='10.0.0.5/8', min_speed=15, max_speed=20 )
    bs1 = net.addBaseStation( 'BS1', ssid= 'new-ssid1', mode= 'g', channel= '1' )
    bs2 = net.addBaseStation( 'BS2', ssid= 'new-ssid2', mode= 'g', channel= '6' )
    bs3 = net.addBaseStation( 'BS3', ssid= 'new-ssid3', mode= 'g', channel= '11' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** Associating and Creating links"
    net.addMesh(car1, ssid='mesh')
    net.addMesh(car2, ssid='mesh')
    net.addMesh(car3, ssid='mesh')
    net.addMesh(car4, ssid='mesh')
    net.addMesh(car5, ssid='mesh')
    net.addLink(bs1, bs2)
    net.addLink(bs1, bs3)
       
    print "*** Starting network"
    net.build()
    c1.start()
    bs1.start( [c1] )
    bs2.start( [c1] )
    bs3.start( [c1] )
    
    """uncomment to plot graph"""
    net.plotGraph(max_x=500, max_y=500)

    """Number of Roads"""
    net.roads(4)

    """Seed"""
    net.seed(20) 

    """Start Mobility"""
    net.startMobility(startTime=0)
   
    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Example #6
0
def topology():

    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    ap1 = net.addBaseStation('ap1',
                             ssid='new-ssid1',
                             mode='g',
                             channel='1',
                             position='15,30,0')
    ap2 = net.addBaseStation('ap2',
                             ssid='new-ssid1',
                             mode='g',
                             channel='6',
                             position='55,30,0')
    s3 = net.addSwitch('s3')
    h4 = net.addHost('h4', ip='10.0.0.4/8')
    c1 = net.addController('c1', controller=Controller, port=6653)

    net.plotHost(h4, position='35,90,0')
    net.plotHost(s3, position='35,80,0')

    print "*** Creating links"
    net.addLink(ap1, s3)
    net.addLink(ap2, s3)
    net.addLink(h4, s3)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    ap2.start([c1])
    s3.start([c1])
    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    net.startMobility(startTime=0)
    net.mobility('sta1', 'start', time=1, position='10,30,0')
    net.mobility('sta1', 'stop', time=40, position='60,30,0')
    net.stopMobility(stopTime=40)

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
Example #7
0
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:01', ip='192.168.0.1/24', position='47.28,50,0' )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:02', ip='192.168.0.2/24', position='54.08,50,0' )
    ap3 = net.addBaseStation( 'ap3', range=20, ssid='ap-ssid3', mode= 'b', channel= '1', position='50,50,0' )
    c4 = net.addController( 'c4', controller=Controller, port=6653 )

    print "*** Starting network"
    net.build()
    c4.start()
    ap3.start( [c4] )

    sta1.cmd('iw dev sta1-wlan0 interface add mon0 type monitor &')
    sta1.cmd('ifconfig mon0 up &')
    sta2.cmd('iw dev sta2-wlan0 interface add mon0 type monitor &')
    sta2.cmd('ifconfig mon0 up &')
    sta2.cmd('pushd /home/alpha/Downloads; python3 -m http.server 80 &')

    getTrace(sta1, 'clientTrace.txt')
    getTrace(sta2, 'serverTrace.txt')

    replayingNetworkBehavior()

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Example #8
0
def topology():
    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', wlans=3)  # 3 wlan added
    sta2 = net.addStation('sta2')  # 1 wlan added
    ap1 = net.addBaseStation('ap1', ssid="ssid_1", mode="g",
                             channel=5)  # 1 wlan added
    c0 = net.addController('c0', controller=Controller)

    print "*** Associating..."
    net.addLink(ap1, sta1)

    net.addHoc(sta1, ssid='adhoc1', mode='g')
    net.addHoc(sta2, ssid='adhoc1', mode='g')

    print "*** Starting network"
    net.build()
    c0.start()
    ap1.start([c0])

    print "***Addressing..."
    sta1.setIP('192.168.10.1/24', intf="sta1-wlan1")
    sta2.setIP('192.168.10.2/24', intf="sta2-wlan0")

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
Example #9
0
def topology():
    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', wlans=3 ) # 3 wlan added
    sta2 = net.addStation( 'sta2' ) # 1 wlan added
    ap1 = net.addBaseStation( 'ap1', ssid="ssid_1", mode="g", channel=5 ) # 1 wlan added
    c0 = net.addController('c0', controller=Controller)

    print "*** Associating..."
    net.addLink(ap1, sta1)

    net.addHoc(sta1, ssid='adhoc1', mode='g')
    net.addHoc(sta2, ssid='adhoc1', mode='g')

    print "*** Starting network"
    net.build()
    c0.start()
    ap1.start( [c0] )

    print "***Addressing..."
    sta1.setIP('192.168.10.1/24', intf="sta1-wlan1")
    sta2.setIP('192.168.10.2/24', intf="sta2-wlan0")

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
def topology():
    "Create a network."
    net = Mininet( wirelessRadios=6, controller=RemoteController, link=TCLink, switch=OVBaseStation )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1' )
    sta2 = net.addStation( 'sta2' )
    bs1 = net.addBaseStation( 'bs1' )

    c0 = net.addController('c0', controller=OVSController, port=6633 )

    print "*** Adding Link"
    net.addLink(sta1, bs1)
    net.addLink(sta2, bs1)

    print "*** Starting network"
    net.build()
    c0.start()
    bs1.start( [c0] )


    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Example #11
0
def topology():
    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', wlans=2)
    h1 = net.addHost('h1', ip="192.168.10.1/24")
    h2 = net.addHost('h2', ip="192.168.20.1/24")
    ap1 = net.addBaseStation('ap1', ssid="ssid_1", mode="g", channel="1")
    ap2 = net.addBaseStation('ap2', ssid="ssid_2", mode="g", channel="6")
    c0 = net.addController('c0',
                           controller=Controller,
                           ip='127.0.0.1',
                           port=6633)

    print "*** Adding Link"
    net.addLink(h1, ap1)
    net.addLink(h2, ap2)
    net.addLink(sta1, ap1)
    net.addLink(sta1, ap2)

    print "*** Starting network"
    net.build()
    c0.start()
    ap1.start([c0])
    ap2.start([c0])
    sta1.cmd('ifconfig sta1-wlan0 192.168.10.10 netmask 255.255.255.0')
    sta1.cmd('ifconfig sta1-wlan1 192.168.20.10 netmask 255.255.255.0')
    print "*** Running CLI"
    CLI(net)
    print "*** Stopping network"
    net.stop()
Example #12
0
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8', position='10,20,0' )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8', position='10,30,0' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='15,30,0' )
    c1 = net.addController( 'c1', controller=Controller )

    """uncomment to plot graph"""
    #net.plotGraph(max_x=60, max_y=60)

    print "*** Creating links"
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Example #13
0
def topology():

    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    h1 = net.addHost("h1", mac="00:00:00:00:00:01", ip="10.0.0.1/8")
    sta1 = net.addStation("sta1", mac="00:00:00:00:00:02", ip="10.0.0.2/8", position="10,20,0")
    sta2 = net.addStation("sta2", mac="00:00:00:00:00:03", ip="10.0.0.3/8", position="10,30,0")
    ap1 = net.addBaseStation("ap1", ssid="new-ssid", mode="g", channel="1", position="15,30,0")
    c1 = net.addController("c1", controller=Controller)

    """uncomment to plot graph"""
    # net.plotGraph(max_x=60, max_y=60)

    print "*** Creating links"
    net.addLink(ap1, h1, 1, 0)
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
Example #14
0
def topology():
    "Create a network."
    net = Mininet( wirelessRadios=3, controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    ap1 = net.addBaseStation( 'ap1', ssid="simplewifi", mode="g", channel="5" )
    sta1 = net.addStation( 'sta1', ip='192.168.0.1/24' )
    sta2 = net.addStation( 'sta2', ip='192.168.0.2/24' )
    h3 = net.addHost( 'h3', ip='192.168.0.3/24' )
    h4 = net.addHost( 'h4', ip='192.168.0.4/24' )

    c0 = net.addController('c0', controller=Controller, ip='127.0.0.1', port=6633 )

    print "*** Adding Link"
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)
    net.addLink(h3, ap1)
    net.addLink(h4, ap1)

    print "*** Starting network"
    net.build()
    c0.start()
    ap1.start( [c0] )

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8', speed=1 )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8', speed=3 )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='50,50,0' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )

    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    getTrace(sta1, 'examples/replaying/replayingMobility/node1.dat')
    getTrace(sta2, 'examples/replaying/replayingMobility/node2.dat')

    replayingMobility()

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
def topology():
    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )
    #wirelessRadios = Number of STAs + APs
    
    print "*** Creating nodes"
    ap1 = net.addBaseStation( 'ap1', ssid="simplewifi", mode="g", channel="5" )
    sta1 = net.addStation( 'sta1', ip='192.168.0.1/24' )
    sta2 = net.addStation( 'sta2', ip='192.168.0.2/24' )
    h3 = net.addHost( 'h3', ip='192.168.0.3/24' )
    h4 = net.addHost( 'h4', ip='192.168.0.4/24' )

    c0 = net.addController('c0', controller=Controller, ip='127.0.0.1', port=6633 )

    print "*** Adding Link"
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)
    net.addLink(h3, ap1)
    net.addLink(h4, ap1)

    print "*** Starting network"
    net.build()
    c0.start()
    ap1.start( [c0] )

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
def topology():
    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    ap1 = net.addBaseStation( 'ap1', ssid="ssid_ap1", txpower=15, mode="g", channel=1, position="10,10,0" )
    sta1 = net.addStation( 'sta1', ip='192.168.0.1/24', txpower=15, position='10,10,0' )
    sta2 = net.addStation( 'sta2', ip='192.168.0.2/24', txpower=15, position='11.36,10,0' )

    print "*** Adding Link"
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)

    "*** Available propagation models: friisPropagationLossModel, twoRayGroundPropagationLossModel, logDistancePropagationLossModel ***"
    net.propagationModel('logDistancePropagationLossModel', exp=3, sL=1)
    #net.propagationModel('ITUPropagationLossModel', pL=50)
    #net.propagationModel('twoRayGroundPropagationLossModel')
    #net.propagationModel('friisPropagationLossModel', sL=2)

    print "*** Starting network"
    net.build()

    for i in range(1,8):
        x = 10+i*1.36
 	y = 10
	z = 0
        pos = '%s,%s,%s' % (x,y,z)
        sta1.moveStationTo(pos)
        print sta1.params['rssi'][0] 

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Example #18
0
def topology():
    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', ip="192.168.0.1/24" )
    sta2 = net.addStation( 'sta2', ip="192.168.0.2/24" )
    sta3 = net.addStation( 'sta3', ip="192.168.0.3/24" )
    sta4 = net.addStation( 'sta4', ip="192.168.0.4/24" )
    ap1 = net.addBaseStation( 'ap1', ssid="ssid_1", mode="g", channel="1" )
    ap2 = net.addBaseStation( 'ap2', ssid="ssid_2", mode="b", channel="6" )
    c0 = net.addController('c0', controller=Controller, ip='127.0.0.1', port=6653 )

    print "*** Adding Link"
    net.addLink(ap1, ap2) #wired connection
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)
    net.addLink(sta3, ap2)
    net.addLink(sta4, ap2)

    print "*** Starting network"
    net.build()
    c0.start()
    ap1.start( [c0] )
    ap2.start( [c0] )

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
def topology():
    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', passwd='123456789a',
                          encrypt='wpa2')  #encrypt=(wpa,wpa2,wep)
    sta2 = net.addStation('sta2', passwd='123456789a',
                          encrypt='wpa2')  #encrypt=(wpa,wpa2,wep)
    ap1 = net.addBaseStation('ap1',
                             ssid="simplewifi",
                             mode="g",
                             channel="1",
                             passwd='123456789a',
                             encrypt='wpa2')  #encrypt=(wpa,wpa2,wep)
    c0 = net.addController('c0',
                           controller=Controller,
                           ip='127.0.0.1',
                           port=6633)

    print "*** Associating Stations"
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)

    print "*** Starting network"
    net.build()
    c0.start()
    ap1.start([c0])

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
def topology():

    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    sta1 = net.addStation("sta1", mac="00:00:00:00:00:02", ip="10.0.0.2/8", speed=1)
    sta2 = net.addStation("sta2", mac="00:00:00:00:00:03", ip="10.0.0.3/8", speed=3)
    ap1 = net.addBaseStation("ap1", ssid="new-ssid", mode="g", channel="1", position="50,50,0")
    c1 = net.addController("c1", controller=Controller)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])

    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    getTrace(sta1, "examples/replaying/replayingMobility/node1.dat")
    getTrace(sta2, "examples/replaying/replayingMobility/node2.dat")

    replayingMobility()

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' )
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='10,10,0' )
    c1 = net.addController( 'c1', controller=Controller )

    """uncomment to plot graph"""
    #net.plotGraph(max_x=60, max_y=60)

    print "*** Associating and Creating links"
    net.addLink(ap1, h1, 1, 0)
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)
    
    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )
    
    
    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWaypoint, GaussMarkov ***"
    net.startMobility(0, model='GaussMarkov', max_x=20, max_y=20, min_v=0.1, max_v=0.3)
   
    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='50,50,0' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** Associating and Creating links"
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)
    
    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )
    
    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    """Seed"""
    net.seed(20) 

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
    net.startMobility(startTime=0, model='RandomDirection', max_x=60, max_y=60, min_v=0.5, max_v=0.5)
   
    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
def topology():
    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    image = 'shub1905/chaos:hostapd_latest'
    image2 = 'shub1905/ubuntu:updated_wpa'
    cmd = '/bin/ash'
    cmd2 = '/bin/bash'

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', ip='10.0.0.1', passwd='123456789a', encrypt='wpa2', cls=Docker, dimage=image2, dcmd=cmd2 )
    sta2 = net.addStation( 'sta2', ip='10.0.0.2', passwd='12346789a', encrypt='wpa2', cls=Docker, dimage=image2, dcmd=cmd2 )
    sta3 = net.addStation( 'sta3', ip='10.0.0.3', passwd='123456789a', encrypt='wpa2', cls=Docker, dimage=image2, dcmd=cmd2 )

    # sta1 = net.addStation( 'sta1', passwd='123456789a', encrypt='wpa2' ) #encrypt=(wpa,wpa2,wep)
    # sta2 = net.addStation( 'sta2', passwd='123456789a', encrypt='wpa2' ) #encrypt=(wpa,wpa2,wep)
    ap1 = net.addBaseStation( 'ap1', ssid="simplewifi", mode="g", channel="5", passwd='123456789a', encrypt='wpa2' ) #encrypt=(wpa,wpa2,wep)

    c0 = net.addController('c0', controller=Controller, ip='127.0.0.1', port=6633 )

    print "*** Associating Stations"
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)
    net.addLink(sta3, ap1)

    print "*** Starting network"
    net.build()
    c0.start()
    ap1.start( [c0] )

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='50,50,0' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** adding Link"
    net.addLink(sta1, ap1)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )

    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    getTrace(sta1, 'examples/replaying/replayingBandwidth/throughputData.dat')

    replayingBandwidth()

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Example #25
0
def topology():

    "Create a network."
    net = Mininet( wirelessRadios=3, controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' )
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8', position='10,20,0' )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8', position='10,30,0' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='15,30,0' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** Creating links"
    net.addLink(ap1, h1, 1, 0)
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Example #26
0
def topology():

    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1',
                          mac='00:00:00:00:00:01',
                          ip='192.168.0.1/24',
                          position='47.28,50,0')
    sta2 = net.addStation('sta2',
                          mac='00:00:00:00:00:02',
                          ip='192.168.0.2/24',
                          position='54.08,50,0')
    ap3 = net.addBaseStation('ap3',
                             range=20,
                             ssid='ap-ssid3',
                             mode='g',
                             channel='1',
                             position='50,50,0')
    c4 = net.addController('c4', controller=Controller, port=6653)

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    print "*** Starting network"
    net.build()
    c4.start()
    ap3.start([c4])

    sta1.cmd('iw dev sta1-wlan0 interface add mon0 type monitor &')
    sta1.cmd('ifconfig mon0 up &')
    sta2.cmd('iw dev sta2-wlan0 interface add mon0 type monitor &')
    sta2.cmd('ifconfig mon0 up &')
    sta2.cmd('pushd /home/alpha/Downloads; python3 -m http.server 80 &')

    getTrace(sta1, 'clientTrace.txt')
    getTrace(sta2, 'serverTrace.txt')

    replayingNetworkBehavior.addNode(sta1)
    replayingNetworkBehavior.addNode(sta2)
    replayingNetworkBehavior()

    #sta1.cmd('tcpdump -i mon0 -s 0 -vvv -w client.pcap &&')
    #sta2.cmd('tcpdump -i mon0 -s 0 -vvv -w server.pcap &&')
    #sta1 tcpdump -i mon0 -s 0 -vvv -w client.pcap && sta1 wget http://192.168.0.2/virtualbox-5.0_5.0.20-106931~Ubuntu~xenial_amd64.deb
    #sta1.cmd('wget http://'+sta2.IP()+'/virtualbox-5.0_5.0.20-106931~Ubuntu~xenial_amd64.deb')

    #sta1.cmd('nohup ping ' + sta2.IP() + ' -c 180 > ping1.log &')
    #sta2.cmd('nohup ping ' + sta1.IP() + ' -c 180 > ping2.log &')
    #sta2.cmd('iperf -s &')
    #sta1.cmd('iperf -c ' + sta2.IP() + ' -i 0.5 -t 60 | awk \'t=120{if(NR>=7 && NR<=25) print $8; else if(NR>=26 && NR<=t+6) print $7}\' > replay1.dat')
    #sta2.cmd('iperf -c ' + sta1.IP() + ' -i 0.5 -t 60 | awk \'t=120{if(NR>=7 && NR<=25) print $8; else if(NR>=26 && NR<=t+6) print $7}\' > replay2.dat &')

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid1', mode= 'g', channel= '1', position='15,50,0' )
    ap2 = net.addBaseStation( 'ap2', ssid= 'new-ssid2', mode= 'g', channel= '6', position='25,30,0' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** Creating links"
    net.addLink(ap1, ap2)
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )
    ap2.start( [c1] )

    ap1.cmd('ifconfig ap1-eth1 20.0.0.2/8')
    ap2.cmd('ifconfig ap2-eth1 20.0.0.3/8')

    print "*** Starting Wishful framework"
    folder = './'

    print "*** ... agents ..."
    agent1 = WishfulAgent(ap1, folder + 'agent', folder + 'agent_config_1.yaml')
    agent2 = WishfulAgent(ap2, folder + 'agent', folder + 'agent_config_2.yaml')
    agent1.start()
    agent2.start()

    print "*** ... controller ..."
    wf_ctrl = WishfulController(ap1, folder + 'global_controller', folder + 'controller_config.yaml')
    wf_ctrl.start()

    print "*** Starting network"

    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    net.startMobility(startTime=0)
    net.mobility('sta1', 'start', time=0, position='10,45,0')
    net.mobility('sta1', 'stop', time=60, position='50,20,0')
    net.mobility('sta2', 'start', time=0, position='0,60,0')
    net.mobility('sta2', 'stop', time=60, position='30,10,0')
    net.stopMobility(stopTime=60)

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    wf_ctrl.stop()    
    agent1.stop()
    agent2.stop()
    net.stop()
Example #28
0
def topology():

    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8')
    ap1 = net.addBaseStation('ap1',
                             ssid='new-ssid1',
                             mode='g',
                             channel='1',
                             position='15,50,0')
    ap2 = net.addBaseStation('ap2',
                             ssid='new-ssid2',
                             mode='g',
                             channel='6',
                             position='25,30,0')
    c1 = net.addController('c1', controller=Controller)

    print "*** Creating links"
    net.addLink(ap1, ap2)
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    ap2.start([c1])
    """uncomment to plot graph"""
    #net.plotGraph(max_x=100, max_y=100)

    net.startMobility(startTime=0)
    net.mobility('sta1', 'start', time=1, position='10,45,0')
    net.mobility('sta2', 'start', time=2, position='10,40,0')
    net.mobility('sta1', 'stop', time=12, position='15,10,0')
    net.mobility('sta2', 'stop', time=22, position='25,25,0')
    net.stopMobility(stopTime=23)

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    car = []
    for x in range(0,20):
        car.append(x)
    for x in range(0,20):
        car[x] = net.addVehicle( 'car%s' % x, wlans=2, ip='10.0.0.%s/8' % (x+1) )
	
    bs1 = net.addBaseStation( 'BS1', ssid= 'new-ssid1', mode= 'g', channel= '1' )
    bs2 = net.addBaseStation( 'BS2', ssid= 'new-ssid2', mode= 'g', channel= '6' )
    bs3 = net.addBaseStation( 'BS3', ssid= 'new-ssid3', mode= 'g', channel= '11' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** Associating and Creating links"
    for x in range(0,20):
        net.addMesh(car[x], ssid='mesh')

    net.addLink(bs1, bs2)
    net.addLink(bs1, bs3)
       
    print "*** Starting network"
    net.build()
    c1.start()
    bs1.start( [c1] )
    bs2.start( [c1] )
    bs3.start( [c1] )
  
    """Available Options: sumo, sumo-gui"""
    #Put your sumocfg file in /mininet/sumo/data
    net.useExternalProgram('sumo-gui', config_file='map.sumocfg')

    """Routing"""
    #net.meshRouting('custom')


    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
def topology():
    "Create a network."
    net = Mininet( controller=Controller )

    info( '*** Adding controller\n' )
    net.addController( 'c0' )

    image = 'ubuntu'
    cmd = '/bin/bash'

    print "*** Creating nodes"
    ap1 = net.addBaseStation( 'ap1', ssid="simplewifi", mode="g", channel="5", passwd='123456789a', encrypt='wpa2')

    sta1 = net.addStation( 'sta1', passwd='123456789a', encrypt='wpa2')
    sta2 = net.addStation( 'sta2', passwd='123456789ab', encrypt='wpa2')
    sta3 = net.addStation( 'sta3', passwd='123456789a', encrypt='wpa2')

    h1 = net.addHost('h1', cls=Docker, dimage=image, dcmd=cmd)
    h2 = net.addHost('h2', cls=Docker, dimage=image, dcmd=cmd)
    h3 = net.addHost('h3')

    h4 = net.addHost('h4', cls=Docker, dimage=image, dcmd=cmd)

    c0 = net.addController('c0', controller=Controller, ip='127.0.0.1', port=6633)

    s1 = net.addSwitch( 's1')
    s2 = net.addSwitch( 's2')

    print "*** Associating Stations"
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)
    net.addLink(sta3, ap1)

    net.addLink(h1, ap1)
    net.addLink(h2, ap1)
    net.addLink(h3, ap1)

    net.addLink(ap1, s1)
    net.addLink(s1, s2)

    net.addLink(s2, h4)

    print "*** Starting network"
    net.build()
    c0.start()
    ap1.start( [c0] )
    s1.start( [c0] )
    s2.start( [c0] )

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
    system('sudo mn -c')
    system('docker stop $(docker ps -aq);docker rm $(docker ps -aq)')
def topology():

    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    car = []
    for x in range(0, 20):
        car.append(x)
    for x in range(0, 20):
        car[x] = net.addVehicle('car%s' % x,
                                wlans=2,
                                ip='10.0.0.%s/8' % (x + 1))

    bs1 = net.addBaseStation('BS1', ssid='new-ssid1', mode='g', channel='1')
    bs2 = net.addBaseStation('BS2', ssid='new-ssid2', mode='g', channel='6')
    bs3 = net.addBaseStation('BS3', ssid='new-ssid3', mode='g', channel='11')
    c1 = net.addController('c1', controller=Controller)

    print "*** Associating and Creating links"
    for x in range(0, 20):
        net.addMesh(car[x], ssid='mesh')

    net.addLink(bs1, bs2)
    net.addLink(bs1, bs3)

    print "*** Starting network"
    net.build()
    c1.start()
    bs1.start([c1])
    bs2.start([c1])
    bs3.start([c1])
    """Available Options: sumo, sumo-gui"""
    #Put your sumocfg file in /mininet/sumo/data
    net.useExternalProgram('sumo-gui', config_file='map.sumocfg')
    """Routing"""
    #net.meshRouting('custom')

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
def topology():

    "Create a network."
    net = Mininet( controller=RemoteController, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1' )
    sta2 = net.addStation( 'sta2', wlans=1, mac='00:02:00:00:00:02', ip='10.0.0.2/8' )
    sta3 = net.addStation( 'sta3', wlans=1, mac='00:02:00:00:00:03', ip='10.0.0.3/8' )
    sta4 = net.addStation( 'sta4', wlans=1, mac='00:02:00:00:00:04', ip='10.0.0.4/8' )
    c5 = net.addController( 'c5', ip='127.0.0.1', port=6633 )
    h7 = net.addHost( 'h7', mac='00:00:00:00:00:07', ip='10.0.0.7/8' )
    
    print "*** Creating links"
    net.addLink(sta4, ap1)
    net.addLink(sta3, ap1)
    net.addLink(sta2, ap1)
    net.addLink(ap1, h7)

    print "*** Starting network"
    net.build()
    c5.start()
    ap1.start( [c5] )
   
    ap1.cmd("iw dev ap1-wlan0 interface add vwlan1 type managed")   
    ap1.cmd("iw dev ap1-wlan0 interface add vwlan2 type managed")
    ap1.cmd("ifconfig vwlan1 hw ether 00:00:00:aa:bb:11")
    ap1.cmd("ifconfig vwlan2 hw ether 00:00:00:aa:bb:22")
    ap1.cmd("ifconfig vwlan1 up")
    ap1.cmd("ifconfig vwlan2 up")
    ap1.cmd("ovs-vsctl add-port ap1 vwlan1")
    ap1.cmd("ovs-vsctl add-port ap1 vwlan2")
    ap1.cmd("echo -e 'interface=vwlan1\ndriver=nl80211\nssid=vwlan1\nhw_mode=g\nchannel=1\nwme_enabled=1\nwmm_enabled=1' > vwlan1.conf")
    ap1.cmd("hostapd -B vwlan1.conf &")
    ap1.cmd("echo -e 'interface=vwlan2\ndriver=nl80211\nssid=vwlan2\nhw_mode=g\nchannel=1\nwme_enabled=1\nwmm_enabled=1' > vwlan2.conf")
    ap1.cmd("hostapd -B vwlan2.conf &")
  
    sta2.cmd("ifconfig sta2-wlan0 down")
    sta2.cmd("iwconfig sta2-wlan0 essid 'vwlan1'")
    sta2.cmd("ifconfig sta2-wlan0 up")

    sta3.cmd("ifconfig sta3-wlan0 down")
    sta3.cmd("iwconfig sta3-wlan0 essid 'vwlan2'")
    sta3.cmd("ifconfig sta3-wlan0 up")

    ### after the above setting, sta2( sta3, or sta4) can ping h7. sta2 can also ping sta3/sta4.

    #the following rule can block sta2 from communicating with other host or station
    ap1.cmd("ovs-ofctl add-flow ap1 priority=65535,ip,nw_dst=10.0.0.2,actions=drop")

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Example #33
0
def topology():
    "Create a network."
    net = Mininet(controller=RemoteController,
                  link=TCLink,
                  switch=OVSKernelSwitch)

    print "*** Creating nodes"
    ap1 = net.addBaseStation('ap1', ssid="ssid_1", mode="g", channel="5")
    ap2 = net.addBaseStation('ap2', ssid="ssid_2", mode="g", channel="11")
    sta3 = net.addStation('sta3', ip="192.168.0.100/24", wlans=2)
    h4 = net.addHost('h4', ip="192.168.0.1/24", mac="00:00:00:00:00:04")
    s5 = net.addSwitch('s5')

    c0 = net.addController('c0',
                           controller=RemoteController,
                           ip='127.0.0.1',
                           port=6653)

    print "*** Adding Link"
    net.addLink(h4, s5, bw=1000)
    net.addLink(ap1, s5, bw=1000)
    net.addLink(ap2, s5, bw=1000)
    net.addLink(ap1, sta3)
    net.addLink(sta3, ap2)

    print "*** Starting network"
    net.build()
    c0.start()
    s5.start([c0])
    ap1.start([c0])
    ap2.start([c0])

    sta3.cmd("ifconfig sta3-wlan1 192.168.1.100/24 up")
    h4.cmd("ifconfig h4-eth0:0 192.168.1.1/24")

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
Example #34
0
def topology():
    "Create a network."
    net = Mininet(wirelessRadios=4,
                  controller=Controller,
                  link=TCLink,
                  switch=OVSKernelSwitch)

    print "*** Creating nodes"
    h1 = net.addHost('h1', ip='192.168.0.10')
    ap1 = net.addBaseStation('ap1', ssid="ssid_1", mode="g", channel="5")
    ap2 = net.addBaseStation('ap2', ssid="ssid_2")
    sta1 = net.addStation('sta1', ip="192.168.0.100")
    s1 = net.addSwitch('s1')

    c0 = net.addController('c0',
                           controller=Controller,
                           ip='127.0.0.1',
                           port=6633)

    print "*** Adding Link"
    net.addLink(h1, s1)
    net.addLink(ap1, s1)
    net.addLink(ap2, s1)
    net.addLink(ap1, sta1)
    net.addLink(sta1, ap2)

    print "*** Starting network"
    net.build()
    c0.start()
    s1.start([c0])
    ap1.start([c0])
    ap2.start([c0])
    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
def topology():
    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=UserSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', position='10,60,0' )
    sta2 = net.addStation( 'sta2', position='20,15,0' )
    sta3 = net.addStation( 'sta3', position='10,25,0' )
    sta4 = net.addStation( 'sta4', position='50,30,0' )
    sta5 = net.addStation( 'sta5', position='45,65,0' )
    ap1 = net.addBaseStation( 'ap1', ssid="ssid", mode="g", channel="1", n_ssids=4, position='30,40,0' )
    c0 = net.addController('c0', controller=Controller, ip='127.0.0.1', port=6653 )

    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    print "*** Starting network"
    net.build()
    c0.start()
    ap1.start( [c0] )

    sta1.setRange(15)
    sta2.setRange(15)
    sta3.setRange(15)
    sta4.setRange(15)
    sta5.setRange(15)

    sta1.cmd('iwconfig sta1-wlan0 essid %s-1 ap %s' % (ap1.params['ssid'], ap1.params['mac'][1]))
    sta2.cmd('iwconfig sta2-wlan0 essid %s-2 ap %s' % (ap1.params['ssid'], ap1.params['mac'][2]))
    sta3.cmd('iwconfig sta3-wlan0 essid %s-2 ap %s' % (ap1.params['ssid'], ap1.params['mac'][2]))
    sta4.cmd('iwconfig sta4-wlan0 essid %s-3 ap %s' % (ap1.params['ssid'], ap1.params['mac'][3]))
    sta5.cmd('iwconfig sta5-wlan0 essid %s-4 ap %s' % (ap1.params['ssid'], ap1.params['mac'][4]))

    ap1.cmd('dpctl unix:/tmp/ap1 meter-mod cmd=add,flags=1,meter=1 drop:rate=100')
    ap1.cmd('dpctl unix:/tmp/ap1 meter-mod cmd=add,flags=1,meter=2 drop:rate=200')
    ap1.cmd('dpctl unix:/tmp/ap1 meter-mod cmd=add,flags=1,meter=3 drop:rate=300')
    ap1.cmd('dpctl unix:/tmp/ap1 meter-mod cmd=add,flags=1,meter=4 drop:rate=400')
    ap1.cmd('dpctl unix:/tmp/ap1 flow-mod table=0,cmd=add in_port=2 meter:1 apply:output=flood')
    ap1.cmd('dpctl unix:/tmp/ap1 flow-mod table=0,cmd=add in_port=3 meter:2 apply:output=flood')
    ap1.cmd('dpctl unix:/tmp/ap1 flow-mod table=0,cmd=add in_port=4 meter:3 apply:output=flood')
    ap1.cmd('dpctl unix:/tmp/ap1 flow-mod table=0,cmd=add in_port=5 meter:4 apply:output=flood')

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Example #36
0
def topology():
    "Create a network."
    net = Mininet( link=TCLink, switch=OVSSwitch )
    c0 = Controller( 'c0', port=6634 )
    c1 = RemoteController( 'c1', ip='127.0.0.1', port=6633 )
    net.addController(c0)
    net.addController(c1) 

    
    print "*** Creating nodes"
    s0 = net.addSwitch('s0')
    ap1 = net.addBaseStation( 'ap1', ssid="ssid_ap1", mode="g", channel="5" )
    ap2 = net.addBaseStation( 'ap2', ssid="ssid_ap2", mode="g", channel="1" )
   
    
    sta1 = net.addStation( 'sta1', ip='192.168.0.1/24' )
    sta2 = net.addStation( 'sta2', ip='192.168.0.2/24' )
    sta3 = net.addStation( 'sta3', ip='192.168.0.3/24' )
    sta4 = net.addStation( 'sta4', ip='192.168.0.4/24' )
    h1 = net.addHost('h0', ip='192.168.0.5')
    h2 = net.addHost('h1', ip='192.168.0.6')
       
    print "*** Adding Link"
    net.addLink(sta1, ap1, bw=10, loss=0)
    net.addLink(sta2, ap1, bw=10, loss=0)
    net.addLink(sta3, ap2, bw=10, loss=0)
    net.addLink(sta4, ap2, bw=10, loss=0)
    net.addLink(ap1, s0)
    net.addLink(ap2, s0)
    net.addLink(h1, s0)
    net.addLink(h2, s0)

    net.build()
    c0.start()
    c1.start()
                                 
                                 
    ap1.start( [c0] )
    ap2.start( [c0] )
    #nat0.start( [c0] )
    s0.start([c1])

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Example #37
0
def topology():

    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1')
    sta2 = net.addStation('sta2')
    ap1 = net.addBaseStation('ap1',
                             ssid='new-ssid',
                             equipmentModel='DI524',
                             mode='g',
                             channel='1',
                             position='50,50,0')
    c1 = net.addController('c1', controller=Controller)

    print "*** Associating and Creating links"
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    """uncomment to plot graph"""
    net.plotGraph(max_x=150, max_y=150)
    """Seed"""
    net.seed(1)

    "*** Available propagation models: friisPropagationLossModel, twoRayGroundPropagationLossModel, logDistancePropagationLossModel ***"
    #   net.propagationModel('youngModel')
    net.propagationModel('friisPropagationLossModel', sL=2)

    "*** Available mobility models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov ***"
    net.startMobility(startTime=0,
                      model='RandomWayPoint',
                      max_x=160,
                      max_y=160,
                      min_v=0.1,
                      max_v=0.2)

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
Example #38
0
def topology():

    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1',
                          mac='00:00:00:00:00:02',
                          ip='10.0.0.2/8',
                          speed=1)
    sta2 = net.addStation('sta2',
                          mac='00:00:00:00:00:03',
                          ip='10.0.0.3/8',
                          speed=3)
    ap1 = net.addBaseStation('ap1',
                             ssid='new-ssid',
                             mode='g',
                             channel='1',
                             position='50,50,0')
    c1 = net.addController('c1', controller=Controller)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    for pos in range(0, 50):
        x = 10 + pos
        y = 1 + pos
        sta1.trackingPos.append('%s,%s,0' % (x, y))

    for pos in range(0, 50):
        x = 100 - pos
        y = 90 - pos
        sta2.trackingPos.append('%s,%s,0' % (x, y))

    tracingMobility()

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
Example #39
0
def topology():
    "Create a network."
    net = Mininet(link=TCLink, switch=OVSSwitch)
    c0 = Controller('c0', port=6634)
    c1 = RemoteController('c1', ip='127.0.0.1', port=6633)
    net.addController(c0)
    net.addController(c1)

    print "*** Creating nodes"
    s0 = net.addSwitch('s0')
    ap1 = net.addBaseStation('ap1', ssid="ssid_ap1", mode="g", channel="5")
    ap2 = net.addBaseStation('ap2', ssid="ssid_ap2", mode="g", channel="1")

    sta1 = net.addStation('sta1', ip='192.168.0.1/24')
    sta2 = net.addStation('sta2', ip='192.168.0.2/24')
    sta3 = net.addStation('sta3', ip='192.168.0.3/24')
    sta4 = net.addStation('sta4', ip='192.168.0.4/24')
    h1 = net.addHost('h0', ip='192.168.0.5')
    h2 = net.addHost('h1', ip='192.168.0.6')

    print "*** Adding Link"
    net.addLink(sta1, ap1, bw=10, loss=0)
    net.addLink(sta2, ap1, bw=10, loss=0)
    net.addLink(sta3, ap2, bw=10, loss=0)
    net.addLink(sta4, ap2, bw=10, loss=0)
    net.addLink(ap1, s0)
    net.addLink(ap2, s0)
    net.addLink(h1, s0)
    net.addLink(h2, s0)

    net.build()
    c0.start()
    c1.start()

    ap1.start([c0])
    ap2.start([c0])
    #nat0.start( [c0] )
    s0.start([c1])

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
def topology():

    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8')
    ap1 = net.addBaseStation('ap1',
                             ssid='new-ssid',
                             mode='g',
                             channel='1',
                             position='50,50,0')
    c1 = net.addController('c1', controller=Controller)

    print "*** Associating and Creating links"
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)
    """Seed"""
    net.seed(20)

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
    #    net.startMobility(startTime=0, model='RandomWalk', max_x=60, max_y=60, min_v=0.1, max_v=0.1)
    net.startMobility(startTime=0,
                      model='RandomDirection',
                      max_x=60,
                      max_y=60,
                      min_v=0.1,
                      max_v=0.1)

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
def topology():

    "Create a network."
    net = Mininet(controller=RemoteController,
                  link=TCLink,
                  switch=OVSKernelSwitch)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1',
                          mac='00:00:00:00:00:02',
                          ip='10.0.0.2/8',
                          position='10,20,0')
    sta2 = net.addStation('sta2',
                          mac='00:00:00:00:00:03',
                          ip='10.0.0.3/8',
                          position='10,30,0')
    ap1 = net.addBaseStation('ap1',
                             ssid='new-ssid',
                             mode='g',
                             channel='1',
                             position='15,30,0')
    c1 = net.addController('c1', controller=RemoteController)
    h1 = net.addHost('h1')
    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    print "*** Creating links"
    net.addLink(ap1, h1)
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
Example #42
0
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid1', mode= 'g', channel= '1', position='15,30,0' )
    ap2 = net.addBaseStation( 'ap2', ssid= 'new-ssid1', mode= 'g', channel= '6', position='55,30,0' )
    s3 = net.addSwitch( 's3' )
    h4 = net.addHost( 'h4', ip='10.0.0.4/8' )
    c1 = net.addController( 'c1', controller=Controller, port=6653 )

    net.plotHost(h4, position='35,90,0')
    net.plotHost(s3, position='35,80,0')

    print "*** Creating links"
    net.addLink(ap1, s3)
    net.addLink(ap2, s3)
    net.addLink(h4, s3)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )
    ap2.start( [c1] )
    s3.start( [c1] )

    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    net.startMobility(startTime=0)
    net.mobility('sta1', 'start', time=1, position='10,30,0')
    net.mobility('sta1', 'stop', time=40, position='60,30,0')
    net.stopMobility(stopTime=40)

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Example #43
0
def topology():
    # Create a network
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    # Create nodes
    sta1 = net.addStation('sta1', mac='02:00:00:00:00:00', ip='10.0.0.2/8')
    sta2 = net.addStation('sta2', mac='02:00:00:00:01:00', ip='10.0.0.3/8')
    ap1 = net.addBaseStation('ap1',
                             ssid='new-ssid1',
                             mode='g',
                             channel='1',
                             position='15,50,0')  # mac=02:00:00:00:02:00
    c1 = net.addController('c1', controller=Controller)

    # Create links
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)

    # Start network
    net.build()
    c1.start()
    ap1.start([c1])

    # Configure IP addresses on AP for binding Wishful agent
    ap1.cmd('ifconfig ap1-eth1 20.0.0.2/8')

    # Start Wishful local controller on AP
    wf_ctrl = WishfulController(ap1, './local_controller', './config.yaml')
    wf_ctrl.start()

    # Generate traffic
    sta1.cmd('ping -c10 %s' % sta2.IP())

    # Show controller log file
    print('WiSHFUL controller logfile content:')
    print(wf_ctrl.read_log_file())
    print('')

    # Stop network
    wf_ctrl.stop()
    net.stop()
def topology():

    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSSwitch)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1',
                          mac='00:00:00:00:00:01',
                          ip='192.168.0.1/24',
                          position='47.28,50,0')
    sta2 = net.addStation('sta2',
                          mac='00:00:00:00:00:02',
                          ip='192.168.0.2/24',
                          position='54.08,50,0')
    ap3 = net.addBaseStation('ap3',
                             ssid='ap-ssid3',
                             mode='b',
                             channel='1',
                             position='50,50,0')
    c4 = net.addController('c4', controller=Controller, port=6653)
    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    print "*** Associating and Creating links"
    net.addLink(sta1, ap3)
    net.addLink(sta2, ap3)

    print "*** Starting network"
    net.build()
    c4.start()
    ap3.start([c4])

    #You have to change the directory of your file
    sta2.cmd('pushd /home/alpha/Downloads; python3 -m http.server 80 &')

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
Example #45
0
def topology():

    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8')
    ap1 = net.addBaseStation('ap1',
                             ssid='new-ssid',
                             mode='g',
                             channel='1',
                             position='50,50,0')
    c1 = net.addController('c1', controller=Controller)

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    print "*** Adding Link"
    sta1.params['associatedTo'][0] = ap1
    sta2.params['associatedTo'][0] = ap1

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    getTrace(sta1, 'examples/replaying/replayingRSSI/node1_rssiData.dat')
    getTrace(sta2, 'examples/replaying/replayingRSSI/node2_rssiData.dat')

    replayingRSSI()

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
Example #46
0
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid1', mode= 'g', channel= '1', position='15,50,0' )
    ap2 = net.addBaseStation( 'ap2', ssid= 'new-ssid2', mode= 'g', channel= '6', position='25,30,0' )
    c1 = net.addController( 'c1', controller=Controller )

    """uncomment to plot graph"""
    #net.plotGraph(max_x=100, max_y=100)

    print "*** Creating links"
    net.addLink(ap1, ap2)
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )
    ap2.start( [c1] )

    net.startMobility(0)
    net.mobility('sta1', 'start', time=1, position='10.0,45.0,0.0')
    net.mobility('sta2', 'start', time=2, position='10.0,40.0,0.0')
    net.mobility('sta1', 'stop', time=12, position='15.0,10,0.0')
    net.mobility('sta2', 'stop', time=22, position='25.0,25,0.0')
    net.stopMobility(23)

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1' )
    sta2 = net.addStation( 'sta2' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', equipmentModel='DI524', mode='g', channel='1', position='50,50,0' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** Associating and Creating links"
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)
    
    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )
    
    """uncomment to plot graph"""
    net.plotGraph(max_x=150, max_y=150)

    """Seed"""
    net.seed(1) 

    "*** Available propagation models: friisPropagationLossModel, twoRayGroundPropagationLossModel, logDistancePropagationLossModel ***"
 #   net.propagationModel('youngModel')
    net.propagationModel('friisPropagationLossModel', sL=2)

    "*** Available mobility models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov ***"
    net.startMobility(startTime=0, model='RandomWayPoint', max_x=160, max_y=160, min_v=0.1, max_v=0.2)
   
    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Example #48
0
def topology():
    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    sta1 = net.addStation("sta1", ip="192.168.0.100")
    sta2 = net.addStation("sta2")
    ap1 = net.addBaseStation("ap1", ssid="ssid_1", mode="g", channel="5")
    c0 = net.addController("c0", controller=Controller)

    net.addWlan(5)  # more 5 wlans available to be used

    print "*** Associating..."
    net.addLink(ap1, sta1)  # Automaticaly add interface wlan0 in sta1

    print "*** Starting network"
    net.build()
    c0.start()
    ap1.start([c0])

    print "*** Adding new Interfaces to STAs"
    station.addWlan(sta1)  # add wlan1 in sta1
    station.addWlan(sta1)  # add wlan2 (unused) in sta1
    station.addWlan(sta2)  # add wlan0 in sta2
    station.addWlan(sta2)  # add wlan1 (unused) in sta2
    station.addWlan(sta2)  # add wlan2 (unused) in sta2

    print "***Creating adhoc network"
    net.addHoc(sta1, "adhoc1", "g", interface="wlan1")
    net.addHoc(sta2, "adhoc1", "g", interface="wlan0")
    sta1.cmd("ifconfig sta1-wlan1 192.168.10.1")
    sta2.cmd("ifconfig sta2-wlan0 192.168.10.2")

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' )
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='45,40,0' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** Associating and Creating links"
    net.addLink(ap1, h1)
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )

    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    net.startMobility(startTime=0)
    net.mobility('sta1', 'start', time=1, position='40.0,30.0,0.0')
    net.mobility('sta2', 'start', time=2, position='40.0,40.0,0.0')
    net.mobility('sta1', 'stop', time=12, position='31.0,10.0,0.0')
    net.mobility('sta2', 'stop', time=22, position='55.0,31.0,0.0')
    net.stopMobility(stopTime=23)

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Example #50
0
def topology():
    # Create a network
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    # Create nodes
    sta1 = net.addStation( 'sta1', mac='02:00:00:00:00:00', ip='10.0.0.2/8' )
    sta2 = net.addStation( 'sta2', mac='02:00:00:00:01:00', ip='10.0.0.3/8' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid1', mode= 'g', channel= '1', position='15,50,0' ) # mac=02:00:00:00:02:00
    c1 = net.addController( 'c1', controller=Controller )

    # Create links
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)

    # Start network
    net.build()
    c1.start()
    ap1.start( [c1] )

    # Configure IP addresses on AP for binding Wishful agent
    ap1.cmd('ifconfig ap1-eth1 20.0.0.2/8')

    # Start Wishful local controller on AP
    wf_ctrl = WishfulController(ap1, './local_controller', './config.yaml')
    wf_ctrl.start()

    # Generate traffic
    sta1.cmd('ping -c10 %s' % sta2.IP())

    # Show controller log file
    print('WiSHFUL controller logfile content:')
    print(wf_ctrl.read_log_file())
    print('')

    # Stop network
    wf_ctrl.stop()
    net.stop()
def topology():
    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', passwd='123456789a', encrypt='wpa2' ) #encrypt=(wpa,wpa2,wep)
    sta2 = net.addStation( 'sta2', passwd='123456789a', encrypt='wpa2' ) #encrypt=(wpa,wpa2,wep)
    ap1 = net.addBaseStation( 'ap1', ssid="simplewifi", mode="g", channel="1", passwd='123456789a', encrypt='wpa2' ) #encrypt=(wpa,wpa2,wep)
    c0 = net.addController('c0', controller=Controller, ip='127.0.0.1', port=6633 )

    print "*** Associating Stations"
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)

    print "*** Starting network"
    net.build()
    c0.start()
    ap1.start( [c0] )

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8', speed=1 )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8', speed=3 )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='50,50,0' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )

    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    for pos in range (0, 50):
        x = 10+pos
        y = 1+pos
        sta1.trackingPos.append('%s,%s,0' % (x, y))

    for pos in range (0, 50):
        x = 100-pos
        y = 90-pos
        sta2.trackingPos.append('%s,%s,0' % (x, y))

    tracingMobility()

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Example #53
0
def topology():

    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    ap1 = net.addBaseStation('ap1',
                             ssid='new-ssid',
                             mode='g',
                             channel='1',
                             position='50,50,0')
    c1 = net.addController('c1', controller=Controller)

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    print "*** adding Link"
    net.addLink(sta1, ap1)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    getTrace(sta1, 'examples/replaying/replayingBandwidth/throughputData.dat')

    replayingBandwidth()

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
Example #54
0
def topology():

    "Create a network."
    net = Mininet(controller=RemoteController,
                  link=TCLink,
                  switch=OVSKernelSwitch)
    staList = []

    print "*** Creating nodes"
    for n in range(10):
        staList.append(n)
        staList[n] = net.addStation('sta%s' % (n + 1),
                                    wlans=2,
                                    mac='00:00:00:00:00:%s' % (n + 1),
                                    ip='192.168.0.%s/24' % (n + 1))
    phyap1 = net.addPhysicalBaseStation('phyap1',
                                        ssid='SBRC16-MininetWiFi',
                                        mode='g',
                                        channel='1',
                                        position='50,115,0',
                                        phywlan='wlan11')
    sta11 = net.addStation('sta11', ip='10.0.0.111/8', position='120,200,0')
    ap2 = net.addBaseStation('ap2',
                             ssid='ap2',
                             mode='g',
                             channel='11',
                             position='100,175,0')
    ap3 = net.addBaseStation('ap3',
                             ssid='ap3',
                             mode='g',
                             channel='6',
                             position='150,50,0')
    ap4 = net.addBaseStation('ap4',
                             ssid='ap4',
                             mode='g',
                             channel='1',
                             position='175,150,0')
    c1 = net.addController('c1', controller=Controller, port=6653)
    root = Node('root', inNamespace=False)
    """uncomment to plot graph"""
    net.plotGraph(max_x=240, max_y=240)
    """Routing"""
    net.meshRouting('custom')
    """Seed"""
    net.seed(20)

    print "*** Associating and Creating links"
    for sta in staList:
        net.addMesh(sta, ssid='meshNet')
    net.addLink(phyap1, ap2)
    net.addLink(ap2, ap3)
    net.addLink(ap3, ap4)

    print "*** Starting network"
    net.build()
    c1.start()
    phyap1.start([c1])
    ap2.start([c1])
    ap3.start([c1])
    ap4.start([c1])

    ip = 201
    for sta in staList:
        sta.setIP('10.0.0.%s/8' % ip, intf="%s-wlan1" % sta)
        ip += 1

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
    net.startMobility(startTime=0,
                      model='RandomWalk',
                      max_x=200,
                      max_y=220,
                      min_v=0.1,
                      max_v=0.2)

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
Example #55
0
def topology():

    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print("*** Creating nodes")
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8')
    ap1 = net.addBaseStation('ap1',
                             ssid='new-ssid1',
                             mode='g',
                             channel='1',
                             position='15,50,0')
    ap2 = net.addBaseStation('ap2',
                             ssid='new-ssid2',
                             mode='g',
                             channel='6',
                             position='25,30,0')
    c1 = net.addController('c1', controller=Controller)

    print("*** Creating links")
    net.addLink(ap1, ap2)
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)

    print("*** Starting network")
    net.build()
    c1.start()
    ap1.start([c1])
    ap2.start([c1])

    "Configure IP addresses on APs for binding Wishful agent"
    ap1.cmd('ifconfig ap1-eth1 20.0.0.2/8')
    ap2.cmd('ifconfig ap2-eth1 20.0.0.3/8')

    print("*** Starting Wishful framework")
    folder = './'

    print("*** ... agents ...")
    agent1 = WishfulAgent(ap1, folder + 'agent',
                          folder + 'agent_config_1.yaml')
    agent2 = WishfulAgent(ap2, folder + 'agent',
                          folder + 'agent_config_2.yaml')
    agent1.start()
    agent2.start()

    print("*** ... controller ...")
    wf_ctrl = WishfulController(ap1, folder + 'global_controller',
                                folder + 'controller_config.yaml')
    wf_ctrl.start()

    print("*** Starting network")
    """uncomment to plot graph"""
    if GUI:
        net.plotGraph(max_x=100, max_y=100)

    if MOBILITY:
        net.startMobility(startTime=0)
        net.mobility('sta1', 'start', time=0, position='10,45,0')
        net.mobility('sta1', 'stop', time=60, position='50,20,0')
        net.mobility('sta2', 'start', time=0, position='0,60,0')
        net.mobility('sta2', 'stop', time=60, position='30,10,0')
        net.stopMobility(stopTime=60)

    print("*** Running CLI")
    CLI(net)

    print("*** Stopping network")
    wf_ctrl.stop()
    agent1.stop()
    agent2.stop()
    net.stop()
def topology():
    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    h1 = net.addHost('h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8')
    h2 = net.addHost('h2', mac='00:00:00:00:00:11', ip='10.0.0.11/8')
    sta1 = net.addStation('sta1', wlans=2, ip='10.0.0.2/8')
    ap1 = net.addBaseStation('ap1',
                             ssid='ssid_ap1',
                             mode='g',
                             channel='6',
                             position='70,25,0')
    ap2 = net.addBaseStation('ap2',
                             ssid='ssid_ap2',
                             mode='g',
                             channel='1',
                             position='30,25,0')
    ap3 = net.addBaseStation('ap3',
                             ssid='ssid_ap3',
                             mode='g',
                             channel='11',
                             position='110,25,0')
    s4 = net.addSwitch('s4', mac='00:00:00:00:00:10')
    c1 = net.addController('c1', controller=Controller)

    print "*** Associating and Creating links"
    net.addLink(ap1, s4)
    net.addLink(ap2, s4)
    net.addLink(ap3, s4)
    net.addLink(s4, h1)
    net.addLink(s4, h2)

    sta1.cmd('modprobe bonding mode=3')
    sta1.cmd('ip link add bond0 type bond')
    sta1.cmd('ip link set bond0 address 02:01:02:03:04:08')
    sta1.cmd('ip link set sta1-wlan0 down')
    sta1.cmd('ip link set sta1-wlan0 address 00:00:00:00:00:11')
    sta1.cmd('ip link set sta1-wlan0 master bond0')
    sta1.cmd('ip link set sta1-wlan1 down')
    sta1.cmd('ip link set sta1-wlan1 address 00:00:00:00:00:12')
    sta1.cmd('ip link set sta1-wlan1 master bond0')
    sta1.cmd('ip addr add 10.0.0.10/8 dev bond0')
    sta1.cmd('ip link set bond0 up')

    print "*** Starting network"
    net.build()
    c1.start()
    s4.start([c1])
    ap1.start([c1])
    ap2.start([c1])
    ap3.start([c1])

    sta1.cmd('ip addr del 10.0.0.2/8 dev sta1-wlan0')
    os.system('ovs-ofctl add-flow s4 actions=normal')
    """seed"""
    net.seed(12)
    """uncomment to plot graph"""
    net.plotGraph(max_x=140, max_y=140)

    "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWaypoint, GaussMarkov ***"
    net.startMobility(startTime=0,
                      model='RandomDirection',
                      max_x=120,
                      max_y=50,
                      min_v=0.4,
                      max_v=0.6)

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
Example #57
0
def topology():
    "Create a network."
    net = Mininet(controller=RemoteController,
                  link=TCLink,
                  switch=OVSKernelSwitch)

    os.system('clear')
    parser = argparse.ArgumentParser(
        description='Compute Access Points over-reservation.')
    parser.add_argument("-aps",
                        metavar='APs',
                        type=int,
                        default=6,
                        help='amount of aps (default: 6)')
    parser.add_argument("-cosA",
                        metavar='MOs',
                        type=int,
                        default=0,
                        help='amount of MOs in CoS A (default: 0)')  # TBD
    parser.add_argument("-cosB",
                        metavar='MOs',
                        type=int,
                        default=0,
                        help='amount of MOs in CoS B (default: 0)')  # TBD
    parser.add_argument("-cosC",
                        metavar='MOs',
                        type=int,
                        default=0,
                        help='amount of MOs in CoS C (default: 0)')  # TBD
    args = parser.parse_args()

    print "*** Starting Simulation..."
    time.sleep(1)

    print "*** Starting Controller"
    c0 = net.addController('c0',
                           controller=RemoteController,
                           ip='127.0.0.1',
                           port=6633)  # Add Controller
    s1 = net.addSwitch('s1')  # Add Switch s1
    s11 = net.addSwitch('s11')  # Add Switch s11
    s12 = net.addSwitch('s12')  # Add Switch s12
    sc1 = net.addSwitch('sc1')  # Add Switch sc1
    sc2 = net.addSwitch('sc2')  # Add Switch sc2
    sc3 = net.addSwitch('sc3')  # Add Switch sc3
    sc4 = net.addSwitch('sc4')  # Add Switch sc4
    sc5 = net.addSwitch('sc5')  # Add Switch sc5
    sc6 = net.addSwitch('sc6')  # Add Switch sc6
    ap0 = net.addBaseStation('ap0', ssid="ssid_0", mode="g",
                             channel="1")  # Add ap0
    sta0 = net.addStation('sta0', ip="10.0.100.1")
    sta00 = net.addStation('sta00', ip="10.0.100.2")
    sta000 = net.addStation('sta000', ip="10.0.100.3")

    print "*** Creating PoAs"  # Cria e faz bootstrapping dos PoAs
    for i in range(1, args.aps + 1):
        print("\nCreating AP" + str(i) + "...")

        globals()['ap%s' % i] = net.addBaseStation(
            'ap' + str(i), ssid="ssid_" + str(i), mode="g",
            channel="1")  # Add AP/PoA   -> ap1 = net.addBaseStation
        globals()['ap%s' % i].start([c0])  # Start AP/PoA -> ap1.start( [c0] )
        print("Bootstrapping PoA" + str(i) + "...")
        print("Displaying PoA Pool" + "...")

    # Definicao da quantidade de MOs em cada CoS
    print "***Initializing scenario"
    cosA_MO = 14  # amount of MO in the CoSA
    cosB_MO = 6
    cosC_MO = 12
    cosX_MO = [cosC_MO, cosB_MO, cosA_MO]
    mn = 1
    sta_list = []

    # Scenario initialization - Criacao de todos os Stations (Necessario antes de addLink)
    print "*** Creating nodes"
    for mo in cosX_MO:
        for m in range(1, mo + 1):
            mo_name = 'sta' + str(mn)
            if (mn == 1):
                globals()['sta%s' % mn] = net.addStation(mo_name,
                                                         ip="10.0.0." +
                                                         str(mn),
                                                         wlans=2)
            else:
                globals()['sta%s' % mn] = net.addStation(mo_name,
                                                         ip="10.0.0." +
                                                         str(mn))
            sta_list.append("sta" + str(mn))
            mn += 1
    print sta_list

    # Initializes scenario in AP0
    mn = 1
    for mo in cosX_MO:
        for m in range(1, mo + 1):
            mo_name = 'sta' + str(mn)
            net.addLink(sta_list[mn - 1], ap0)
            sta = globals()['sta%s' % mn]
            sta.cmdPrint("sudo python ./scripts/server.py -ip 10.0.0." +
                         str(mn) + " -p 8088 &")
            sta.cmdPrint("sudo ./scripts/iperf_client.sh &")
            mn += 1

    print "*** Creating link between devices"
    for poa in range(1, args.aps + 1):
        net.addLink(globals()['ap%s' % poa], s1)

    print "*** Adding link ap0 and sta0"

    #	net.addLink(s1, s11)
    #	net.addLink(s1, s12)
    #	net.addLink(s1, sc1)
    #	net.addLink(s1, sc2)
    #	net.addLink(s1, sc3)
    #	net.addLink(s1, sc4)
    #	net.addLink(s1, sc5)
    #	net.addLink(s1, sc6)

    net.addLink(s11, sc2)
    net.addLink(s11, sc1)
    net.addLink(s12, sc1)
    net.addLink(s12, sc3)
    net.addLink(sc1, sc2)
    net.addLink(sc1, sc3)
    net.addLink(sc3, sc4)
    net.addLink(sc2, sc5)
    net.addLink(sc2, sc4)
    net.addLink(sc4, sc6)

    net.addLink(sc5, ap0)
    net.addLink(sc5, ap1)
    net.addLink(sc5, ap2)
    net.addLink(sc5, ap3)
    net.addLink(sc6, ap4)
    net.addLink(sc6, ap5)
    net.addLink(sc6, ap6)

    net.addLink(sta0, s1)
    net.addLink(sta00, s12)
    net.addLink(sta000, s12)

    print "*** Starting network"
    net.build()
    c0.start()
    s1.start([c0])
    s11.start([c0])
    s12.start([c0])
    sc1.start([c0])
    sc2.start([c0])
    sc3.start([c0])
    sc4.start([c0])
    sc5.start([c0])
    sc6.start([c0])
    ap0.start([c0])
    ap1.start([c0])
    ap2.start([c0])
    ap3.start([c0])
    ap4.start([c0])
    ap5.start([c0])
    ap6.start([c0])

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
Example #58
0
def topology():

    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    h1 = net.addHost('h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8')
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    sta2 = net.addStation('sta2', wlans=2, ip='10.0.0.3/8')
    sta3 = net.addStation('sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8')
    sta4 = net.addStation('sta4', wlans=2, ip='10.0.0.5/8')
    sta5 = net.addStation('sta5', mac='00:00:00:00:00:06', ip='10.0.0.6/8')
    sta6 = net.addStation('sta6', wlans=2, ip='10.0.0.7/8')

    ap1 = net.addBaseStation('ap1',
                             ssid='new-ssid1',
                             mode='g',
                             channel='1',
                             position='30,30,0',
                             range=30)
    ap2 = net.addBaseStation('ap2',
                             ssid='new-ssid2',
                             mode='g',
                             channel='2',
                             position='60,30,0',
                             range=40)
    ap3 = net.addBaseStation('ap3',
                             ssid='new-ssid3',
                             mode='g',
                             channel='3',
                             position='30,50,0',
                             range=35)
    ap4 = net.addBaseStation('ap4',
                             ssid='new-ssid4',
                             mode='g',
                             channel='4',
                             position='60,50,0',
                             range=45)
    c1 = net.addController('c1', controller=Controller)

    print "*** Associating and Creating links"
    net.addLink(ap1, ap2)
    net.addLink(ap1, ap3)
    net.addLink(ap1, ap4)
    net.addLink(ap2, ap3)
    net.addLink(ap2, ap4)
    net.addLink(ap3, ap4)

    net.addLink(ap1, h1)
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)
    net.addLink(ap2, sta3)
    net.addLink(ap3, sta4)
    net.addLink(ap4, sta5)
    net.addLink(ap4, sta6)
    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    ap2.start([c1])
    ap3.start([c1])
    ap4.start([c1])

    net.seed(10)
    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    net.startMobility(startTime=0,
                      model='RandomWayPoint',
                      max_x=60,
                      max_y=60,
                      min_v=0.1,
                      max_v=0.5,
                      AC='ssf')

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
Example #59
0
def topology():

    "Create a network."
    net = Mininet(controller=RemoteController,
                  link=TCLink,
                  switch=OVSKernelSwitch)

    print "*** Creating nodes"
    ap1 = net.addBaseStation('ap1', ssid='new-ssid', mode='g', channel='1')
    sta2 = net.addStation('sta2',
                          wlans=1,
                          mac='00:02:00:00:00:02',
                          ip='10.0.0.2/8')
    sta3 = net.addStation('sta3',
                          wlans=1,
                          mac='00:02:00:00:00:03',
                          ip='10.0.0.3/8')
    sta4 = net.addStation('sta4',
                          wlans=1,
                          mac='00:02:00:00:00:04',
                          ip='10.0.0.4/8')
    c5 = net.addController('c5', ip='127.0.0.1', port=6633)
    h7 = net.addHost('h7', mac='00:00:00:00:00:07', ip='10.0.0.7/8')

    print "*** Creating links"
    net.addLink(sta4, ap1)
    net.addLink(sta3, ap1)
    net.addLink(sta2, ap1)
    net.addLink(ap1, h7)

    print "*** Starting network"
    net.build()
    c5.start()
    ap1.start([c5])

    ap1.cmd("iw dev ap1-wlan0 interface add vwlan1 type managed")
    ap1.cmd("iw dev ap1-wlan0 interface add vwlan2 type managed")
    ap1.cmd("ifconfig vwlan1 hw ether 00:00:00:aa:bb:11")
    ap1.cmd("ifconfig vwlan2 hw ether 00:00:00:aa:bb:22")
    ap1.cmd("ifconfig vwlan1 up")
    ap1.cmd("ifconfig vwlan2 up")
    ap1.cmd("ovs-vsctl add-port ap1 vwlan1")
    ap1.cmd("ovs-vsctl add-port ap1 vwlan2")
    ap1.cmd(
        "echo -e 'interface=vwlan1\ndriver=nl80211\nssid=vwlan1\nhw_mode=g\nchannel=1\nwme_enabled=1\nwmm_enabled=1' > vwlan1.conf"
    )
    ap1.cmd("hostapd -B vwlan1.conf &")
    ap1.cmd(
        "echo -e 'interface=vwlan2\ndriver=nl80211\nssid=vwlan2\nhw_mode=g\nchannel=1\nwme_enabled=1\nwmm_enabled=1' > vwlan2.conf"
    )
    ap1.cmd("hostapd -B vwlan2.conf &")

    sta2.cmd("ifconfig sta2-wlan0 down")
    sta2.cmd("iwconfig sta2-wlan0 essid 'vwlan1'")
    sta2.cmd("ifconfig sta2-wlan0 up")

    sta3.cmd("ifconfig sta3-wlan0 down")
    sta3.cmd("iwconfig sta3-wlan0 essid 'vwlan2'")
    sta3.cmd("ifconfig sta3-wlan0 up")

    ### after the above setting, sta2( sta3, or sta4) can ping h7. sta2 can also ping sta3/sta4.

    #the following rule can block sta2 from communicating with other host or station
    ap1.cmd(
        "ovs-ofctl add-flow ap1 priority=65535,ip,nw_dst=10.0.0.2,actions=drop"
    )

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()