def topology():

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

    print "*** Creating nodes"
    car = []
    stas = []
    for x in range(0, 10):
        car.append(x)
        stas.append(x)
    for x in range(0, 10):
        car[x] = net.addCar('car%s' % (x),
                            wlans=1,
                            ip='10.0.0.%s/8' % (x + 1),
                            mode='b',
                            max_x=40,
                            max_y=40,
                            range=1000)

    rsu10 = net.addAccessPoint('rsu10',
                               ssid='rsu10',
                               mode='g',
                               channel='1',
                               position='3500,2500,0',
                               range=500)
    rsu11 = net.addAccessPoint('rsu11',
                               ssid='rsu11',
                               mode='g',
                               channel='6',
                               position='3000,2500,0',
                               range=500)
    rsu12 = net.addAccessPoint('rsu12',
                               ssid='rsu12',
                               mode='g',
                               channel='11',
                               position='2500,3000,0',
                               range=500)
    rsu13 = net.addAccessPoint('rsu13',
                               ssid='rsu13',
                               mode='g',
                               channel='11',
                               position='4000,3000,0',
                               range=500)
    rsu14 = net.addAccessPoint('rsu14',
                               ssid='rsu14',
                               mode='g',
                               channel='11',
                               position='4500,3000,0',
                               range=500)
    c1 = net.addController('c1',
                           controller=Controller,
                           ip='127.0.0.1',
                           port=6633)

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

    net.meshRouting('custom')

    net.addLink(rsu10, rsu11)
    net.addLink(rsu11, rsu12)
    net.addLink(rsu12, rsu13)
    net.addLink(rsu13, rsu14)
    """Available Options: sumo, sumo-gui"""
    # Put your sumocfg file in /mininet/sumo/data
    net.useExternalProgram('sumo-gui', config_file='map.sumocfg')

    print "*** Starting network"
    net.build()
    c1.start()
    rsu10.start([c1])
    rsu11.start([c1])
    rsu12.start([c1])
    rsu13.start([c1])
    rsu14.start([c1])
    i = 201
    for sw in net.vehicles:
        sw.start([c1])
        os.system('ifconfig %s 10.0.0.%s' % (sw, i))
        i += 1

    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

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

    print "*** Stopping network"
    net.stop()
Example #4
0
def topology():
    "Create a network."
    net = Mininet(controller=Controller, switch=OVSKernelSwitch,
                  enable_wmediumd=True, enable_interference=True)
   
    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))
    
    e1 = net.addAccessPoint('e1', ssid='vanet-ssid', mac='00:00:00:11:00:01',
                            mode='g', channel='1', passwd='123456789a',
                            encrypt='wpa2', position='1127.02,513.27,0')
    e2 = net.addAccessPoint('e2', ssid='vanet-ssid', mac='00:00:00:11:00:02',
                            mode='g', channel='6', passwd='123456789a',
                            encrypt='wpa2', position='1024.82,469.75,0')
    e3 = net.addAccessPoint('e3', ssid='vanet-ssid', mac='00:00:00:11:00:03',
                            mode='g', channel='11', passwd='123456789a',
                            encrypt='wpa2', position='914.42,299.22,0')
    e4 = net.addAccessPoint('e4', ssid='vanet-ssid', mac='00:00:00:11:00:04',
                            mode='g', channel='1', passwd='123456789a',
                            encrypt='wpa2', position='1165.62,345.92,0')
    e5 = net.addAccessPoint('e5', ssid='vanet-ssid', mac='00:00:00:11:00:05',
                            mode='g', channel='6', passwd='123456789a',
                            encrypt='wpa2', position='1159.62,151.61,0')
    e6 = net.addAccessPoint('e6', ssid='vanet-ssid', mac='00:00:00:11:00:06',
                            mode='g', channel='11', passwd='123456789a',
                            encrypt='wpa2', position='1363.68,337.40,0')


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

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

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

    print "*** add links"
    net.addLink(e1, e2)
    net.addLink(e2, e3)
    net.addLink(e3, e4)
    net.addLink(e4, e5)
    net.addLink(e5, e6)

    print "*** Starting SUMO"
    net.useExternalProgram('sumo-gui', config_file='ucla.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('ip addr add 10.0.0.%s dev %s' % (i, sw))
        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

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

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

    "Create a network."
    net = Mininet(controller=Controller,
                  link=TCLink,
                  accessPoint=UserAP,
                  enable_wmediumd=True,
                  enable_interference=True)

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

    e1 = net.addAccessPoint('e1',
                            ssid='vanet-ssid',
                            mac='00:00:00:11:00:01',
                            mode='g',
                            channel='1',
                            passwd='123456789a',
                            encrypt='wpa2',
                            position='3279.02,3736.27,0')
    e2 = net.addAccessPoint('e2',
                            ssid='vanet-ssid',
                            mac='00:00:00:11:00:02',
                            mode='g',
                            channel='6',
                            passwd='123456789a',
                            encrypt='wpa2',
                            position='2320.82,3565.75,0')
    e3 = net.addAccessPoint('e3',
                            ssid='vanet-ssid',
                            mac='00:00:00:11:00:03',
                            mode='g',
                            channel='11',
                            passwd='123456789a',
                            encrypt='wpa2',
                            position='2806.42,3395.22,0')
    e4 = net.addAccessPoint('e4',
                            ssid='vanet-ssid',
                            mac='00:00:00:11:00:04',
                            mode='g',
                            channel='1',
                            passwd='123456789a',
                            encrypt='wpa2',
                            position='3332.62,3253.92,0')
    e5 = net.addAccessPoint('e5',
                            ssid='vanet-ssid',
                            mac='00:00:00:11:00:05',
                            mode='g',
                            channel='6',
                            passwd='123456789a',
                            encrypt='wpa2',
                            position='2887.62,2935.61,0')
    e6 = net.addAccessPoint('e6',
                            ssid='vanet-ssid',
                            mac='00:00:00:11:00:06',
                            mode='g',
                            channel='11',
                            passwd='123456789a',
                            encrypt='wpa2',
                            position='2351.68,3083.40,0')
    c1 = net.addController('c1',
                           controller=Controller,
                           ip='127.0.0.1',
                           port=6653)

    net.propagationModel("logDistancePropagationLossModel", exp=2.5)

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

    print "*** Configuring Propagation Model"
    net.propagationModel("logDistancePropagationLossModel", exp=2)

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

    net.addLink(e1, e2)
    net.addLink(e2, e3)
    net.addLink(e3, e4)
    net.addLink(e4, e5)
    net.addLink(e5, e6)

    "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.cmd('ifconfig %s-wlan0 192.168.0.%s/24 up' % (car, i))
        car.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (car, i))
        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 v in net.carsSTA:
        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.carsSTA:
        i = 1
        j = 1
        for v2 in net.carsSTA:
            if v1 != v2:
                v1.cmd('route add -host 192.168.1.%s gw 10.0.0.%s' % (j, i))
            i += 1
            j += 2

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

    print "*** Stopping network"
    net.stop()
