示例#1
0
 def rssi(self, ppm, n):
     currentTime = time()
     staList = self.net.stations
     ang = {}
     for sta in staList:
         ang[sta] = random.uniform(0, 360)
         sta.wintfs[0].freq = sta.wintfs[0].get_freq()
     while self.thread_._keep_alive:
         if len(staList) == 0:
             break
         time_ = time() - currentTime
         for sta in staList:
             if hasattr(sta, 'time'):
                 if time_ >= sta.time[0]:
                     ap = sta.wintfs[0].associatedTo  # get AP
                     sta.wintfs[0].rssi = sta.rssi[0]
                     if ap:
                         rssi = sta.rssi[0]
                         dist = self.calc_dist(sta, ap, rssi, ppm, n)
                         self.set_pos(sta, ap, dist, ang[sta])
                         wirelessLink(sta.wintfs[0], dist)
                     del sta.rssi[0]
                     del sta.time[0]
                 if len(sta.time) == 0:
                     staList.remove(sta)
         sleep(0.01)
示例#2
0
 def rssi(self, Mininet_wifi, propagationModel='', n=0):
     currentTime = time()
     staList = Mininet_wifi.stations
     ang = {}
     for sta in staList:
         ang[sta] = random.uniform(0, 360)
         sta.wintfs[0].freq = sta.wintfs[0].get_freq()
     while mobility.thread_._keep_alive:
         if len(staList) == 0:
             break
         time_ = time() - currentTime
         for sta in staList:
             if hasattr(sta, 'time'):
                 if time_ >= sta.time[0]:
                     ap = sta.wintfs[0].associatedTo  # get AP
                     sta.wintfs[0].rssi = sta.rssi[0]
                     if ap != '':
                         rssi = sta.rssi[0]
                         dist = int('%d' % self.calculateDistance(
                             sta, ap, rssi, propagationModel, n))
                         self.setPos(Mininet_wifi, sta, ap, dist, ang[sta])
                         wirelessLink(sta, ap, dist, wlan=0, ap_wlan=0)
                     del sta.rssi[0]
                     del sta.time[0]
                 if len(sta.time) == 0:
                     staList.remove(sta)
         sleep(0.01)
示例#3
0
 def rssi(self, Mininet_wifi, propagationModel='', n=0):
     currentTime = time()
     staList = Mininet_wifi.stations
     ang = {}
     for sta in staList:
         ang[sta] = random.uniform(0, 360)
         sta.params['freq'][0] = sta.get_freq(0)
     while mobility.thread_._keep_alive:
         if len(staList) == 0:
             break
         time_ = time() - currentTime
         for sta in staList:
             if hasattr(sta, 'time'):
                 if time_ >= sta.time[0]:
                     ap = sta.params['associatedTo'][0]  # get AP
                     sta.params['rssi'][0] = sta.rssi[0]
                     if ap != '':
                         rssi = sta.rssi[0]
                         dist = int('%d' % self.calculateDistance(sta, ap, rssi,
                                                                  propagationModel, n))
                         self.moveNodeTo(sta, ap, dist, ang[sta])
                         wirelessLink(sta, ap, 0, dist)
                     del sta.rssi[0]
                     del sta.time[0]
                 if len(sta.time) == 0:
                     staList.remove(sta)
         sleep(0.01)
示例#4
0
 def rssi(self, Mininet_wifi, propagationModel='', n=0):
     #if mobility.DRAW:
     #    instantiateGraph(mininet)
     currentTime = time()
     staList = Mininet_wifi.stations
     ang = {}
     for sta in staList:
         ang[sta] = random.uniform(0, 360)
         sta.params['frequency'][0] = sta.get_freq(0)
     while True:
         if len(staList) == 0:
             break
         time_ = time() - currentTime
         for sta in staList:
             if hasattr(sta, 'time'):
                 if time_ >= sta.time[0]:
                     ap = sta.params['associatedTo'][0]  # get AP
                     sta.params['rssi'][0] = sta.rssi[0]
                     if ap != '':
                         rssi = sta.rssi[0]
                         dist = int('%d' % self.calculateDistance(sta, ap, rssi,
                                                                  propagationModel, n))
                         self.moveNodeTo(sta, ap, dist, ang[sta])
                         wirelessLink(sta, ap, 0, dist)
                     del sta.rssi[0]
                     del sta.time[0]
                 if len(sta.time) == 0:
                     staList.remove(sta)
         sleep(0.01)
示例#5
0
 def setAssociation(self, ap, intf=None):
     "Force association to given AP"
     wlan = self.get_wlan(intf)
     intf = self.wintfs[wlan]
     ap_intf = ap.wintfs[0]
     if hasattr(self, 'position') and hasattr(ap, 'position'):
         dist = self.get_distance_to(ap)
         if dist <= ap_intf.range:
             if intf.bgscan_threshold:
                 intf.handover_ieee80211r(ap_intf)
                 intf.update(ap_intf)
             elif intf.associatedTo != ap:
                 if intf.associatedTo:
                     intf.disconnect()
                     intf.rssi = 0
                 intf.associate_infra(ap_intf)
                 wirelessLink(intf, dist)
             else:
                 info('%s is already connected!\n' % ap)
             self.configLinks()
         else:
             info("%s is out of range!\n" % ap)
     elif not hasattr(self, 'position') and not hasattr(ap, 'position'):
         intf.associate_infra(ap_intf)