Ejemplo n.º 1
0
    def configureWmediumd(self, stations, accessPoints):
        """ 
        Updates values for frequency and channel
        
        :param stations: list of stations
        :param accessPoints: list of access points
        """
        intfrefs = []
        links = []
        positions = []
        txpowers = []
        cars = []

        for node in stations:
            if 'carsta' in node.params:
                cars.append(node.params['carsta'])

        nodes = stations + accessPoints + cars

        for node in nodes:
            node.wmediumdIface = DynamicWmediumdIntfRef(node)
            intfrefs.append(node.wmediumdIface)

        if self.enable_interference:
            mode = WmediumdConstants.WMEDIUMD_MODE_INTERFERENCE
            for node in nodes:
                if 'position' not in node.params:
                    posX = 0
                    posY = 0
                    posZ = 0
                else:
                    posX = node.params['position'][0]
                    posY = node.params['position'][1]
                    posZ = node.params['position'][2]
                node.lastpos = [0, 0, 0]
                positions.append(
                    WmediumdPosition(node.wmediumdIface, [posX, posY, posZ]))
                txpowers.append(
                    WmediumdTXPower(node.wmediumdIface,
                                    float(node.params['txpower'][0])))
        else:
            mode = WmediumdConstants.WMEDIUMD_MODE_SNR
            for node in self.wlinks:
                links.append(
                    WmediumdSNRLink(node[0].wmediumdIface,
                                    node[1].wmediumdIface,
                                    node[0].params['snr'][0]))
                links.append(
                    WmediumdSNRLink(node[1].wmediumdIface,
                                    node[0].wmediumdIface,
                                    node[0].params['snr'][0]))

        WmediumdStarter.initialize(intfrefs, links, mode=mode, positions=positions, enable_interference=self.enable_interference, \
                                   auto_add_links=False, txpowers=txpowers, with_server=True)
        WmediumdStarter.start()
Ejemplo n.º 2
0
def topology():
    """Create a network. sta1 <--> sta2 <--> sta3"""

    print "*** Connect wmediumd manager"
    WmediumdManager.connect()

    print "*** Network creation"
    net = Mininet()

    print "*** Creating nodes"
    sta1 = net.addStation('sta1')
    sta2 = net.addStation('sta2')
    sta3 = net.addStation('sta3')

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

    print "*** Configure wmediumd"
    # This should be done right after the station has been initialized
    sta1wlan0 = DynamicWmediumdIntfRef(sta1)
    sta2wlan0 = DynamicWmediumdIntfRef(sta2)
    sta3wlan0 = DynamicWmediumdIntfRef(sta3)

    intfrefs = [sta1wlan0, sta2wlan0, sta3wlan0]
    links = [
        WmediumdSNRLink(sta1wlan0, sta2wlan0, 15),
        WmediumdSNRLink(sta2wlan0, sta1wlan0, 15),
        WmediumdSNRLink(sta2wlan0, sta3wlan0, 15),
        WmediumdSNRLink(sta3wlan0, sta2wlan0, 15)]

    for intfref in intfrefs:
        WmediumdManager.register_interface(intfref.get_intf_mac())

    for link in links:
        WmediumdManager.update_link_snr(link)

    print "*** Creating links"
    net.addHoc(sta1, ssid='adNet')
    net.addHoc(sta2, ssid='adNet')
    net.addHoc(sta3, ssid='adNet')

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

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

    print "*** Disconnecting wmediumd manager"
    WmediumdManager.disconnect()

    print "*** Stopping network"
    net.stop()