Example #6
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 = raw_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(controller=Vanet_controller,
                  link=TCLink,
                  accessPoint=UserAP,
                  switch=SD_Car_Switch,
                  station=SD_station,
                  enable_wmediumd=True,
                  enable_interference=True)

    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),
                             cls=car_type)

    e1 = net.addAccessPoint('e1',
                            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)
    e2 = net.addAccessPoint('e2',
                            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)
    e3 = net.addAccessPoint('e3',
                            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)
    e4 = net.addAccessPoint('e4',
                            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)
    e5 = net.addAccessPoint('e5',
                            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)
    e6 = net.addAccessPoint('e6',
                            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)

    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)
    net.propagationModel("logDistancePropagationLossModel", 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)

    "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.cmd('ifconfig %s-wlan0 192.168.0.%s/24 up' % (car, i))
        car.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (car, i))
        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 v in net.carsSTA:
        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.carsSTA:
        i = 1
        j = 1
        for v2 in net.carsSTA:
            if v1 != v2:
                v1.cmd('route add -host 192.168.1.%s gw 10.0.0.%s' % (j, i))
            i += 1
            j += 2

    c1.Initialize_resources(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(net)

    print "*** Stopping network"
    net.stop()
Example #7
0
def topology():
    "Create a network."
    net = Mininet(controller=None, accessPoint=UserAP,
                  enable_wmediumd=True, enable_interference=True)
    
    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))
    
    ap1 = net.addAccessPoint('ap1', ssid='vanet-ssid',
                            mode='g', channel='1', position='1127.02,513.27,0', range='40')
    ap2 = net.addAccessPoint('ap2', ssid='vanet-ssid',
                            mode='g', channel='6', position='1024.82,469.75,0', range='40')
    ap3 = net.addAccessPoint('ap3', ssid='vanet-ssid',
                            mode='g', channel='11', position='914.42,299.22,0', range='40')
    ap4 = net.addAccessPoint('ap4', ssid='vanet-ssid',
                            mode='g', channel='1', position='1165.62,345.92,0', range='40')
    ap5 = net.addAccessPoint('ap5', ssid='vanet-ssid',
                            mode='g', channel='6', position='1159.62,151.61,0', range='40')
    ap6 = net.addAccessPoint('ap6', ssid='vanet-ssid',
                            mode='g', channel='11', position='1363.68,337.40,0', range='40')


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

    h1 = net.addHost('h1', mac='00:00:00:11:00:01', ip='10.0.0.1/8')

    s1 = net.addSwitch('s1', mac='00:00:00:00:00:01')
    s2 = net.addSwitch('s2', mac='00:00:00:00:00:02')
    s3 = net.addSwitch('s3', mac='00:00:00:00:00:03')
    s4 = net.addSwitch('s4', mac='00:00:00:00:00:04')
    lte = net.addSwitch('s10', mac='00:00:00:00:00:10')

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

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

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

    print "*** Add Wifi links"
    net.addLink(s1, h1)
    net.addLink(s2,s1, bw=10, delay='5ms', loss=2, use_htb=True)
    net.addLink(s3,s1, bw=10, delay='10ms', loss=1, use_htb=True)
    net.addLink(s4,s1, bw=10, delay='10ms', loss=1, use_htb=True)

    net.addLink(ap1, s2)
    net.addLink(ap2, s3)
    net.addLink(ap3, s4)

    print "*** Add LTE links"
    for x in range(0, 10):
        net.addLink(lte,'car%s' % (x))
    net.addLink(lte,s1,bw=10, delay='50ms', loss=1, use_htb=True)

    print "*** Starting SUMO"
    net.useExternalProgram('sumo-gui', config_file='ucla.sumocfg')

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