NFVBENCH-169: UDP port random step correction 37/70237/1
authorfmenguy <francoisregis.menguy@orange.com>
Fri, 29 May 2020 14:09:03 +0000 (16:09 +0200)
committerfmenguy <francoisregis.menguy@orange.com>
Fri, 29 May 2020 14:12:38 +0000 (16:12 +0200)
Change-Id: I1ff96c02ea5b3abd126f303e3197dbcaf60e7dc3
Signed-off-by: fmenguy <francoisregis.menguy@orange.com>
nfvbench/traffic_client.py
nfvbench/traffic_gen/trex_gen.py

index f26a747..6d52475 100755 (executable)
@@ -246,11 +246,8 @@ class Device(object):
         else:
             self.ip_block = IpBlock(self.ip, step, self.ip_size)
 
-        if generator_config.gen_config.udp_port_step == 'random':
-            step = 1
-        else:
-            step = generator_config.gen_config.udp_port_step
-        self.udp_ports = UdpPorts(src_min, src_max, dst_min, dst_max, step)
+        self.udp_ports = UdpPorts(src_min, src_max, dst_min, dst_max,
+                                  generator_config.gen_config.udp_port_step)
         self.gw_ip_block = IpBlock(generator_config.gateway_ips[port],
                                    generator_config.gateway_ip_addrs_step,
                                    self.chain_count)
index de9500a..7f48a2a 100644 (file)
@@ -388,11 +388,19 @@ class TRex(AbstractTrafficGenerator):
         udp_args = {}
         if stream_cfg['udp_src_port']:
             udp_args['sport'] = int(stream_cfg['udp_src_port'])
-            udp_args['sport_step'] = int(stream_cfg['udp_port_step'])
+            if stream_cfg['udp_port_step'] == 'random':
+                step = 1
+            else:
+                step = stream_cfg['udp_port_step']
+            udp_args['sport_step'] = int(step)
             udp_args['sport_max'] = int(stream_cfg['udp_src_port_max'])
         if stream_cfg['udp_dst_port']:
             udp_args['dport'] = int(stream_cfg['udp_dst_port'])
-            udp_args['dport_step'] = int(stream_cfg['udp_port_step'])
+            if stream_cfg['udp_port_step'] == 'random':
+                step = 1
+            else:
+                step = stream_cfg['udp_port_step']
+            udp_args['dport_step'] = int(step)
             udp_args['dport_max'] = int(stream_cfg['udp_dst_port_max'])
 
         pkt_base /= IP(src=stream_cfg['ip_src_addr'], dst=stream_cfg['ip_dst_addr']) / \
@@ -439,7 +447,7 @@ class TRex(AbstractTrafficGenerator):
                 max_value=udp_args['sport_max'],
                 size=2,
                 seed=random.randint(0, 32767),
-                limit=udp_args['udp_src_count'])
+                limit=stream_cfg['udp_src_count'])
             dst_fv_port = STLVmFlowVarRepeatableRandom(
                 name="p_dst",
                 min_value=udp_args['dport'],