Ejemplo n.º 3
0
 def apInRange(self, sta, ap, wlan, dist):
     """
     When ap is in range
     
     :param sta: station
     :param ap: access point
     :param wlan: wlan ID
     :param dist: distance between source and destination  
     """
     if self.rec_rssi:
         os.system('hwsim_mgmt -k %s %s >/dev/null 2>&1' %
                   (sta.phyID[wlan], abs(int(sta.params['rssi'][wlan]))))
     if ap not in sta.params['apsInRange']:
         sta.params['apsInRange'].append(ap)
         rssi_ = setChannelParams.setRSSI(sta, ap, wlan, dist)
         ap.params['stationsInRange'][sta] = rssi_
     else:
         rssi_ = setChannelParams.setRSSI(sta, ap, wlan, dist)
         ap.params['stationsInRange'][sta] = rssi_
     if ap == sta.params['associatedTo'][wlan]:
         rssi_ = setChannelParams.setRSSI(sta, ap, wlan, dist)
         sta.params['rssi'][wlan] = rssi_
         snr_ = setChannelParams.setSNR(sta, wlan)
         sta.params['snr'][wlan] = snr_
         if sta not in ap.params['associatedStations']:
             ap.params['associatedStations'].append(sta)
         if not WmediumdServerConn.connected and dist >= 0.01:
             setChannelParams(sta, ap, wlan, dist)
         if WmediumdServerConn.connected and dist >= 0.01:
             WmediumdServerConn.send_snr_update(
                 WmediumdSNRLink(sta.wmediumdIface, ap.wmediumdIface,
                                 sta.params['snr'][wlan]))
     setChannelParams.recordParams(sta, ap)
Ejemplo n.º 4
0
def topology():
    """Create a network. sta1 <--> sta2 <--> sta3"""

    print "*** Network creation"
    net = Mininet()

    print "*** Configure wmediumd"
    sta1wlan0 = WmediumdIntfRef('sta1', 'sta1-wlan0', '02:00:00:00:00:00')
    sta2wlan0 = WmediumdIntfRef('sta2', 'sta2-wlan0', '02:00:00:00:01:00')
    sta3wlan0 = WmediumdIntfRef('sta3', 'sta3-wlan0', '02:00:00:00:02:00')

    intfrefs = [sta1wlan0, sta2wlan0, sta3wlan0]
    links = [
        WmediumdSNRLink(sta1wlan0, sta2wlan0, 15),
        WmediumdSNRLink(sta2wlan0, sta1wlan0, 15),
        WmediumdSNRLink(sta2wlan0, sta3wlan0, 15),
        WmediumdSNRLink(sta3wlan0, sta2wlan0, 15)
    ]
    WmediumdStarter.initialize(intfrefs, links)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1')
    sta2 = net.addStation('sta2')
    sta3 = net.addStation('sta3')

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

    print "*** Start wmediumd"
    WmediumdStarter.start()

    print "*** Creating links"
    net.addHoc(sta1, ssid='adNet')
    net.addHoc(sta2, ssid='adNet')
    net.addHoc(sta3, ssid='adNet')

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

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

    print "*** Stopping wmediumd"
    WmediumdStarter.stop()

    print "*** Stopping network"
    net.stop()
Ejemplo n.º 5
0
def topology():
    """Create a network. sta1 <--> sta2 <--> sta3"""

    print "*** Network creation"
    net = Mininet()

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', range=50, position='10,10,0')
    sta2 = net.addStation('sta2', range=50, position='20,10,0')
    sta3 = net.addStation('sta3', range=50, position='30,10,0')

    print "*** Configure wmediumd"
    # This should be done right after the station has been initialized
    sta1.wmediumdIface = DynamicWmediumdIntfRef(sta1)
    sta2.wmediumdIface = DynamicWmediumdIntfRef(sta2)
    sta3.wmediumdIface = DynamicWmediumdIntfRef(sta3)

    intfrefs = [sta1.wmediumdIface, sta2.wmediumdIface, sta3.wmediumdIface]
    links = [
        WmediumdSNRLink(sta1.wmediumdIface, sta2.wmediumdIface, 15),
        WmediumdSNRLink(sta2.wmediumdIface, sta1.wmediumdIface, 15),
        WmediumdSNRLink(sta2.wmediumdIface, sta3.wmediumdIface, 15),
        WmediumdSNRLink(sta3.wmediumdIface, sta2.wmediumdIface, 15)
    ]
    WmediumdStarter.initialize(intfrefs, links, with_server=True)

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

    print "*** Start wmediumd"
    WmediumdStarter.start()

    print "*** Plotting graph ***"
    net.plotGraph(max_x=200, max_y=200)

    print "*** Enabling Mesh Routing ***"
    net.meshRouting('custom')

    print "*** Creating links"
    net.addMesh(sta1, ssid='adNet')
    net.addMesh(sta2, ssid='adNet')
    net.addMesh(sta3, ssid='adNet')

    print "*** Starting network"
    net.start()
    print "\n\n\n"
    print "*** Pinging sta2"
    sta1.cmdPrint('ping -c 1 10.0.0.2')

    print "*** Update wmediumd"
    WmediumdServerConn.connect()

    # Required when the position of the nodes are previously defined. Useful to set channel params.
    net.autoAssociation()

    CLI(net)

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

    print "*** Stopping wmediumd"
    WmediumdServerConn.disconnect()
    WmediumdStarter.stop()
