コード例 #1
0
 def testDefaultDpid(self):
     """Verify that the default dpid is assigned using a valid provided
     canonical apname if no dpid is passed in ap creation."""
     ap = Mininet_wifi(
         topo=Topo_WiFi(),
         accessPoint=self.accessPointClass,
         station=Station,
         controller=Controller,
     ).addAccessPoint('ap1')
     self.assertEqual(ap.defaultDpid(), ap.dpid)
コード例 #2
0
 def testActualDpidAssignment(self):
     """Verify that AP dpid is the actual dpid assigned if dpid is
     passed in ap creation."""
     dpid = self.dpidFrom(0xABCD)
     ap = Mininet_wifi(
         topo=Topo_WiFi(),
         accessPoint=self.accessPointClass,
         station=Station,
         controller=Controller,
     ).addAccessPoint('ap1', dpid=dpid)
     self.assertEqual(ap.dpid[1:], dpid)
コード例 #3
0
    def testDefaultDpidLen(self):
        """Verify that Default dpid length is 16 characters consisting of
        16 - len(hex of first string of contiguous digits passed in ap
        name) 0's followed by hex of first string of contiguous digits passed
        in ap name."""
        ap = Mininet_wifi(
            topo=Topo_WiFi(),
            accessPoint=self.accessPointClass,
            station=Station,
            controller=Controller,
        ).addAccessPoint('ap123')

        self.assertEqual(ap.dpid, self.dpidFrom(123))
