Ejemplo n.º 1
0
def topology(autoTxPower):
    "Create a network."
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference)

    info("*** Creating nodes\n")
    if autoTxPower:
        sta1 = net.addStation('sta1', position='10,10,0', range=100)
        sta2 = net.addStation('sta2', position='50,10,0', range=100)
        sta3 = net.addStation('sta3', position='90,10,0', range=100)
    else:
        sta1 = net.addStation('sta1', position='10,10,0')
        sta2 = net.addStation('sta2', position='50,10,0')
        sta3 = net.addStation('sta3', position='90,10,0')

    net.propagationModel(model="logDistance", exp=4)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    info("*** Creating links\n")
    net.addLink(sta1, cls=adhoc, ssid='adhocNet', mode='g', channel=5)
    net.addLink(sta2, cls=adhoc, ssid='adhocNet', mode='g', channel=5)
    net.addLink(sta3, cls=adhoc, ssid='adhocNet', mode='g', channel=5)

    info("*** Starting network\n")
    net.build()

    info("*** Running CLI\n")
    CLI_wifi(net)

    info("*** Stopping network\n")
    net.stop()
Ejemplo n.º 2
0
def topology():

    net = Mininet_wifi(controller=Controller, accessPoint=OVSKernelAP)

    info("*** Creating nodes\n")
    net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.1/8',
                   position='30,60,0')
    net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.2/8',
                   position='70,30,0')
    ap1 = net.addAccessPoint('ap1', ssid='new-ssid', mode='g', channel='1',
                             position='50,50,0')
    c1 = net.addController('c1', controller=Controller)
    h1 = net.addHost('h1', ip='10.0.0.3/8')

    net.propagationModel(model="logDistance", exp=4.5)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    info("*** Creating links\n")
    net.addLink(ap1, h1)

    net.plotGraph(max_x=100, max_y=100)

    info("*** Starting network\n")
    net.build()
    c1.start()
    ap1.start([c1])

    info("*** Running CLI\n")
    CLI_wifi(net)

    info("*** Stopping network\n")
    net.stop()
Ejemplo n.º 3
0
def topology():
    "Create a network."
    net = Mininet_wifi(link=wmediumd, enable_interference=True)

    print "*** Creating nodes"
    net.addStation('sta1', position='10,20,0')
    net.addStation('sta2', position='40,30,0')
    net.addStation('sta3', position='60,20,0')
    net.addAccessPoint('ap1',
                       ssid="my-ssid",
                       mode="a",
                       channel="36",
                       failMode='standalone',
                       position='10,10,0')

    print "*** Configuring Propagation Model"
    net.propagationModel(model="logDistance", exp=4)

    net.plotGraph(max_x=100, max_y=100)

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

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

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

    print "*** Stopping network"
    net.stop()
Ejemplo n.º 4
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller, link=wmediumd,
                       accessPoint=OVSKernelAP, wmediumd_mode=interference,
                       noise_threshold=-91, fading_coefficient=3)

    info("*** Creating nodes\n")
    ap1 = net.addAccessPoint('ap1', ssid='new-ssid', mode='a', channel='36',
                             position='15,30,0')
    net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.1/8',
                   position='10,20,0')
    net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.2/8',
                   position='20,50,0')
    net.addStation('sta3', mac='00:00:00:00:00:04', ip='10.0.0.3/8',
                   position='20,60,10')
    c1 = net.addController('c1', controller=Controller)

    info("*** Configuring Propagation Model\n")
    net.propagationModel(model="logDistance", exp=4)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    net.plotGraph(max_x=100, max_y=100)

    info("*** Starting network\n")
    net.build()
    c1.start()
    ap1.start([c1])

    info("*** Running CLI\n")
    CLI_wifi(net)

    info("*** Stopping network\n")
    net.stop()
Ejemplo n.º 5
0
def topology(wmediumd):

    "Create a network."
    if wmediumd:
        net = Mininet_wifi(controller=Controller, accessPoint=UserAP, enable_wmediumd=True, enable_interference=True)
    else:
        net = Mininet_wifi(controller=Controller, accessPoint=UserAP)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:01', ip='10.0.0.1/8', position='120,140,0')
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:02', ip='10.0.0.2/8', position='10,30,0')
    sta3 = net.addStation('sta3', mac='00:00:00:00:00:03', ip='10.0.0.3/8', position='10,50,0')
    ap1 = net.addAccessPoint('ap1', ssid='new-ssid', mode='g', channel='1', position='15,30,0', ieee80211r='yes', mobility_domain='a1b2', passwd='123456789a', encrypt='wpa2')
    c1 = net.addController('c1', controller=Controller)

    print "*** Configuring Propagation Model"
    net.propagationModel(model="logDistance", exp = 4.2)

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

    'plotting graph'
    net.plotGraph(max_x=150, max_y=150)

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

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

    print "*** Stopping network"
    net.stop()
Ejemplo n.º 6
0
def topology():

    "Create a network."
    net = Mininet_wifi(controller=Controller,
                       switch=OVSKernelSwitch,
                       accessPoint=OVSKernelAP)

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

    net.propagationModel(model="logDistance", exp=4.3)

    print("*** Configuring WiFi Nodes")
    net.configureWifiNodes()

    h1.plot(position='35,90,0')
    s3.plot(position='35,80,0')

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

    'plotting graph'
    net.plotGraph(max_x=100, max_y=100)

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

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

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

    print("*** Stopping network")
    net.stop()
Ejemplo n.º 7
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller, accessPoint=OVSKernelAP)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1',
                          mac='00:00:00:00:00:02',
                          ip='10.0.0.2/8',
                          range=20)
    sta2 = net.addStation('sta2',
                          mac='00:00:00:00:00:03',
                          ip='10.0.0.3/8',
                          range=20)
    ap1 = net.addAccessPoint('ap1',
                             ssid='ssid-ap1',
                             mode='g',
                             channel='1',
                             position='15,30,0',
                             range=30)
    ap2 = net.addAccessPoint('ap2',
                             ssid='ssid-ap2',
                             mode='g',
                             channel='6',
                             position='55,30,0',
                             range=30)
    c1 = net.addController('c1', controller=Controller)

    net.propagationModel(model="logDistance", exp=5)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    info("*** Creating links\n")
    net.addLink(ap1, ap2)

    net.plotGraph(max_x=100, max_y=100)

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

    info("*** Starting network\n")
    net.build()
    c1.start()
    ap1.start([c1])
    ap2.start([c1])

    info("*** Running CLI\n")
    CLI_wifi(net)

    info("*** Stopping network\n")
    net.stop()
Ejemplo n.º 8
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller, accessPoint=OVSKernelAP)

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

    net.propagationModel(model="logDistance", exp=5)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    info("*** Associating and Creating links\n")
    net.addLink(ap1, ap2)
    net.addLink(ap2, ap3)

    net.plotGraph(max_x=120, max_y=120)

    net.associationControl('ssf')

    net.seed(1)

    net.startMobility(time=0, model='RandomWayPoint', max_x=120, max_y=120,
                      min_v=0.3, max_v=0.5)

    info("*** Starting network\n")
    net.build()
    c1.start()
    ap1.start([c1])
    ap2.start([c1])
    ap3.start([c1])

    info("*** Running CLI\n")
    CLI_wifi(net)

    info("*** Stopping network\n")
    net.stop()
Ejemplo n.º 9
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller,
                       accessPoint=UserAP,
                       enable_wmediumd=True,
                       enable_interference=True)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1',
                          radius_passwd='sdnteam',
                          encrypt='wpa2',
                          radius_identity='joe',
                          position='110,120,0')
    sta2 = net.addStation('sta2',
                          radius_passwd='hello',
                          encrypt='wpa2',
                          radius_identity='bob',
                          position='200,100,0')
    ap1 = net.addAccessPoint('ap1',
                             ssid='simplewifi',
                             authmode='8021x',
                             mode='a',
                             channel='36',
                             encrypt='wpa2',
                             position='150,100,0')
    c0 = net.addController('c0',
                           controller=Controller,
                           ip='127.0.0.1',
                           port=6633)

    info("*** Configuring Propagation Model\n")
    net.propagationModel(model="logDistance", exp=3.5)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    info("*** Associating Stations\n")
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)

    net.plotGraph(max_x=300, max_y=300)

    info("*** Starting network\n")
    net.build()
    c0.start()
    ap1.start([c0])

    info("*** Running CLI\n")
    CLI_wifi(net)

    info("*** Stopping network\n")
    net.stop()
