summaryrefslogtreecommitdiffstats
path: root/nfvbench/traffic_gen
diff options
context:
space:
mode:
Diffstat (limited to 'nfvbench/traffic_gen')
-rw-r--r--nfvbench/traffic_gen/dummy.py30
-rw-r--r--nfvbench/traffic_gen/traffic_base.py4
-rw-r--r--nfvbench/traffic_gen/trex.py31
3 files changed, 27 insertions, 38 deletions
diff --git a/nfvbench/traffic_gen/dummy.py b/nfvbench/traffic_gen/dummy.py
index 2a1064f..9beea28 100644
--- a/nfvbench/traffic_gen/dummy.py
+++ b/nfvbench/traffic_gen/dummy.py
@@ -32,13 +32,7 @@ class DummyTG(AbstractTrafficGenerator):
self.duration_sec = traffic_client.config.duration_sec
self.intf_speed = traffic_client.generator_config.intf_speed
self.set_response_curve()
- # for packet capture, generate 2*scc random packets
- # normally we should generate packets coming from the right dest macs
- scc = traffic_client.config.service_chain_count
- self.packet_list = [self._get_packet_capture(mac_id) for mac_id in range(scc * 2)]
-
- def _get_packet_capture(self, mac_id):
- return {'binary': 'SSSSSS01234' + str(mac_id)}
+ self.packet_list = None
def get_version(self):
return "0.1"
@@ -164,7 +158,7 @@ class DummyTG(AbstractTrafficGenerator):
latencies[port].avg_usec = 50
def get_macs(self):
- return ['00.00.00.00.00.01', '00.00.00.00.00.02']
+ return ['00:00:00:00:00:01', '00:00:00:00:00:02']
def get_port_speed_gbps(self):
"""Return the local port speeds.
@@ -180,7 +174,17 @@ class DummyTG(AbstractTrafficGenerator):
pass
def fetch_capture_packets(self):
- pass
+ def _get_packet_capture(mac):
+ # convert text to binary
+ src_mac = mac.replace(':', '').decode('hex')
+ return {'binary': 'SSSSSS' + src_mac}
+
+ # for packet capture, generate 2*scc random packets
+ # normally we should generate packets coming from the right dest macs
+ self.packet_list = []
+ for dest_macs in self.traffic_client.generator_config.get_dest_macs():
+ for mac in dest_macs:
+ self.packet_list.append(_get_packet_capture(mac))
def stop_traffic(self):
pass
@@ -199,5 +203,9 @@ class DummyTG(AbstractTrafficGenerator):
def resolve_arp(self):
"""Resolve ARP sucessfully."""
- LOG.info('Dummy TG ARP OK')
- return True
+ def get_macs(port, scc):
+ return ['00:00:00:00:%02x:%02x' % (port, chain) for chain in range(scc)]
+ scc = self.traffic_client.generator_config.service_chain_count
+ res = [get_macs(port, scc) for port in range(2)]
+ LOG.info('Dummy TG ARP: %s', str(res))
+ return res
diff --git a/nfvbench/traffic_gen/traffic_base.py b/nfvbench/traffic_gen/traffic_base.py
index adb2bd0..459af0f 100644
--- a/nfvbench/traffic_gen/traffic_base.py
+++ b/nfvbench/traffic_gen/traffic_base.py
@@ -113,7 +113,9 @@ class AbstractTrafficGenerator(object):
def resolve_arp(self):
"""Resolve all configured remote IP addresses.
- return: True if ARP resolved successfully
+ return: None if ARP failed to resolve for all IP addresses
+ else a dict of list of dest macs indexed by port#
+ the dest macs in the list are indexed by the chain id
"""
pass
diff --git a/nfvbench/traffic_gen/trex.py b/nfvbench/traffic_gen/trex.py
index 31b0867..71b81c0 100644
--- a/nfvbench/traffic_gen/trex.py
+++ b/nfvbench/traffic_gen/trex.py
@@ -67,9 +67,6 @@ class TRex(AbstractTrafficGenerator):
self.port_handle = []
self.chain_count = self.generator_config.service_chain_count
self.rates = []
- # A dict of list of dest macs indexed by port#
- # the dest macs in the list are indexed by the chain id
- self.arps = {}
self.capture_id = None
self.packet_list = []
@@ -453,7 +450,9 @@ class TRex(AbstractTrafficGenerator):
def resolve_arp(self):
"""Resolve all configured remote IP addresses.
- return: True if ARP resolved successfully
+ return: None if ARP failed to resolve for all IP addresses
+ else a dict of list of dest macs indexed by port#
+ the dest macs in the list are indexed by the chain id
"""
self.client.set_service_mode(ports=self.port_handle)
LOG.info('Polling ARP until successful...')
@@ -513,9 +512,8 @@ class TRex(AbstractTrafficGenerator):
self.client.set_service_mode(ports=self.port_handle, enabled=False)
if len(arps) == len(self.port_handle):
- self.arps = arps
- return True
- return False
+ return arps
+ return None
def __is_rate_enough(self, l2frame_size, rates, bidirectional, latency):
"""Check if rate provided by user is above requirements. Applies only if latency is True."""
@@ -567,12 +565,6 @@ class TRex(AbstractTrafficGenerator):
stream_cfgs = [d.get_stream_configs() for d in self.generator_config.devices]
self.rates = [utils.to_rate_str(rate) for rate in rates]
for chain_id, (fwd_stream_cfg, rev_stream_cfg) in enumerate(zip(*stream_cfgs)):
- if self.arps:
- # in case of external chain with ARP, fill in the proper dest MAC
- # based on the 2 ARP replies for each chain
- fwd_stream_cfg['mac_dst'] = self.arps[self.port_handle[0]][chain_id]
- rev_stream_cfg['mac_dst'] = self.arps[self.port_handle[1]][chain_id]
-
streamblock[0].extend(self.generate_streams(self.port_handle[0],
chain_id,
fwd_stream_cfg,
@@ -614,19 +606,6 @@ class TRex(AbstractTrafficGenerator):
"""
return [port['speed'] for port in self.port_info]
- def get_dest_macs(self):
- """Return the dest MAC for all chains for both ports for the current traffic setup.
-
- return: a list of MAC addresses indexed by the port# [[m00, m01...], [m10, m11...]]
-
- If ARP are used, resolve_arp() must be called prior to calling this method.
- """
- # if ARP was used, return the dest MACs resolved by ARP
- if self.arps:
- return [self.arps[port] for port in self.port_handle]
- # no ARP, use the dest MACs as configured in the devices
- return [d.dest_macs for d in self.generator_config.devices]
-
def clear_stats(self):
"""Clear all stats in the traffic gneerator."""
if self.port_handle: