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 """ from mininet.node import Car nodes = stations + aps for node in nodes: for wlan in range(0, len(node.params['wlan'])): if isinstance(node, Car) 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 = sta.get_distance_to(ap) if dist <= ap.params['range'][0]: mobility.handover(sta, ap, wlan, ap_wlan=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)
def moveNodeTo(self, sta, ap, dist, ang): x = float('%.2f' % (dist * cos(ang) + int(ap.params['position'][0]))) y = float('%.2f' % (dist * sin(ang) + int(ap.params['position'][1]))) sta.params['position'] = x, y, 0 mobility.parameters_(sta) if mininetWiFi.DRAW: try: plot2d.graphUpdate(sta) except: pass
def autoAssociation(self, stations, accessPoints): """ This is useful to make the users' life easier :param stations: list of stations :param accessPoints: list of access points """ nodes = stations + accessPoints 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 node.setTxPower_(node.params['wlan'][wlan], node.params['txpower'][wlan]) node.setAntennaGain_(node.params['wlan'][wlan], node.params['antennaGain'][wlan]) #node.setAntennaHeight_(node.params['wlan'][wlan], node.params['antennaHeight'][wlan]) ap = [] for node in accessPoints: if 'link' in node.params: ap.append(node) nodes = stations + ap if self.nroads == 0: for node in stations: for wlan in range(0, len(node.params['wlan'])): if node.func[wlan] == 'mesh': mobility.meshNodes.append(node) elif node.func[wlan] == 'adhoc': mobility.adhocNodes.append(node) for node in nodes: if 'position' in node.params and 'link' not in node.params: mobility.accessPoints = accessPoints mobility.parameters_(node) for sta in stations: for wlan in range(0, len(sta.params['wlan'])): for ap in accessPoints: if 'position' in sta.params and 'position' in ap.params: dist = link.getDistance(sta, ap) if dist <= ap.params['range']: mobility.handover(sta, ap, wlan)
def autoAssociation(self, stations, accessPoints): """ This is useful to make the users' life easier :param stations: list of stations :param accessPoints: list of access points """ nodes = stations + accessPoints for node in nodes: for wlan in range(0, len(node.params['wlan'])): node.setTxPower_(node.params['wlan'][wlan], node.params['txpower'][wlan]) ap = [] for node in accessPoints: if 'link' in node.params: ap.append(node) nodes = stations + ap if not self.isVanet: for node in stations: for wlan in range(0, len(node.params['wlan'])): if node.func[wlan] == 'mesh': mobility.meshNodes.append(node) elif node.func[wlan] == 'adhoc': mobility.adhocNodes.append(node) for node in nodes: if 'position' in node.params and 'link' not in node.params: mobility.accessPoints = accessPoints mobility.parameters_(node) for sta in stations: for wlan in range(0, len(node.params['wlan'])): for ap in accessPoints: if 'position' in sta.params and 'position' in ap.params: dist = link.getDistance(sta, ap) if dist <= ap.params['range']: mobility.handover(sta, ap, wlan, dist)
def mobility(self, mininet): if mininetWiFi.DRAW: instantiateGraph(mininet) currentTime = time.time() staList = mininet.stations stations = [] for node in staList: if 'speed' in node.params: stations.append(node) node.currentTime = 1 / node.params['speed'] node.time = float(1.0 / node.params['speed']) while True: time_ = time.time() - currentTime if len(stations) == 0: break for node in stations: while time_ >= node.currentTime and len(node.position) != 0: node.moveNodeTo(node.position[0]) mobility.parameters_(node) del node.position[0] node.currentTime += node.time if len(node.position) == 0: stations.remove(node)
def mobility(self, mininet, nodes): from mininet.node import AP, Station if nodes == None: nodes = mininet.stations + mininet.aps for node in nodes: if isinstance(node, Station): if 'position' in node.params and node not in mobility.stations: mobility.stations.append(node) if isinstance(node, AP): if 'position' in node.params and node not in mobility.aps: mobility.aps.append(node) if mininetWiFi.DRAW: instantiateGraph(mininet) if mininetWiFi.is3d: plot = plot3d else: plot = plot2d currentTime = time.time() if nodes is None: nodes = mininet.stations for node in nodes: if 'speed' in node.params: node.lastpos = 0, 0, 0 node.currentTime = 1 / node.params['speed'] node.timestamp = float(1.0 / node.params['speed']) node.isStationary = False if hasattr(node, 'time'): self.timestamp = True if self.timestamp: while True: time_ = time.time() - currentTime time.sleep(0.00001) if len(nodes) == 0: break for node in nodes: if hasattr(node, 'position'): position_ = (0, 0, 0) if time_ >= float(node.time[0]): position_ = node.position[0] del node.position[0] del node.time[0] if position_ != (0, 0, 0): node.setPosition(position_) if len(node.position) == 0: nodes.remove(node) mobility.parameters_() plot.graphPause() else: while True: time_ = time.time() - currentTime time.sleep(0.00001) if len(nodes) == 0: break for node in nodes: if hasattr(node, 'position'): position = (0, 0, 0) while time_ >= node.currentTime and len( node.position) != 0: position = node.position[0] del node.position[0] node.currentTime += node.timestamp if position != (0, 0, 0): node.setPosition(position) if len(node.position) == 0: nodes.remove(node) mobility.parameters_() plot.graphPause()