From 2f343e008fc202f1d16beb5747663002c5aa5457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20R=C3=B6sler?= Date: Sun, 4 Nov 2018 22:14:29 +0100 Subject: [PATCH 01/15] create wifi simulation module --- uniflex_module_simple/__init__.py | 3 +- uniflex_module_simple/module_simple4.py | 255 ++++++++++++++++++++++++ 2 files changed, 257 insertions(+), 1 deletion(-) create mode 100644 uniflex_module_simple/module_simple4.py diff --git a/uniflex_module_simple/__init__.py b/uniflex_module_simple/__init__.py index f8ece79..bf997f6 100644 --- a/uniflex_module_simple/__init__.py +++ b/uniflex_module_simple/__init__.py @@ -1,3 +1,4 @@ from .module_simple import * from .module_simple2 import * -from .module_simple3 import * \ No newline at end of file +from .module_simple3 import * +from .module_simple4 import * diff --git a/uniflex_module_simple/module_simple4.py b/uniflex_module_simple/module_simple4.py new file mode 100644 index 0000000..a963ca4 --- /dev/null +++ b/uniflex_module_simple/module_simple4.py @@ -0,0 +1,255 @@ +import time +import logging +import random + +from datetime import datetime + +from sbi.wifi.net_device import WiFiNetDevice +from sbi.wifi.events import PacketLossEvent, SpectralScanSampleEvent + +from uniflex.core import modules +from uniflex.core import exceptions +from uniflex.core.common import UniFlexThread + +__author__ = "Piotr Gawlowicz, Sascha Rösler" +__copyright__ = "Copyright (c) 2015, Technische Universität Berlin" +__version__ = "0.1.0" +__email__ = "{gawlowicz}@tkn.tu-berlin.de, s.roesler@campus.tu-berlin.de" + + +class SpectralScanner(UniFlexThread): + """docstring for SpectralScanner""" + + def __init__(self, module): + super().__init__(module) + + def task(self): + while not self.is_stopped(): + self.module.log.info("Spectral scan sample") + sample = SpectralScanSampleEvent( + sample=random.uniform(0, 64)) + self.module.send_event(sample) + time.sleep(1) + + +class PacketLossMonitor(UniFlexThread): + """docstring for SpectralScanner""" + + def __init__(self, module): + super().__init__(module) + + def task(self): + while not self.is_stopped(): + self.module.log.debug("Packet Lost") + event = PacketLossEvent() + # yeld or send Event to controller + self.module.send_event(event) + time.sleep(random.uniform(0, 10)) + + +class SimpleModule4(modules.DeviceModule, WiFiNetDevice): + def __init__(self, **kwargs): + super(SimpleModule4, self).__init__() + self.log = logging.getLogger('SimpleModule') + self.channel = 1 + self.chw = 'HT20' # channel bandwidth + self.power = 1 + + self.stopRssi = True + + self._packetLossMonitor = PacketLossMonitor(self) + self._spectralScanner = SpectralScanner(self) + + self.connectedDevices = {} + + if "MAC_List" in kwargs: + for connectedMAC in kwargs["MAC_List"]: + self.connectedDevices[connectedMAC] = { + "inactive time": 0, + "rx bytes": 0, + "rx packets": 0, + "tx bytes": 0, + "tx packets": 0, + "tx retries": 0, + "tx failed": 0, + "signal": -60, + "signal avg": -59, + "tx bitrate": 144.4, + "rx bitrate": 144.4, + "expected throughput": 46.875, + "authorized": "yes", + "authenticated": "yes", + "preamble": "long", + "WMM/WME": "yes", + "MFP": "no", + "TDLS peer": "no", + "last update": datetime.now()} + else: + self.log.warning("There are no conneted devices!") + + @modules.on_start() + def _myFunc_1(self): + self.log.info("This function is executed on agent start".format()) + + @modules.on_exit() + def _myFunc_2(self): + self.log.info("This function is executed on agent exit".format()) + + @modules.on_connected() + def _myFunc_3(self): + self.log.info("This function is executed on connection" + " to global controller".format()) + + @modules.on_disconnected() + def _myFunc_4(self): + self.log.info( + "This function is executed after connection with global" + " controller was lost".format()) + + @modules.on_first_call_to_module() + def _myFunc_5(self): + self.log.info( + "This function is executed before first UPI" + " call to module".format()) + + def _before_set_channel(self): + self.log.info("This function is executed before set_channel".format()) + + def _after_set_channel(self): + self.log.info("This function is executed after set_channel".format()) + + @modules.before_call(_before_set_channel) + @modules.after_call(_after_set_channel) + def set_channel(self, channel, iface, **kwargs): + self.log.info(("Simple Module sets channel: {} " + + "on device: {} and iface: {}") + .format(channel, self.device, iface)) + self.channel = channel + if "channel_width" in kwargs: + if kwargs["channel_width"] in [None|'HT20'|'HT40-'|'HT40+']: + self.chw = kwargs["channel_width"] + else: + self.log.error("The given channel_width is invalid") + return ["SET_CHANNEL_OK", channel, 0] + + def get_channel(self, iface): + self.log.debug( + "Simple Module gets channel of device: {} and iface: {}" + .format(self.device, iface)) + return self.channel + + def get_channel_width(self, iface): + self.log.debug( + "Simple Module gets channel of device: {} and iface: {}" + .format(self.device, iface)) + return self.chw + + def set_tx_power(self, power, iface): + self.log.debug("Set power: {} on device: {} and iface: {}" + .format(power, self.device, iface)) + self.power = power + return {"SET_TX_POWER_OK_value": power} + + def get_tx_power(self, iface): + self.log.debug( + "Simple Module gets TX power on device: {} and iface: {}" + .format(self.device, iface)) + return self.power + + def packet_loss_monitor_start(self): + if self._packetLossMonitor.is_running(): + return True + + self.log.info("Start Packet Loss Monitor") + self._packetLossMonitor.start() + return True + + def packet_loss_monitor_stop(self): + self.log.info("Stop Packet Loss Monitor") + self._packetLossMonitor.stop() + return True + + def is_packet_loss_monitor_running(self): + return self._packetLossMonitor.is_running() + + def spectral_scan_start(self): + if self._spectralScanner.is_running(): + return True + + self.log.info("Start spectral scanner") + self._spectralScanner.start() + return True + + def spectral_scan_stop(self): + self.log.info("Stop spectral scanner") + self._spectralScanner.stop() + return True + + def is_spectral_scan_running(self): + return self._spectralScanner.is_running() + + def clean_per_flow_tx_power_table(self, iface): + self.log.debug("clean per flow tx power table".format()) + raise exceptions.FunctionExecutionFailedException( + func_name='radio.clean_per_flow_tx_power_table', err_msg='wrong') + + def get_info_of_connected_devices(self, ifaceName): + ''' + Returns information about associated STAs + for a node running in AP mode + tbd: use Netlink API + ''' + + self.log.info("Simple Module generates info on assoc clients on iface: %s" % str(ifaceName)) + + res = {} + + for mac_addr in self.connectedDevices: + values = self.connectedDevices[mac_addr] + + res[mac_addr] = { + "inactive time": (str(values["inactive time"]), "ms"), + "rx bytes": (str(values["rx bytes"]), None), + "rx packets": (str(values["rx packets"]), None), + "tx bytes": (str(values["tx bytes"]), None), + "tx packets": (str(values["tx packets"]), None), + "tx retries": (str(values["tx retries"]), None), + "tx failed": (str(values["tx failed"]), None), + "signal": (str(values["signal"]), "dBm"), + "signal avg": (str(values["signal avg"]), "dBm"), + "tx bitrate": (str(values["tx bitrate"]), "MBit/sec"), + "rx bitrate": (str(values["rx bitrate"]), "MBit/sec"), + "expected throughput":(str(values["expected throughput"]), "Mbps"), + "authorized": (values["authorized"], None), + "authenticated": (values["authenticated"], None), + "preamble": (values["preamble"], None), + "WMM/WME": (values["WMM/WME"], None), + "MFP": (values["MFP"], None), + "TDLS peer": (values["TDLS peer"], None), + "timestamp": (str(datetime.now()), None)} + return res + + def set_packet_counter(self, flows, ifaceName): + self.log.info("Simple Module generates some traffic for clients on iface: %s" % str(ifaceName)) + for mac_addr in self.connectedDevices: + flowsOnChannel = 0 + for flow in flows: + if flow["channel number"] == self.channel: + flowsOnChannel += 1 + + lastUpdate = self.connectedDevices[mac_addr]["last update"] + timestamp = datetime.now() + + + dif = timestamp - lastUpdate + difMs = (dif.total_seconds() * 1000 * + 1 + dif.microseconds / 1000.0) + + newRxPackets = random.uniform(0, (dif.total_seconds() / 2.0 + 1)) + self.connectedDevices[mac_addr]["rx packets"] += int(newRxPackets) + self.connectedDevices[mac_addr]["rx bytes"] += int(newRxPackets * random.uniform(100, 200)) + + newTxPackets = difMs / 1000.0 * 7.0 / flowsOnChannel #+ random.uniform(0, difMs / 10) + self.connectedDevices[mac_addr]["tx packets"] += int(newTxPackets) + self.connectedDevices[mac_addr]["tx bytes"] += int(newTxPackets * random.uniform(700000, 800000)) + + self.connectedDevices[mac_addr]["last update"] = timestamp From fc02a9e0013dc013ee92af8aab4670ff6f37f7bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20R=C3=B6sler?= Date: Sun, 11 Nov 2018 20:18:13 +0100 Subject: [PATCH 02/15] add get_interfaces() --- uniflex_module_simple/module_simple4.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/uniflex_module_simple/module_simple4.py b/uniflex_module_simple/module_simple4.py index a963ca4..0cae6fa 100644 --- a/uniflex_module_simple/module_simple4.py +++ b/uniflex_module_simple/module_simple4.py @@ -172,6 +172,9 @@ def packet_loss_monitor_stop(self): def is_packet_loss_monitor_running(self): return self._packetLossMonitor.is_running() + def get_interfaces(self): + return ['wlan0'] + def spectral_scan_start(self): if self._spectralScanner.is_running(): return True From 5abe01532f9a08f2746fec811ae8867730512ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20R=C3=B6sler?= Date: Sun, 9 Dec 2018 15:55:13 +0100 Subject: [PATCH 03/15] add logging --- uniflex_module_simple/module_simple4.py | 1 + 1 file changed, 1 insertion(+) diff --git a/uniflex_module_simple/module_simple4.py b/uniflex_module_simple/module_simple4.py index 0cae6fa..197e05d 100644 --- a/uniflex_module_simple/module_simple4.py +++ b/uniflex_module_simple/module_simple4.py @@ -173,6 +173,7 @@ def is_packet_loss_monitor_running(self): return self._packetLossMonitor.is_running() def get_interfaces(self): + self.log.info("read interfaces") return ['wlan0'] def spectral_scan_start(self): From cc28bb90cf9a944c994a71e35271d3efa90a7629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20R=C3=B6sler?= Date: Wed, 6 Mar 2019 13:18:51 +0100 Subject: [PATCH 04/15] debug module --- uniflex_module_simple/module_simple4.py | 55 +++++++++++++++++++------ 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/uniflex_module_simple/module_simple4.py b/uniflex_module_simple/module_simple4.py index 197e05d..9718d85 100644 --- a/uniflex_module_simple/module_simple4.py +++ b/uniflex_module_simple/module_simple4.py @@ -56,14 +56,20 @@ def __init__(self, **kwargs): self.power = 1 self.stopRssi = True + self.channel_change = False self._packetLossMonitor = PacketLossMonitor(self) self._spectralScanner = SpectralScanner(self) self.connectedDevices = {} - if "MAC_List" in kwargs: - for connectedMAC in kwargs["MAC_List"]: + if "myMAC" in kwargs: + self.myMAC = kwargs['myMAC'] + else: + self.log.error("There are no MAC-Address for the AP!") + + if "clients" in kwargs: + for connectedMAC in kwargs["clients"]: self.connectedDevices[connectedMAC] = { "inactive time": 0, "rx bytes": 0, @@ -86,7 +92,10 @@ def __init__(self, **kwargs): "last update": datetime.now()} else: self.log.warning("There are no conneted devices!") - + + if "neighbors" in kwargs: + self.neighbors = kwargs["neighbors"] + @modules.on_start() def _myFunc_1(self): self.log.info("This function is executed on agent start".format()) @@ -124,6 +133,10 @@ def set_channel(self, channel, iface, **kwargs): self.log.info(("Simple Module sets channel: {} " + "on device: {} and iface: {}") .format(channel, self.device, iface)) + + if self.channel != channel: + self.channel_change = True + self.channel = channel if "channel_width" in kwargs: if kwargs["channel_width"] in [None|'HT20'|'HT40-'|'HT40+']: @@ -233,27 +246,45 @@ def get_info_of_connected_devices(self, ifaceName): "timestamp": (str(datetime.now()), None)} return res - def set_packet_counter(self, flows, ifaceName): + def get_address(self): + return self.myMAC + + def set_packet_counter(self, rrmPlan, ifaceName): self.log.info("Simple Module generates some traffic for clients on iface: %s" % str(ifaceName)) + + sameChannelAPs = 0 + + for device in rrmPlan: + if device["channel number"] == self.channel and device["mac address"] in self.neighbors: + sameChannelAPs += 1 + for mac_addr in self.connectedDevices: - flowsOnChannel = 0 - for flow in flows: - if flow["channel number"] == self.channel: - flowsOnChannel += 1 lastUpdate = self.connectedDevices[mac_addr]["last update"] timestamp = datetime.now() dif = timestamp - lastUpdate + difMs = (dif.total_seconds() * 1000 * + 1 + dif.microseconds / 1000.0) - newRxPackets = random.uniform(0, (dif.total_seconds() / 2.0 + 1)) + # change of channel takes 100ms + if self.channel_change: + difMs -= 200 + + + bandwidth = 54 * 10e6 / 1000 # 54 MBit/sec in ms + bandwidth /= (sameChannelAPs +1) # devide bandwidth by number of APs in range + bandwidth /= len(self.connectedDevices) # deice bandwidth by number of clients + bandwidth_packet = bandwidth / (60000 * 8) # Bits per Packet (60000 < 65535), 0.11 p ms + + newRxPackets = 5 # low upload self.connectedDevices[mac_addr]["rx packets"] += int(newRxPackets) - self.connectedDevices[mac_addr]["rx bytes"] += int(newRxPackets * random.uniform(100, 200)) + self.connectedDevices[mac_addr]["rx bytes"] += int(newRxPackets * 60000)#* random.uniform(10000, 60000)) - newTxPackets = difMs / 1000.0 * 7.0 / flowsOnChannel #+ random.uniform(0, difMs / 10) + newTxPackets = difMs * bandwidth_packet self.connectedDevices[mac_addr]["tx packets"] += int(newTxPackets) - self.connectedDevices[mac_addr]["tx bytes"] += int(newTxPackets * random.uniform(700000, 800000)) + self.connectedDevices[mac_addr]["tx bytes"] += int(newTxPackets * random.uniform(40000, 60000)) self.connectedDevices[mac_addr]["last update"] = timestamp + self.channel_change = False From ef2c512d311f94225811ca1e1a20a5844b83ea3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20R=C3=B6sler?= Date: Thu, 7 Mar 2019 22:00:02 +0100 Subject: [PATCH 05/15] add debug interface --- uniflex_module_simple/module_simple4.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/uniflex_module_simple/module_simple4.py b/uniflex_module_simple/module_simple4.py index 9718d85..38ba2aa 100644 --- a/uniflex_module_simple/module_simple4.py +++ b/uniflex_module_simple/module_simple4.py @@ -96,6 +96,16 @@ def __init__(self, **kwargs): if "neighbors" in kwargs: self.neighbors = kwargs["neighbors"] + self.channelSwitchingTime = 100 + self.channelBandwith = 54e6 + + if "simulation" in kwargs: + if "channelSwitchingTime" in kwargs['simulation']: + self.channelSwitchingTime = kwargs['simulation']['channelSwitchingTime'] + if "channelThroughput" in kwargs['simulation']: + self.channelSwitchingTime = kwargs['simulation']['channelThroughput'] + + @modules.on_start() def _myFunc_1(self): self.log.info("This function is executed on agent start".format()) @@ -259,7 +269,6 @@ def set_packet_counter(self, rrmPlan, ifaceName): sameChannelAPs += 1 for mac_addr in self.connectedDevices: - lastUpdate = self.connectedDevices[mac_addr]["last update"] timestamp = datetime.now() @@ -270,10 +279,10 @@ def set_packet_counter(self, rrmPlan, ifaceName): # change of channel takes 100ms if self.channel_change: - difMs -= 200 + difMs -= self.channelSwitchingTime - bandwidth = 54 * 10e6 / 1000 # 54 MBit/sec in ms + bandwidth = self.channelThroughput / 1000 # 54 MBit/sec in ms bandwidth /= (sameChannelAPs +1) # devide bandwidth by number of APs in range bandwidth /= len(self.connectedDevices) # deice bandwidth by number of clients bandwidth_packet = bandwidth / (60000 * 8) # Bits per Packet (60000 < 65535), 0.11 p ms From 610abe72f214b735c6c1b5622dd1e593f473cdaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20R=C3=B6sler?= Date: Thu, 7 Mar 2019 22:14:28 +0100 Subject: [PATCH 06/15] add debug interface --- uniflex_module_simple/module_simple4.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/uniflex_module_simple/module_simple4.py b/uniflex_module_simple/module_simple4.py index 38ba2aa..a7404c6 100644 --- a/uniflex_module_simple/module_simple4.py +++ b/uniflex_module_simple/module_simple4.py @@ -98,12 +98,15 @@ def __init__(self, **kwargs): self.channelSwitchingTime = 100 self.channelBandwith = 54e6 + self.txBytesRandom = 0 if "simulation" in kwargs: if "channelSwitchingTime" in kwargs['simulation']: self.channelSwitchingTime = kwargs['simulation']['channelSwitchingTime'] if "channelThroughput" in kwargs['simulation']: self.channelSwitchingTime = kwargs['simulation']['channelThroughput'] + if "txBytesRandom" in kwargs['simulation']: + self.txBytesRandom = kwargs['simulation']['txBytesRandom'] @modules.on_start() @@ -293,7 +296,10 @@ def set_packet_counter(self, rrmPlan, ifaceName): newTxPackets = difMs * bandwidth_packet self.connectedDevices[mac_addr]["tx packets"] += int(newTxPackets) - self.connectedDevices[mac_addr]["tx bytes"] += int(newTxPackets * random.uniform(40000, 60000)) + if(self.txBytesRandom > 0 && < 1): + self.connectedDevices[mac_addr]["tx bytes"] += int(newTxPackets * random.uniform(int(60000 * (1-self.txBytesRandom)), 60000)) + else + self.connectedDevices[mac_addr]["tx bytes"] += int(newTxPackets * 60000) self.connectedDevices[mac_addr]["last update"] = timestamp self.channel_change = False From 2f3b413cab393ae914899e485a590f067ad60d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20R=C3=B6sler?= Date: Sun, 10 Mar 2019 23:09:01 +0100 Subject: [PATCH 07/15] debug interface --- uniflex_module_simple/module_simple4.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/uniflex_module_simple/module_simple4.py b/uniflex_module_simple/module_simple4.py index a7404c6..d38ed4c 100644 --- a/uniflex_module_simple/module_simple4.py +++ b/uniflex_module_simple/module_simple4.py @@ -104,7 +104,7 @@ def __init__(self, **kwargs): if "channelSwitchingTime" in kwargs['simulation']: self.channelSwitchingTime = kwargs['simulation']['channelSwitchingTime'] if "channelThroughput" in kwargs['simulation']: - self.channelSwitchingTime = kwargs['simulation']['channelThroughput'] + self.channelBandwith = kwargs['simulation']['channelThroughput'] if "txBytesRandom" in kwargs['simulation']: self.txBytesRandom = kwargs['simulation']['txBytesRandom'] @@ -277,28 +277,25 @@ def set_packet_counter(self, rrmPlan, ifaceName): dif = timestamp - lastUpdate - difMs = (dif.total_seconds() * 1000 * + 1 + dif.microseconds / 1000.0) # change of channel takes 100ms if self.channel_change: difMs -= self.channelSwitchingTime - - bandwidth = self.channelThroughput / 1000 # 54 MBit/sec in ms + bandwidth = self.channelBandwith / 1000 # 54 MBit/sec in ms bandwidth /= (sameChannelAPs +1) # devide bandwidth by number of APs in range bandwidth /= len(self.connectedDevices) # deice bandwidth by number of clients bandwidth_packet = bandwidth / (60000 * 8) # Bits per Packet (60000 < 65535), 0.11 p ms - newRxPackets = 5 # low upload self.connectedDevices[mac_addr]["rx packets"] += int(newRxPackets) self.connectedDevices[mac_addr]["rx bytes"] += int(newRxPackets * 60000)#* random.uniform(10000, 60000)) newTxPackets = difMs * bandwidth_packet self.connectedDevices[mac_addr]["tx packets"] += int(newTxPackets) - if(self.txBytesRandom > 0 && < 1): + if(self.txBytesRandom > 0 and self.txBytesRandom < 1): self.connectedDevices[mac_addr]["tx bytes"] += int(newTxPackets * random.uniform(int(60000 * (1-self.txBytesRandom)), 60000)) - else + else: self.connectedDevices[mac_addr]["tx bytes"] += int(newTxPackets * 60000) self.connectedDevices[mac_addr]["last update"] = timestamp From 46545d96452db842b7a42229892fa41a1b9ce888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20R=C3=B6sler?= Date: Tue, 16 Apr 2019 20:50:52 +0200 Subject: [PATCH 08/15] print uuid --- uniflex_module_simple/module_simple4.py | 1 + 1 file changed, 1 insertion(+) diff --git a/uniflex_module_simple/module_simple4.py b/uniflex_module_simple/module_simple4.py index d38ed4c..8573ea4 100644 --- a/uniflex_module_simple/module_simple4.py +++ b/uniflex_module_simple/module_simple4.py @@ -51,6 +51,7 @@ class SimpleModule4(modules.DeviceModule, WiFiNetDevice): def __init__(self, **kwargs): super(SimpleModule4, self).__init__() self.log = logging.getLogger('SimpleModule') + self.log.info("This is SimpleModule4 with UUID: " + self.uuid) self.channel = 1 self.chw = 'HT20' # channel bandwidth self.power = 1 From 75b9f633308aeee6c0c711592f0756075eb65607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20R=C3=B6sler?= Date: Sat, 11 May 2019 15:11:43 +0200 Subject: [PATCH 09/15] add comments --- uniflex_module_simple/module_simple4.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/uniflex_module_simple/module_simple4.py b/uniflex_module_simple/module_simple4.py index 8573ea4..5e4eb7e 100644 --- a/uniflex_module_simple/module_simple4.py +++ b/uniflex_module_simple/module_simple4.py @@ -14,7 +14,7 @@ __author__ = "Piotr Gawlowicz, Sascha Rösler" __copyright__ = "Copyright (c) 2015, Technische Universität Berlin" __version__ = "0.1.0" -__email__ = "{gawlowicz}@tkn.tu-berlin.de, s.roesler@campus.tu-berlin.de" +__email__ = "{gawlowicz}@tkn.tu-berlin.de, {s.roesler}@campus.tu-berlin.de" class SpectralScanner(UniFlexThread): @@ -99,13 +99,16 @@ def __init__(self, **kwargs): self.channelSwitchingTime = 100 self.channelBandwith = 54e6 + self.channelBandwithList = [] self.txBytesRandom = 0 if "simulation" in kwargs: if "channelSwitchingTime" in kwargs['simulation']: self.channelSwitchingTime = kwargs['simulation']['channelSwitchingTime'] + if "channelThroughputDefault" in kwargs['simulation']: + self.channelBandwith = kwargs['simulation']['channelThroughputDefault'] if "channelThroughput" in kwargs['simulation']: - self.channelBandwith = kwargs['simulation']['channelThroughput'] + self.channelBandwithList = kwargs['simulation']['channelThroughput'] if "txBytesRandom" in kwargs['simulation']: self.txBytesRandom = kwargs['simulation']['txBytesRandom'] @@ -264,6 +267,13 @@ def get_address(self): return self.myMAC def set_packet_counter(self, rrmPlan, ifaceName): + ''' + Simulates information about associated STAs + Takes the current state of the network: Map AP-Channel + Simple model: Devide bandwidth by all neighbouring devices on the same channel +1 + Number of bits is calculated by time since last call. Has internal state + Calculate number of packets by deviding the resulting throughput by 65535 Bits/packet + ''' self.log.info("Simple Module generates some traffic for clients on iface: %s" % str(ifaceName)) sameChannelAPs = 0 @@ -284,7 +294,12 @@ def set_packet_counter(self, rrmPlan, ifaceName): if self.channel_change: difMs -= self.channelSwitchingTime - bandwidth = self.channelBandwith / 1000 # 54 MBit/sec in ms + #take channel specific bandwidth + if self.channelBandwidthList[self.channel] not None: + bandwidth = self.channelBandwidthList[self.channel] / 1000 + else: + bandwidth = self.channelBandwith / 1000 # 54 MBit/sec in ms + bandwidth /= (sameChannelAPs +1) # devide bandwidth by number of APs in range bandwidth /= len(self.connectedDevices) # deice bandwidth by number of clients bandwidth_packet = bandwidth / (60000 * 8) # Bits per Packet (60000 < 65535), 0.11 p ms From 7edea99fa841da1c45786cbac10319d86b18c38d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20R=C3=B6sler?= Date: Fri, 7 Jun 2019 13:55:32 +0200 Subject: [PATCH 10/15] simulate time, return num of clients and neighbours --- uniflex_module_simple/module_simple4.py | 26 +++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/uniflex_module_simple/module_simple4.py b/uniflex_module_simple/module_simple4.py index 5e4eb7e..3cbceef 100644 --- a/uniflex_module_simple/module_simple4.py +++ b/uniflex_module_simple/module_simple4.py @@ -63,6 +63,7 @@ def __init__(self, **kwargs): self._spectralScanner = SpectralScanner(self) self.connectedDevices = {} + self.rrmPlan = [] if "myMAC" in kwargs: self.myMAC = kwargs['myMAC'] @@ -99,7 +100,7 @@ def __init__(self, **kwargs): self.channelSwitchingTime = 100 self.channelBandwith = 54e6 - self.channelBandwithList = [] + self.channelBandwidthList = [] self.txBytesRandom = 0 if "simulation" in kwargs: @@ -108,7 +109,7 @@ def __init__(self, **kwargs): if "channelThroughputDefault" in kwargs['simulation']: self.channelBandwith = kwargs['simulation']['channelThroughputDefault'] if "channelThroughput" in kwargs['simulation']: - self.channelBandwithList = kwargs['simulation']['channelThroughput'] + self.channelBandwidthList = kwargs['simulation']['channelThroughput'] if "txBytesRandom" in kwargs['simulation']: self.txBytesRandom = kwargs['simulation']['txBytesRandom'] @@ -266,7 +267,14 @@ def get_info_of_connected_devices(self, ifaceName): def get_address(self): return self.myMAC - def set_packet_counter(self, rrmPlan, ifaceName): + def get_current_neighbours(self, ifaceName): + neighborslist = [] + for device in self.rrmPlan: + if device["channel number"] == self.channel and device["mac address"] in self.neighbors: + neighborslist.append(device["mac address"]) + return neighborslist + + def set_packet_counter(self, rrmPlan, ifaceName, steptime=None): ''' Simulates information about associated STAs Takes the current state of the network: Map AP-Channel @@ -276,11 +284,14 @@ def set_packet_counter(self, rrmPlan, ifaceName): ''' self.log.info("Simple Module generates some traffic for clients on iface: %s" % str(ifaceName)) - sameChannelAPs = 0 + self.rrmPlan = rrmPlan + sameChannelAPs = len(self.get_current_neighbours(ifaceName)) + ''' for device in rrmPlan: if device["channel number"] == self.channel and device["mac address"] in self.neighbors: sameChannelAPs += 1 + ''' for mac_addr in self.connectedDevices: lastUpdate = self.connectedDevices[mac_addr]["last update"] @@ -290,13 +301,16 @@ def set_packet_counter(self, rrmPlan, ifaceName): dif = timestamp - lastUpdate difMs = (dif.total_seconds() * 1000 * + 1 + dif.microseconds / 1000.0) + if steptime: + difMs = steptime * 1000 + # change of channel takes 100ms if self.channel_change: difMs -= self.channelSwitchingTime #take channel specific bandwidth - if self.channelBandwidthList[self.channel] not None: - bandwidth = self.channelBandwidthList[self.channel] / 1000 + if len(self.channelBandwidthList) >= self.channel: + bandwidth = self.channelBandwidthList[self.channel-1] / 1000 else: bandwidth = self.channelBandwith / 1000 # 54 MBit/sec in ms From 8fee28eb96c9927def27482399de1e3d7fab3dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20R=C3=B6sler?= Date: Sat, 8 Jun 2019 23:19:09 +0200 Subject: [PATCH 11/15] change number of clients during runtime --- uniflex_module_simple/module_simple4.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/uniflex_module_simple/module_simple4.py b/uniflex_module_simple/module_simple4.py index 3cbceef..51910e4 100644 --- a/uniflex_module_simple/module_simple4.py +++ b/uniflex_module_simple/module_simple4.py @@ -65,6 +65,8 @@ def __init__(self, **kwargs): self.connectedDevices = {} self.rrmPlan = [] + self.clientconfig = None + if "myMAC" in kwargs: self.myMAC = kwargs['myMAC'] else: @@ -95,6 +97,8 @@ def __init__(self, **kwargs): else: self.log.warning("There are no conneted devices!") + self.clientNumber = len(self.connectedDevices) + if "neighbors" in kwargs: self.neighbors = kwargs["neighbors"] @@ -112,7 +116,15 @@ def __init__(self, **kwargs): self.channelBandwidthList = kwargs['simulation']['channelThroughput'] if "txBytesRandom" in kwargs['simulation']: self.txBytesRandom = kwargs['simulation']['txBytesRandom'] + if "clientnum" in kwargs['simulation']: + self.clientNumber = kwargs['simulation']['clientnum'] + if "clientconf" in kwargs['simulation']: + self.clientconf = kwargs['simulation']['clientconf'] + if self.clientconf: + f = open(self.clientconf, "r") + self.clientNumber = int(f.readline()) + f.close() @modules.on_start() def _myFunc_1(self): @@ -239,6 +251,11 @@ def get_info_of_connected_devices(self, ifaceName): res = {} + if self.clientconf: + f = open(self.clientconf, "r") + self.clientNumber = int(f.readline()) + f.close() + for mac_addr in self.connectedDevices: values = self.connectedDevices[mac_addr] @@ -262,7 +279,7 @@ def get_info_of_connected_devices(self, ifaceName): "MFP": (values["MFP"], None), "TDLS peer": (values["TDLS peer"], None), "timestamp": (str(datetime.now()), None)} - return res + return res[:self.clientNumber] def get_address(self): return self.myMAC @@ -293,6 +310,11 @@ def set_packet_counter(self, rrmPlan, ifaceName, steptime=None): sameChannelAPs += 1 ''' + if self.clientconf: + f = open(self.clientconf, "r") + self.clientNumber = int(f.readline()) + f.close() + for mac_addr in self.connectedDevices: lastUpdate = self.connectedDevices[mac_addr]["last update"] timestamp = datetime.now() From eff8984006b1efcace418f39c4a0516a9b69a54f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20R=C3=B6sler?= Date: Sun, 9 Jun 2019 20:20:51 +0200 Subject: [PATCH 12/15] add functionality --- uniflex_module_simple/module_simple4.py | 28 ++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/uniflex_module_simple/module_simple4.py b/uniflex_module_simple/module_simple4.py index 51910e4..456a294 100644 --- a/uniflex_module_simple/module_simple4.py +++ b/uniflex_module_simple/module_simple4.py @@ -119,12 +119,12 @@ def __init__(self, **kwargs): if "clientnum" in kwargs['simulation']: self.clientNumber = kwargs['simulation']['clientnum'] if "clientconf" in kwargs['simulation']: - self.clientconf = kwargs['simulation']['clientconf'] - - if self.clientconf: - f = open(self.clientconf, "r") - self.clientNumber = int(f.readline()) - f.close() + self.clientconfig = kwargs['simulation']['clientconf'] + + if self.clientconfig: + f = open(self.clientconfig, "r") + self.clientNumber = int(f.readline()) + f.close() @modules.on_start() def _myFunc_1(self): @@ -251,14 +251,17 @@ def get_info_of_connected_devices(self, ifaceName): res = {} - if self.clientconf: - f = open(self.clientconf, "r") + if self.clientconfig: + f = open(self.clientconfig, "r") self.clientNumber = int(f.readline()) f.close() + i = 0 for mac_addr in self.connectedDevices: values = self.connectedDevices[mac_addr] + if i >= self.clientNumber: + break res[mac_addr] = { "inactive time": (str(values["inactive time"]), "ms"), "rx bytes": (str(values["rx bytes"]), None), @@ -279,9 +282,10 @@ def get_info_of_connected_devices(self, ifaceName): "MFP": (values["MFP"], None), "TDLS peer": (values["TDLS peer"], None), "timestamp": (str(datetime.now()), None)} - return res[:self.clientNumber] + i += 1 + return res - def get_address(self): + def get_address(self, ifaceName=""): return self.myMAC def get_current_neighbours(self, ifaceName): @@ -310,8 +314,8 @@ def set_packet_counter(self, rrmPlan, ifaceName, steptime=None): sameChannelAPs += 1 ''' - if self.clientconf: - f = open(self.clientconf, "r") + if self.clientconfig: + f = open(self.clientconfig, "r") self.clientNumber = int(f.readline()) f.close() From 4eb5580c3bd64420b2c79fbb9d9f2ab647be8595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20R=C3=B6sler?= Date: Wed, 19 Jun 2019 16:50:35 +0200 Subject: [PATCH 13/15] implement round robin training state --- uniflex_module_simple/module_simple4.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/uniflex_module_simple/module_simple4.py b/uniflex_module_simple/module_simple4.py index 456a294..96a1571 100644 --- a/uniflex_module_simple/module_simple4.py +++ b/uniflex_module_simple/module_simple4.py @@ -98,6 +98,7 @@ def __init__(self, **kwargs): self.log.warning("There are no conneted devices!") self.clientNumber = len(self.connectedDevices) + self.scenario = 0 if "neighbors" in kwargs: self.neighbors = kwargs["neighbors"] @@ -106,6 +107,8 @@ def __init__(self, **kwargs): self.channelBandwith = 54e6 self.channelBandwidthList = [] self.txBytesRandom = 0 + self.mode = "" + self.numsClients = [0] if "simulation" in kwargs: if "channelSwitchingTime" in kwargs['simulation']: @@ -120,6 +123,10 @@ def __init__(self, **kwargs): self.clientNumber = kwargs['simulation']['clientnum'] if "clientconf" in kwargs['simulation']: self.clientconfig = kwargs['simulation']['clientconf'] + if "mode" in kwargs['simulation']: + self.mode = kwargs['simulation']['mode'] + if "numsClients" in kwargs['simulation']: + self.numsClients = kwargs['simulation']['numsClients'] if self.clientconfig: f = open(self.clientconfig, "r") @@ -251,11 +258,14 @@ def get_info_of_connected_devices(self, ifaceName): res = {} - if self.clientconfig: + if self.clientconfig and self.mode == "working": f = open(self.clientconfig, "r") self.clientNumber = int(f.readline()) f.close() + if self.mode == "training" and len(self.numsClients) > self.scenario: + self.clientNumber = self.numsClients[scenario] + i = 0 for mac_addr in self.connectedDevices: values = self.connectedDevices[mac_addr] @@ -285,7 +295,7 @@ def get_info_of_connected_devices(self, ifaceName): i += 1 return res - def get_address(self, ifaceName=""): + def getHwAddr(self, ifaceName=""): return self.myMAC def get_current_neighbours(self, ifaceName): @@ -295,7 +305,7 @@ def get_current_neighbours(self, ifaceName): neighborslist.append(device["mac address"]) return neighborslist - def set_packet_counter(self, rrmPlan, ifaceName, steptime=None): + def set_packet_counter(self, rrmPlan, ifaceName, steptime=None, scenario=0): ''' Simulates information about associated STAs Takes the current state of the network: Map AP-Channel @@ -314,11 +324,17 @@ def set_packet_counter(self, rrmPlan, ifaceName, steptime=None): sameChannelAPs += 1 ''' - if self.clientconfig: + self.scenario = scenario + + if self.clientconfig and self.mode == "working": f = open(self.clientconfig, "r") self.clientNumber = int(f.readline()) f.close() + if self.mode == "training" and len(self.numsClients) > scenario: + self.log.info("Simple Module switches to scenario: %s" % str(scenario)) + self.clientNumber = self.numsClients[scenario] + for mac_addr in self.connectedDevices: lastUpdate = self.connectedDevices[mac_addr]["last update"] timestamp = datetime.now() From ff7ec940bfa160c75b64c8dd83a10a72617dedcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20R=C3=B6sler?= Date: Thu, 25 Jul 2019 10:40:36 +0200 Subject: [PATCH 14/15] run multiple scenarios --- uniflex_module_simple/module_simple4.py | 187 ++++++++++++++++++------ 1 file changed, 140 insertions(+), 47 deletions(-) diff --git a/uniflex_module_simple/module_simple4.py b/uniflex_module_simple/module_simple4.py index 96a1571..44dd221 100644 --- a/uniflex_module_simple/module_simple4.py +++ b/uniflex_module_simple/module_simple4.py @@ -1,6 +1,9 @@ import time import logging import random +import numpy as np +import pickle +import json from datetime import datetime @@ -62,9 +65,6 @@ def __init__(self, **kwargs): self._packetLossMonitor = PacketLossMonitor(self) self._spectralScanner = SpectralScanner(self) - self.connectedDevices = {} - self.rrmPlan = [] - self.clientconfig = None if "myMAC" in kwargs: @@ -72,32 +72,42 @@ def __init__(self, **kwargs): else: self.log.error("There are no MAC-Address for the AP!") + self.numsClients = [0] + if "simulation" in kwargs: + if "numsClients" in kwargs['simulation']: + self.numsClients = kwargs['simulation']['numsClients'] + + self.connectedDevices = [] + for i in range(len(self.numsClients)): + self.connectedDevices.append({}) + if "clients" in kwargs: for connectedMAC in kwargs["clients"]: - self.connectedDevices[connectedMAC] = { - "inactive time": 0, - "rx bytes": 0, - "rx packets": 0, - "tx bytes": 0, - "tx packets": 0, - "tx retries": 0, - "tx failed": 0, - "signal": -60, - "signal avg": -59, - "tx bitrate": 144.4, - "rx bitrate": 144.4, - "expected throughput": 46.875, - "authorized": "yes", - "authenticated": "yes", - "preamble": "long", - "WMM/WME": "yes", - "MFP": "no", - "TDLS peer": "no", - "last update": datetime.now()} + for i in range(len(self.numsClients)): + self.connectedDevices[i][connectedMAC] = { + "inactive time": 0, + "rx bytes": 0, + "rx packets": 0, + "tx bytes": 0, + "tx packets": 0, + "tx retries": 0, + "tx failed": 0, + "signal": -60, + "signal avg": -59, + "tx bitrate": 144.4, + "rx bitrate": 144.4, + "expected throughput": 46.875, + "authorized": "yes", + "authenticated": "yes", + "preamble": "long", + "WMM/WME": "yes", + "MFP": "no", + "TDLS peer": "no", + "last update": datetime.now()} else: self.log.warning("There are no conneted devices!") - self.clientNumber = len(self.connectedDevices) + self.clientNumber = len(self.connectedDevices[0]) self.scenario = 0 if "neighbors" in kwargs: @@ -108,7 +118,10 @@ def __init__(self, **kwargs): self.channelBandwidthList = [] self.txBytesRandom = 0 self.mode = "" - self.numsClients = [0] + + self.generatorMaxNumClients = 0 + self.generatorScenariosPerAPSetting = 0 + self.clientPrefix = "cc:cc:cc:cc:cc:" if "simulation" in kwargs: if "channelSwitchingTime" in kwargs['simulation']: @@ -125,8 +138,72 @@ def __init__(self, **kwargs): self.clientconfig = kwargs['simulation']['clientconf'] if "mode" in kwargs['simulation']: self.mode = kwargs['simulation']['mode'] - if "numsClients" in kwargs['simulation']: - self.numsClients = kwargs['simulation']['numsClients'] + if "scenariosPerAPSetting" in kwargs['simulation']: + self.generatorScenariosPerAPSetting = kwargs['simulation']['scenariosPerAPSetting'] + if "maxNumClients" in kwargs['simulation']: + self.generatorMaxNumClients = kwargs['simulation']['maxNumClients'] + if "clientPrefix" in kwargs['simulation']: + self.clientPrefix = kwargs['simulation']['clientPrefix'] + + if self.mode == 'generator': + #generate client MACs + myMACs = [] + for i in range(self.generatorMaxNumClients): + myMACs.append(self.clientPrefix + hex(i)[2:].zfill(2)) + + #renew connectedDevices + self.connectedDevices = [] + for i in range(self.generatorScenariosPerAPSetting * len(self.neighbors)): + self.connectedDevices.append({}) + + for connectedMAC in myMACs: + # for each scenario, generate the client list + for i in range(self.generatorScenariosPerAPSetting * len(self.neighbors)): + self.connectedDevices[i][connectedMAC] = { + "inactive time": 0, + "rx bytes": 0, + "rx packets": 0, + "tx bytes": 0, + "tx packets": 0, + "tx retries": 0, + "tx failed": 0, + "signal": -60, + "signal avg": -59, + "tx bitrate": 144.4, + "rx bitrate": 144.4, + "expected throughput": 46.875, + "authorized": "yes", + "authenticated": "yes", + "preamble": "long", + "WMM/WME": "yes", + "MFP": "no", + "TDLS peer": "no", + "last update": datetime.now()} + + #generate numsClients + if "scenarioBackup" in kwargs['simulation']: + try: + with open(kwargs['simulation']["scenarioBackup"], 'r') as f: # Python 3: open(..., 'wb') + self.numsClients = np.array(json.loads(f.read())) + print(self.numsClients) + self.log.info("Load scenario of last run") + except ValueError as e: + self.numsClients = np.random.randint(self.generatorMaxNumClients, size=self.generatorScenariosPerAPSetting * len(self.neighbors)) + self.log.info("File format is wrong" + str(e)) + except IOError as e: + self.log.info("File not found. Skip loading" + str(e)) + self.numsClients = np.random.randint(self.generatorMaxNumClients, size=self.generatorScenariosPerAPSetting* len(self.neighbors)) + + with open(kwargs['simulation']["scenarioBackup"], 'w') as f: # Python 3: open(..., 'wb') + f.write(json.dumps(self.numsClients.tolist())) + else: + self.numsClients = np.random.randint(self.generatorMaxNumClients, size=self.generatorScenariosPerAPSetting * len(self.neighbors)) + + #generate neighbors + temp = [] + for i in range(self.generatorScenariosPerAPSetting): + temp.extend(self.neighbors) + self.neighbors = temp if self.clientconfig: f = open(self.clientconfig, "r") @@ -263,12 +340,12 @@ def get_info_of_connected_devices(self, ifaceName): self.clientNumber = int(f.readline()) f.close() - if self.mode == "training" and len(self.numsClients) > self.scenario: - self.clientNumber = self.numsClients[scenario] + if (self.mode == "training" or self.mode == 'generator') and len(self.numsClients) > self.scenario: + self.clientNumber = self.numsClients[self.scenario] i = 0 - for mac_addr in self.connectedDevices: - values = self.connectedDevices[mac_addr] + for mac_addr in self.connectedDevices[self.scenario]: + values = self.connectedDevices[self.scenario][mac_addr] if i >= self.clientNumber: break @@ -298,13 +375,16 @@ def get_info_of_connected_devices(self, ifaceName): def getHwAddr(self, ifaceName=""): return self.myMAC - def get_current_neighbours(self, ifaceName): + def get_current_neighbours(self, ifaceName, rrmPlan): neighborslist = [] - for device in self.rrmPlan: - if device["channel number"] == self.channel and device["mac address"] in self.neighbors: + for device in rrmPlan: + if device["channel number"] == self.channel and device["mac address"] in self.neighbors[self.scenario]: neighborslist.append(device["mac address"]) return neighborslist + def get_neighbours(self, ifaceName): + return self.neighbors[self.scenario] + def set_packet_counter(self, rrmPlan, ifaceName, steptime=None, scenario=0): ''' Simulates information about associated STAs @@ -315,9 +395,6 @@ def set_packet_counter(self, rrmPlan, ifaceName, steptime=None, scenario=0): ''' self.log.info("Simple Module generates some traffic for clients on iface: %s" % str(ifaceName)) - self.rrmPlan = rrmPlan - sameChannelAPs = len(self.get_current_neighbours(ifaceName)) - ''' for device in rrmPlan: if device["channel number"] == self.channel and device["mac address"] in self.neighbors: @@ -331,12 +408,23 @@ def set_packet_counter(self, rrmPlan, ifaceName, steptime=None, scenario=0): self.clientNumber = int(f.readline()) f.close() - if self.mode == "training" and len(self.numsClients) > scenario: + self.log.info("Simple Module rrm plan: %s" % str(rrmPlan)) + self.log.info("Simple Module scenario: %s" % str(scenario)) + self.log.info("Simple Module mode: %s" % str(self.mode)) + self.log.info("Simple Module numsClients: %s" % str(self.numsClients)) + + if (self.mode == "training" or self.mode == "generator") and len(self.numsClients) > scenario: self.log.info("Simple Module switches to scenario: %s" % str(scenario)) self.clientNumber = self.numsClients[scenario] - for mac_addr in self.connectedDevices: - lastUpdate = self.connectedDevices[mac_addr]["last update"] + if self.clientNumber <= 0: + return + + sameChannelAPs = len(self.get_current_neighbours(ifaceName, rrmPlan)) + + + for mac_addr in self.connectedDevices[self.scenario]: + lastUpdate = self.connectedDevices[self.scenario][mac_addr]["last update"] timestamp = datetime.now() @@ -357,18 +445,23 @@ def set_packet_counter(self, rrmPlan, ifaceName, steptime=None, scenario=0): bandwidth = self.channelBandwith / 1000 # 54 MBit/sec in ms bandwidth /= (sameChannelAPs +1) # devide bandwidth by number of APs in range - bandwidth /= len(self.connectedDevices) # deice bandwidth by number of clients + bandwidth /= self.clientNumber # devide bandwidth by number of clients bandwidth_packet = bandwidth / (60000 * 8) # Bits per Packet (60000 < 65535), 0.11 p ms newRxPackets = 5 # low upload - self.connectedDevices[mac_addr]["rx packets"] += int(newRxPackets) - self.connectedDevices[mac_addr]["rx bytes"] += int(newRxPackets * 60000)#* random.uniform(10000, 60000)) + self.connectedDevices[self.scenario][mac_addr]["rx packets"] += int(newRxPackets) + self.connectedDevices[self.scenario][mac_addr]["rx bytes"] += int(newRxPackets * 60000)#* random.uniform(10000, 60000)) + #self.log.info("Simple Module simulationtime %s" % str(difMs)) + #self.log.info("Simple Module same aps on channel %s" % str(sameChannelAPs)) + #self.log.info("Simple Module current clients %s" % str(self.clientNumber)) newTxPackets = difMs * bandwidth_packet - self.connectedDevices[mac_addr]["tx packets"] += int(newTxPackets) + self.connectedDevices[self.scenario][mac_addr]["tx packets"] += int(newTxPackets) if(self.txBytesRandom > 0 and self.txBytesRandom < 1): - self.connectedDevices[mac_addr]["tx bytes"] += int(newTxPackets * random.uniform(int(60000 * (1-self.txBytesRandom)), 60000)) + self.connectedDevices[self.scenario][mac_addr]["tx bytes"] += int(newTxPackets * random.uniform(int(60000 * (1-self.txBytesRandom)), 60000)) else: - self.connectedDevices[mac_addr]["tx bytes"] += int(newTxPackets * 60000) + self.connectedDevices[self.scenario][mac_addr]["tx bytes"] += int(newTxPackets * 60000) + + #self.log.info("Simple Module adds %s Bytes" % str(int(newTxPackets * 60000))) - self.connectedDevices[mac_addr]["last update"] = timestamp + self.connectedDevices[self.scenario][mac_addr]["last update"] = timestamp self.channel_change = False From 670cf9d9a4ba6856ce3a89fda918b73e6e37594e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20R=C3=B6sler?= Date: Mon, 29 Jul 2019 10:08:57 +0200 Subject: [PATCH 15/15] debug --- uniflex_module_simple/module_simple4.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uniflex_module_simple/module_simple4.py b/uniflex_module_simple/module_simple4.py index 44dd221..cd86839 100644 --- a/uniflex_module_simple/module_simple4.py +++ b/uniflex_module_simple/module_simple4.py @@ -205,7 +205,7 @@ def __init__(self, **kwargs): temp.extend(self.neighbors) self.neighbors = temp - if self.clientconfig: + if self.clientconfig and self.mode == 'working': f = open(self.clientconfig, "r") self.clientNumber = int(f.readline()) f.close()