Ejemplo n.º 10
0
def topology():

    "Create a network."
    net = Mininet_wifi(accessPoint=OVSKernelAP)

    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.addAccessPoint('ap1',
                             ssid='ssid-ap1',
                             mode='g',
                             channel='1',
                             failMode='standalone',
                             position='15,30,0')
    ap2 = net.addAccessPoint('ap2',
                             ssid='ssid-ap2',
                             mode='g',
                             channel='6',
                             failMode='standalone',
                             position='55,30,0')

    net.propagationModel(model='logDistance', exp=5)

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

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

    'plotting graph'
    net.plotGraph(max_x=100, max_y=100)

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

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

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

    print "*** Stopping network"
    net.stop()
Ejemplo n.º 11
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    ap1 = net.addAccessPoint('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')

    net.propagationModel(model='logDistance', exp=3, sL=1)
    # net.propagationModel('ITUPropagationLossModel', pL=50)
    # net.propagationModel('twoRayGroundPropagationLossModel')
    # net.propagationModel('friisPropagationLossModel', sL=2)

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

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

    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_wifi(net)

    print "*** Stopping network"
    net.stop()
Ejemplo n.º 12
0
def topology():
    "Create a network."
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference,
                       configureWiFiDirect=True, autoAssociation=False)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', ip='10.0.0.1/8', position='10,10,0',
                          inNamespace=False)
    sta2 = net.addStation('sta2', ip='10.0.0.2/8', position='20,20,0')

    info("*** Configuring Propagation Model\n")
    net.propagationModel(model="logDistance", exp=3.5)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    net.plotGraph(max_x=200, max_y=200)

    info("*** Starting WiFi Direct\n")
    intf='wlxf4f26d193319'
    net.addLink(sta1, cls=physicalWifiDirectLink, intf=intf)
    net.addLink(sta2, cls=wifiDirectLink)

    info("*** Starting network\n")
    net.build()

    sta1.cmd('wpa_cli -ista1-wlan0 p2p_find')
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_find')
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_peers')
    sleep(3)
    sta1.cmd('wpa_cli -ista1-wlan0 p2p_peers')
    sleep(3)
    pin = sta1.cmd('wpa_cli -ista1-wlan0 p2p_connect %s pin auth'
                   % sta2.params['mac'][1])
    sleep(3)
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_connect %s %s'
             % (sta1.params['mac'][1], pin))

    # This is the interface/ip addr of the physical node
    os.system('ip addr add 10.0.0.3/8 dev %s' % intf)

    info("*** Running CLI\n")
    CLI_wifi(net)

    info("*** Stopping network\n")
    net.stop()
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller, accessPoint=OVSAP,
                       link=wmediumd, wmediumd_mode=interference)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.1/8', speed=4)
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.2/8', speed=6)
    sta3 = net.addStation('sta3', mac='00:00:00:00:00:04', ip='10.0.0.3/8', speed=3)
    sta4 = net.addStation('sta4', mac='00:00:00:00:00:05', ip='10.0.0.4/8', speed=3)
    ap1 = net.addAccessPoint('ap1', ssid='new-ssid', mode='g', channel='1',
                             position='45,45,0')
    c1 = net.addController('c1', controller=Controller)

    info("*** Configuring Propagation Model\n")
    net.propagationModel(model="logDistance", exp=4.5)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    info("*** Creating links\n")
    net.addLink(sta3, cls=adhoc, ssid='adhocNet')
    net.addLink(sta4, cls=adhoc, ssid='adhocNet')

    'ploting graph'
    #net.plotGraph(max_x=200, max_y=200)

    info("*** Starting network\n")
    net.build()
    c1.start()
    ap1.start([c1])

    getTrace(sta1, 'examples/replaying/replayingMobility/node1.dat')
    getTrace(sta2, 'examples/replaying/replayingMobility/node2.dat')
    getTrace(sta3, 'examples/replaying/replayingMobility/node3.dat')
    getTrace(sta4, 'examples/replaying/replayingMobility/node4.dat')

    replayingMobility(net)

    info("*** Running CLI\n")
    CLI_wifi(net)

    info("*** Stopping network\n")
    net.stop()
Ejemplo n.º 14
0
def topology():

    "Create a network."
    net = Mininet_wifi(controller=Controller,
                       accessPoint=OVSKernelAP,
                       link=wmediumd)

    info("*** Creating nodes\n")
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid',
                             mode='a',
                             channel='36',
                             position='150,150,0')
    net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8')
    c1 = net.addController('c1', controller=Controller)

    info("*** Configuring Propagation Model\n")
    net.propagationModel(model="logDistance", exp=3)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    net.plotGraph(max_x=300, max_y=300)

    net.seed(20)

    net.startMobility(time=0,
                      model='RandomDirection',
                      max_x=300,
                      max_y=300,
                      min_v=0.5,
                      max_v=0.8)

    info("*** Starting network\n")
    net.build()
    c1.start()
    ap1.start([c1])

    info("*** Running CLI\n")
    CLI_wifi(net)

    info("*** Stopping network\n")
    net.stop()
Ejemplo n.º 15
0
def topology():
    "Create a network."
    net = Mininet_wifi(link=wmediumd,
                       wmediumd_mode=interference,
                       configureWiFiDirect=True,
                       autoAssociation=False)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', ip='10.0.0.1/8', position='10,10,0')
    sta2 = net.addStation('sta2', ip='10.0.0.2/8', position='20,20,0')

    info("*** Configuring Propagation Model\n")
    net.propagationModel(model="logDistance", exp=3.5)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    net.plotGraph(max_x=200, max_y=200)

    info("*** Starting WiFi Direct\n")
    net.addLink(sta1, cls=wifiDirectLink)
    net.addLink(sta2, cls=wifiDirectLink)

    info("*** Starting network\n")
    net.build()

    sta1.cmd('wpa_cli -ista1-wlan0 p2p_find')
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_find')
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_peers')
    sleep(3)
    sta1.cmd('wpa_cli -ista1-wlan0 p2p_peers')
    sleep(3)
    pin = sta1.cmd('wpa_cli -ista1-wlan0 p2p_connect %s pin auth' %
                   sta2.params['mac'][0])
    sleep(3)
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_connect %s %s' %
             (sta1.params['mac'][0], pin))

    info("*** Running CLI\n")
    CLI_wifi(net)

    info("*** Stopping network\n")
    net.stop()
Ejemplo n.º 16
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller,
                       accessPoint=OVSKernelAP,
                       driver='capwap_wtp',
                       enable_wmediumd=True,
                       enable_interference=True)

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

    info("*** Configuring Propagation Model\n")
    net.propagationModel(model="logDistance", exp=4)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    net.plotGraph(max_x=100, max_y=100)

    info("*** Starting network\n")
    net.build()
    c1.start()
    ap1.start([c1])

    info("*** Running CLI\n")
    CLI_wifi(net)

    info("*** Stopping network\n")
    net.stop()
Ejemplo n.º 17
0
def topology():

    "Create a network."
    net = Mininet_wifi(controller=Controller, accessPoint=OVSKernelAP)

    info("*** Creating nodes\n")
    net.addStation('sta1', antennaHeight='1', antennaGain='5')
    net.addStation('sta2', antennaHeight='1', antennaGain='5')
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid',
                             equipmentModel='DI524',
                             mode='g',
                             channel='1',
                             position='50,50,0')
    c1 = net.addController('c1', controller=Controller)

    net.propagationModel(model="logDistance", exp=4)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    net.plotGraph(max_x=100, max_y=100)

    net.seed(1)

    net.startMobility(time=0,
                      model='RandomWayPoint',
                      max_x=100,
                      max_y=100,
                      min_v=0.5,
                      max_v=0.5)

    info("*** Starting network\n")
    net.build()
    c1.start()
    ap1.start([c1])

    info("*** Running CLI\n")
    CLI_wifi(net)

    info("*** Stopping network\n")
    net.stop()