Ejemplo n.º 6
0
    def configureWmediumd(cls, mininet):
        """ 
        Updates values for frequency and channel
        """
        from mininet.node import Car

        intfrefs = []
        links = []
        positions = []
        txpowers = []
        cars = []

        cls.configureWiFiDirect = mininet.configureWiFiDirect
        cls.configure4addr = mininet.configure4addr
        cls.enable_error_prob = mininet.enable_error_prob
        cls.enable_interference = mininet.enable_interference
        cls.enable_spec_prob_link = mininet.enable_spec_prob_link

        for node in mininet.stations:
            if 'carsta' in node.params:
                cars.append(node.params['carsta'])

        nodes = mininet.stations + mininet.aps + cars
        for node in nodes:
            node.wmIface = []
            if isinstance(node, Car):
                wlans = 1
            elif '_4addr' in node.params and node.params['_4addr'] == 'ap':
                wlans = 1
            else:
                wlans = len(node.params['wlan'])
            for wlan in range(0, wlans):
                node.wmIface.append(wlan)
                node.wmIface[wlan] = DynamicWmediumdIntfRef(node, intf=wlan)
                intfrefs.append(node.wmIface[wlan])

        if cls.enable_interference:
            mode = WmediumdConstants.WMEDIUMD_MODE_INTERFERENCE
            for node in nodes:
                if 'position' not in node.params:
                    posX = 0
                    posY = 0
                    posZ = 0
                else:
                    posX = node.params['position'][0]
                    posY = node.params['position'][1]
                    posZ = node.params['position'][2]
                node.lastpos = [posX, posY, posZ]

                if isinstance(node, Car):
                    wlans = 1
                elif '_4addr' in node.params and node.params['_4addr'] == 'ap':
                    wlans = 1
                else:
                    wlans = len(node.params['wlan'])
                for wlan in range(0, wlans):
                    positions.append(
                        WmediumdPosition(node.wmIface[wlan],
                                         [posX, posY, posZ]))
                    txpowers.append(
                        WmediumdTXPower(node.wmIface[wlan],
                                        float(node.params['txpower'][wlan])))
        elif cls.enable_spec_prob_link:
            mode = WmediumdConstants.WMEDIUMD_MODE_SPECPROB
        elif cls.enable_error_prob:
            mode = WmediumdConstants.WMEDIUMD_MODE_ERRPROB
            for node in cls.wlinks:
                links.append(
                    WmediumdERRPROBLink(node[0].wmIface[0], node[1].wmIface[0],
                                        node[2]))
                links.append(
                    WmediumdERRPROBLink(node[1].wmIface[0], node[0].wmIface[0],
                                        node[2]))
        else:
            mode = WmediumdConstants.WMEDIUMD_MODE_SNR
            for node in cls.wlinks:
                links.append(
                    WmediumdSNRLink(node[0].wmIface[0], node[1].wmIface[0],
                                    node[0].params['rssi'][0] - (-91)))
                links.append(
                    WmediumdSNRLink(node[1].wmIface[0], node[0].wmIface[0],
                                    node[0].params['rssi'][0] - (-91)))

        WmediumdStarter.initialize(intfrefs,
                                   links,
                                   mode=mode,
                                   positions=positions,
                                   enable_interference=cls.enable_interference,
                                   auto_add_links=False,
                                   txpowers=txpowers,
                                   with_server=True)
        WmediumdStarter.start(mininet, propagationModel)
