def handover(self, sta, ap, wlan, dist):
        """
        handover
        
        :param sta: station
        :param ap: access point
        :param wlan: wlan ID
        :param dist: distance between source and destination   
        """
        changeAP = False
        """Association Control: mechanisms that optimize the use of the APs"""
        if self.associationControlMethod != '' and sta.params['associatedTo'][wlan] != ap \
            and sta.params['associatedTo'][wlan] != '':
            ac = self.associationControlMethod
            value = associationControl(sta, ap, wlan, ac)
            changeAP = value.changeAP

        if sta.params['associatedTo'][wlan] == '' or changeAP == True:
            if ap not in sta.params['associatedTo']:
                cls = Association
                if 'encrypt' not in ap.params:
                    cls.associate_noEncrypt(sta, ap, wlan)
                else:
                    if ap.params['encrypt'][0] == 'wpa' or ap.params[
                            'encrypt'][0] == 'wpa2':
                        cls.associate_wpa(sta, ap, wlan)
                    elif ap.params['encrypt'][0] == 'wep':
                        cls.associate_wep(sta, ap, wlan)
                self.updateAssociation(sta, ap, wlan)
Exemple #2
0
 def handover(self, sta, ap, wlan, dist):
     """
     handover
     
     :param sta: station
     :param ap: access point
     :param wlan: wlan ID
     :param dist: distance between source and destination   
     """
     associated = True        
     
     if dist > ap.params['range']:
         if ap == sta.params['associatedTo'][wlan]:
             sta.pexec('iw dev %s disconnect' % sta.params['wlan'][wlan])
             sta.params['associatedTo'][wlan] = ''
             sta.params['rssi'][wlan] = 0
             sta.params['snr'][wlan] = 0
             sta.params['channel'][wlan] = 0
             sta.params['frequency'][wlan] = 0
             ap.params['associatedStations'].pop(sta, None)
     else:
         if dist >= 0.01 and sta.params['associatedTo'][wlan] == ap:
             self.updateParams(sta, ap, wlan)
             setChannelParams(sta, ap, wlan, dist)
         
         if sta.params['associatedTo'][wlan] == '':        
             associated = False        
         else:        
             associated = False
 
         if ap == sta.params['associatedTo'][wlan] or dist <= ap.params['range']:
             changeAP = False
             """Association Control: mechanisms that optimize the use of the APs"""
             if self.associationControlMethod != False and sta.params['associatedTo'][wlan] != '':
                 ac = self.associationControlMethod
                 value = associationControl(sta, ap, wlan, ac)
                 changeAP = value.changeAP
 
             if associated == False or changeAP == True:
                 if ap not in sta.params['associatedTo']:
                     if sta.params['associatedTo'][wlan] == '' or changeAP == True:
                         if 'encrypt' not in ap.params:
                             self.associate_infra(sta, ap, wlan)
                         else:
                             if ap.params['encrypt'][0] == 'wpa' or ap.params['encrypt'][0] == 'wpa2':
                                 self.associate_wpa(sta, ap, wlan)
                             elif ap.params['encrypt'][0] == 'wep':
                                 self.associate_wep(sta, ap, wlan)
                         if dist >= 0.01 and sta.params['associatedTo'][wlan] != '':
                             self.updateParams(sta, ap, wlan)
                             setChannelParams(sta, ap, wlan, dist)