def topology():
    "Create a network."
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', position='10,10,0', inNamespace=False)
    sta2 = net.addStation('sta2', position='50,10,0')
    sta3 = net.addStation('sta3', position='90,10,0')

    net.propagationModel(model="logDistance", exp=4)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    info("*** Creating links\n")
    # intf: physical interface
    net.addLink(sta1,
                cls=physicalMesh,
                intf='wlxf4f26d193319',
                ssid='meshNet',
                channel=5)
    net.addLink(sta2, cls=mesh, ssid='meshNet', channel=5)
    net.addLink(sta3, cls=mesh, ssid='meshNet', channel=5)

    net.plotGraph(max_x=100, max_y=100)

    info("*** Starting network\n")
    net.build()

    # This is the interface/ip addr of the physical node
    os.system('ip addr add 10.0.0.4/8 dev physta1-mp0')

    info("*** Running CLI\n")
    CLI_wifi(net)

    # Delete the interface created previously
    os.system('iw dev physta1-mp0 del')

    info("*** Stopping network\n")
    net.stop()
Ejemplo n.º 19
0
def topology():
    "Create a network."
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference)

    print("*** Creating nodes")
    sta1 = net.addStation('sta1', position='10,10,0')
    sta2 = net.addStation('sta2', position='60,10,0')
    sta3 = net.addStation('sta3', position='100,10,0')
    sta4 = net.addStation('sta4', position='10,140,0')
    sta5 = net.addStation('sta5', position='60,140,0')
    sta6 = net.addStation('sta6', position='100,140,0')

    print("*** Configuring Propagation Model")
    net.propagationModel(model="logDistance", exp=4.5)

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

    print("*** Creating links")
    net.addLink(sta1, cls=mesh, ssid='meshNet')
    net.addLink(sta2, cls=mesh, ssid='meshNet')
    net.addLink(sta3, cls=mesh, ssid='meshNet')
    net.addLink(sta4, cls=adhoc, ssid='adhocNet')
    net.addLink(sta5, cls=adhoc, ssid='adhocNet')
    net.addLink(sta6, cls=adhoc, ssid='adhocNet')

    net.plotGraph(max_x=200, max_y=200)

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

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

    print("*** Stopping network")
    net.stop()
Ejemplo n.º 20
0
def topology():
    "Create a network."
    net = Mininet_wifi(link=wmediumd, enable_interference=True)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', position='10,10,0')
    sta2 = net.addStation('sta2', position='60,10,0')
    sta3 = net.addStation('sta3', position='100,10,0')
    sta4 = net.addStation('sta4', position='10,140,0')
    sta5 = net.addStation('sta5', position='60,140,0')
    sta6 = net.addStation('sta6', position='100,140,0')

    print "*** Configuring Propagation Model"
    net.propagationModel(model="logDistance", exp=4.5)

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

    print "*** Creating links"
    net.addMesh(sta1, ssid='meshNet')
    net.addMesh(sta2, ssid='meshNet')
    net.addMesh(sta3, ssid='meshNet')
    net.addHoc(sta4, ssid='adhocNet')
    net.addHoc(sta5, ssid='adhocNet')
    net.addHoc(sta6, ssid='adhocNet')

    net.plotGraph(max_x=200, max_y=200)

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

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

    print "*** Stopping network"
    net.stop()
Ejemplo n.º 21
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller,
                       link=wmediumd,
                       accessPoint=OVSKernelAP,
                       wmediumd_mode=interference,
                       noise_threshold=-91,
                       fading_coefficient=1)

    info("*** Creating nodes\n")

    ap10 = net.addAccessPoint('Mobile1',
                              ssid='Mobile1',
                              mode='a',
                              channel=channelMobile1,
                              position=positionMobile1,
                              range=rangeMobile1,
                              antennaGain=antennaGainMobile1,
                              txpower=txpowerMobile1,
                              antennaHeight=antennaHeightMobile1)

    ap1 = net.addAccessPoint('ap1',
                             ssid='Antenna1',
                             mode='a',
                             channel=channelAP1,
                             position=positionAP1,
                             range=rangeAP1,
                             antennaGain=antennaGainAP1,
                             txpower=txpowerAP1,
                             antennaHeight=antennaHeightAP1)

    ap2 = net.addAccessPoint('ap2',
                             ssid='Antenna2',
                             mode='a',
                             channel=channelAP2,
                             position=positionAP2,
                             range=rangeAP2,
                             antennaGain=antennaGainAP2,
                             txpower=txpowerAP2,
                             antennaHeight=antennaHeightAP2)

    ap3 = net.addAccessPoint('ap3',
                             ssid='Antenna3',
                             mode='a',
                             channel=channelAP3,
                             position=positionAP3,
                             range=rangeAP3,
                             antennaGain=antennaGainAP3,
                             txpower=txpowerAP3,
                             antennaHeight=antennaHeightAP3)

    c1 = net.addController('c1', controller=Controller)
    net.propagationModel(model="logNormalShadowing", exp=3)
    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    net.plotGraph(max_x=100, max_y=100)

    info("*** Starting network\n")
    net.build()
    c1.start()
    ap1.start([c1])
    ap2.start([c1])
    ap3.start([c1])
    ap10.start([c1])  #Mobile from ap10 forward

    #AP1 TO MODE MONITOR
    ap1.cmd("ifconfig ap1-wlan1 down")
    ap1.cmd('iwconfig ap1-wlan1 mode monitor')
    ap1.cmd('ifconfig ap1-wlan1 up')

    #AP2 TO MODE MONITOR
    ap2.cmd("ifconfig ap2-wlan1 down")
    ap2.cmd('iwconfig ap2-wlan1 mode monitor')
    ap2.cmd('ifconfig ap2-wlan1 up')

    #AP3 TO MODE MONITOR
    ap3.cmd("ifconfig ap3-wlan1 down")
    ap3.cmd('iwconfig ap3-wlan1 mode monitor')
    ap3.cmd('ifconfig ap3-wlan1 up')

    info("*** Running CLI\n")
    CLI_wifi(net)

    info("*** Stopping network\n")
    net.stop()