Ejemplo n.º 7
0
 def setSNRWmediumd(self, sta, ap, snr):
     "Set SNR for wmediumd"
     WmediumdServerConn.send_snr_update(
         WmediumdSNRLink(sta.wmIface[0], ap.wmIface[0], snr))
     WmediumdServerConn.send_snr_update(
         WmediumdSNRLink(ap.wmIface[0], sta.wmIface[0], snr))
Ejemplo n.º 8
0
 def customMeshRouting(self, sta, wlan, stations):
     """Custom Mesh Routing"""
     associate = False
     controlMeshMac = []
     command = ''
     for ref_sta in stations:
         if ref_sta.type == 'vehicle':
             ref_sta = ref_sta.params['carsta']
         for ref_wlan in range(len(ref_sta.params['wlan'])):
             if ref_sta != sta and ref_sta.func[
                     ref_wlan] == 'mesh' and 'position' in sta.params:
                 dist = setChannelParams.getDistance(sta, ref_sta)
                 totalRange = int(sta.params['range'])
                 ref_totalRange = int(ref_sta.params['range'])
                 if ref_totalRange > totalRange:
                     totalRange = ref_totalRange
                 if dist <= totalRange:
                     if ref_sta.func[ref_wlan] == 'mesh':
                         if sta.params['associatedTo'][
                                 wlan] == ref_sta.params['associatedTo'][
                                     ref_wlan]:
                             associate = True
                             if not WmediumdServerConn.connected:
                                 setChannelParams(sta=sta,
                                                  wlan=wlan,
                                                  dist=dist)
             elif 'position' not in sta.params:
                 associate = True
     """Adding all reached target paths"""
     if associate:
         exist = []
         sta_ref = []
         sta_ref.append(sta)
         j = 0
         exist.append(sta)
         while j < len(stations):
             j += 1
             if sta_ref == []:
                 break
             else:
                 newsta = sta_ref[0]
             for x, y in zip(listNodes.nodesX, listNodes.nodesY):
                 if x == sta and y not in exist:
                     if WmediumdServerConn.connected:
                         WmediumdServerConn.send_snr_update(
                             WmediumdSNRLink(sta.wmediumdIface,
                                             y.wmediumdIface,
                                             sta.params['snr'][wlan]))
                     else:
                         command = 'iw dev %s mpath new %s next_hop %s' % (sta.params['wlan'][wlan], \
                                                                           y.meshMac[wlan], y.meshMac[wlan])
                         debug('\n' + command)
                         sta.pexec(command)
                     exist.append(y)
                     controlMeshMac.append(y.meshMac[wlan])
                     sta_ref.append(y)
                 elif x == newsta and y not in exist:
                     if WmediumdServerConn.connected:
                         pass
                     else:
                         command = 'iw dev %s mpath new %s next_hop %s' % (sta.params['wlan'][wlan], \
                                                                           y.meshMac[wlan], x.meshMac[wlan])
                         debug('\n' + command)
                         sta.pexec(command)
                     exist.append(y)
                     controlMeshMac.append(y.meshMac[wlan])
                     sta_ref.append(y)
             if newsta in sta_ref:
                 sta_ref.remove(newsta)
     """delete unknown paths"""
     if associate:
         for ref_sta in stations:
             for ref_wlan in range(len(ref_sta.params['wlan'])):
                 if ref_sta != sta and ref_sta.func[ref_wlan] == 'mesh':
                     if ref_sta.type == 'vehicle':
                         ref_wlan = 0
                         ref_sta = ref_sta.params['carsta']
                     if ref_sta.meshMac[ref_wlan] not in controlMeshMac:
                         sta.pexec('iw dev %s mpath del %s' %
                                   (sta.params['wlan'][wlan],
                                    ref_sta.meshMac[ref_wlan]))
     """mesh leave"""
     if associate == False:
         debug('\niw dev %s mesh leave' % sta.params['wlan'][wlan])
         sta.pexec('iw dev %s mesh leave' % sta.params['wlan'][wlan])
         sta.params['associatedTo'][wlan] = ''