コード例 #4
0
ファイル: simplewifi25.py プロジェクト: izacarias/ace4sdn
def topology(nodes, rep):
    "Create a network."
    net = Mininet_wifi(controller=Controller, accessPoint=OVSKernelAP)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1')
    sta2 = net.addStation('sta2')
    sta3 = net.addStation('sta3')
    sta4 = net.addStation('sta4')
    sta5 = net.addStation('sta5')
    sta6 = net.addStation('sta6')
    sta7 = net.addStation('sta7')
    sta8 = net.addStation('sta8')
    sta9 = net.addStation('sta9')
    sta10 = net.addStation('sta10')
    sta11 = net.addStation('sta11')
    sta12 = net.addStation('sta12')
    sta13 = net.addStation('sta13')
    sta14 = net.addStation('sta14')
    sta15 = net.addStation('sta15')
    sta16 = net.addStation('sta16')
    sta17 = net.addStation('sta17')
    sta18 = net.addStation('sta18')
    sta19 = net.addStation('sta19')
    sta20 = net.addStation('sta20')
    sta21 = net.addStation('sta21')
    sta22 = net.addStation('sta22')
    sta23 = net.addStation('sta23')
    sta24 = net.addStation('sta24')
    sta25 = net.addStation('sta25')

    h1 = net.addHost('h1')
    h2 = net.addHost('h2')

    ap1 = net.addAccessPoint('ap1', ssid="simplewifi", mode="g", channel="5")

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

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

    info("*** Associating Stations\n")
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)
    net.addLink(sta3, ap1)
    net.addLink(sta4, ap1)
    net.addLink(sta5, ap1)
    net.addLink(sta6, ap1)
    net.addLink(sta7, ap1)
    net.addLink(sta8, ap1)
    net.addLink(sta9, ap1)
    net.addLink(sta10, ap1)
    net.addLink(sta11, ap1)
    net.addLink(sta12, ap1)
    net.addLink(sta13, ap1)
    net.addLink(sta14, ap1)
    net.addLink(sta15, ap1)
    net.addLink(sta16, ap1)
    net.addLink(sta17, ap1)
    net.addLink(sta18, ap1)
    net.addLink(sta19, ap1)
    net.addLink(sta20, ap1)
    net.addLink(sta21, ap1)
    net.addLink(sta22, ap1)
    net.addLink(sta23, ap1)
    net.addLink(sta24, ap1)
    net.addLink(sta25, ap1)

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

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

    info("*** Ping All\n")
    net.pingAll()

    h1.cmd('sudo iperf -s -u -i 1 -t 30 > iperf_s_n' + nodes + '_r' + rep + ' &')
    h2.sendCmd('iperf -u -c ' + h1.IP() + ' -b 10M -i 1 -t 30 > iperf_c_n'+ nodes +'_r' + rep)
    # removing the SDN Controller
    ap1.cmd("ovs-vsctl --db=unix:/var/run/openvswitch/db.sock del-controller ap1")

    makeTerm( sta1, cmd="python /media/sf_shared/node.py 10.0.0.1 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta2, cmd="python /media/sf_shared/node.py 10.0.0.2 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta3, cmd="python /media/sf_shared/node.py 10.0.0.3 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta4, cmd="python /media/sf_shared/node.py 10.0.0.4 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta5, cmd="python /media/sf_shared/node.py 10.0.0.5 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta6, cmd="python /media/sf_shared/node.py 10.0.0.6 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta7, cmd="python /media/sf_shared/node.py 10.0.0.7 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta8, cmd="python /media/sf_shared/node.py 10.0.0.8 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta9, cmd="python /media/sf_shared/node.py 10.0.0.9 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta10, cmd="python /media/sf_shared/node.py 10.0.0.10 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta11, cmd="python /media/sf_shared/node.py 10.0.0.11 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta12, cmd="python /media/sf_shared/node.py 10.0.0.12 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta13, cmd="python /media/sf_shared/node.py 10.0.0.13 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta14, cmd="python /media/sf_shared/node.py 10.0.0.14 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta15, cmd="python /media/sf_shared/node.py 10.0.0.15 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta16, cmd="python /media/sf_shared/node.py 10.0.0.16 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta17, cmd="python /media/sf_shared/node.py 10.0.0.17 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta18, cmd="python /media/sf_shared/node.py 10.0.0.18 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta19, cmd="python /media/sf_shared/node.py 10.0.0.19 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta20, cmd="python /media/sf_shared/node.py 10.0.0.20 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta21, cmd="python /media/sf_shared/node.py 10.0.0.21 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta22, cmd="python /media/sf_shared/node.py 10.0.0.22 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta23, cmd="python /media/sf_shared/node.py 10.0.0.23 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta24, cmd="python /media/sf_shared/node.py 10.0.0.24 -nodes 25 -rep 1;sleep 2" )
    makeTerm( sta25, cmd="python /media/sf_shared/node.py 10.0.0.25 -nodes 25 -rep 1;sleep 2" )

    info("*** Waiting for iperf to terminate.\n")
    results = {}
    results[h2] = h2.waitOutput()
    h1.cmd('kill $!')

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

    info("*** Stopping network\n")
    net.stop()
コード例 #5
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()
コード例 #6
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()
コード例 #7
0
def topobuild():
    net = Mininet_wifi(controller=None,
                       link=TCLink,
                       switch=OVSSwitch,
                       waitConnected=True,
                       autoSetMacs=True)
    c0 = net.addController('c0',
                           controller=RemoteController,
                           ip='127.0.0.1',
                           port=6653)
    # net.addController(c)
    net.start()
    graph = nx.DiGraph()
    edges = [(0, 1, 1), (0, 5, 1), (1, 5, 1), (1, 2, 1), (2, 6, 1), (2, 3, 1),
             (2, 4, 1), (3, 6, 1), (3, 4, 1), (4, 7, 1), (5, 6, 1), (5, 8, 1),
             (5, 10, 1), (6, 7, 1), (6, 8, 1), (7, 9, 1), (8, 9, 1)]
    for (x, y, z) in edges:
        if (y, x, z) in edges:
            edges.remove((y, x, z))
    graph.add_weighted_edges_from(edges)
    total_node = len(graph.nodes)
    aps = {}
    host = []
    for node in range(total_node):
        print 'node:', node
        aps['ap%s' % (node + 1)] = net.addAccessPoint('ap%s' % (node + 1),
                                                      ssid='ssid%s' %
                                                      (node + 1))
        sta1 = net.addStation('sta%s' % (node + 1), cpu=.5 / total_node)

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

    for node in range(total_node):
        net.addLink('sta%s' % (node + 1), 'ap%s' % (node + 1))

    for (sw1, sw2, z) in edges:
        sw1 = int(sw1) + 1
        sw2 = int(sw2) + 1
        if (sw1 < total_node) and (sw2 < total_node):
            net.addLink("ap%d" % sw1, "ap%d" % sw2)

    net.build()
    c0.start()
    for node in range(total_node):
        aps['ap%s' % (node + 1)].start([c0])

    return net
コード例 #8
0
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()
コード例 #9
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()
コード例 #10
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller, accessPoint=UserAP)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', passwd='123456789a', encrypt='wpa2')
    sta2 = net.addStation('sta2', passwd='123456789a', encrypt='wpa2')
    ap1 = net.addAccessPoint('ap1',
                             ssid="simplewifi",
                             mode="g",
                             channel="1",
                             passwd='123456789a',
                             encrypt='wpa2')
    c0 = net.addController('c0',
                           controller=Controller,
                           ip='127.0.0.1',
                           port=6633)

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

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

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

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

    info("*** Stopping network\n")
    net.stop()