Ejemplo n.º 22
0
def topology():
    car_type = SD_Car
    op = raw_input("Choose Type of Experiment: (1)v2i \t (2)v2v \nChoice:")
    if(op == "1"):
        v2v = False
        pass
    else:
        v2v = True
        caching = input(
            "What do you prefere to run:\n (1)car-level caching enabled (2)car-level caching disbled \nChoice: ")
        if(caching == "1"):
            car_type = SD_C_Car
        else:
            car_type = SD_Car

    "Create a network."
    net = Mininet_wifi(controller=Vanet_controller, accessPoint=UserAP,
                       switch=SD_Car_Switch, station=SD_station,link=wmediumd,
                       wmediumd_mode=interference)

    print ("*** Creating nodes")
    cars = []
    stas = []
    for x in range(0, 10):
        cars.append(x)
        stas.append(x)
    for x in range(0, 10):
        cars[x] = net.addCar('car%s' % (x), wlans=1,
                             ip='10.0.0.%s/8' % (x + 1), encrypt='wpa2', cls=car_type)

    e1 = net.addAccessPoint('e1', wlans=2, ssid='vanet-ssid,', mac='00:00:00:11:00:01', mode='g', channel='1',
                            passwd='123456789a', encrypt='wpa2', position='3332.62,3253.92,0', cls=eNodeB, inNamespace=True)
    e2 = net.addAccessPoint('e2', wlans=2, ssid='vanet-ssid,', mac='00:00:00:11:00:02', mode='g', channel='1',
                            passwd='123456789a', encrypt='wpa2', position='3279.02,3736.27,0', cls=eNodeB, inNamespace=True)
    e3 = net.addAccessPoint('e3', wlans=2, ssid='vanet-ssid,', mac='00:00:00:11:00:03', mode='g', channel='11',
                            passwd='123456789a', encrypt='wpa2', position='2806.42,3395.22,0', cls=eNodeB, inNamespace=True)
    e4 = net.addAccessPoint('e4', wlans=2, ssid='vanet-ssid,', mac='00:00:00:11:00:04', mode='g', channel='6',
                            passwd='123456789a', encrypt='wpa2', position='2320.82,3565.75,0', cls=eNodeB, inNamespace=True)
    e5 = net.addAccessPoint('e5', wlans=2, ssid='vanet-ssid,', mac='00:00:00:11:00:05', mode='g', channel='6',
                            passwd='123456789a', encrypt='wpa2', position='2887.62,2935.61,0', cls=eNodeB, inNamespace=True)
    e6 = net.addAccessPoint('e6', wlans=2, ssid='vanet-ssid,', mac='00:00:00:11:00:06', mode='g', channel='11',
                            passwd='123456789a', encrypt='wpa2', position='2351.68,3083.40,0', cls=eNodeB, inNamespace=True)

    client = net.addHost('cloud', cls=Cloud_host)
    switch = net.addSwitch('switch', dpid='4000000000000000', cls=SD_Switch)
    c1 = net.addController(
        'c1', controller=Vanet_controller, ip='127.0.0.1', port=6653)
    # "logDistancePropagationLossModel"
    net.propagationModel(exp=2.8)

    if(v2v):
        print ("*** Setting bgscan")
        net.setBgscan(signal=-45, s_inverval=5, l_interval=10)

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

    net.addLink(switch, e1)
    net.addLink(client, switch)
    """net.addLink(e1, e2)
    net.addLink(e2, e3)
    net.addLink(e3, e4)
    net.addLink(e4, e5)
    net.addLink(e5, e6)"""
    
    net.addLink(e1, intf = 'e1-wlan2', cls=mesh, ssid='mesh-ssid')
    net.addLink(e2, intf = 'e2-wlan2', cls=mesh, ssid='mesh-ssid')
    net.addLink(e3, intf = 'e3-wlan2', cls=mesh, ssid='mesh-ssid')
    net.addLink(e4, intf = 'e4-wlan2', cls=mesh, ssid='mesh-ssid')
    net.addLink(e5, intf = 'e5-wlan2', cls=mesh, ssid='mesh-ssid')
    net.addLink(e6, intf = 'e6-wlan2', cls=mesh, ssid='mesh-ssid')

    "Available Options: sumo, sumo-gui"
    net.useExternalProgram('sumo-gui', config_file='map.sumocfg')

    print ("*** Starting network")
    net.build()
    c1.start()
    e1.start([c1])
    e2.start([c1])
    e3.start([c1])
    e4.start([c1])
    e5.start([c1])
    e6.start([c1])

    i = 201
    for sw in net.carsSW:
        sw.start([c1])
        os.system('ifconfig %s 10.0.0.%s' % (sw, i))
        i += 1

    i = 1
    j = 2
    for car in cars:
        car.setIP('192.168.0.%s/24' % i, intf='%s-wlan0' % car)
        car.setIP('192.168.1.%s/24' % i, intf='%s-eth1' % car)
        car.cmd('ip route add 10.0.0.0/8 via 192.168.1.%s' % j)
        i += 2
        j += 2

    i = 1
    j = 2
    for carsta in net.carsSTA:
        carsta.setIP('10.0.0.%s/24' % i, intf='%s-mp0' % carsta)
        carsta.setIP('192.168.1.%s/24' % j, intf='%s-eth2' % carsta)
        # May be confuse, but it allows ping to the name instead of ip addr
        carsta.setIP('10.0.0.%s/24' % i, intf='%s-wlan0' % carsta)
        carsta.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
        i += 1
        j += 2

    for carsta1 in net.carsSTA:
        i = 1
        j = 1
        for carsta2 in net.carsSTA:
            if carsta1 != carsta2:
                carsta1.cmd('route add -host 192.168.1.%s gw 10.0.0.%s' % (j, i))
            i += 1
            j += 2

    # Assigning IPs for Access points wlan interfaces
    IPs = ['90','91','92','93','94','95','96']
    for i in range(0,6):
        net.aps[i].cmd('ifconfig e%s-wlan1 192.168.0.%s'%(i+1,IPs[i]))
        net.aps[i].cmd('ifconfig e%s-mp2 192.168.2.%s'%(i+1,i+1))
        net.aps[i].extIP = '192.168.0.%s'%(IPs[i])

    c1.initializeNetworkResources(net)

    if(v2v):
        raw_input("Press Enter to continue (wait 30sec after t=28)...")
        os.system('clear')
        os.system('ovs-ofctl mod-flows car2SW in_port=2,actions=drop')
        cars[2].cmdPrint('iwconfig car2-wlan0')
        sleep(3)
        cars[6].cmdPrint('iwconfig car6-wlan0')
        print ("****************************************************")
        print ("*** Both car2 and car6 are associated to enodeB5 ***")
        print ("****************************************************")
        sleep(6)
        os.system('clear')
        print ("****************************************************************")
        print ("*** Car6 is so far from enodeB5. Trying to send data by car2 ***")
        print ("****************************************************************")
        sleep(6)
        os.system('clear')
        print ("**************************************")
        print ("*** Trying to send data to car6... ***")
        print ("**************************************")
        cars[2].cmdPrint('ping -c5 10.0.0.7')
        print ("****************************************************************************************************")
        print ("*** Car2: V2V is blocked! Car6 is unreachable! Controller, please let me talk directly with car6 ***")
        print ("****************************************************************************************************")
        sleep(6)
        os.system('clear')
        print ("***********************************************")
        print ("*** controller says: Car6 is now reachable! ***")
        print ("***********************************************")
        os.system('ovs-ofctl mod-flows car2SW in_port=2,actions=1')
        sleep(6)
        os.system('clear')
        cars[2].cmdPrint('ping -c5 10.0.0.7')
        os.system('clear')
        print ("***********************************")
        print ("*** Car2: Requesting Content for car6! ***")
        print ("***********************************")
        sleep(1)
        cars[2].RequestContent(net, 2)
        print ("***********************************")
        print ("*** Car2: Thank you Controller! ***")
        print ("***********************************")
    else:
        print ("***********************************")
        print ("********  V2I experiment **********")
        print ("***********************************")
        raw_input("PressEnter after T=28 ...")

        print ("type>> py car4.RequestContent(net)")

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

    print ("*** Stopping network")
    net.stop()
Ejemplo n.º 23
0
def topology():

    "Create a network."
    net = Mininet_wifi(controller=Controller, switch=OVSKernelSwitch,
                  enable_wmediumd=True, enable_interference=True)

    info("*** Creating nodes\n")
    cars = []
    for x in range(0, 10):
        cars.append(x)
    for x in range(0, 10):
        min_ = random.randint(1, 4)
        max_ = random.randint(11, 30)
        cars[x] = net.addCar('car%s' % (x + 1), wlans=1,
                             ip='10.0.0.%s/8'% (x + 1), min_speed=min_,
                             max_speed=max_)

    rsu11 = net.addAccessPoint('RSU11', ssid='RSU11', mode='g',
                               channel='1')
    rsu12 = net.addAccessPoint('RSU12', ssid='RSU12', mode='g',
                               channel='6')
    rsu13 = net.addAccessPoint('RSU13', ssid='RSU13', mode='g',
                               channel='11')
    rsu14 = net.addAccessPoint('RSU14', ssid='RSU14', mode='g',
                               channel='11')
    c1 = net.addController('c1', controller=Controller)

    info("*** Configuring Propagation Model\n")
    net.propagationModel(model="logDistance", exp=4.5)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    info("*** Associating and Creating links\n")
    net.addLink(rsu11, rsu12)
    net.addLink(rsu11, rsu13)
    net.addLink(rsu11, rsu14)

    net.plotGraph(max_x=500, max_y=500)

    net.roads(10)

    net.startMobility(time=0)

    info("*** Starting network\n")
    net.build()
    c1.start()
    rsu11.start([c1])
    rsu12.start([c1])
    rsu13.start([c1])
    rsu14.start([c1])

    i = 201
    for sw in net.carsSW:
        sw.start([c1])
        os.system('ip addr add 10.0.0.%s dev %s' % (i, sw))
        i += 1

    i = 1
    j = 2
    k = 1
    for car in cars:
        car.setIP('192.168.0.%s/24' % k, intf='%s-wlan0' % car)
        car.setIP('192.168.1.%s/24' % i, intf='%s-eth1' % car)
        car.cmd('ip route add 10.0.0.0/8 via 192.168.1.%s' % j)
        i += 2
        j += 2
        k += 1

    i = 1
    j = 2
    for carsta in net.carsSTA:
        carsta.setIP('10.0.0.%s/24' % i, intf='%s-mp0' % carsta)
        carsta.setIP('192.168.1.%s/24' % j, intf='%s-eth2' % carsta)
        # May be confuse, but it allows ping to the name instead of ip addr
        carsta.setIP('10.0.0.%s/24' % i, intf='%s-wlan0' % carsta)
        carsta.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
        i += 1
        j += 2

    for carsta1 in net.carsSTA:
        i = 1
        j = 1
        for carsta2 in net.carsSTA:
            if carsta1 != carsta2:
                carsta1.cmd('route add -host 192.168.1.%s gw 10.0.0.%s' % (j, i))
            i += 1
            j += 2

    info("*** Running CLI\n")
    CLI_wifi(net)

    info("*** Stopping network\n")
    net.stop()