Exemple #3
0
    def handover(self, sta, ap, wlan, dist):
        """handover"""
        associated = True

        if dist > ap.params['range']:
            if ap == sta.params['associatedTo'][wlan]:
                sta.pexec('iw dev %s disconnect' % sta.params['wlan'][wlan])
                sta.params['associatedTo'][wlan] = ''
                sta.params['rssi'][wlan] = 0
                ap.params['associatedStations'].remove(sta)
        else:
            if dist >= 0.01 and sta.params['associatedTo'][wlan] == ap:
                self.updateParams(sta, ap, wlan)
                setInfraChannelParams(sta, ap, wlan, dist, self.staList)

            if sta.params['associatedTo'][wlan] == '':
                associated = False
            else:
                associated = False

            if ap == sta.params['associatedTo'][
                    wlan] or dist <= ap.params['range']:
                changeAP = False
                """Association Control: mechanisms that optimize the use of the APs"""
                if self.associationControlMethod != False and sta.params[
                        'associatedTo'][wlan] != '':
                    ac = self.associationControlMethod
                    value = associationControl(sta, ap, wlan, ac)
                    changeAP = value.changeAP

                # Go to handover
                if associated == False or changeAP == True:
                    if ap not in sta.params['associatedTo']:
                        if sta.params['associatedTo'][
                                wlan] == '' or changeAP == True:
                            if 'encrypt' not in ap.params:
                                self.associate_infra(sta, ap, wlan)
                            else:
                                if ap.params['encrypt'][
                                        0] == 'wpa' or ap.params['encrypt'][
                                            0] == 'wpa2':
                                    self.associate_wpa(sta, ap, wlan)
                                elif ap.params['encrypt'][0] == 'wep':
                                    self.associate_wep(sta, ap, wlan)
                            if dist >= 0.01 and sta.params['associatedTo'][
                                    wlan] != '':
                                setInfraChannelParams(sta, ap, wlan, dist,
                                                      self.staList)
        # have to verify this
        time.sleep(0.01)
Exemple #4
0
 def setChannelParameters(self, sta, ap, dist, wlan):
     """ Wifi Parameters """
     associated = True
     time = abs(sta.speed)
     staList = emulationEnvironment.staList
     
     if ap == sta.associatedAp[wlan]:
         if dist > ap.range + sta.range:  
             sta.pexec('iw dev %s-wlan%s disconnect' % (sta, wlan))
             sta.associatedAp[wlan] = 'NoAssociated'
             sta.rssi[wlan] = 0
             sta.snr[wlan] = 0
             emulationEnvironment.numberOfAssociatedStations(ap)
         else:
             #if emulationEnvironment.continue_:
             channelParameters(sta, ap, wlan, dist, staList, time)
     else:   
         if dist < ap.range + sta.range:            
             aps = 0
             for n in range(0,len(sta.associatedAp)):
                 if str(sta.associatedAp[n]) != 'NoAssociated':
                     aps+=1
             if len(sta.associatedAp) == aps:
                 associated = True
             else:
                 associated = False
         else:
             associated = False
     if ap == sta.associatedAp[wlan] or dist < (ap.range + sta.range):
         #Only if it is a mobility environment
         changeAP = False
         association_Control = dict ()
         
         """Association Control: mechanisms that optimize the use of the APs"""
         if emulationEnvironment.associationControlMethod != False:
             ac = emulationEnvironment.associationControlMethod              
             value = associationControl(sta, ap, wlan, ac)
             changeAP = value.changeAP
             association_Control.setdefault( 'ac', ac )                
             
         #Go to handover    
         if associated == False or changeAP == True:
             self.handover(sta, ap, wlan, dist, changeAP, **association_Control)
             channelParameters(sta, ap, wlan, dist, staList, time)