コード例 #11
0
def topology():

    "Create a network."
    net = Mininet_wifi(controller=RemoteController)

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

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

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

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

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

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

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

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

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

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

    print("*** Stopping network")
    net.stop()
コード例 #12
0
def topology(isVirtual):
    "Create a network."
    net = Mininet_wifi(controller=Controller, accessPoint=OVSKernelAP)

    info("*** Creating nodes\n")
    if isVirtual:
        sta1 = net.addStation('sta1', nvif=2)
    else:
        sta1 = net.addStation('sta1')
    sta2 = net.addStation('sta2')
    if isVirtual:
        ap1 = net.addAccessPoint('ap1',
                                 ssid="simplewifi",
                                 mode="g",
                                 channel="5")
    else:
        # isolate_clientes: Client isolation can be used to prevent low-level
        # bridging of frames between associated stations in the BSS.
        # By default, this bridging is allowed.
        # OpenFlow rules are required to allow communication among nodes
        ap1 = net.addAccessPoint('ap1',
                                 ssid="simplewifi",
                                 isolate_clientes=True,
                                 mode="g",
                                 channel="5")
    c0 = net.addController('c0',
                           controller=Controller,
                           ip='127.0.0.1',
                           port=6633)

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

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

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

    if not isVirtual:
        ap1.cmd('ovs-ofctl add-flow ap1 "priority=0,arp,in_port=1,'
                'actions=output:in_port,normal"')
        ap1.cmd('ovs-ofctl add-flow ap1 "priority=0,icmp,in_port=1,'
                'actions=output:in_port,normal"')
        ap1.cmd('ovs-ofctl add-flow ap1 "priority=0,udp,in_port=1,'
                'actions=output:in_port,normal"')
        ap1.cmd('ovs-ofctl add-flow ap1 "priority=0,tcp,in_port=1,'
                'actions=output:in_port,normal"')

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

    info("*** Stopping network\n")
    net.stop()