Ejemplo n.º 24
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=RemoteController,
                       accessPoint=OVSKernelAP,
                       link=wmediumd,
                       wmediumd_mode=interference)
    os.system('service network-manager stop')

    info("*** Creating nodes\n")
    # Mesh Portal (USB Dongle) connect to real mesh network
    mpoint = net.addStation('mpoint',
                            mac='20:50:00:00:00:01',
                            position='50,150,0',
                            ip='10.0.3.1/24',
                            range=100,
                            inNamespace=False)

    # End station
    sta1 = net.addStation('sta1',
                          mac='20:50:00:00:00:02',
                          position='50,50,0',
                          ip='10.0.3.2/24',
                          range=100)
    sta2 = net.addStation('sta2',
                          mac='20:50:00:00:00:03',
                          position='150,50,0',
                          ip='10.0.3.3/24',
                          range=100)
    sta3 = net.addStation('sta3',
                          mac='20:50:00:00:00:04',
                          position='250,300,0',
                          ip='10.0.3.4/24',
                          range=100)
    sta4 = net.addStation('sta4',
                          mac='20:50:00:00:00:05',
                          position='350,200,0',
                          ip='10.0.3.5/24',
                          range=100)

    # Mesh Router/Relay Configuration
    mr1 = net.addStation('mr1',
                         wlans=2,
                         type='mesh',
                         mac='20:50:00:00:00:06,20:50:00:00:00:07',
                         ssid="ssid3,",
                         mode="g",
                         channel="1",
                         position='200,100,0',
                         ip='10.0.3.6/24')
    mr2 = net.addStation(
        'mr2',
        wlans=2,
        type='mesh',
        mac='20:50:00:00:00:08,20:50:00:00:00:09',
        ssid="ssid4,",
        mode="g",
        channel="1",
        position='250,200,0',
        ip='10.0.3.7/24',
    )

    # Openflow Enabled Mesh Access Point
    ap1 = net.addAccessPoint('ap1',
                             wlans=2,
                             type='mesh',
                             ssid="ssid1,",
                             dpid='20:50:00:00:00:00:00:01',
                             position='100,100,0',
                             mode="g",
                             channel="1")
    ap2 = net.addAccessPoint('ap2',
                             wlans=2,
                             type='mesh',
                             ssid="ssid2,",
                             dpid='20:50:00:00:00:00:00:02',
                             position='300,250,0',
                             mode='g',
                             channel='1')

    # Remote Controller Configuration
    c0 = net.addController('c0',
                           controller=RemoteController,
                           ip='172.31.132.205',
                           port=6653)

    net.propagationModel(model="logDistance", exp=3.6)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    print "*** Associating Stations"
    #Hosting mesh network and associating nodes
    net.addLink(mpoint,
                cls=physicalMesh,
                intf='wlx8416f91916ac',
                ssid='mesh-ssid',
                channel=1)
    net.addLink(ap1, cls=mesh, intf='ap1-wlan2', ssid='mesh-ssid', channel=1)
    net.addLink(ap2, cls=mesh, intf='ap2-wlan2', ssid='mesh-ssid', channel=1)
    net.addLink(mr1, cls=mesh, intf='mr1-wlan0', ssid='mesh-ssid', channel=1)
    net.addLink(mr2, cls=mesh, intf='mr2-wlan0', ssid='mesh-ssid', channel=1)

    print """plotting graph"""
    net.plotGraph(max_x=400, max_y=400)

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

    # Assign IP address to USB dongle mesh interface
    os.system('ip addr add 10.0.0.3/16 dev phympoint-mp0')

    # Add route in the root system for the other mesh network
    os.system('route add -net 10.0.2.0/24 gw 10.0.2.1 phympoint-mp0')
    os.system('route add -net 10.0.1.0/24 gw 10.0.1.1 phympoint-mp0')
    # Enable IP forwarding in mesh portal
    mpoint.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')

    # Add gateway entry in the nodes
    sta1.cmd('route add -net 10.0.0.0/16 gw 10.0.3.1')
    sta2.cmd('route add -net 10.0.0.0/16 gw 10.0.3.1')
    sta3.cmd('route add -net 10.0.0.0/16 gw 10.0.3.1')
    sta4.cmd('route add -net 10.0.0.0/16 gw 10.0.3.1')
    mr1.cmd('route add -net 10.0.0.0/16 gw 10.0.3.1')
    mr2.cmd('route add -net 10.0.0.0/16 gw 10.0.3.1')

    # Start controller and Openflow enabled mesh access points
    c0.start()
    ap1.start([c0])
    ap2.start([c0])

    # Fog node/processing nodes intialization
    print("***Waiting for network intialization")
    time.sleep(5)
    mr1.cmd('python3 sensorserver.py 10.0.1.6 &')
    mr2.cmd('python3 sensorserver.py 10.0.3.7 13550 10.0.3.6 12550 &')
    mr1.cmd('python3 worker.py &')
    mr2.cmd('python3 worker.py &')
    sta1.cmd('python3 actuator.py &')
    print("***Waiting to activate sensor")
    time.sleep(15)
    sta2.cmd('python3 sensor.py 10.0.3.6 temp 10.0.3.2 &')

    info("*** Running CLI\n")
    CLI_wifi(net)

    # Delete the mesh interface created previously
    os.system('iw dev phympoint-mp0 del')

    print "*** Stopping network"
    net.stop()
    os.system('mn -c')
    os.system('pkill -9 python3')
Ejemplo n.º 25
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller,
                       accessPoint=OVSKernelAP,
                       link=wmediumd,
                       wmediumd_mode=interference,
                       configure4addr=True,
                       autoAssociation=False)

    info("*** Creating nodes\n")
    ap1 = net.addAccessPoint('ap1',
                             _4addr="ap",
                             ssid="wds-ssid1",
                             mode="g",
                             channel="1",
                             position='30,30,0')
    ap2 = net.addAccessPoint('ap2',
                             _4addr="client",
                             ssid="wds-ssid2",
                             mode="g",
                             channel="1",
                             position='40,60,0')
    ap3 = net.addAccessPoint('ap3',
                             _4addr="client",
                             ssid="wds-ssid3",
                             mode="g",
                             channel="1",
                             position='50,30,0')
    sta1 = net.addStation('sta1', ip="192.168.0.1/24", position='31,32,0')
    sta2 = net.addStation('sta2', ip="192.168.0.2/24", position='32,34,0')
    sta3 = net.addStation('sta3', ip="192.168.0.3/24", position='41,62,0')
    sta4 = net.addStation('sta4', ip="192.168.0.4/24", position='42,64,0')
    sta5 = net.addStation('sta5', ip="192.168.0.5/24", position='51,32,0')
    sta6 = net.addStation('sta6', ip="192.168.0.6/24", position='52,34,0')
    c0 = net.addController('c0',
                           controller=Controller,
                           ip='127.0.0.1',
                           port=6633)

    info("*** Configuring Propagation Model\n")
    net.propagationModel(model="logDistance", exp=4.5)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    info("*** Adding Link\n")
    net.addLink(ap1, ap2, cls=_4address)
    net.addLink(ap1, ap3, cls=_4address)
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)
    net.addLink(sta3, ap2)
    net.addLink(sta4, ap2)
    net.addLink(sta5, ap3)
    net.addLink(sta6, ap3)

    net.plotGraph(max_x=100, max_y=100)

    info("*** Starting network\n")
    net.build()
    c0.start()
    ap1.start([c0])
    ap2.start([c0])
    ap3.start([c0])

    info("*** Running CLI\n")
    CLI_wifi(net)

    info("*** Stopping network\n")
    net.stop()