Ejemplo n.º 9
0
def topology():
    """Create a network. sta1 <--> sta2 <--> sta3"""

    print "*** Network creation"
    net = Mininet()

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', range=200)
    sta2 = net.addStation('sta2', range=200)
    sta3 = net.addStation('sta3', range=200)

    print "*** Configure wmediumd"
    # This should be done right after the station has been initialized
    sta1.wmediumdIface = DynamicWmediumdIntfRef(sta1)
    sta2.wmediumdIface = DynamicWmediumdIntfRef(sta2)
    sta3.wmediumdIface = DynamicWmediumdIntfRef(sta3)

    intfrefs = [sta1.wmediumdIface, sta2.wmediumdIface, sta3.wmediumdIface]
    links = [
        WmediumdSNRLink(sta1.wmediumdIface, sta2.wmediumdIface, 15),
        WmediumdSNRLink(sta2.wmediumdIface, sta1.wmediumdIface, 15),
        WmediumdSNRLink(sta2.wmediumdIface, sta3.wmediumdIface, 15),
        WmediumdSNRLink(sta3.wmediumdIface, sta2.wmediumdIface, 15)]
    WmediumdStarter.initialize(intfrefs, links, with_server=True)

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

    print "*** Start wmediumd"
    WmediumdStarter.start()

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

    net.meshRouting('custom')

    net.seed(20)

    print "*** Creating links"
    net.addMesh(sta1, ssid='adNet')
    net.addMesh(sta2, ssid='adNet')
    net.addMesh(sta3, ssid='adNet')

    print "*** Starting network"
    net.start()
    print "\n\n\n"
    print "*** Pinging sta2"
    sta1.cmdPrint('ping -c 1 10.0.0.2')

    print "*** Setting up the mobility model"
    net.startMobility(startTime=0, model='RandomDirection', max_x=220, max_y=220, min_v=0.1, max_v=0.2)

    print "*** Update wmediumd"
    WmediumdServerConn.connect()

    CLI(net)

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

    print "*** Stopping wmediumd"
    WmediumdServerConn.disconnect()
    WmediumdStarter.stop()
