From 70e642c54ffbf50e860e87de3bdcb8fa65d8bac4 Mon Sep 17 00:00:00 2001 From: Yichen Wang Date: Thu, 3 Aug 2017 17:48:07 -0700 Subject: Support to customize sport and dport for UDP traffic Change-Id: I40f28f28dd105f18ab69c5b5a56086ff3a06f2f6 Signed-off-by: Yichen Wang --- nfvbench/traffic_gen/trex.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'nfvbench/traffic_gen/trex.py') diff --git a/nfvbench/traffic_gen/trex.py b/nfvbench/traffic_gen/trex.py index 6c2a304..8aca290 100644 --- a/nfvbench/traffic_gen/trex.py +++ b/nfvbench/traffic_gen/trex.py @@ -139,7 +139,12 @@ class TRex(AbstractTrafficGenerator): if stream_cfg['vlan_tag'] is not None: pkt_base /= Dot1Q(vlan=stream_cfg['vlan_tag']) - pkt_base /= IP() / UDP() + udp_args = {} + if stream_cfg['udp_src_port']: + udp_args['sport'] = int(stream_cfg['udp_src_port']) + if stream_cfg['udp_dst_port']: + udp_args['dport'] = int(stream_cfg['udp_dst_port']) + pkt_base /= IP() / UDP(**udp_args) if stream_cfg['ip_addrs_step'] == 'random': src_fv = STLVmFlowVarRepetableRandom( -- cgit 1.2.3-korg