def topology(mobility):
    'Create a network.'
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference)

    info("*** Creating nodes\n")
    if mobility:
        sta1 = net.addStation('sta1',
                              mac='00:00:00:00:00:01',
                              ip='192.168.0.1/24')
    else:
        sta1 = net.addStation('sta1',
                              mac='00:00:00:00:00:01',
                              ip='192.168.0.1/24',
                              position='20,60,0')
    sta2 = net.addStation('sta2',
                          mac='00:00:00:00:00:02',
                          ip='192.168.1.1/24',
                          position='90,60,0')
    ap1 = net.addStation('ap1',
                         type='ap',
                         mac='02:00:00:00:01:00',
                         ip='192.168.0.10/24',
                         ssid="apadhoc-ssid1",
                         mode="g",
                         channel="1",
                         position='40,60,0')
    ap2 = net.addStation('ap2',
                         type='ap',
                         mac='02:00:00:00:02:00',
                         ip='192.168.1.10/24',
                         ssid="apadhoc-ssid2",
                         mode="g",
                         channel="6",
                         position='70,60,0')

    net.propagationModel(model="logDistance", exp=4.5)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    info("*** Adding Link\n")
    net.addLink(ap1, ap2)  # wired connection

    info("*** Plotting Graph\n")
    net.plotGraph(max_x=120, max_y=120)

    if mobility:
        net.startMobility(time=1)
        net.mobility(sta1, 'start', time=2, position='20.0,60.0,0.0')
        net.mobility(sta1, 'stop', time=6, position='110.0,60.0,0.0')
        net.stopMobility(time=6)

    info("*** Starting network\n")
    net.build()

    ap1.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
    ap2.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')

    ap1.setIP('192.168.2.1/24', intf='ap1-eth1')
    ap2.setIP('192.168.2.2/24', intf='ap2-eth1')
    ap1.cmd('route add -net 192.168.1.0/24 gw 192.168.2.2')
    ap2.cmd('route add -net 192.168.0.0/24 gw 192.168.2.1')
    sta1.cmd('route add -net 192.168.1.0/24 gw 192.168.0.10')
    sta1.cmd('route add -net 192.168.2.0/24 gw 192.168.0.10')
    sta2.cmd('route add -net 192.168.0.0/24 gw 192.168.1.10')
    sta2.cmd('route add -net 192.168.2.0/24 gw 192.168.1.10')

    info("*** Running CLI\n")
    CLI_wifi(net)

    info("*** Stopping network\n")
    net.stop()
def topology():

    "Create a network."
    net = Mininet_wifi(controller=RemoteController,
                       accessPoint=UserAP,
                       link=wmediumd,
                       wmediumd_mode=interference)
    staList = []
    internetIface = 'enp2s0'
    usbDongleIface = 'wlan2'

    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:' + '%02x' % (n + 1),
                                    ip='192.168.0.%s/24' % (n + 1))
    phyap1 = net.addPhysicalBaseStation(
        'phyap1',
        wlans=2,
        protocols='OpenFlow13',
        ssid='Sigcomm-2016-Mininet-WiFi,Sigcomm-2016-Mininet-WiFi',
        mode='g',
        channel='1',
        position='50,115,0',
        phywlan=usbDongleIface)
    ap2 = net.addAccessPoint('ap2',
                             protocols='OpenFlow13',
                             ssid='ap-ssid2',
                             mode='g',
                             channel='11',
                             position='100,175,0')
    ap3 = net.addAccessPoint('ap3',
                             protocols='OpenFlow13',
                             ssid='ap-ssid3',
                             mode='g',
                             channel='6',
                             position='150,115,0')
    ap4 = net.addAccessPoint('ap4',
                             protocols='OpenFlow13',
                             ssid='ap-ssid4',
                             mode='g',
                             channel='11',
                             position='100,55,0')
    c5 = net.addController('c5', controller=RemoteController, port=6653)
    sta11 = net.addStation('sta11', ip='10.0.0.111/8', position='60,100,0')
    h12 = net.addHost('h12', ip='10.0.0.109/8')
    root = net.addHost('root', ip='10.0.0.254/8', inNamespace=False)

    print("*** Configuring Propagation Model")
    net.propagationModel(model="logDistance", exp=4)

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

    print("*** Creating links")
    for sta in staList:
        net.addLink(sta, cls=mesh, ssid='meshNet')

    net.plotGraph(max_x=240, max_y=240)

    "Seed"
    net.seed(20)

    print("*** Associating and Creating links")
    net.addLink(phyap1, ap2)
    net.addLink(ap2, ap3)
    net.addLink(sta11, phyap1, 0, 1)
    net.addLink(ap3, ap4)
    net.addLink(ap4, phyap1)
    net.addLink(root, ap3)
    net.addLink(phyap1, h12)

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

    time.sleep(2)
    'output=all,flood'
    ap3.cmd(
        'dpctl unix:/tmp/ap3 meter-mod cmd=add,flags=1,meter=1 drop:rate=100')
    ap3.cmd(
        'dpctl unix:/tmp/ap3 flow-mod table=0,cmd=add in_port=4,eth_type=0x800,ip_dst=10.0.0.100,meter:1 apply:output=flood'
    )
    phyap1.cmd(
        'dpctl unix:/tmp/phyap1 flow-mod table=0,cmd=add in_port=2,ip_dst=10.0.0.109,eth_type=0x800,ip_proto=6,tcp_dst=80 apply:set_field=tcp_dst:80,set_field=ip_dst:10.0.0.111,output=5'
    )
    phyap1.cmd(
        'dpctl unix:/tmp/phyap1 flow-mod table=0,cmd=add in_port=1,eth_type=0x800,ip_proto=6,tcp_src=80 apply:set_field=ip_src:10.0.0.109,output=2'
    )

    fixNetworkManager(root, 'root-eth0')

    startNAT(root, internetIface)

    sta11.cmd('ip route add default via 10.0.0.254')
    sta11.cmd('pushd /home/fontes; python3 -m http.server 80 &')

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

    net.startMobility(startTime=0,
                      model='RandomWalk',
                      max_x=200,
                      max_y=200,
                      min_v=0.1,
                      max_v=0.2)

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

    print("*** Stopping network")
    net.stop()