Exemple #5
0
 def setChannelParameters(self, sta, ap, dist, wlan):
     """ Wifi Parameters """
     associated = True
     time = abs(sta.params['speed'])
     staList = self.staList
     
     if ap == sta.associatedAp[wlan]:
         if dist > ap.range + sta.range:  
             debug( '\niw dev %s disconnect' % sta.params['wlan'][wlan] )
             sta.pexec('iw dev %s disconnect' % sta.params['wlan'][wlan])
             sta.associatedAp[wlan] = 'NoAssociated'
             sta.params['rssi'][wlan] = 0
             sta.params['snr'][wlan] = 0
             self.numberOfAssociatedStations(ap)
         else:
             channelParameters(sta, ap, wlan, dist, staList, time)
     else:   
         if dist < ap.range + sta.range:            
             aps = 0
             for n in range(0,len(sta.associatedAp)):
                 if str(sta.associatedAp[n]) != 'NoAssociated':
                     aps+=1
             if len(sta.associatedAp) == aps:
                 associated = True
             else:
                 associated = False
         else:
             associated = False
     if ap == sta.associatedAp[wlan] or dist < (ap.range + sta.range):
         #Only if it is a mobility environment
         changeAP = False
         association_Control = dict ()
         
         """Association Control: mechanisms that optimize the use of the APs"""
         if self.associationControlMethod != False:
             ac = self.associationControlMethod              
             value = associationControl(sta, ap, wlan, ac)
             changeAP = value.changeAP
             association_Control.setdefault( 'ac', ac )                
             
         #Go to handover    
         if associated == False or changeAP == True:
             self.handover(sta, ap, wlan, dist, changeAP, **association_Control)
             channelParameters(sta, ap, wlan, dist, staList, time)
 def setChannelParameters(self, sta, ap, dist, wlan):
     """ Wifi Parameters """
     associated = True
     #time = abs(sta.params['speed'])
     staList = self.staList
     
     if ap == sta.params['associatedTo'][wlan]:            
         if dist > ap.range:  
             debug('\niw dev %s disconnect' % sta.params['wlan'][wlan])
             sta.pexec('iw dev %s disconnect' % sta.params['wlan'][wlan])
             sta.params['associatedTo'][wlan] = ''
             sta.params['rssi'][wlan] = 0
             sta.params['snr'][wlan] = 0
             ap.associatedStations.remove(sta)
         else:
             channelParameters(sta, ap, wlan, dist, staList, 0)
     else:  
         if dist < ap.range:  
             if sta.params['associatedTo'][wlan] == '':
                 associated = False
         else:
             associated = False
     if ap == sta.params['associatedTo'][wlan] or dist < ap.range:
         changeAP = False
         ac = None
         sta.params['frequency'][wlan] = channelParameters.frequency(ap, 0)
         sta.params['channel'][wlan] = ap.params['channel'][0]
         
         """Association Control: mechanisms that optimize the use of the APs"""
         if self.associationControlMethod != False:
             ac = self.associationControlMethod              
             value = associationControl(sta, ap, wlan, ac)
             changeAP = value.changeAP
             
         #Go to handover    
         if associated == False or changeAP == True:
             self.handover(sta, ap, wlan, dist, changeAP, ac)
             channelParameters(sta, ap, wlan, dist, staList, 0)
     else:
         #have to verify this
         time.sleep(0.01)
 def setChannelParameters(self, sta, ap, dist, wlan):
     """ Wifi Parameters """
     associated = True
     #time = abs(sta.params['speed'])
     staList = self.staList
     
     if ap == sta.params['associatedTo'][wlan]:            
         if dist > ap.params['range']:  
             debug('\niw dev %s disconnect' % sta.params['wlan'][wlan])
             sta.pexec('iw dev %s disconnect' % sta.params['wlan'][wlan])
             sta.params['associatedTo'][wlan] = ''
             sta.params['rssi'][wlan] = 0
             sta.params['snr'][wlan] = 0
             ap.associatedStations.remove(sta)
         else:
             channelParameters(sta, ap, wlan, dist, staList, 0)
     else:  
         if dist < ap.params['range']:  
             if sta.params['associatedTo'][wlan] == '':
                 associated = False
         else:
             associated = False
     if ap == sta.params['associatedTo'][wlan] or dist < ap.params['range']:
         changeAP = False
         ac = None
         sta.params['frequency'][wlan] = channelParameters.frequency(ap, 0)
         sta.params['channel'][wlan] = ap.params['channel'][0]
         
         """Association Control: mechanisms that optimize the use of the APs"""
         if self.associationControlMethod != False:
             ac = self.associationControlMethod              
             value = associationControl(sta, ap, wlan, ac)
             changeAP = value.changeAP
             
         #Go to handover    
         if associated == False or changeAP == True:
             self.handover(sta, ap, wlan, dist, changeAP, ac)
             channelParameters(sta, ap, wlan, dist, staList, 0)
     else:
         #have to verify this
         time.sleep(0.01)