def topology():

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

    print "*** Creating nodes"
    sta1 = net.addStation('sta1',
                          mac='00:00:00:00:00:01',
                          ip='10.0.0.1/8',
                          range=10)
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid1',
                             mode='g',
                             channel='1',
                             position='15,30,0',
                             range=33)
    ap2 = net.addAccessPoint('ap2',
                             ssid='new-ssid1',
                             mode='g',
                             channel='6',
                             position='55,30,0',
                             range=33)
    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)

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

    net.plotNode(h1, position='35,90,0')
    net.plotNode(s3, 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(net)

    print "*** Stopping network"
    net.stop()
def topology():
    "Create a network."
    net = Mininet(controller=RemoteController,
                  link=TCLink,
                  switch=OVSKernelSwitch,
                  accessPoint=OVSKernelAP)
    global gnet
    gnet = net

    print "*** Creating nodes "
    car = []
    stas = []
    for x in range(0, 4):
        car.append(x)
        stas.append(x)
    for x in range(0, 4):
        car[x] = net.addCar('car%s' % (x), wlans=2, ip='10.0.0.%s/8' % (x + 1), \
        mac='00:00:00:00:00:0%s' % x, mode='b')

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

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

    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)

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

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

    print "*** Configuring interfaces "

    i = 1
    j = 2
    for c in car:
        c.cmd('ifconfig %s-wlan0 192.168.0.%s/24 up' % (c, i))
        c.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (c, i))
        c.cmd('ip route add 10.0.0.0/8 via 192.168.1.%s' % j)
        i += 2
        j += 2

    i = 1
    j = 2
    for v in net.vehiclesSTA:
        v.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (v, j))
        v.cmd('ifconfig %s-mp0 10.0.0.%s/24 up' % (v, i))
        v.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
        i += 1
        j += 2

    for v1 in net.vehiclesSTA:
        i = 1
        j = 1
        for v2 in net.vehiclesSTA:
            if v1 != v2:
                v1.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.vehiclesSTA[0].cmd('ifconfig car0STA-eth0 200.0.10.50')

    # Bonding interfaces for car0

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

    # more configuring and routing commands

    car[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.vehiclesSTA[3].cmd('ip route add 200.0.10.2 via 192.168.1.7')
    net.vehiclesSTA[3].cmd('ip route add 200.0.10.100 via 10.0.0.1')
    net.vehiclesSTA[0].cmd('ip route add 200.0.10.2 via 10.0.0.4')

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

    car[0].cmdPrint(
        "xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T 'car0' &")
    #car[3].cmdPrint("xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T 'car3' &")
    client.cmdPrint(
        "xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T 'client' &")
    """plot graph"""
    net.plotGraph(max_x=250, max_y=250)

    net.startGraph()

    # remove previous data
    os.system('rm *.vanetdata')

    # stream video using VLC

    car[0].cmdPrint(
        "vlc -vvv /home/mininet/Desktop/bunnyMob.mp4 --sout '#duplicate{dst=rtp{dst=200.0.10.2,port=5004,mux=ts},dst=display}' :sout-keep &"
    )
    client.cmdPrint("vlc rtp://@200.0.10.2:5004 &")

    # starting positions for cars

    car[0].moveNodeTo('110,100,0')
    car[1].moveNodeTo('80,100,0')
    car[2].moveNodeTo('65,100,0')
    car[3].moveNodeTo('50,100,0')

    # delete all previous flow rules

    #os.system('ovs-ofctl del-flows switch')

    # sleep...

    #time.sleep(3)

    # start experiment, 20 secs for each phase

    apply_experiment(car, client, switch)

    # Uncomment the line below to generate the graph that you implemented
    graphic()

    # kills all the xterms that have been opened
    #os.system('pkill xterm')

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

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

    print "*** Creating nodes"
    car = []
    stas = []
    for x in range(0, 4):
        car.append(x)
        stas.append(x)
    for x in range(0, 4):
        car[x] = net.addCar('car%s' % (x), wlans=2, ip='10.0.0.%s/8' % (x + 1), \
        mac='00:00:00:00:00:0%s' % x, mode='b')

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

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

    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)

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

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

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

    car[0].cmd('modprobe bonding mode=3')
    car[0].cmd('ip link add bond0 type bond')
    car[0].cmd('ip link set bond0 address 02:01:02:03:04:08')
    car[0].cmd('ip link set car0-eth0 down')
    car[0].cmd('ip link set car0-eth0 address 00:00:00:00:00:11')
    car[0].cmd('ip link set car0-eth0 master bond0')
    car[0].cmd('ip link set car0-wlan0 down')
    car[0].cmd('ip link set car0-wlan0 address 00:00:00:00:00:15')
    car[0].cmd('ip link set car0-wlan0 master bond0')
    car[0].cmd('ip link set car0-wlan1 down')
    car[0].cmd('ip link set car0-wlan1 address 00:00:00:00:00:13')
    car[0].cmd('ip link set car0-wlan1 master bond0')
    car[0].cmd('ip addr add 200.0.10.100/24 dev bond0')
    car[0].cmd('ip link set bond0 up')
    """plot graph"""
    net.plotGraph(max_x=250, max_y=250)

    net.startGraph()

    os.system('rm *.data')

    # Uncomment and modify the two commands below to stream video using VLC
    car[0].cmdPrint(
        "vlc -vvv bunnyMob.mp4 --sout '#duplicate{dst=rtp{dst=200.0.10.2,port=5004,,mux=ts},dst=display}' :sout-keep &"
    )
    client.cmdPrint("vlc rtp://@200.0.10.2:5004 &")

    car[0].moveNodeTo('110,100,0')
    car[1].moveNodeTo('80,100,0')
    car[2].moveNodeTo('65,100,0')
    car[3].moveNodeTo('50,100,0')

    os.system('ovs-ofctl del-flows switch')

    time.sleep(3)

    apply_experiment(car, client, switch, net)

    print "*** Generating graphic"
    graphic()

    # kills all the xterms that have been opened
    os.system('pkill xterm')

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

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

    print "*** Creating nodes"
    car = []
    stas = []
    for x in range(0, 4):
        car.append(x)
        stas.append(x)
    for x in range(0, 4):
        car[x] = net.addCar('car%s' % (x), wlans=2, ip='10.0.0.%s/8' % (x + 1), \
        mac='00:00:00:00:00:0%s' % x, mode='b')

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

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

    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, car[0])
    net.addLink(eNodeB2, car[0])
    net.addLink(eNodeB1, car[3])

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

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

    i = 1
    j = 2
    for c in car:
        c.cmd('ifconfig %s-wlan0 192.168.0.%s/24 up' % (c, i))
        c.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (c, i))
        c.cmd('ip route add 10.0.0.0/8 via 192.168.1.%s' % j)
        i += 2
        j += 2

    i = 1
    j = 2
    for v in net.vehiclesSTA:
        v.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (v, j))
        v.cmd('ifconfig %s-mp0 10.0.0.%s/24 up' % (v, i))
        v.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
        i += 1
        j += 2

    for v1 in net.vehiclesSTA:
        i = 1
        j = 1
        for v2 in net.vehiclesSTA:
            if v1 != v2:
                v1.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.vehiclesSTA[0].cmd('ifconfig car0STA-eth0 200.0.10.50')

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

    #connect through the other cars
    car[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.vehiclesSTA[3].cmd('ip route add 200.0.10.2 via 192.168.1.7')
    net.vehiclesSTA[3].cmd('ip route add 200.0.10.100 via 10.0.0.1')
    net.vehiclesSTA[0].cmd('ip route add 200.0.10.2 via 10.0.0.4')

    car[0].cmd('ip route add 10.0.0.4 via 200.0.10.50')
    car[0].cmd('ip route add 192.168.1.7 via 200.0.10.50')
    car[0].cmd('ip route add 200.0.10.2 via 200.0.10.50')
    car[3].cmd('ip route add 200.0.10.100 via 192.168.1.8')
    """plot graph"""
    net.plotGraph(max_x=250, max_y=250)

    net.startGraph()

    # Uncomment and modify the two commands below to stream video using VLC
    # client(ip:200.0.10.2) is streaming and car0(ip:200.0.10.100) is the receiver
    car[0].cmdPrint(
        "vlc -vvv bunnyMob.mp4 --sout '#duplicate{dst=rtp{dst=200.0.10.2,port=5004,mux=ts},dst=display}' :sout-keep &"
    )
    client.cmdPrint("vlc rtp://@200.0.10.2:5004 &")

    car[0].moveNodeTo('95,100,0')
    car[1].moveNodeTo('80,100,0')
    car[2].moveNodeTo('65,100,0')
    car[3].moveNodeTo('50,100,0')

    time.sleep(2)

    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')

    apply_experiment(car, client, switch)

    # Uncomment the line below to generate the graph that you implemented

    graphic1()  #total packets transmited,throughtput (through ifconfig)

    graphic2()  #packets dropped (through ifconfig)

    #graphic3()    #bandwidth (through iperf)

    #graphic4()    #jitter (through iperf)

    graphic5()  #latency (through ping)

    # kills all the xterms that have been opened
    os.system('pkill xterm')

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

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

    taskTime = 20

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

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

    eNodeB1 = net.addAccessPoint('eNodeB1',
                                 ssid='eNodeB1',
                                 dpid='1000000000000000',
                                 mode='ac',
                                 channel='1',
                                 position='80,75,0')
    eNodeB2 = net.addAccessPoint('eNodeB2',
                                 ssid='eNodeB2',
                                 dpid='2000000000000000',
                                 mode='ac',
                                 channel='6',
                                 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')

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

    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, car[0])
    net.addLink(eNodeB2, car[0])
    net.addLink(eNodeB1, car[3])

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

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

    i = 1
    j = 2
    for c in car:
        c.cmd('ifconfig %s-wlan0 192.168.0.%s/24 up' % (c, i))
        c.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (c, i))
        c.cmd('ip route add 10.0.0.0/8 via 192.168.1.%s' % j)
        i += 2
        j += 2

    i = 1
    j = 2
    for v in net.vehiclesSTA:
        v.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (v, j))
        v.cmd('ifconfig %s-mp0 10.0.0.%s/24 up' % (v, i))
        v.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
        i += 1
        j += 2

    for v1 in net.vehiclesSTA:
        i = 1
        j = 1
        for v2 in net.vehiclesSTA:
            if v1 != v2:
                v1.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.vehiclesSTA[3].cmd('ifconfig car3STA-eth1 200.0.10.1')
    net.vehiclesSTA[0].cmd('ifconfig car0STA-eth0 200.0.10.50')

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

    car[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.vehiclesSTA[3].cmd('ip route add 200.0.10.2 via 192.168.1.7')
    net.vehiclesSTA[3].cmd('ip route add 200.0.10.100 via 10.0.0.1')
    net.vehiclesSTA[0].cmd('ip route add 200.0.10.2 via 10.0.0.4')

    car[0].cmd('ip route add 10.0.0.4 via 200.0.10.50')
    car[0].cmd('ip route add 192.168.1.7 via 200.0.10.50')
    car[0].cmd('ip route add 200.0.10.2 via 200.0.10.50')
    car[3].cmd('ip route add 200.0.10.100 via 192.168.1.8')
    """uncomment to plot graph"""
    net.plotGraph(max_x=250, max_y=250)

    net.startGraph()

    os.system('rm *.vanetdata')

    #os.system('xterm -hold -title "car0" -e "util/m car0 ping 200.0.10.2" &')
    car[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')

    car[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')

    timeout = time.time() + taskTime
    currentTime = time.time()
    i = 0
    while True:
        if time.time() > timeout:
            break
        if time.time() - currentTime >= i:
            car[0].cmd(
                'ifconfig bond0 | grep \"TX packets\" | awk -F\' \' \'{print $3}\' >> %s'
                % c0_pkt)
            client.cmd(
                'ifconfig client-eth0 | grep \"RX packets\" | awk -F\' \' \'{print $3}\' >> %s'
                % switch_pkt)
            car[0].cmd(
                'ifconfig bond0 | grep \"bytes\" | awk -F\' \' \'NR==2{print $5}\' >> %s'
                % c0_throughput)
            client.cmd(
                'ifconfig client-eth0 | grep \"bytes\" | awk -F\' \' \'NR==1{print $5}\' >> %s'
                % switch_throughput)
            i += 0.5

    print "Moving nodes"
    car[0].moveNodeTo('150,100,0')
    car[1].moveNodeTo('120,100,0')
    car[2].moveNodeTo('90,100,0')
    car[3].moveNodeTo('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')

    car[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:
            car[0].cmd(
                'ifconfig bond0 | grep \"TX packets\" | awk -F\' \' \'{print $3}\' >> %s'
                % c0_pkt)
            client.cmd(
                'ifconfig client-eth0 | grep \"RX packets\" | awk -F\' \' \'{print $3}\' >> %s'
                % switch_pkt)
            car[0].cmd(
                'ifconfig bond0 | grep \"bytes\" | awk -F\' \' \'NR==2{print $5}\' >> %s'
                % c0_throughput)
            client.cmd(
                'ifconfig client-eth0 | grep \"bytes\" | awk -F\' \' \'NR==1{print $5}\' >> %s'
                % switch_throughput)
            i += 0.5

    print "Moving nodes"
    car[0].moveNodeTo('190,100,0')
    car[1].moveNodeTo('150,100,0')
    car[2].moveNodeTo('120,100,0')
    car[3].moveNodeTo('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:
            car[0].cmd(
                'ifconfig bond0 | grep \"TX packets\" | awk -F\' \' \'{print $3}\' >> %s'
                % c0_pkt)
            client.cmd(
                'ifconfig client-eth0 | grep \"RX packets\" | awk -F\' \' \'{print $3}\' >> %s'
                % switch_pkt)
            car[0].cmd(
                'ifconfig bond0 | grep \"bytes\" | awk -F\' \' \'NR==2{print $5}\' >> %s'
                % c0_throughput)
            client.cmd(
                'ifconfig client-eth0 | grep \"bytes\" | awk -F\' \' \'NR==1{print $5}\' >> %s'
                % switch_throughput)
            i += 0.5

    print "*** Generating graphic"
    graphic()

    os.system('pkill xterm')

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

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

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

    print "*** Creating nodes"
    car = []
    stas = []
    for x in range(0, 4):
        car.append(x)
        stas.append(x)
    for x in range(0, 4):
        car[x] = net.addCar('car%s' % (x), wlans=2, ip='10.0.0.%s/8' % (x + 1), \
        mac='00:00:00:00:00:0%s' % x, mode='b')

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

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

    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)

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

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

    i = 1
    j = 2
    for c in car:
        c.cmd('ifconfig %s-wlan0 192.168.0.%s/24 up' % (c, i))
        c.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (c, i))
        c.cmd('ip route add 10.0.0.0/8 via 192.168.1.%s' % j)
        i += 2
        j += 2

    i = 1
    j = 2
    for v in net.vehiclesSTA:
        v.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (v, j))
        v.cmd('ifconfig %s-mp0 10.0.0.%s/24 up' % (v, i))
        v.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
        i += 1
        j += 2

    for v1 in net.vehiclesSTA:
        i = 1
        j = 1
        for v2 in net.vehiclesSTA:
            if v1 != v2:
                v1.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.vehiclesSTA[0].cmd('ifconfig car0STA-eth0 200.0.10.50')

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

    car[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.vehiclesSTA[3].cmd('ip route add 200.0.10.2 via 192.168.1.7')
    net.vehiclesSTA[3].cmd('ip route add 200.0.10.100 via 10.0.0.1')
    net.vehiclesSTA[0].cmd('ip route add 200.0.10.2 via 10.0.0.4')

    car[0].cmd('ip route add 10.0.0.4 via 200.0.10.50')
    car[0].cmd('ip route add 192.168.1.7 via 200.0.10.50')
    car[0].cmd('ip route add 200.0.10.2 via 200.0.10.50')
    car[3].cmd('ip route add 200.0.10.100 via 192.168.1.8')
    """plot graph"""
    net.plotGraph(max_x=250, max_y=250)

    net.startGraph()

    # Uncomment and modify the two commands below to stream video using VLC
    car[0].cmdPrint(
        "cvlc -vvv bwcLow.mp4 --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 &")

    car[0].moveNodeTo('95,100,0')
    car[1].moveNodeTo('80,100,0')
    car[2].moveNodeTo('65,100,0')
    car[3].moveNodeTo('50,100,0')

    os.system('ovs-ofctl del-flows switch')

    time.sleep(3)

    apply_experiment(car, client, switch, net)

    # Uncomment the line below to generate the graph that you implemented
    graphic()

    # kills all the xterms that have been opened
    #os.system('pkill xterm')

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

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

    print "*** Creating nodes"
    car = []
    for x in range(0, 4):
        car.append(x)
    for x in range(0, 4):
        car[x] = net.addCar('car%s' % (x), wlans=2, ip='10.0.0.%s/8' % (x + 1), \
        mac='00:00:00:00:00:0%s' % x, mode='b')

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

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

    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)

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

    i = 1
    j = 2
    for c in car:
        c.cmd('ifconfig %s-wlan0 192.168.0.%s/24 up' % (c, i))
        c.cmd('ifconfig %s-wlan1 192.168.1.%s/24 up' % (c, i))
        i += 2
        j += 2

    print "\n"
    client.cmd('ifconfig client-eth0 200.0.10.2')

    car[0].cmd('modprobe bonding mode=3')
    car[0].cmd('ip link add bond0 type bond')
    car[0].cmd('ip link set bond0 address 02:01:02:03:04:08')
    car[0].cmd('ip link set car0-wlan0 down')
    car[0].cmd('ip link set car0-wlan0 address 00:00:00:00:00:15')
    car[0].cmd('ip link set car0-wlan0 master bond0')
    car[0].cmd('ip link set car0-wlan1 down')
    car[0].cmd('ip link set car0-wlan1 address 00:00:00:00:00:13')
    car[0].cmd('ip link set car0-wlan1 master bond0')
    car[0].cmd('ip addr add 200.0.10.100/24 dev bond0')
    car[0].cmd('ip link set bond0 up')
    """plot graph"""
    net.plotGraph(max_x=250, max_y=250)

    net.startGraph()
    # streaming video
    car[0].cmdPrint(
        "vlc -vvv ./bunnyMob.mp4 --sout '#duplicate{dst=rtp{dst=200.0.10.2,port=5004,mux=ts},dst=display}' :sout-keep --meta-title 'car0' &"
    )
    client.cmdPrint("vlc rtp://@200.0.10.2:5004 --meta-title 'client' &")

    car[0].moveNodeTo('110,100,0')
    car[1].moveNodeTo('80,100,0')
    car[2].moveNodeTo('65,100,0')
    car[3].moveNodeTo('50,100,0')
    car[0].cmd('ip route add 200.0.10.2 via 200.0.10.100')

    apply_experiment(car, client, switch)

    # Uncomment the line below to generate the graph that you implemented
    graphic()

    # kills all the xterms that have been opened
    #--------------------- os.system('pkill xterm')

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

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

    print "*** Creating nodes"
    car = []
    car.append(0)
    car[0] = net.addCar('car0',
                        wlans=2,
                        ip='10.0.0.1/8',
                        mac='00:00:00:00:00:00',
                        mode='b')

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

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

    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)

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

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

    client.cmd('ifconfig client-eth0 200.0.10.2')

    # Broadcast policy: transmits everything on all slave interfaces. This mode provides fault tolerance.
    car[0].cmd('modprobe bonding mode=3')
    # Network device configuration, bonding car phisical architecture into one interface
    car[0].cmd('ip link add bond0 type bond')
    car[0].cmd('ip link set bond0 address 02:01:02:03:04:08')
    car[0].cmd('ip link set car0-eth0 down')
    car[0].cmd('ip link set car0-eth0 address 00:00:00:00:00:11')
    car[0].cmd('ip link set car0-eth0 master bond0')
    car[0].cmd('ip link set car0-wlan0 down')
    car[0].cmd('ip link set car0-wlan0 address 00:00:00:00:00:15')
    car[0].cmd('ip link set car0-wlan0 master bond0')
    car[0].cmd('ip link set car0-wlan1 down')
    car[0].cmd('ip link set car0-wlan1 address 00:00:00:00:00:13')
    car[0].cmd('ip link set car0-wlan1 master bond0')
    car[0].cmd('ip addr add 200.0.10.100/24 dev bond0')
    car[0].cmd('ip link set bond0 up')
    """plot graph"""
    net.plotGraph(max_x=250, max_y=250)

    net.startGraph()

    # Uncomment and modify the two commands below to stream video using VLC
    # car[0].cmdPrint(
    #    "vlc -vvv bunnyMob.mp4 --sout '#duplicate{dst=rtp{dst=200.0.10.2,port=5004,mux=ts},dst=display}' :sout-keep &")
    #client.cmdPrint("vlc rtp://@200.0.10.2:5004 &")

    car[0].moveNodeTo('95,100,0')

    os.system('ovs-ofctl del-flows switch')

    time.sleep(3)

    apply_experiment(car, client, switch)

    # Uncomment the line below to generate the graph that you implemented
    # graphic()

    # kills all the xterms that have been opened
    os.system('pkill xterm')

    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,
                  accessPoint=OVSKernelAP)
    global gnet
    gnet = net

    print "*** Creating nodes"
    car = []
    stas = []
    for x in range(0, 4):
        car.append(x)
        stas.append(x)
    for x in range(0, 4):
        car[x] = net.addCar('car%s' % (x), wlans=2, ip='10.0.0.%s/8' % (x + 1), \
        mac='00:00:00:00:00:0%s' % x, mode='b')

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

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

    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)

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

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

    i = 1
    j = 2
    for c in car:
        c.cmd('ifconfig %s-wlan0 192.168.0.%s/24 up' % (c, i))
        c.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (c, i))
        c.cmd('ip route add 10.0.0.0/8 via 192.168.1.%s' % j)
        i += 2
        j += 2

    i = 1
    j = 2
    for v in net.vehiclesSTA:
        v.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (v, j))
        v.cmd('ifconfig %s-mp0 10.0.0.%s/24 up' % (v, i))
        v.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
        i += 1
        j += 2

    for v1 in net.vehiclesSTA:
        i = 1
        j = 1
        for v2 in net.vehiclesSTA:
            if v1 != v2:
                v1.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')

    car[0].cmd('ifconfig car0-wlan0 200.0.10.150')
    car[0].cmd('ifconfig car0-wlan1 200.0.10.100')

    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.vehiclesSTA[0].cmd('ip route add 200.0.10.100 via 10.0.0.1')
    net.vehiclesSTA[0].cmd('ip route add 200.0.10.2 via 10.0.0.1')

    car[0].cmd('ip route add 200.0.10.2 via 200.0.10.150')
    car[0].cmd('ip route add 200.0.10.100 via 192.168.1.2')
    #car[0].cmd('ip route add 200.0.10.2 via 200.0.10.100')
    """plot graph"""
    net.plotGraph(max_x=250, max_y=250)

    net.startGraph()

    # Uncomment and modify the two commands below to stream video using VLC
    car[0].cmdPrint(
        "vlc -vvv bunnyMob.mp4 --sout '#duplicate{dst=rtp{dst=200.0.10.2,port=5004,mux=ts},dst=display}' :sout-keep &"
    )
    client.cmdPrint("vlc rtp://@200.0.10.2:5004 &")

    car[0].moveNodeTo('95,100,0')
    car[1].moveNodeTo('80,100,0')
    car[2].moveNodeTo('65,100,0')
    car[3].moveNodeTo('50,100,0')

    os.system('ovs-ofctl del-flows switch')

    time.sleep(3)

    apply_experiment(car, client, switch)

    # Uncomment the line below to generate the graph that you implemented
    graphic()

    # kills all the xterms that have been opened
    os.system('pkill xterm')

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

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

	print "*** Creating nodes"
	car = []
	stas = []
	for x in range(0, 4):
		car.append(x)
		stas.append(x)
	for x in range(0, 4):
		car[x] = net.addCar('car%s' % (x), wlans=2, ip='10.0.0.%s/8' % (x + 1), \
		mac='00:00:00:00:00:0%s' % x, mode='b')
    
	eNodeB1 = net.addAccessPoint('eNodeB1', ssid='eNodeB1', dpid='1000000000000000', mode='ac', channel='1', position='80,75,0', range=60)
	eNodeB2 = net.addAccessPoint('eNodeB2', ssid='eNodeB2', dpid='2000000000000000', mode='ac', channel='6', position='180,75,0', range=70)
	rsu1 = net.addAccessPoint('rsu1', ssid='rsu1', dpid='3000000000000000', mode='g', channel='11', position='140,120,0', range=40)
	c1 = net.addController('c1', controller=Controller)
	client = net.addHost ('client')
	switch = net.addSwitch ('switch', dpid='4000000000000000')

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

	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)

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

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

	i = 1
	j = 2
	for c in car:
		c.cmd('ifconfig %s-wlan0 192.168.0.%s/24 up' % (c, i))
		c.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (c, i))
		c.cmd('ip route add 10.0.0.0/8 via 192.168.1.%s' % j)
		i += 2
		j += 2

	i = 1
	j = 2
	for v in net.vehiclesSTA:
		v.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (v, j))
		v.cmd('ifconfig %s-mp0 10.0.0.%s/24 up' % (v, i))
		v.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
		i += 1
		j += 2

	for v1 in net.vehiclesSTA:
		i = 1
		j = 1
		for v2 in net.vehiclesSTA:
			if v1 != v2:
				v1.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.vehiclesSTA[0].cmd('ifconfig car0STA-eth0 200.0.10.50')

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

	car[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.vehiclesSTA[3].cmd('ip route add 200.0.10.2 via 192.168.1.7')
	net.vehiclesSTA[3].cmd('ip route add 200.0.10.100 via 10.0.0.1')
	net.vehiclesSTA[0].cmd('ip route add 200.0.10.2 via 10.0.0.4')

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

	"""plot graph"""
	net.plotGraph(max_x=250, max_y=250)

	net.startGraph()

	# STREAMING commands
	car[0].cmdPrint("cvlc -vvv bunnyMob.mp4 --sout '#duplicate{dst=rtp{dst=200.0.10.2,port=5004,mux=ts},dst=display}' :sout-keep &")
	car[0].cmdPrint("echo $!") # PID of latest bg process
	client.cmdPrint("cvlc rtp://200.0.10.2:5004/bunnyMob.mp4 &")
	client.cmdPrint("echo $!")

	car[0].moveNodeTo('95,100,0')
	car[1].moveNodeTo('80,100,0')
	car[2].moveNodeTo('65,100,0')
	car[3].moveNodeTo('50,100,0')

	os.system('ovs-ofctl del-flows switch')

	time.sleep(3)

	#apply_experiment(car,client,switch,net) # DOKIMH XWRIS FUNCTION
	time.sleep(2)
	print "Applying first phase"
	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')

	car[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')
	#me aftes edw tis entoles pane ta mhnymata #gia kapoio logo de tis dexetai mesa apo python 
	#client.cmd('ip route add 200.0.10.100 via 200.0.10.2')
	#car[0].cmd('ip route add 200.0.10.2 via 200.0.10.100')

	CLI(net)#kanw xterm client ,car0 kai tis prosthetw

	#ifconfig output gathering
	#~ t_end = time.time() + 21 #gia 20 seconds 
	#~ print time.time()
	print "ifonfig output gathering"
	t_simulation = 0
	while t_simulation < 20:
		car[0].cmd('ifconfig bond0 | grep \"TX packets\" >> %s' % packets_t_car0)
		car[0].cmd('ifconfig bond0 | grep \"TX bytes\" >> %s' % bytes_t_car0)
		car[3].cmd('ifconfig car3-eth0 | grep \"RX packets\" >> %s' % packets_r_car3)
		car[3].cmd('ifconfig car3-eth0 | grep \"RX bytes\" >> %s' % bytes_r_car3)

		car[3].cmd('ifconfig car3-wlan0 | grep \"TX packets\" >> %s' % packets_t_car3)
		car[3].cmd('ifconfig car3-wlan0 | grep \"TX bytes\" >> %s' % bytes_t_car3)
		client.cmd('ifconfig client-eth0 | grep \"RX packets\" >> %s' % packets_r_client)
		client.cmd('ifconfig client-eth0 | grep \"RX bytes\" >> %s' % bytes_r_client)
		time.sleep(1)
		t_simulation=t_simulation+1    

	#iperf output gathering
	client.cmdPrint('iperf -s -u -i 1 > %s &' % iperf_out_srv)
	car[0].cmdPrint('iperf -u -i 1 -t 20 -c 200.0.10.2')
	#client.cmdPrint('sudo kill -9 $!') #skotwnw th diergasia tou iperf ston client
	
	#ping output gathering
	#~ car[3].cmd('ping -t 1 -c 20 200.0.10.100 > %s' % ping_v2v) #ping sto car3->car0
	#~ car[3].cmd('ping -t 1 -c 20 200.0.10.2 > %s' % ping_v2i) #ping sto car3->client
	car[0].cmd('ping -t 1 -c 20 200.0.10.2 > %s' % car0_pings_client)
	client.cmd('ping -t 1 -c 20 200.0.10.100 > %s' % client_pings_car0)
    
	graphic1()
	print "xterm client -> sudo kill -9 <client_iperf_bg_process_PID>"
	CLI(net)

	#end of phase 1 
	print "Moving nodes"
	car[0].moveNodeTo('150,100,0')
	car[1].moveNodeTo('120,100,0')
	car[2].moveNodeTo('90,100,0')
	car[3].moveNodeTo('70,100,0')

	time.sleep(2)
	print "Applying second phase"

	os.system('ovs-ofctl del-flows switch')
	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 mod-flows switch in_port=3,actions=output:4')
	os.system('ovs-ofctl mod-flows switch in_port=4,actions=output:3')

	#~ mallon prepei ksana xterm client car0 kai tis parakatw
	#~ client.cmd('route add -host 200.0.10.100 gw 200.0.10.2')
	#~ car[0].cmd('route add -host 200.0.10.2 gw 200.0.10.100')
	#~ telika tis eixe akomh perasmenes apo to prohgoumeno xterm client car0

	print "ifonfig output gathering"
	t_simulation = 0
	while t_simulation < 20:
		car[0].cmd('ifconfig bond0 | grep \"TX packets\" >> %s' % packets2_t_car0)
		car[0].cmd('ifconfig bond0 | grep \"TX bytes\" >> %s' % bytes2_t_car0)
		client.cmd('ifconfig client-eth0 | grep \"RX packets\" >> %s' % packets2_r_client)
		client.cmd('ifconfig client-eth0 | grep \"RX bytes\" >> %s' % bytes2_r_client)
		time.sleep(1)
		t_simulation=t_simulation+1    

	print 'iperf output gathering'
	#CLI(net)
	client.cmdPrint('iperf -s -u -i 1 > %s &' % iperf2_out_srv)
	car[0].cmdPrint('iperf -u -i 1 -t 20 -c 200.0.10.2')
	#client.cmdPrint('sudo kill -9 $!') #skotwnw th diergasia tou iperf ston client
	
	print 'ping output gathering'
	#~ car[3].cmd('ping -t 1 -c 20 200.0.10.100 > %s' % ping_v2v) #ping sto car3->car0
	#~ car[3].cmd('ping -t 1 -c 20 200.0.10.2 > %s' % ping_v2i) #ping sto car3->client
	car[0].cmd('ping -t 1 -c 20 200.0.10.2 > %s' % car0_pings2_client)
	client.cmd('ping -t 1 -c 20 200.0.10.100 > %s' % client_pings2_car0)
	

	graphic2()
	time.sleep(2)
    #################################################################################
    
	print "Moving nodes"
	car[0].moveNodeTo('190,100,0')
	car[1].moveNodeTo('150,100,0')
	car[2].moveNodeTo('120,100,0')
	car[3].moveNodeTo('90,100,0')

	time.sleep(2)
	print "Applying third phase"
    
    ################################################################################ 
    #   1) Add the flow rules below and routing commands if needed
	os.system('ovs-ofctl del-flows switch')
	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')

    #   2) Calculate Network Measurements using IPerf or command line tools(ifconfig)
    #       Hint: Remember that you can insert commands via the mininet
    #       Example: car[0].cmd('ifconfig bond0 | grep \"TX packets\" >> %s' % output.data)
	print "*** CLI 3 *** -- check if streaming is happening(eNodeB2 only) (car0 ping client)"
	print "ifonfig output gathering"
	t_simulation = 0
	while t_simulation < 20:
		car[0].cmd('ifconfig bond0 | grep \"TX packets\" >> %s' % packets3_t_car0)
		car[0].cmd('ifconfig bond0 | grep \"TX bytes\" >> %s' % bytes3_t_car0)
		client.cmd('ifconfig client-eth0 | grep \"RX packets\" >> %s' % packets3_r_client)
		client.cmd('ifconfig client-eth0 | grep \"RX bytes\" >> %s' % bytes3_r_client)
		time.sleep(1)
		t_simulation=t_simulation+1    

	print 'iperf output gathering'
	CLI(net)
	client.cmdPrint('iperf -s -u -i 1 > %s &' % iperf3_out_srv)
	car[0].cmdPrint('iperf -u -i 1 -t 20 -c 200.0.10.2')
	#client.cmdPrint('sudo kill -9 $!') #skotwnw th diergasia tou iperf ston client
	
	print 'ping output gathering'
	#~ car[3].cmd('ping -t 1 -c 20 200.0.10.100 > %s' % ping_v2v) #ping sto car3->car0
	#~ car[3].cmd('ping -t 1 -c 20 200.0.10.2 > %s' % ping_v2i) #ping sto car3->client
	car[0].cmd('ping -t 1 -c 20 200.0.10.2 > %s' % car0_pings3_client)
	client.cmd('ping -t 1 -c 20 200.0.10.100 > %s' % client_pings3_car0)

    # Uncomment the line below to generate the graph that you implemented
	graphic3()
#	time.sleep(5) #na prolavei na fortwsei ta figures
    # kills all the xterms that have been opened
#    os.system('pkill xterm')

#    print "*** Running CLI"
	print "last CLI before closing"
	CLI(net)

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