Ejemplo n.º 10
0
    def configureWmediumd(self, stations, accessPoints):
        """ 
        Updates values for frequency and channel
        
        :param stations: list of stations
        :param accessPoints: list of access points
        """
        intfrefs = []
        links = []
        positions = []
        txpowers = []
        cars = []

        for node in stations:
            if 'carsta' in node.params:
                cars.append(node.params['carsta'])

        nodes = stations + accessPoints + cars

        for node in nodes:
            node.wmIface = []
            if node.type == 'vehicle':
                wlans = 1
            elif '_4addr' in node.params and node.params['_4addr'] == 'ap':
                wlans = 1
            else:
                wlans = len(node.params['wlan'])
            for wlan in range(0, wlans):
                node.wmIface.append(wlan)
                node.wmIface[wlan] = DynamicWmediumdIntfRef(node, intf=wlan)
                intfrefs.append(node.wmIface[wlan])

        if self.enable_interference:
            mode = WmediumdConstants.WMEDIUMD_MODE_INTERFERENCE
            for node in nodes:
                if 'position' not in node.params:
                    posX = 0
                    posY = 0
                    posZ = 0
                else:
                    posX = node.params['position'][0]
                    posY = node.params['position'][1]
                    posZ = node.params['position'][2]
                node.lastpos = [0, 0, 0]

                if hasattr(node, 'type') and node.type == 'vehicle':
                    wlans = 1
                elif '_4addr' in node.params and node.params['_4addr'] == 'ap':
                    wlans = 1
                else:
                    wlans = len(node.params['wlan'])
                for wlan in range(0, wlans):
                    positions.append(
                        WmediumdPosition(node.wmIface[wlan],
                                         [posX, posY, posZ]))
                    txpowers.append(
                        WmediumdTXPower(node.wmIface[wlan],
                                        float(node.params['txpower'][wlan])))
        elif self.enable_spec_prob_link:
            mode = WmediumdConstants.WMEDIUMD_MODE_SPECPROB
        elif self.enable_error_prob:
            mode = WmediumdConstants.WMEDIUMD_MODE_ERRPROB
        else:
            mode = WmediumdConstants.WMEDIUMD_MODE_SNR
            for node in self.wlinks:
                links.append(
                    WmediumdSNRLink(node[0].wmIface[0], node[1].wmIface[0],
                                    node[0].params['rssi'][0] - (-91)))
                links.append(
                    WmediumdSNRLink(node[1].wmIface[0], node[0].wmIface[0],
                                    node[0].params['rssi'][0] - (-91)))

        WmediumdStarter.initialize(intfrefs, links, mode=mode, positions=positions, enable_interference=self.enable_interference, \
                                   auto_add_links=False, txpowers=txpowers, with_server=True)
        WmediumdStarter.start()
Ejemplo n.º 11
0
 def setSNRWmediumd(cls, sta, ap, snr):
     "Send SNR to wmediumd"
     WmediumdServerConn.send_snr_update(
         WmediumdSNRLink(sta.wmIface[0], ap.wmIface[0], snr))
     WmediumdServerConn.send_snr_update(
         WmediumdSNRLink(ap.wmIface[0], sta.wmIface[0], snr))
