summaryrefslogtreecommitdiffstats
path: root/nfvbench/traffic_gen/trex.py
diff options
context:
space:
mode:
authorYichen Wang <yicwang@cisco.com>2017-08-03 17:48:07 -0700
committerYichen Wang <yicwang@cisco.com>2017-08-03 18:20:30 -0700
commit70e642c54ffbf50e860e87de3bdcb8fa65d8bac4 (patch)
tree7cd8d13e93d254f467224223f8daf775fbb85cf5 /nfvbench/traffic_gen/trex.py
parent04a7de082bd221eae3c7004f4e0b99dfa4f8be91 (diff)
Support to customize sport and dport for UDP traffic
Change-Id: I40f28f28dd105f18ab69c5b5a56086ff3a06f2f6 Signed-off-by: Yichen Wang <yicwang@cisco.com>
Diffstat (limited to 'nfvbench/traffic_gen/trex.py')
-rw-r--r--nfvbench/traffic_gen/trex.py7
1 files changed, 6 insertions, 1 deletions
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(