コード例 #13
0
def topology():
    """
          *ap2--h4.      .s7.
         *         .    .    .
    sta1*           s6--     s9--h10
        *          .    .    .
         *        .      .  .
          *ap3--h5        s8
    """

    "Create a network."
    net = Mininet_wifi(controller=RemoteController, switch=OVSKernelSwitch)

    print("*** Creating nodes")
    sta1 = net.addStation('sta1',
                          wlans=2,
                          ip='10.0.0.10/8',
                          position='51,10,0')
    ap2 = net.addAccessPoint('ap2',
                             mac='00:00:00:00:00:02',
                             equipmentModel='TLWR740N',
                             protocols='OpenFlow10',
                             ssid='ssid_ap2',
                             mode='g',
                             channel='6',
                             position='55,17,0')
    ap3 = net.addAccessPoint('ap3',
                             mac='00:00:00:00:00:03',
                             equipmentModel='TLWR740N',
                             protocols='OpenFlow10',
                             ssid='ssid_ap3',
                             mode='n',
                             channel='1',
                             position='50,11,0')
    h4 = net.addHost('h4', mac='00:00:00:00:00:04', ip='10.0.0.254/8')
    h5 = net.addHost('h5', mac='00:00:00:00:00:05', ip='192.168.0.254/24')
    s6 = net.addSwitch('s6', mac='00:00:00:00:00:06', protocols='OpenFlow10')
    s7 = net.addSwitch('s7', mac='00:00:00:00:00:07', protocols='OpenFlow10')
    s8 = net.addSwitch('s8', mac='00:00:00:00:00:08', protocols='OpenFlow10')
    s9 = net.addSwitch('s9', mac='00:00:00:00:00:09', protocols='OpenFlow10')
    h10 = net.addHost('h10', mac='00:00:00:00:00:10', ip='192.168.1.254/24')
    c11 = net.addController('c11', controller=RemoteController, ip='127.0.0.1')

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

    print("*** Associating and Creating links")
    net.addLink(ap2, sta1)
    net.addLink(ap3, sta1)
    net.addLink(ap2, h4, bw=1000)
    net.addLink(ap3, h5, bw=1000)
    net.addLink(s6, h4, bw=1000)
    net.addLink(s6, h5, bw=1000)
    net.addLink(s6, s7, bw=1000)
    net.addLink(s6, s8, bw=1000)
    net.addLink(s7, s9, bw=1000)
    net.addLink(s8, s9, bw=1000)
    net.addLink(s9, h10, bw=1000)

    h4.cmd('ifconfig h4-eth1 192.168.1.1/24')
    h5.cmd('ifconfig h5-eth1 192.168.1.2/24')

    sta1.cmd('ifconfig sta1-wlan0 10.0.0.10/8')
    sta1.cmd('ifconfig sta1-wlan1 192.168.0.10/24')

    sta1.cmd('ip route add default 10.0.0.254/8 via sta1-wlan0')
    sta1.cmd('ip route add default 192.168.0.254/24 via sta1-wlan1')

    sta1.cmd('ip rule add from 10.0.0.10 table 1')
    sta1.cmd('ip rule add from 192.168.0.10 table 2')

    sta1.cmd('ip route add 10.0.0.0 dev sta1-wlan0 scope link table 1')
    sta1.cmd('ip route add default via 10.0.0.254 dev sta1-wlan0 table 1')

    sta1.cmd('ip route add 192.168.0.0 dev sta1-wlan1 scope link table 2')
    sta1.cmd('ip route add default via 192.168.0.254 dev sta1-wlan1 table 2')

    sta1.cmd(
        'ip route add default scope global nexthop via 10.0.0.254 dev sta1-wlan0'
    )

    print("*** Starting network")
    net.build()
    c11.start()
    s6.start([c11])
    s7.start([c11])
    s8.start([c11])
    s9.start([c11])
    ap2.start([c11])
    ap3.start([c11])

    h10.cmd('ip route add 10.0.0.0/8 via 192.168.1.1')
    h10.cmd('ip route add 192.168.0.0/24 via 192.168.1.2')

    h4.cmd('sysctl -w net.ipv4.ip_forward=1')
    h5.cmd('sysctl -w net.ipv4.ip_forward=1')

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

    print("*** Stopping network")
    net.stop()