Ejemplo n.º 12
0
    def apInRange(self, sta, ap, wlan, dist):
        """
        When ap is in range
        
        :param sta: station
        :param ap: access point
        :param wlan: wlan ID
        :param dist: distance between source and destination  
        """

        outevent = False
        if self.rec_rssi:
            os.system('hwsim_mgmt -k %s %s >/dev/null 2>&1' %
                      (sta.phyID[wlan], abs(int(sta.params['rssi'][wlan]))))
        if ap not in sta.params['apsInRange']:
            sta.params['apsInRange'].append(ap)
            rssi_ = setChannelParams.setRSSI(sta, ap, wlan, dist)
            ap.params['stationsInRange'][sta] = rssi_
        else:
            rssi_ = setChannelParams.setRSSI(sta, ap, wlan, dist)
            ap.params['stationsInRange'][sta] = rssi_
            if sta in ap.params['associatedStations'] and ap.params[
                    'stationsInRange'][sta] > -43 and ap.func[0] == 'ap':
                sta.params['minswch'] = False
            if sta in ap.params['associatedStations'] and ap.params[
                    'stationsInRange'][sta] > -45.95 and ap.func[0] == 'ap':
                sta.params['maxswch'] = False
            outevent = True
        if ap == sta.params['associatedTo'][wlan]:
            rssi_ = setChannelParams.setRSSI(sta, ap, wlan, dist)
            sta.params['rssi'][wlan] = rssi_
            snr_ = setChannelParams.setSNR(sta, wlan)
            sta.params['snr'][wlan] = snr_
            if sta not in ap.params['associatedStations']:
                ap.params['associatedStations'].append(sta)
            if not WmediumdServerConn.connected and dist >= 0.01:
                setChannelParams(sta, ap, wlan, dist)
            if ap.func[0] == 'ap':
                #~ ap.params['out']=False
                if ap.params['stationsInRange'][sta] <= -44 and sta.params[
                        'minswch'] == False:
                    #~ ap.cmd('echo "%s,%s" > /dev/udp/%s/5005' %(sta.params['mac'][0], ap.params['stationsInRange'][sta],ap.params['controller_IP']))
                    #~ print(sta.params['mac'], ap.params['stationsInRange'][sta],ap.params['controller_IP'],ap.name)

                    #~ ap.cmd('echo "%s,%s,%s,%s" > /dev/udp/%s/5005' %(sta.params['mac'][0], ap.params['stationsInRange'][sta],['ASSO'],ap.params['controller_IP']))
                    #~ print 'STA ' + str(sta.params['mac']) + 'is ASSOCIATED to '+ ap.name + ' With RSSI ' + str(ap.params['stationsInRange'][sta])
                    ap.cmdPrint('echo "%s,%s,%s,%d" > /dev/udp/%s/5005' %
                                (sta.params['mac'][0],
                                 ap.params['stationsInRange'][sta], "ASSO", 1,
                                 ap.params['controller_IP']))
                    sta.params['minswch'] = True
                    sta.params['x'] = len(sta.params['apsInRange']) - 1
                    ap.params['AssoMacRSSI1'][sta.params['mac'][
                        0]] = ap.params['stationsInRange'][sta]
                elif ap.params['stationsInRange'][sta] <= -46 and sta.params[
                        'maxswch'] == False:
                    #~ print 'STA ' + str(sta.params['mac']) + 'is ASSOCIATED to '+ ap.name + ' With RSSI ' + str(ap.params['stationsInRange'][sta])
                    ap.cmdPrint('echo "%s,%s,%s,%d" > /dev/udp/%s/5005' %
                                (sta.params['mac'][0],
                                 ap.params['stationsInRange'][sta], "ASSO", 2,
                                 ap.params['controller_IP']))
                    #~ ap.cmd('echo "%s,%s,%s,%s" > /dev/udp/%s/5005' %(sta.params['mac'][0], ap.params['stationsInRange'][sta],['ASSO'],ap.params['controller_IP']))
                    sta.params['maxswch'] = True
                    sta.params['y'] = len(sta.params['apsInRange']) - 1
                    ap.params['AssoMacRSSI2'][sta.params['mac'][
                        0]] = ap.params['stationsInRange'][sta]
                    #~ if (ap.params['AssoMacRSSI1'] != {}) and (ap.params['AssoMacRSSI2'] != {}):
                    #~ if (ap.params['AssoMacRSSI1'][sta.params['mac'][0]] != None) and (ap.params['AssoMacRSSI2'][sta.params['mac'][0]] != None):
                    #~ print (ap.name, 'ASSO', sta.params['mac'], ap.params['AssoMacRSSI2'][sta.params['mac'][0]] - ap.params['AssoMacRSSI1'][sta.params['mac'][0]])
                    #~ ap.cmd('echo "%s,%s" > /dev/udp/%s/5005' %(sta.params['mac'][0], ap.params['stationsInRange'][sta],ap.params['controller_IP']))

                    #~ Uncomment this one for exact getrssi
                    #~ ap.cmd('echo "%s,%s,%s" > /dev/udp/%s/5005' %(sta.params['mac'][0], ap.params['AssoMacRSSI2'][sta.params['mac'][0]] - ap.params['AssoMacRSSI1'][sta.params['mac'][0]],'ASSO',ap.params['controller_IP']))
                    #~ print 'STA ' + str(sta.params['mac']) + 'is ASSOCIATED to '+ ap.name + ' With RSSI ' + str(ap.params['stationsInRange'][sta])
            if WmediumdServerConn.connected and dist >= 0.01:
                WmediumdServerConn.send_snr_update(
                    WmediumdSNRLink(sta.wmediumdIface, ap.wmediumdIface,
                                    sta.params['snr'][wlan]))
        elif ap != sta.params['associatedTo'][wlan] and sta.params[
                'x'] > 0 and ap.func[0] == 'ap':
            #~ ap.params['out'][sta.params['mac'][0]]=True
            #~ print 'STA ' + str(sta.params['mac']) + 'is in RANGE of '+ ap.name + ' With RSSI ' + str(ap.params['stationsInRange'][sta])
            ap.cmdPrint(
                'echo "%s,%s,%s,%d" > /dev/udp/%s/5005' %
                (sta.params['mac'][0], ap.params['stationsInRange'][sta],
                 "RANGE", 1, ap.params['controller_IP']))
            #~ ap.cmd('echo "%s,%s,%s,%s" > /dev/udp/%s/5005' %(sta.params['mac'][0], ap.params['stationsInRange'][sta],['RANGE'],ap.params['controller_IP']))
            sta.params['x'] = sta.params['x'] - 1
            ap.params['InRgMacRSSI1'][sta.params['mac']
                                      [0]] = ap.params['stationsInRange'][sta]
            ap.params['r1_r2_sentevent'][0] = True
        elif ap != sta.params['associatedTo'][wlan] and sta.params[
                'y'] > 0 and ap.func[0] == 'ap':
            #~ ap.params['out'][sta.params['mac'][0]]=False
            #~ print 'STA ' + str(sta.params['mac']) + 'is in RANGE of '+ ap.name + ' With RSSI ' + str(ap.params['stationsInRange'][sta])
            ap.cmdPrint(
                'echo "%s,%s,%s,%d" > /dev/udp/%s/5005' %
                (sta.params['mac'][0], ap.params['stationsInRange'][sta],
                 "RANGE", 2, ap.params['controller_IP']))
            #~ ap.cmdPrint('echo "%s,%s,%s,%d" > /dev/udp/%s/5005' %(sta.params['mac'][0], ap.params['stationsInRange'][sta], "DONE", 2, ap.params['controller_IP']))
            #~ ap.cmd('echo "%s,%s,%s,%s" > /dev/udp/%s/5005' %(sta.params['mac'][0], ap.params['stationsInRange'][sta],['RANGE'],ap.params['controller_IP']))
            sta.params['y'] = sta.params['y'] - 1
            ap.params['InRgMacRSSI2'][sta.params['mac']
                                      [0]] = ap.params['stationsInRange'][sta]
            ap.params['r1_r2_sentevent'][1] = True
            if ap.params['r1_r2_sentevent'] == [
                    True, True
            ] or ap.params['r1_r2_sentevent'] == [False, True]:
                ap.params['r1_r2_sentevent'] = [False, False]
            #~ if (ap.params['InRgMacRSSI1'] != {}) and (ap.params['InRgMacRSSI2'] != {}):
            #~ if (ap.params['InRgMacRSSI1'][sta.params['mac'][0]] != None) and (ap.params['InRgMacRSSI2'][sta.params['mac'][0]] != None):
            #~ print (ap.name, 'InRg', sta.params['mac'], ap.params['InRgMacRSSI2'][sta.params['mac'][0]] - ap.params['InRgMacRSSI1'][sta.params['mac'][0]])
            #~ ap.cmd('echo "%s,%s,%s" > /dev/udp/%s/5005' %(sta.params['mac'][0], ap.params['InRgMacRSSI2'][sta.params['mac'][0]] - ap.params['InRgMacRSSI1'][sta.params['mac'][0]],'RANGE',ap.params['controller_IP']))
            #~ elif  ap.func[0]=='ap' and ap != sta.params['associatedTo'][wlan] and float(setChannelParams.getDistance(ap, sta))>=((float(ap.params['range']))-1) and outevent==True:
            #~ if sta not in ap.params['associatedStations'] and ap.params['r1_r2_sentevent']==[True,False]:
            #~ ap.cmdPrint('echo "%s,%s,%s,%d" > /dev/udp/%s/5005' %(sta.params['mac'][0], ap.params['stationsInRange'][sta], "OUT", 1, ap.params['controller_IP']))

        setChannelParams.recordParams(sta, ap)