Beispiel #1
0
 def set_pos(self, sta, ap, dist, ang):
     x = float('%.2f' % (dist * cos(ang) + int(ap.position[0])))
     y = float('%.2f' % (dist * sin(ang) + int(ap.position[1])))
     sta.position = x, y, 0
     ConfigMobLinks(sta)
     if self.net.draw:
         try:
             sta.update_2d()
         except:
             pass
Beispiel #2
0
    def mobility(self, nodes):
        if nodes is None:
            nodes = self.net.stations + self.net.aps
        for node in nodes:
            if isinstance(node, Station):
                if hasattr(node, 'position') and node not in self.stations:
                    self.stations.append(node)
            if isinstance(node, AP):
                if hasattr(node, 'position') and node not in self.aps:
                    self.aps.append(node)

        if self.net.draw:
            self.net.isReplaying = False
            self.net.check_dimension(nodes)

        currentTime = time()
        for node in nodes:
            if 'speed' not in node.params:
                node.params['speed'] = 1.0
            node.currentTime = 1 / node.params['speed']
            node.timestamp = float(1.0 / node.params['speed'])
            if hasattr(node, 'time'):
                self.timestamp = True

        calc_pos = self.notimestamp_
        if self.timestamp:
            calc_pos = self.timestamp_

        while self.thread_._keep_alive:
            time_ = time() - currentTime
            if len(nodes) == 0:
                break
            for node in nodes:
                if node in self.stations:
                    calc_pos(node, time_)
                    if len(node.p) == 0:
                        nodes.remove(node)
                    ConfigMobLinks()
                    if self.net.draw:
                        node.update_2d()
            if self.net.draw:
                PlotGraph.pause()
Beispiel #3
0
 def configLinks(self):
     "Applies channel params and handover"
     from mn_wifi.mobility import ConfigMobLinks
     ConfigMobLinks(self)