コード例 #1
0
    def autoAssociation(cls, stations, aps):
        """
        This is useful to make the users' life easier
        
        :param stations: list of stations
        :param aps: list of access points
        """
        nodes = stations + aps
        for node in nodes:
            for wlan in range(0, len(node.params['wlan'])):
                if node.type == 'vehicle' and wlan == 1:
                    node = node.params['carsta']
                    wlan = 0
        ap = []
        for node in aps:
            if 'link' in node.params:
                ap.append(node)

        nodes = stations + ap

        if cls.nroads == 0:
            for node in nodes:
                if 'position' in node.params and 'link' not in node.params:
                    mobility.aps = aps
                    mobility.parameters_(node)

            for sta in stations:
                for wlan in range(0, len(sta.params['wlan'])):
                    for ap in aps:
                        if 'position' in sta.params and 'position' in ap.params:
                            dist = wirelessLink.getDistance(sta, ap)
                            if dist <= ap.params['range'][0]:
                                mobility.handover(sta, ap, wlan)
コード例 #2
0
 def customAssociationControl(self, sta, ap, wlan, ac):
     """Mechanisms that optimize the use of the APs
     llf: Least-loaded-first
     ssf: Strongest-signal-first"""
     if ac == "llf":
         apref = sta.params['associatedTo'][wlan]
         if apref != '':
             ref_llf = len(apref.params['associatedStations'])
             if len(ap.params['associatedStations']) + 2 < ref_llf:
                 debug('iw dev %s disconnect' % sta.params['wlan'][wlan])
                 sta.pexec('iw dev %s disconnect' % sta.params['wlan'][wlan])
                 self.changeAP = True
         else:
             self.changeAP = True
     elif ac == "ssf":
         distance = wirelessLink.getDistance(sta, sta.params['associatedTo'][wlan])
         RSSI = wirelessLink.setRSSI(sta, sta.params['associatedTo'][wlan], wlan, distance)
         refDistance = wirelessLink.getDistance(sta, ap)
         refRSSI = wirelessLink.setRSSI(sta, ap, wlan, refDistance)
         if float(refRSSI) > float(RSSI + 0.1):
             debug('iw dev %s disconnect' % sta.params['wlan'][wlan])
             sta.pexec('iw dev %s disconnect' % sta.params['wlan'][wlan])
             self.changeAP = True
     return self.changeAP
コード例 #3
0
 def getDistance(cls, src, dst):
     "Get the distance between two nodes"
     dist = wirelessLink.getDistance(src, dst)
     return dist
コード例 #4
0
 def getDistance(self, src, dst):
     dist = wirelessLink.getDistance(src, dst)
     return dist