コード例 #14
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller,
                       link=wmediumd,
                       wmediumd_mode=interference)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:11', position='1,1,0')
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:12', position='31,11,0')
    ap1 = net.addAccessPoint('ap1', wlans=2, ssid='ssid1,', position='10,10,0')
    ap2 = net.addAccessPoint('ap2', wlans=2, ssid='ssid2,', position='30,10,0')
    ap3 = net.addAccessPoint('ap3', wlans=2, ssid='ssid3,', position='50,10,0')
    c0 = net.addController('c0')

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

    info("*** Associating Stations\n")
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap2)
    net.addLink(ap1, intf='ap1-wlan2', cls=mesh, ssid='mesh-ssid', channel=5)
    net.addLink(ap2, intf='ap2-wlan2', cls=mesh, ssid='mesh-ssid', channel=5)
    net.addLink(ap3, intf='ap3-wlan2', cls=mesh, ssid='mesh-ssid', channel=5)

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

    ap1.cmd('iw dev %s-mp1 interface add %s-mon0 type monitor' %
            (ap1.name, ap1.name))
    ap2.cmd('iw dev %s-mp1 interface add %s-mon0 type monitor' %
            (ap2.name, ap2.name))
    ap1.cmd('ifconfig %s-mon0 up' % ap1.name)
    ap2.cmd('ifconfig %s-mon0 up' % ap2.name)

    ifname = 'enp2s0'
    collector = environ.get('COLLECTOR', '127.0.0.1')
    sampling = environ.get('SAMPLING', '10')
    polling = environ.get('POLLING', '10')
    sflow = 'ovs-vsctl -- --id=@sflow create sflow agent=%s target=%s ' \
            'sampling=%s polling=%s --' % (ifname,collector,sampling,polling)

    for ap in net.aps:
        sflow += ' -- set bridge %s sflow=@sflow' % ap
        print(' '.join([ap.name for ap in net.aps]))
        quietRun(sflow)

    agent = '127.0.0.1'
    topo = {'nodes': {}, 'links': {}}
    for ap in net.aps:
        topo['nodes'][ap.name] = {'agent': agent, 'ports': {}}

    path = '/sys/devices/virtual/mac80211_hwsim/'
    for child in listdir(path):
        dir_ = '/sys/devices/virtual/mac80211_hwsim/' + '%s' % child + '/net/'
        for child_ in listdir(dir_):
            node = child_[:3]
            if node in topo['nodes']:
                ifindex = open(dir_ + child_ + '/ifindex').read().split(
                    '\n', 1)[0]
                topo['nodes'][node]['ports'][child_] = {'ifindex': ifindex}

    path = '/sys/devices/virtual/net/'
    for child in listdir(path):
        parts = re.match('(^.+)-(.+)', child)
        if parts == None: continue
        if parts.group(1) in topo['nodes']:
            ifindex = open(path + child + '/ifindex').read().split('\n', 1)[0]
            topo['nodes'][parts.group(1)]['ports'][child] = {
                'ifindex': ifindex
            }

    i = 0
    for ap1 in net.aps:
        j = 0
        for ap2 in net.aps:
            if j > i:
                linkName = '%s-%s' % (ap1.name, ap2.name)
                topo['links'][linkName] = {
                    'node1': ap1.name,
                    'port1': 'ap1-mp1',
                    'node2': ap2.name,
                    'port2': 'ap2-mp1'
                }
                #topo['links'][linkName] = {'node1': ap1.name, 'port1': 'ap1-mon0',
                # 'node2': ap2.name, 'port2': 'ap2-mon0'}

                intfs = ap1.connectionsTo(ap2)
                for intf in intfs:
                    #ap1ifIdx = topo['nodes'][ap1.name]['ports'][intf[0].name]['ifindex']
                    #ap2ifIdx = topo['nodes'][ap2.name]['ports'][intf[1].name]['ifindex']
                    linkName = '%s-%s' % (ap1.name, ap2.name)
                    topo['links'][linkName] = {
                        'node1': ap1.name,
                        'port1': intf[0].name,
                        'node2': ap2.name,
                        'port2': intf[1].name
                    }
            j += 1
        i += 1

    put('http://127.0.0.1:8008/topology/json', data=dumps(topo))

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

    info("*** Stopping network\n")
    net.stop()
