def bw(self, distance, sta, ap, wlan): mode = ap.mode signalRange = ap.range customStep = self.custom_step(mode) custombw = self.custom_bw(mode) if distance != 0: if ap.equipmentModel == None: bw = self.set_bw_node_moving(mode) for n in range(0,signalRange+1): sta.receivedPower[wlan] = -50 - distance if n % customStep==0: if n>=distance: return bw elif distance > signalRange: return 0 bw = bw - custombw elif ap.equipmentModel != None and self.propagationModel == '': sta.receivedPower[wlan] = -50 - distance if sta.associatedAp[wlan] != 'NoAssociated': r = deviceDataRate(ap, sta, wlan) self.rate = r.rate else: self.rate = 0 return self.rate else: if sta.associatedAp[wlan] != 'NoAssociated': r = deviceDataRate(ap, sta, wlan) self.rate = r.rate else: self.rate = 0 return self.rate else: return self.set_bw(mode)
def calculateRate(self, sta, ap, dist): value = deviceDataRate(sta, ap, 0) custombw = value.rate rate = value.rate / 2.5 if ap.equipmentModel == None: rate = custombw * (1.1**-dist) if rate <= 0: rate = 1 return rate
def setBw(self, ap, iface): """ Set bw to AP """ value = deviceDataRate(ap, None, None) bw = value.rate ap.cmd("tc qdisc replace dev %s \ root handle 2: tbf rate %sMbit burst 15000 latency 2ms" % (iface, bw)) #Reordering packets ap.cmd('tc qdisc add dev %s parent 2:1 handle 10: pfifo limit 1000' % (iface))
def calculateRate(self, sta, ap, dist): value = deviceDataRate(sta, ap, 0) custombw = value.rate rate = value.rate / 2.5 if ap.equipmentModel == None: rate = custombw * (1.1 ** -dist) if rate <= 0: rate = 1 return rate
def calculateRate(self, sta, ap, dist): value = deviceDataRate(sta, ap, 0) custombw = value.rate rate = value.rate / 2.5 if 'equipmentModel' not in ap.params.keys(): rate = custombw * (1.1 ** -dist) if rate <= 0: rate = 1 return rate
def setBw(self, ap, wlan): """ Set bw to AP """ iface = str(ap) + '-wlan' + str(wlan) value = deviceDataRate(ap, None, None) bw = value.rate ap.pexec("tc qdisc replace dev %s \ root handle 2: netem rate %.2fmbit \ latency 1ms \ delay 0.1ms" % (iface, bw)) #Reordering packets ap.pexec('tc qdisc add dev %s parent 2:1 pfifo limit 1000' % iface)
def setBW(self, sta=None, ap=None, wlan=0, dist=0): """set BW :param sta: station :param ap: access point :param wlan: wlan ID :param dist: distance between source and destination """ value = deviceDataRate(sta, ap, wlan) custombw = value.rate rate = eval(self.equationBw) if rate <= 0.0: rate = 0.1 return rate
def setBw(self, ap, wlan): """ Set bw to AP """ iface = str(ap.virtualWlan) + str(wlan) if ap.equipmentModel == None: bw = wifiParameters.set_bw(ap.mode) else: r = deviceDataRate(ap, None, wlan) bw = r.rate os.system("tc qdisc replace dev %s \ root handle 2: netem rate %.2fmbit \ latency 1ms \ delay 0.1ms" % (iface, bw)) #Reordering packets os.system('tc qdisc add dev %s parent 2:1 pfifo limit 10000' % iface)
def addHoc(self, node, cls=None, **params): """ Configure AdHoc node: name of the node cls: custom association class/constructor params: parameters for station """ if 'intf' in params: for intf_ in node.params['wlan']: if params['intf'] == intf_: wlan = node.params['wlan'].index(intf_) else: wlan = node.ifaceToAssociate node.func[wlan] = 'adhoc' node.params['txpower'][wlan] = 20 node.params['ssid'] = [] for w in range(0, len(node.params['wlan'])): node.params['ssid'].append('') ssid = ("%s" % params.pop('ssid', {})) if (ssid != "{}"): node.params['ssid'][wlan] = ssid node.params['associatedTo'][wlan] = ssid else: node.params['ssid'][wlan] = 'adhocNetwork' node.params['associatedTo'][wlan] = 'adhocNetwork' deviceRange(node) value = deviceDataRate(sta=node, wlan=wlan) self.bw = value.rate enable_wmediumd = self.useWmediumd if 'channel' in params: node.setChannel(node.params['wlan'][wlan], params['channel']) cls = Association cls.configureAdhoc(node, wlan, enable_wmediumd) if 'intf' not in params: node.ifaceToAssociate += 1
def addHoc(self, node, cls=None, **params): """ Configure AdHoc node: name of the node cls: custom association class/constructor params: parameters for station """ if 'intf' in params: for intf_ in node.params['wlan']: if params['intf'] == intf_: wlan = node.params['wlan'].index(intf_) else: wlan = node.ifaceToAssociate node.func[wlan] = 'adhoc' options = { 'ip': ipAdd(params['nextIP'], ipBaseNum=params['ipBaseNum'], prefixLen=params['prefixLen']) + '/%s' % params['prefixLen'] } options.update(params) node.params['cell'] = [] node.params['ssid'] = [] for w in range(0, len(node.params['wlan'])): node.params['cell'].append('') node.params['ssid'].append('') ip = ("%s" % params.pop('ip', {})) if ip == "{}": ip = options['ip'] ssid = ("%s" % params.pop('ssid', {})) if (ssid != "{}"): node.params['ssid'][wlan] = ssid node.params['associatedTo'][wlan] = ssid else: node.params['ssid'][wlan] = 'adhocNetwork' node.params['associatedTo'][wlan] = 'adhocNetwork' cell = ("%s" % params.pop('cell', {})) if (cell != "{}"): node.params['cell'][wlan] = cell else: if 'position' not in node.params: node.params['cell'][wlan] = 'FE:4C:6A:B5:A9:7E' deviceRange(node) value = deviceDataRate(sta=node, wlan=wlan) self.bw = value.rate options['sta'] = node options.update(params) # Set default MAC - this should probably be in Link options.setdefault('addr1', self.randMac()) cls = Association cls.configureAdhoc(node, self.useWmediumd) if 'intf' not in params: node.ifaceToAssociate += 1
def setDataRate(self, sta=None, ap=None, wlan=0): value = deviceDataRate(sta, ap, wlan) return value
def setDataRate(cls, sta=None, ap=None, wlan=0): "Set the rate" value = deviceDataRate(sta, ap, wlan) return value
def addMesh(self, node, cls=None, **params): """ Configure wireless mesh node: name of the node cls: custom association class/constructor params: parameters for node """ if 'intf' in params: for intf_ in node.params['wlan']: if params['intf'] == intf_: wlan = node.params['wlan'].index(intf_) else: if node.type == 'station': wlan = node.ifaceToAssociate else: wlan = 0 node.func[wlan] = 'mesh' options = { 'ip': ipAdd(params['nextIP'], ipBaseNum=params['ipBaseNum'], prefixLen=params['prefixLen']) + '/%s' % params['prefixLen'] } options.update(params) node.params['ssid'] = [] if hasattr(node, 'meshMac'): for n in range(len(node.params['wlan'])): node.meshMac.append('') node.params['ssid'].append('') else: node.meshMac = [] for n in range(len(node.params['wlan'])): node.meshMac.append('') node.params['ssid'].append('') ip = ("%s" % params.pop('ip', {})) if ip == "{}": ip = options['ip'] ssid = ("%s" % params['ssid']) if (ssid != "{}"): node.params['ssid'][wlan] = ssid else: node.params['ssid'][wlan] = 'meshNetwork' deviceRange(node) value = deviceDataRate(sta=node, wlan=wlan) self.bw = value.rate options['node'] = node options.update(params) # Set default MAC - this should probably be in Link options.setdefault('addr1', self.randMac()) cls = Association cls.configureMesh(node, wlan) if 'intf' not in params: node.ifaceToAssociate += 1