summaryrefslogtreecommitdiffstats
path: root/nfvbench/traffic_gen/traffic_base.py
diff options
context:
space:
mode:
authorKerim Gokarslan <kgokarsl@cisco.com>2017-10-13 17:29:58 -0700
committerKerim Gokarslan <kgokarsl@cisco.com>2017-10-16 11:53:49 -0700
commita79debff4a6436522feebd2221865a2a6a917a58 (patch)
treee798895746a4edddc083b6e618f766d7905a7fbc /nfvbench/traffic_gen/traffic_base.py
parent211bc02b88a19153eb33f9a4f6670638bf469676 (diff)
NFVBENCH-40 Add pylint to tox
Change-Id: Ic55a07145f27c4cfaa6df5523df3940ca4433af1 Signed-off-by: Kerim Gokarslan <kgokarsl@cisco.com>
Diffstat (limited to 'nfvbench/traffic_gen/traffic_base.py')
-rw-r--r--nfvbench/traffic_gen/traffic_base.py44
1 files changed, 27 insertions, 17 deletions
diff --git a/nfvbench/traffic_gen/traffic_base.py b/nfvbench/traffic_gen/traffic_base.py
index 064b2a2..568fae2 100644
--- a/nfvbench/traffic_gen/traffic_base.py
+++ b/nfvbench/traffic_gen/traffic_base.py
@@ -14,76 +14,86 @@
import abc
+from nfvbench.log import LOG
+import traffic_utils
+
+
class TrafficGeneratorException(Exception):
pass
class AbstractTrafficGenerator(object):
-
# src_mac (6) + dst_mac (6) + mac_type (2) + frame_check (4) = 18
l2_header_size = 18
imix_l2_sizes = [64, 594, 1518]
imix_l3_sizes = [size - l2_header_size for size in imix_l2_sizes]
imix_ratios = [7, 4, 1]
- imix_avg_l2_size = sum(map(
- lambda imix: 1.0 * imix[0] * imix[1],
- zip(imix_l2_sizes, imix_ratios))) / sum(imix_ratios)
+
+ imix_avg_l2_size = sum(
+ [1.0 * imix[0] * imix[1] for imix in zip(imix_l2_sizes, imix_ratios)]) / sum(imix_ratios)
+
+ traffic_utils.imix_avg_l2_sizes = imix_avg_l2_size
def __init__(self, config):
self.config = config
@abc.abstractmethod
- def get_version():
+ def get_version(self):
# Must be implemented by sub classes
return None
@abc.abstractmethod
- def init():
+ def init(self):
# Must be implemented by sub classes
return None
@abc.abstractmethod
- def connect():
+ def connect(self):
# Must be implemented by sub classes
return None
@abc.abstractmethod
- def config_interface():
+ def config_interface(self):
# Must be implemented by sub classes
return None
@abc.abstractmethod
- def create_traffic():
+ def create_traffic(self):
# Must be implemented by sub classes
return None
- @abc.abstractmethod
- def modify_traffic():
+ def modify_rate(self, rate, reverse):
+ port_index = int(reverse)
+ port = self.port_handle[port_index]
+ self.rates[port_index] = traffic_utils.to_rate_str(rate)
+ LOG.info('Modified traffic stream for %s, new rate=%s.', port,
+ traffic_utils.to_rate_str(rate))
+
+ def modify_traffic(self):
# Must be implemented by sub classes
return None
@abc.abstractmethod
- def get_stats():
+ def get_stats(self):
# Must be implemented by sub classes
return None
- @abc.abstractmethod
- def clear_traffic():
+ def clear_traffic(self):
# Must be implemented by sub classes
return None
@abc.abstractmethod
- def start_traffic():
+ def start_traffic(self):
# Must be implemented by sub classes
return None
@abc.abstractmethod
- def stop_traffic():
+ def stop_traffic(self):
# Must be implemented by sub classes
return None
@abc.abstractmethod
- def cleanup():
+ def cleanup(self):
# Must be implemented by sub classes
return None