コード例 #15
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.startMobility(time=0, model='RandomWayPoint', max_x=120, max_y=120,
                      min_v=0.3, max_v=0.5, seed=1, associationControl='ssf')

    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()
コード例 #16
0
def topology(coord):
    "Create a network."
    net = Mininet_wifi(controller=Controller, accessPoint=OVSKernelAP)

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

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

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

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

    if coord:
        sta1.coord = ['40.0,30.0,0.0', '31.0,10.0,0.0', '31.0,30.0,0.0']
        sta2.coord = ['40.0,40.0,0.0', '55.0,31.0,0.0', '55.0,81.0,0.0']

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

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

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

    info("*** Stopping network\n")
    net.stop()
コード例 #17
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()
コード例 #18
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller,
                       link=TCLink,
                       accessPoint=UserAP,
                       disableAutoAssociation=True)

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

    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()
コード例 #19
0
def topology():

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

    print("*** Creating nodes")
    for n in range(10):
        staList.append(n)
        staList[n] = net.addStation('sta%s' % (n + 1),
                                    wlans=2,
                                    mac='00:00:00:00:00:%s' % (n + 1),
                                    ip='192.168.0.%s/24' % (n + 1))
    phyap1 = net.addAccessPoint('phyap1',
                                protocols='OpenFlow13',
                                ssid='Sigcomm-2016-Mininet-WiFi',
                                mode='g',
                                channel='1',
                                position='50,115,0',
                                phywlan=usbDongleIface,
                                cls=physicalAP)
    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 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)

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

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

    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

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

    print("*** Stopping network")
    net.stop()
コード例 #20
0
def topology():

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

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

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

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

    sta1.cmd('iw dev sta1-wlan0 interface add mon0 type monitor &')
    sta1.cmd('ifconfig mon0 up &')
    sta2.cmd('iw dev sta2-wlan0 interface add mon0 type monitor &')
    sta2.cmd('ifconfig mon0 up &')
    if py_version_info < (3,0)
        sta2.cmd('pushd /home/alpha/Downloads; python -m http.server 80 &')
    else:
        sta2.cmd('pushd /home/alpha/Downloads; python3 -m http.server 80 &')

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

    replayingNetworkConditions.addNode(sta1)
    replayingNetworkConditions.addNode(sta2)
    replayingNetworkConditions(net)

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

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

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

    print("*** Stopping network")
    net.stop()
コード例 #21
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()
コード例 #22
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller, switch=OVSKernelSwitch)

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

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

    info("*** Associating...\n")
    net.addLink(ap1, sta1)
    net.addHoc(sta1, ssid='adhoc1')
    net.addHoc(sta2, ssid='adhoc1')

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

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

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

    info("*** Stopping network\n")
    net.stop()
コード例 #23
0
def topology():
    "Create a network."
    net = Mininet_wifi( controller=RemoteController, switch=OVSKernelSwitch )

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

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

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

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

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

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

    print "*** Stopping network"
    net.stop()
コード例 #24
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()
コード例 #25
0
def topology(mobility):
    "Create a network."
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference)

    info("*** Creating nodes\n")
    if mobility:
        sta1 = net.addStation('sta1')
        sta2 = net.addStation('sta2')
        sta3 = net.addStation('sta3')
    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')

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

    info("*** Creating links\n")
    net.addMesh(sta1, ssid='meshNet', channel=5)
    net.addMesh(sta2, ssid='meshNet', channel=5)
    net.addMesh(sta3, ssid='meshNet', channel=5)

    if mobility:
        net.plotGraph(max_x=100, max_y=100)

        net.seed(20)

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

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

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

    info("*** Stopping network\n")
    net.stop()
コード例 #26
0
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()
コード例 #27
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller,
                       accessPoint=OVSKernelAP,
                       driver='capwap_wtp',
                       link=wmediumd,
                       wmediumd_mode=interference)

    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()
コード例 #28
0
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()
コード例 #29
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()
コード例 #30
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()