Example #1
0
def topology():

    net = Mininet(controller=Controller, link=TCLink, accessPoint=OVSKernelAP)

    print "*** Creating nodes"
    ap1 = net.addAccessPoint('ap1',
                             ssid='ssid-ap1',
                             mode='g',
                             channel='1',
                             position='10,30,0',
                             range='20')
    ap2 = net.addAccessPoint('ap2',
                             ssid='ssid-ap2',
                             mode='g',
                             channel='6',
                             position='50,30,0',
                             range='20')
    sta1 = net.addStation('sta1',
                          mac='00:00:00:00:00:01',
                          ip='10.0.0.1/8',
                          position='10,20,0')
    sta2 = net.addStation('sta2',
                          mac='00:00:00:00:00:02',
                          ip='10.0.0.2/8',
                          position='50,20,0')
    c1 = net.addController('c1', controller=Controller)

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()
    """plot graph"""
    net.plotGraph(max_x=60, max_y=60)

    # Comment out the following two lines to disable AP
    print "*** Enabling association control (AP)"
    net.associationControl('ssf')

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

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

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

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

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

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

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

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

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

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

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

    print "*** Creating nodes"
    ## The mobile node
    sta1 = net.addStation('sta1',
                          wlans=2,
                          mac='00:00:00:00:00:02',
                          ip='10.0.0.2/24')
    ## The long range, poor quality access point
    ap1 = net.addAccessPoint('ap1',
                             ssid='ap1-ssid',
                             mode='g',
                             channel='1',
                             position='50,50,0',
                             range=51)
    ## The sort range, good quality access points
    ap2 = net.addAccessPoint('ap2',
                             ssid='ap2-ssid',
                             mode='g',
                             channel='4',
                             position='10,10,0',
                             range=30)
    ap3 = net.addAccessPoint('ap3',
                             ssid='ap3-ssid',
                             mode='g',
                             channel='4',
                             position='90,10,0',
                             range=30)
    ap4 = net.addAccessPoint('ap4',
                             ssid='fast-ssid',
                             mode='g',
                             channel='4',
                             position='50,80,0',
                             range=10)
    ## Controller for the APs (don't need to change this)
    c1 = net.addController('c1', controller=Controller)
    ## The host, will run the HTTP server in this example
    h1 = net.addHost('h1', ip='10.0.0.3/24')

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

    ## (ap2--ap3--ap4)
    print "*** Creating links"
    net.addLink(ap2, ap3)
    net.addLink(ap3, ap4)

    ## Poor quality link ap1---h1
    net.addLink(ap1, h1, bw=2, delay='10ms', max_queue_size=1000)
    ## Good quality link ap2---h1 (note that ap2--ap3--ap4)
    net.addLink(ap2, h1)

    ## Just to make sure the interfaces are correctly set
    net.addLink(ap1, sta1)
    net.addLink(ap2, sta1)

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

    ## Manually set a second IP for h1 and sta1
    sta1.setIP('10.1.0.2/24', intf='sta1-wlan1')
    h1.setIP('10.1.0.3/24', intf='h1-eth1')

    ## Run a simple HTTP server on h1
    print "*** Starting HTTP server on H1"
    h1.cmdPrint('python -m SimpleHTTPServer 80 &')

    h1.cmdPrint("python code/server.py &")
    """association control"""
    net.associationControl('ssf')
    """Plot graph"""
    net.plotGraph(max_x=100, max_y=100)
    """Seed"""
    net.seed(20)

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

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

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

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

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

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

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    ap2.start([c1])
    ap3.start([c1])
    """uncomment to plot graph"""
    net.plotGraph(max_x=120, max_y=120)
    """association control"""
    net.associationControl('ssf')
    """Seed"""
    net.seed(1)
    """ *** Available models: 
                RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov
	*** Association Control (AC) - mechanism that optimizes the use of the APs:
                llf (Least-Loaded-First)
                ssf (Strongest-Signal-First)"""
    net.startMobility(startTime=0,
                      model='RandomWayPoint',
                      max_x=120,
                      max_y=120,
                      min_v=0.3,
                      max_v=0.5)

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

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

    print "Creating nodes"

    h1 = net.addHost('h1', mac='00:00:00:00:00:01', ip='10.0.0.1/24')
    h2 = net.addHost('h2', mac='00:00:00:00:00:02', ip='10.0.0.2/24')

    sw10 = net.addSwitch('sw10')
    sw20 = net.addSwitch('sw20')
    sw30 = net.addSwitch('sw30')
    sw40 = net.addSwitch('sw40')

    ap1 = net.addAccessPoint('ap1',
                             ssid='AP1',
                             mode='g',
                             channel='1',
                             position='40,120,0',
                             range='30')
    ap2 = net.addAccessPoint('ap2',
                             ssid='AP2',
                             mode='g',
                             channel='6',
                             position='80,120,0',
                             range='30')
    ap3 = net.addAccessPoint('ap3',
                             ssid='AP3',
                             mode='g',
                             channel='11',
                             position='120,120,0',
                             range='30')
    ap4 = net.addAccessPoint('ap4',
                             ssid='AP4',
                             mode='g',
                             channel='1',
                             position='160,120,0',
                             range='30')
    ap5 = net.addAccessPoint('ap5',
                             ssid='AP5',
                             mode='g',
                             channel='6',
                             position='60,80,0',
                             range='30')
    ap6 = net.addAccessPoint('ap6',
                             ssid='AP6',
                             mode='g',
                             channel='11',
                             position='100,80,0',
                             range='30')
    ap7 = net.addAccessPoint('ap7',
                             ssid='AP7',
                             mode='g',
                             channel='1',
                             position='140,80,0',
                             range='30')
    ap8 = net.addAccessPoint('ap8',
                             ssid='AP8',
                             mode='g',
                             channel='6',
                             position='180,80,0',
                             range='30')
    ap9 = net.addAccessPoint('ap9',
                             ssid='AP9',
                             mode='g',
                             channel='11',
                             position='40,40,0',
                             range='30')
    ap10 = net.addAccessPoint('ap10',
                              ssid='AP10',
                              mode='g',
                              channel='1',
                              position='80,40,0',
                              range='30')
    ap11 = net.addAccessPoint('ap11',
                              ssid='AP11',
                              mode='g',
                              channel='6',
                              position='120,40,0',
                              range='30')
    ap12 = net.addAccessPoint('ap12',
                              ssid='AP12',
                              mode='g',
                              channel='11',
                              position='160,40,0',
                              range='30')

    sta1 = net.addStation('sta1', mac='00:00:00:00:00:10', ip='10.0.0.10/24')
    c0 = net.addController('c0',
                           controller=RemoteController,
                           ip='127.0.0.1',
                           port=6653)

    net.configureWifiNodes()

    print "Associating and creating links"
    net.addLink(sw10, sw20)
    net.addLink(sw20, sw30)
    net.addLink(sw30, sw40)
    net.addLink(sw10, h1)
    net.addLink(sw20, h2)
    net.addLink(sw10, ap1)
    net.addLink(sw10, ap2)
    net.addLink(sw10, ap6)
    net.addLink(sw20, ap3)
    net.addLink(sw20, ap4)
    net.addLink(sw20, ap8)
    net.addLink(sw30, ap5)
    net.addLink(sw30, ap9)
    net.addLink(sw30, ap10)
    net.addLink(sw40, ap7)
    net.addLink(sw40, ap11)
    net.addLink(sw40, ap12)

    print "Starting network"
    net.build()
    c0.start()
    sw10.start([c0])
    sw20.start([c0])
    sw30.start([c0])
    sw40.start([c0])
    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])
    ap10.start([c0])
    ap11.start([c0])
    ap12.start([c0])

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

    net.associationControl('ssf')
    net.seed(1)

    start = 2
    net.startMobility(startTime=0,
                      model='RandomDirection',
                      max_x=200,
                      max_y=150,
                      min_v=3.0,
                      max_v=5.0)
    # net.mobility(sta2, 'start', time=start, position='0.0,0.0,0.0')
    # net.mobility(sta2, 'stop', time=start+10, position='20.0,20.0,0.0')
    # net.stopMobility(stopTime=start+11)

    thread.start_new_thread(MySocket().start, (net, ))

    print "Running CLI"
    CLI(net)

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

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

    print "*** Creating nodes"
    sta1 = net.addStation('sta1',
                          mac='00:00:00:00:00:02',
                          position='70.0,50.0,0.0',
                          ip='10.0.0.1/8',
                          range=10)
    ap1 = net.addAccessPoint('ap1',
                             ssid='ssid_ap1',
                             mode='g',
                             channel='1',
                             position='50,50,0',
                             range='50')
    ap2 = net.addAccessPoint('ap2',
                             ssid='ssid_ap2',
                             mode='g',
                             channel='1',
                             position='125,50,0',
                             range='50',
                             ip='10.8.8.8/8')
    ap3 = net.addAccessPoint('ap3',
                             ssid='ssid_ap3',
                             mode='g',
                             channel='1',
                             position='175,50,0',
                             range='50')
    c1 = net.addController('c1', controller=Controller)
    h1 = net.addHost('h1', ip='10.0.0.3/8')

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

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

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

    # Comment out the following two lines to disable AP
    print "*** Enabling association control (AP)"
    net.associationControl('ssf')

    net.startMobility(startTime=0)
    net.mobility(sta1, 'start', time=60, position='70.0,50.0,0.0')
    net.mobility(sta1, 'stop', time=150, position='200.0,50,0.0')
    net.stopMobility(time=151)

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

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

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

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', wlans=2)
    sta2 = net.addStation('sta2', wlans=2)
    sta3 = net.addStation('sta3', wlans=2)
    ap1 = net.addAccessPoint('ap1',
                             ssid='ssid-ap1',
                             mode='g',
                             channel='11',
                             position='115,62,0')
    ap2 = net.addAccessPoint('ap2',
                             ssid='ssid-ap2',
                             mode='g',
                             channel='1',
                             position='57,142,0')
    c1 = net.addController('c1', controller=Controller)

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

    sta1.setIP('10.0.0.2/8', intf="sta1-wlan0")
    sta2.setIP('10.0.0.3/8', intf="sta2-wlan0")
    sta3.setIP('10.0.0.4/8', intf="sta3-wlan0")
    sta1.setIP('192.168.10.1/24', intf="sta1-wlan1")
    sta2.setIP('192.168.10.2/24', intf="sta2-wlan1")
    sta3.setIP('192.168.10.3/24', intf="sta3-wlan1")

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

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

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

    net.associationControl('ssf')

    net.startMobility(time=0)
    net.mobility(sta1, 'start', time=1, position='86,188,0')
    net.mobility(sta2, 'start', time=1, position='78,195,0')
    net.mobility(sta3, 'start', time=1, position='93,195,0')
    net.mobility(sta1, 'stop', time=250, position='86,0,0')
    net.mobility(sta2, 'stop', time=250, position='78,7,0')
    net.mobility(sta3, 'stop', time=250, position='93,7,0')
    net.stopMobility(time=250)

    sleep(10)

    s1 = net.get('sta1')
    s2 = net.get('sta2')
    s3 = net.get('sta3')
    popens = {}  # Python subprocess.Popen objects keyed by Mininet hosts
    startTime = int(time()) + SYNC_START
    endTime = startTime + EXPERIMENT_DURATION

    print "*** Starting %d second experiment in %d second(s) - at Unix epoch: %d..." % (
        EXPERIMENT_DURATION, (startTime - int(time())), startTime)

    popens[s1] = s1.popen(EXECUTABLE_PATH, '-addr=%s' % s1.IP(),
                          '-dsts=%s,%s' % (s2.IP(), s3.IP()),
                          '-start=%d' % startTime)
    popens[s2] = s2.popen(EXECUTABLE_PATH, '-role=F', '-addr=%s' % s2.IP())
    popens[s3] = s3.popen(EXECUTABLE_PATH, '-role=F', '-addr=%s' % s3.IP())

    with open(OUTPUT_FILE, 'w') as f:
        for h, line in pmonitor(popens, timeoutms=500):
            if h:
                f.write('<%s>: %s' % (h.name, line))
            if time() >= endTime:
                break

    popens[s1].send_signal(SIGINT)
    popens[s2].send_signal(SIGINT)
    popens[s3].send_signal(SIGINT)

    f.close()

    print "*** Ending experiment..."

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

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

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

    print "*** Creating nodes"

    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid1',
                             mode='g',
                             channel='1',
                             position='30,40,0',
                             range='35')
    ap2 = net.addAccessPoint('ap2',
                             ssid='new-ssid2',
                             mode='g',
                             channel='6',
                             position='80,40,0',
                             range='35')

    sta1 = net.addStation(
        'sta1',
        mac='00:00:00:00:00:02',
        ip='10.0.0.2/8',
        range='3',
    )
    sta2 = net.addStation('sta2',
                          mac='00:00:00:00:00:03',
                          ip='10.0.0.3/8',
                          position='40,58,0',
                          range='3')
    sta3 = net.addStation('sta3',
                          mac='00:00:00:00:00:04',
                          ip='10.0.0.4/8',
                          position='25,60,0',
                          range='3')
    sta4 = net.addStation('sta4',
                          mac='00:00:00:00:00:05',
                          ip='10.0.0.5/8',
                          position='70,40,0',
                          range='3')
    sta5 = net.addStation('sta5',
                          mac='00:00:00:00:00:06',
                          ip='10.0.0.6/8',
                          position='25,20,0',
                          range='3')
    sta6 = net.addStation('sta6',
                          mac='00:00:00:00:00:07',
                          ip='10.0.0.7/8',
                          position='20,40,0',
                          range='3')
    c1 = net.addController('c1', controller=Controller)

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

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

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

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

    net.associationControl('llf')

    net.seed(1)

    #net.startMobility(AC='llf', time=0)
    #net.mobility(sta1, 'start', time=1, position='0,50,0')
    #net.mobility(sta1, 'stop', time=49, position='100,50,0')
    #net.stopMobility(time=50)

    net.startMobility(time=0,
                      model='RandomWayPoint',
                      max_x=120,
                      max_y=80,
                      min_v=1,
                      max_v=1.2,
                      AC='llf')
    #net.startMobility(time=0, model='RandomDirection', max_x=140, max_y=140, min_v=0.7, max_v=0.9, AC='llf')
    #net.startMobility(time=0, model='RandomWalk', max_x=140, max_y=140, min_v=0.7, max_v=0.9, AC='llf')

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

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

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

        print "*** Creating nodes"
        self.sta14 = net.addStation('sta14',
                                    mac='00:00:00:00:00:15',
                                    ip='10.0.0.15/8',
                                    range=50)
        self.h1 = net.addHost('h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8')
        self.ap1 = net.addAccessPoint('ap1',
                                      ssid='ssid-ap1',
                                      mode='g',
                                      channel='1',
                                      position='200,30,0',
                                      range=180)
        self.ap2 = net.addAccessPoint('ap2',
                                      ssid='ssid-ap2',
                                      mode='g',
                                      channel='1',
                                      position='100,230,0',
                                      range=180)
        self.ap3 = net.addAccessPoint('ap3',
                                      ssid='ssid-ap3',
                                      mode='g',
                                      channel='1',
                                      position='300,230,0',
                                      range=180)

        c1 = net.addController('c1', controller=Controller)

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

        print "*** Associating and Creating links"
        net.addLink(self.h1, self.ap1)
        net.addLink(self.ap1, self.ap2)
        net.addLink(self.ap2, self.ap3)
        """uncomment to plot graph"""
        net.plotGraph(max_x=400, max_y=400)
        """association control"""
        net.associationControl("ssf")
        """Seed"""
        net.seed(5)
        """random walking"""
        net.startMobility(time=0,
                          model='RandomDirection',
                          max_x=400,
                          max_y=400,
                          min_v=3,
                          max_v=5)

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

        print "*** Running CLI"
        CLI(net)
        second = self.sleeptime(0, 0, 1)

        # new_rssi = [chanFunt(ap1,sta14),chanFunt(ap2,sta14),chanFunt(ap3,sta14)]
        # n_actions, n_APs = len(new_rssi), len(new_rssi)
        # brain = DeepQNetwork(n_actions,n_APs,param_file = None)

        # state = new_rssi
        # print 'initial observation:' + str(state)
        try:
            while True:
                time.sleep(second)
                new_rssi = [
                    self.chanFunt(self.ap1, self.sta14),
                    self.chanFunt(self.ap2, self.sta14),
                    self.chanFunt(self.ap3, self.sta14)
                ]
                print new_rssi, self.connected_tag(self.sta14)
                # print _getreward(sta14,h1)
                print self.iperf([self.sta14, self.h1], seconds=0.0000001)
                # action,q_value = brain.choose_action(state)
                # reward, nextstate = step(rssi_tag(sta14),action)

                # brain.setPerception(state, action, reward, nextstate)
                # state = nextstate
        except KeyboardInterrupt:
            print 'saving replayMemory...'
            # brain.saveReplayMemory()
        pass
        # print new_rssi
        # snr_dict = map(setSNR,new_rssi)

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

    print "*** Creating nodes"
    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)

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

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

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

    net.associationControl('ssf')

    net.seed(1)

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

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

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

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

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', wlans=2)
    sta2 = net.addStation('sta2', wlans=2)
    sta3 = net.addStation('sta3', wlans=2)
    ap1 = net.addAccessPoint('ap1', ssid='ssid-ap1', mode='g', channel='11', position='115,62,0')
    ap2 = net.addAccessPoint('ap2', ssid='ssid-ap2', mode='g', channel='1', position='57,142,0')
    c1 = net.addController('c1', controller=Controller)

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

    sta1.setIP('10.0.0.2/8', intf="sta1-wlan0")
    sta2.setIP('10.0.0.3/8', intf="sta2-wlan0")
    sta3.setIP('10.0.0.4/8', intf="sta3-wlan0")
    sta1.setIP('192.168.10.1/24', intf="sta1-wlan1")
    sta2.setIP('192.168.10.2/24', intf="sta2-wlan1")
    sta3.setIP('192.168.10.3/24', intf="sta3-wlan1")

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

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

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

    net.associationControl('ssf')

    net.startMobility(time=0)
    net.mobility(sta1, 'start', time=1, position='86,188,0')
    net.mobility(sta2, 'start', time=1, position='78,195,0')
    net.mobility(sta3, 'start', time=1, position='93,195,0')
    net.mobility(sta1, 'stop', time=250, position='86,0,0')
    net.mobility(sta2, 'stop', time=250, position='78,7,0')
    net.mobility(sta3, 'stop', time=250, position='93,7,0')
    net.stopMobility(time=250)

    sleep(10)

    """
    print "*** Starting test..."
    s1 = net.get('sta1')
    s2 = net.get('sta2')
    s2.sendCmd('./rcv.py')
    sleep(1)
    s1.sendCmd('./send.py')
    sleep(1)
    s2.waitOutput()
    s1.waitOutput()
    s1.cmd('kill %send.py')
    s2.cmd('kill %rcv.py')
    print "*** Ending test..."
    """
    print "*** Starting test..."
    s1 = net.get('sta1')
    s2 = net.get('sta2')
    s3 = net.get('sta3')
    po2 = s2.popen('./rcv.py', s2.IP(), '%s.out' % s2.name)
    po3 = s3.popen('./rcv.py', s3.IP(), '%s.out' % s3.name)
    sleep(1)
    po1 = s1.popen('./send.py')
    sleep(5)
    po1.send_signal( SIGINT )
    po2.send_signal( SIGINT )
    po3.send_signal( SIGINT )
    print "*** Ending test..."

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

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

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8')
    sta3 = net.addStation('sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8')
    ap1 = net.addAccessPoint('ap1',
                             ssid='ssid-ap1',
                             mode='g',
                             channel='11',
                             position='115,62,0')
    ap2 = net.addAccessPoint('ap2',
                             ssid='ssid-ap2',
                             mode='g',
                             channel='1',
                             position='57,142,0')
    c1 = net.addController('c1', controller=Controller)

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

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

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

    net.associationControl('ssf')

    net.startMobility(time=0)
    net.mobility(sta1, 'start', time=1, position='86,188,0')
    net.mobility(sta2, 'start', time=1, position='78,195,0')
    net.mobility(sta3, 'start', time=1, position='93,195,0')
    net.mobility(sta1, 'stop', time=250, position='86,0,0')
    net.mobility(sta2, 'stop', time=250, position='78,7,0')
    net.mobility(sta3, 'stop', time=250, position='93,7,0')
    net.stopMobility(time=250)

    print "*** Waiting until stations are in range of ap2..."
    sleep(55)

    print "*** Starting test..."
    s1 = net.get('sta1')
    s2 = net.get('sta2')
    outfile = '/tmp/%s.out' % s2.name
    s2.cmd('./rcv.py 2>&1 > %s &' % outfile)
    sleep(1)
    s1.cmd('./send.py')
    sleep(1)
    s1.cmd('kill %send.py')
    s2.cmd('kill %rcv.py')
    print "*** Ending test..."

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

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