def topology():
    "Create a network."
    net = Mininet_wifi(controller=RemoteController, accessPoint=OVSKernelAP,
                  link=wmediumd, enable_interference=True)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', position='50,50,0', ip='10.0.0.1/16', range=80)
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:03', position='150,50,0', ip='10.0.0.2/16', range=80)
    sta3 = net.addStation('sta3', mac='00:00:00:00:00:04', position='250,300,0', ip='10.0.0.3/16', range=80)    
    sta4 = net.addStation('sta4', mac='00:00:00:00:00:05', position='350,200,0', ip='10.0.0.4/16', range=80)
    #sta5 = net.addStation('sta5', mac='00:00:00:00:00:06', position='150,50,0', ip='10.0.0.5/16', range=80)
    #sta6 = net.addStation('sta6', mac='00:00:00:00:00:07', position='150,150,0', ip='10.0.0.6/16', range=80) 
    #sta7 = net.addStation('sta7', mac='00:00:00:00:00:08', position='150,250,0', ip='10.0.0.7/16', range=80)
    #sta17 = net.addStation('sta17', mac='00:00:00:00:00:18', position='150,200,0', ip='10.0.0.17/16', range=80)
    #sta8 = net.addStation('sta8', mac='00:00:00:00:00:09', position='150,350,0', ip='10.0.0.8/16', range=80)
    #sta9 = net.addStation('sta9', mac='00:00:00:00:00:10', position='250,50,0', ip='10.0.0.9/16', range=80)    
    #sta10 = net.addStation('sta10', mac='00:00:00:00:00:11', position='250,150,0', ip='10.0.0.10/16', range=80)
    #sta11 = net.addStation('sta11', mac='00:00:00:00:00:12', position='250,250,0', ip='10.0.0.11/16', range=80)
    #sta12 = net.addStation('sta12', mac='00:00:00:00:00:13', position='250,350,0', ip='10.0.0.12/16', range=80)
    #sta13 = net.addStation('sta13', mac='00:00:00:00:00:14', position='350,50,0', ip='10.0.0.13/16', range=80)
    #sta14 = net.addStation('sta14', mac='00:00:00:00:00:15', position='350,150,0', ip='10.0.0.14/16', range=80)
    #sta15 = net.addStation('sta15', mac='00:00:00:00:00:16', position='350,250,0', ip='10.0.0.15/16', range=80)
    #sta16 = net.addStation('sta16', mac='00:00:00:00:00:17', position='350,350,0', ip='10.0.0.16/16', range=80)
    
    ap1 = net.addAccessPoint('ap1', wlans=2, type='mesh', ssid="ssid1,", position='100,100,0', mode="g", channel="1")
    ap2 = net.addAccessPoint('ap2', wlans=2, type='mesh', ssid="ssid2,", position='300,250,0', mode='g', channel='1')
    mr1 = net.addStation('mr1', wlans=2, type='mesh', ssid="ssid3,", mode="g", channel="1", position='200,100,0')
    mr2 = net.addStation('mr2', wlans=2, type='mesh', ssid="ssid4,", mode="g", channel="1", position='250,200,0')


    #ap3 = net.addAccessPoint('ap3', wlans=2, type='mesh', ssid='ssid5,', position='200,120,0', mode="g", channel="1")
    #ap4 = net.addAccessPoint('ap4', wlans=2, type='mesh', ssid='ssid6,', position='250,210,0', mode='g', channel='5')
    #ap5 = net.addAccessPoint('ap5', wlans=2, type='mesh', ssid='ssid5,', position='200,200,0', mode='g', channel='5')
    #ap6 = net.addAccessPoint('ap6', wlans=2, type='mesh', ssid='ssid6,', position='200,300,0', mode='g', channel='5')
    #ap7 = net.addAccessPoint('ap7', wlans=2, type='mesh', ssid='ssid7,', position='300,100,0', mode='g', channel='11')
    #ap8 = net.addAccessPoint('ap8', wlans=2, type='mesh', ssid='ssid8,', position='300,200,0', mode='g', channel='11')
    #ap9 = net.addAccessPoint('ap9', wlans=2, type='mesh', ssid='ssid9,', position='300,300,0', mode='g', channel='11')

    
    
    #ap1.setMAC('40:00:00:00:00:18', ap9.params['mac'][0])
    #ap1.setRange(110,ap1.params['wlan'][1])
    #ap2.setRange(110,ap2.params['wlan'][0])
    #ap3.setRange(110,ap3.params['wlan'][0])
    #ap4.setRange(110,ap4.params['wlan'][0])
    #ap5.setRange(110,ap5.params['wlan'][0])
    #ap6.setRange(110,ap6.params['wlan'][0])
    #ap7.setRange(110,ap7.params['wlan'][0])
    #ap8.setRange(110,ap8.params['wlan'][0])
    #ap9.setRange(110,ap9.params['wlan'][0])
    
    c0 = net.addController('c0', controller=RemoteController, ip='172.31.132.232', port=6653)
    
    print "***configuring propagation model"
    net.propagationModel(model="logDistance", exp=3.6)
   
    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    print "*** Associating Stations"
    net.addMesh(ap1, intf='ap1-wlan2', ssid='mesh-ssid', channel=1)
    net.addMesh(ap2, intf='ap2-wlan2', ssid='mesh-ssid', channel=1)
    net.addMesh(mr1, intf='mr1-wlan0', ssid='mesh-ssid', channel=1)
    net.addMesh(mr2, intf='mr2-wlan0', ssid='mesh-ssid', channel=1)
    #net.addMesh(ap3, intf='ap3-wlan2', ssid='mesh-ssid', channel=1)
    #net.addMesh(ap4, intf='ap4-wlan2', ssid='mesh-ssid', channel=1)
    #net.addLink(ap5, intf='ap5-wlan2', cls=mesh, ssid='mesh-ssid', channel=5)
    #net.addLink(ap6, intf='ap6-wlan2', cls=mesh, ssid='mesh-ssid', channel=5)
    #net.addLink(ap7, intf='ap7-wlan2', cls=mesh, ssid='mesh-ssid', channel=5)
    #net.addLink(ap8, intf='ap8-wlan2', cls=mesh, ssid='mesh-ssid', channel=5)
    #net.addLink(ap9, intf='ap9-wlan2', cls=mesh, ssid='mesh-ssid', channel=5)
       
    print """plotting graph"""
    net.plotGraph(max_x=400, max_y=400)
    
    #"""association control"""
    net.associationControl('ssf')

    print """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(time=0, model='RandomWayPoint', max_x=120, max_y=120, min_v=0.3, max_v=0.5)
    print "*** Starting network"
    net.build()
    c0.start()
    ap1.start([c0])
    ap2.start([c0])
    #ap3.start([c0])
    #ap4.start([c0])
    #ap5.start([c0])
    #ap6.start([c0])
    #ap7.start([c0])
    #ap8.start([c0])
    #ap9.start([c0])
    #ap1.cmd(" ifconfig ap1-mp2 10.0.0.51")
    #ap2.cmd(" ifconfig ap2-mp2 10.0.0.52")
    #ap3.cmd(" ifconfig ap3-wlan1 172.31.0.3/16")
    #ap4.cmd(" ifconfig ap4-wlan1 172.31.0.4/16")
    #ap5.cmd(" ifconfig ap5-wlan1 172.31.0.5/16")
    #ap6.cmd(" ifconfig ap6-wlan1 172.31.0.6/16")
    #ap7.cmd(" ifconfig ap7-wlan1 172.31.0.7/16")
    #ap8.cmd(" ifconfig ap8-wlan1 172.31.0.8/16")
    #ap9.cmd(" ifconfig ap9-wlan1 172.31.0.9/16")
    #ap1.cmd(" iw dev ap1-wlan1 interface add mon0 type monitor")
  #  ap1.cmd("ifconfig mon0 up")
    
    info("*** Running CLI\n")
    CLI_wifi(net)
    
    print "*** Stopping network"
    net.stop()
Ejemplo n.º 29
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller,
                       accessPoint=UserAP,
                       autoAssociation=False)

    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.addAccessPoint('ap1',
                             vssids=4,
                             ssid="ssid,ssid1,ssid2,ssid3,ssid4",
                             mode="g",
                             channel="1",
                             position='30,40,0')
    c0 = net.addController('c0',
                           controller=Controller,
                           ip='127.0.0.1',
                           port=6653)

    net.propagationModel(model='logDistance', exp=5)

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

    "plotting 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 ap %s' %
             (ap1.params['ssid'][1], ap1.params['mac'][1]))
    sta2.cmd('iwconfig sta2-wlan0 essid %s ap %s' %
             (ap1.params['ssid'][2], ap1.params['mac'][2]))
    sta3.cmd('iwconfig sta3-wlan0 essid %s ap %s' %
             (ap1.params['ssid'][2], ap1.params['mac'][2]))
    sta4.cmd('iwconfig sta4-wlan0 essid %s ap %s' %
             (ap1.params['ssid'][3], ap1.params['mac'][3]))
    sta5.cmd('iwconfig sta5-wlan0 essid %s ap %s' %
             (ap1.params['ssid'][4], 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_wifi(net)

    print("*** Stopping network")
    net.stop()
Ejemplo n.º 30
0
def topology():

    taskTime = 20
    ncars = 4

    "Create a network."
    net = Mininet_wifi(controller=Controller, switch=OVSKernelSwitch,
                       accessPoint=OVSKernelAP)

    print("*** Creating nodes")
    cars = []
    stas = []
    for idx in range(0, ncars):
        cars.append(idx)
        stas.append(idx)
    for idx in range(0, ncars):
        cars[idx] = net.addCar('car%s' % idx, wlans=2, ip='10.0.0.%s/8'
                                                          % (idx + 1), range="50,50",
        mac='00:00:00:00:00:0%s' % idx, mode='b', position='%d,%d,0'
                                                           % ((120 - (idx * 20)),
                                                              (100 - (idx * 0))))

    eNodeB1 = net.addAccessPoint('eNodeB1', ssid='eNodeB1', dpid='1000000000000000',
                                 mode='ac', channel='36', position='80,75,0')
    eNodeB2 = net.addAccessPoint('eNodeB2', ssid='eNodeB2', dpid='2000000000000000',
                                 mode='ac', channel='40', position='180,75,0')
    rsu1 = net.addAccessPoint('rsu1', ssid='rsu1', dpid='3000000000000000', mode='g',
                              channel='11', position='140,120,0')
    c1 = net.addController('c1', controller=Controller)
    client = net.addHost ('client')
    switch = net.addSwitch ('switch', dpid='4000000000000000')

    client.plot(position='125,230,0')
    switch.plot(position='125,200,0')

    print("*** Configuring Propagation Model")
    net.propagationModel(model="logDistance", exp=4.1)

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

    print("*** Creating links")
    net.addLink(eNodeB1, switch)
    net.addLink(eNodeB2, switch)
    net.addLink(rsu1, switch)
    net.addLink(switch, client)
    net.addLink(rsu1, cars[0])
    net.addLink(eNodeB2, cars[0])
    net.addLink(eNodeB1, cars[3])

    'Plotting Graph'
    net.plotGraph(max_x=250, max_y=250)

    print("*** Starting network")
    net.build()
    c1.start()
    eNodeB1.start([c1])
    eNodeB2.start([c1])
    rsu1.start([c1])
    switch.start([c1])

    for sw in net.carsSW:
        sw.start([c1])

    i = 1
    j = 2
    for car in cars:
        car.setIP('192.168.0.%s/24' % i, intf='%s-wlan0' % car)
        car.setIP('192.168.1.%s/24' % i, intf='%s-eth2' % car)
        car.cmd('ip route add 10.0.0.0/8 via 192.168.1.%s' % j)
        car.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
        i += 2
        j += 2

    i = 1
    j = 2
    for carsta in net.carsSTA:
        carsta.setIP('10.0.0.%s/24' % i, intf='%s-mp0' % carsta)
        carsta.setIP('192.168.1.%s/24' % j, intf='%s-eth3' % carsta)
        carsta.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
        i += 1
        j += 2

    for carsta1 in net.carsSTA:
        i = 1
        j = 1
        for carsta2 in net.carsSTA:
            if carsta1 != carsta2:
                carsta1.cmd('route add -host 192.168.1.%s gw 10.0.0.%s' % (j, i))
            i += 1
            j += 2

    client.cmd('ifconfig client-eth0 200.0.10.2')
    net.carsSTA[0].cmd('ifconfig car0STA-eth3 200.0.10.50')

    cars[0].cmd('modprobe bonding mode=3')
    cars[0].cmd('ip link add bond0 type bond')
    cars[0].cmd('ip link set bond0 address 02:01:02:03:04:08')
    cars[0].cmd('ip link set car0-eth2 down')
    cars[0].cmd('ip link set car0-eth2 address 00:00:00:00:00:11')
    cars[0].cmd('ip link set car0-eth2 master bond0')
    cars[0].cmd('ip link set car0-wlan0 down')
    cars[0].cmd('ip link set car0-wlan0 address 00:00:00:00:00:15')
    cars[0].cmd('ip link set car0-wlan0 master bond0')
    cars[0].cmd('ip link set car0-wlan1 down')
    cars[0].cmd('ip link set car0-wlan1 address 00:00:00:00:00:13')
    cars[0].cmd('ip link set car0-wlan1 master bond0')
    cars[0].cmd('ip addr add 200.0.10.100/24 dev bond0')
    cars[0].cmd('ip link set bond0 up')

    cars[3].cmd('ifconfig car3-wlan0 200.0.10.150')

    client.cmd('ip route add 192.168.1.8 via 200.0.10.150')
    client.cmd('ip route add 10.0.0.1 via 200.0.10.150')

    net.carsSTA[3].cmd('ip route add 200.0.10.2 via 192.168.1.7')
    net.carsSTA[3].cmd('ip route add 200.0.10.100 via 10.0.0.1')
    net.carsSTA[0].cmd('ip route add 200.0.10.2 via 10.0.0.4')

    cars[0].cmd('ip route add 10.0.0.4 via 200.0.10.50')
    cars[0].cmd('ip route add 192.168.1.7 via 200.0.10.50')
    cars[0].cmd('ip route add 200.0.10.2 via 200.0.10.50')
    cars[3].cmd('ip route add 200.0.10.100 via 192.168.1.8')

    os.system('rm *.vanetdata')

    #os.system('xterm -hold -title "car0" -e "util/m car0 ping 200.0.10.2" &')
    cars[0].cmdPrint("cvlc -vvv v4l2:///dev/video0 --mtu 1000 --sout \'#transcode{vcodec=mp4v,vb=800,scale=1,\
                acodec=mpga,ab=128,channels=1}: duplicate{dst=display,dst=rtp{sdp=rtsp://200.0.10.100:8080/helmet.sdp}}\' &")
    client.cmdPrint("cvlc rtsp://200.0.10.100:8080/helmet.sdp &")

    os.system('ovs-ofctl mod-flows switch in_port=1,actions=drop')
    os.system('ovs-ofctl mod-flows switch in_port=2,actions=drop')
    os.system('ovs-ofctl mod-flows switch in_port=3,actions=drop')

    time.sleep(2)

    print("applying first rule")
    os.system('ovs-ofctl mod-flows switch in_port=1,actions=output:4')
    os.system('ovs-ofctl mod-flows switch in_port=4,actions=output:1')
    os.system('ovs-ofctl mod-flows switch in_port=2,actions=drop')
    os.system('ovs-ofctl mod-flows switch in_port=3,actions=drop')
    os.system('ovs-ofctl del-flows eNodeB1')
    os.system('ovs-ofctl del-flows eNodeB2')
    os.system('ovs-ofctl del-flows rsu1')

    cars[0].cmd('ip route add 200.0.10.2 via 200.0.10.50')
    client.cmd('ip route add 200.0.10.100 via 200.0.10.150')

    kernel = 0
    var = client.cmd('ifconfig client-eth0 | grep \"bytes\" | awk -F\' \' \'NR==1{print $5}\'')
    if var:
        kernel = 1

    timeout = time.time() + taskTime
    currentTime = time.time()
    i = 0
    while True:
        if time.time() > timeout:
            break
        if time.time() - currentTime >= i:
            recordValues(cars[0], client, kernel)
            i += 0.5

    print("Moving nodes")
    cars[0].setPosition('150,100,0')
    cars[1].setPosition('120,100,0')
    cars[2].setPosition('90,100,0')
    cars[3].setPosition('70,100,0')

    # time.sleep(3)

    print("applying second rule")
    os.system('ovs-ofctl mod-flows switch in_port=1,actions=drop')
    os.system('ovs-ofctl mod-flows switch in_port=2,actions=output:4')
    os.system('ovs-ofctl mod-flows switch in_port=4,actions=output:2,3')
    os.system('ovs-ofctl mod-flows switch in_port=3,actions=output:4')
    os.system('ovs-ofctl del-flows eNodeB1')
    os.system('ovs-ofctl del-flows eNodeB2')
    os.system('ovs-ofctl del-flows rsu1')

    cars[0].cmd('ip route del 200.0.10.2 via 200.0.10.50')
    client.cmd('ip route del 200.0.10.100 via 200.0.10.150')

    timeout = time.time() + taskTime
    currentTime = time.time()
    i = 0
    while True:
        if time.time() > timeout:
            break
        if time.time() - currentTime >= i:
            recordValues(cars[0], client, kernel)
            i += 0.5

    print("Moving nodes")
    cars[0].setPosition('190,100,0')
    cars[1].setPosition('150,100,0')
    cars[2].setPosition('120,100,0')
    cars[3].setPosition('90,100,0')

    # time.sleep(2)

    print("applying third rule")
    os.system('ovs-ofctl mod-flows switch in_port=1,actions=drop')
    os.system('ovs-ofctl mod-flows switch in_port=3,actions=drop')
    os.system('ovs-ofctl mod-flows switch in_port=2,actions=output:4')
    os.system('ovs-ofctl mod-flows switch in_port=4,actions=output:2')
    os.system('ovs-ofctl del-flows eNodeB1')
    os.system('ovs-ofctl del-flows eNodeB2')
    os.system('ovs-ofctl del-flows rsu1')

    timeout = time.time() + taskTime
    currentTime = time.time()
    i = 0
    while True:
        if time.time() > timeout:
            break
        if time.time() - currentTime >= i:
            recordValues(cars[0], client, kernel)
            i += 0.5

    print("*** Generating graph")
    graphic()

    os.system('pkill -f vlc')
    os.system('pkill xterm')

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

    #os.system('rm *.vanetdata')

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