diff options
author | Yaroslav Brustinov <ybrustin@cisco.com> | 2016-12-18 20:11:31 +0200 |
---|---|---|
committer | Yaroslav Brustinov <ybrustin@cisco.com> | 2016-12-19 11:23:48 +0200 |
commit | 5cfeb192a3ff47c5cacc21abe20db2f61a66dd2b (patch) | |
tree | 57a455e70d9ac9c453495f4929ac9fac5b9fb011 /scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py | |
parent | cc4bd93b660505a7c9d8e370a1220377907fa6d2 (diff) |
changes from code review
Change-Id: I628608643d902bd6310b04b8036fc5f1fcc42309
Signed-off-by: Yaroslav Brustinov <ybrustin@cisco.com>
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py')
-rwxr-xr-x | scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py | 55 |
1 files changed, 17 insertions, 38 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py index 3bce671a..26613e56 100755 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py @@ -1028,6 +1028,11 @@ class STLProfile(object): # check filename if not os.path.isfile(pcap_file): raise STLError("file '{0}' does not exists".format(pcap_file)) + if speedup <= 0: + raise STLError('Speedup should not be negative.') + if min_ipg_usec and min_ipg_usec < 0: + raise STLError('min_ipg_usec should not be negative.') + # make sure IPG is not less than 0.001 usec if (ipg_usec is not None and (ipg_usec < 0.001 * speedup) and @@ -1092,34 +1097,24 @@ class STLProfile(object): def __pkts_to_streams (pkts, ipg_usec, min_ipg_usec, speedup, loop_count, vm, packet_hook, start_delay_usec = 0): streams = [] - if speedup == 0: - raise STLError('Speedup should not be 0') - if min_ipg_usec and min_ipg_usec < 0: - raise STLError('min_ipg_usec should not be negative.') - if packet_hook: pkts = [(packet_hook(cap), meta) for (cap, meta) in pkts] - if ipg_usec == None: - constant_diff = None - else: - constant_diff = ipg_usec / float(speedup) - if min_ipg_usec is not None: - constant_diff = max(constant_diff, min_ipg_usec) - for i, (cap, meta) in enumerate(pkts, start = 1): # IPG - if not provided, take from cap - if constant_diff is None: + if ipg_usec is None: packet_time = meta[0] * 1e6 + meta[1] if i == 1: - isg = min_ipg_usec if min_ipg_usec else 0 - else: - isg = (packet_time - prev_time) / float(speedup) - if min_ipg_usec: - isg = max(isg, min_ipg_usec) + prev_time = packet_time + isg = (packet_time - prev_time) / float(speedup) + if min_ipg_usec and isg < min_ipg_usec: + isg = min_ipg_usec prev_time = packet_time - else: - isg = constant_diff + else: # user specified ipg + if min_ipg_usec: + isg = min_ipg_usec + else: + isg = ipg_usec / float(speedup) # handle last packet if i == len(pkts): @@ -1128,28 +1123,12 @@ class STLProfile(object): else: next = i + 1 action_count = 0 - self_start = False if i != 1 else True - - # add stream with delay that will not be part of loop: "delayed_start" -> 1 -> 2 -> 3 -> ... -> 1 -> 2 - if start_delay_usec and i == 1: - if loop_count == 1: # no loop actually - isg = start_delay_usec - else: - streams.append(STLStream(name = 'delayed_start', - packet = STLPktBuilder(pkt_buffer = cap, vm = vm), - mode = STLTXSingleBurst(total_pkts = 1, percentage = 100), - self_start = True, - isg = start_delay_usec, - action_count = action_count, - next = next)) - action_count = max(0, action_count - 1) - self_start = False streams.append(STLStream(name = i, packet = STLPktBuilder(pkt_buffer = cap, vm = vm), mode = STLTXSingleBurst(total_pkts = 1, percentage = 100), - self_start = self_start, - isg = isg, + self_start = True if (i == 1) else False, + isg = isg, # usec action_count = action_count, next = next)) |