forked from IxiaKeysight/FT2Classic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
perfUtils.tcl
3302 lines (2991 loc) · 117 KB
/
perfUtils.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# $Id: perfUtils.tcl,v 1.9 2019/02/07 14:03:03 kkg Exp $
# Copyright (c) 2009,2014 by Cisco Systems, Inc.
#
# Name: perfUtils.tcl
#
# Purpose:
# The perfUtils library currently has just one major proc
# for finding NDR (No Drop Rate) and latency.
# This is based on Binary Search algorithm.
# This library can be used for other performance utilities as well.
#
# Author:
# Muhammad A Imam - [email protected]
# Yuefeng Jiang - [email protected]
# Ruoying Pan - [email protected]
#
# Usage:
# set auto_path [linsert $auto_path 0 \
# [file join $env(AUTOTEST) regression lib mid_range_routing]]
# package require perfUtils
#
# Description:
# findNdr - The procedure uses a binary search algorithm to find the NDR
# using the ports and streams information provided by the user.
# The user must provide all of the mandatory argumrnts and
# optionally can provide the optional arguments mentioned below.
# The proc can also obtain latency based on statistical sampling.
# The proc can handle any type of traffic that can be configured
# in IxExplorer as streams. It handles multicast traffic seprately.
# The proc assumes the following:
# 1. The traffic streams will be setup by the user
# 2. On receiving ports packets have to be filtered in UDS1 or UDS2
# public proc:
# perfUtils::findNdr
# perfUtils::parseNdrResults
# perfUtils::writePerfValues
# perfUtils::writeMyPerfValues
# perfUtils::generate_keyed_result
# private proc:
# perfUtils::_run_IxExplorer_test
# perfUtils::_run_IxNetwork_test
# perfUtils::_run_IxNetwork_test2
# perfUtils::_get_txPkts_IxExplorer
# perfUtils::_get_rxPkts_IxExplorer
# perfUtils::_get_latency_IxExplorer
# perfUtils::_run_traffic_IxExplorer
# perfUtils::_set_curRate_IxNetwork
# perfUtils::_enable_stats_IxNetwork
# perfUtils::_get_txPkts_IxNetwork
# perfUtils::_get_txPkts_IxNetwork2
# perfUtils::_get_txRxPkts_IxNetwork
# perfUtils::_get_rxPkts_IxNetwork
# perfUtils::_get_rxPkts_IxNetwork2
# perfUtils::_get_latency_IxNetwork
# perfUtils::_get_latency_IxNetwork2
# perfUtils::_run_traffic_IxNetwork
# perfUtils::_maxrate
# perfUtils::_maxrate2
# perfUtils::_framesize
# perfUtils::_parse_tx_ports
# perfUtils::_parse_rx_ports
# perfUtils::_parse_mtx_ports
# perfUtils::_parse_mrx_ports
# perfUtils::_error
#
# Requirements:
# HLTAPI for generator being used
#
# Bugs:
# Bugs need to fix
# 1.
#
# Limitations:
# 1. All ports involved in the test need to be of the same capacity
# i.e. All of them to be 1Gig or 10Gig.
# The API cannot handle if the situation
# when one port is 1 Gig and the other is 10 Gig
# 2. The API assumes, if there are multiple streams per port,
# all streams have the same frame size defined
# 3. If calculating NDR for IMIX, specify the max_rate, otherwise
# the proc will puick a random max_rate based on the packet sizes
#package provide perfUtils 1.0
set script_dir [file dirname [info script]]
set sourcefile1 [file join $script_dir "mcpModules.tcl"]
set sourcefile2 [file join $script_dir "constants.h"]
if {[file exists $sourcefile1] && [file exists $sourcefile2]} {
if { [catch {
source [file join $script_dir "mcpModules.tcl"]
source [file join $script_dir "constants.h"]
} errmsg ] } {
set diag "Couldn't source mcpModules.tcl or constants.h, err: $errmsg"
ats_log -error $diag
ats_results -result fail -goto end
}
} else {
set diag "Couldn't source mcpModules.tcl or constants.h, file not exist"
ats_log -error $diag
ats_results -result fail -goto end
}
namespace eval ::perfUtils {
namespace export *
}
####################################################
# Description
####################################################
procDescr perfUtils::findNdr {
Description:
The procedure uses a binary search algorithm to find the NDR using the
ports and streams information provided by the user. The user must
provide all of the mandatory argumrnts and optionally can provide the
optional arguments mentioned below. The proc can also obtain latency
based on statistical sampling. The proc can handle any type of traffic
that can be configured in IxExplorer as streams. The proc handles
multicast traffic seprately.
The proc assumes the following:
1. The traffic streams will be setup by the user
2. On receiving ports the packets have to be filtered in UDS1 or UDS2
Usage:
set result [perfUtils::findNdr \
-tx_ports <Keyed List> \
-rx_ports <Keyed List> \
-mtx_ports <Keyed List> \
-max_rate <Numeric Value> \
-min_rate <Numeric Value> \
-threshold <Numeric Value> \
-run_time <Numeric value> \
-uds <uds1|uds2> \
-debug <0|1> \
-latency <0|1> \
-uut <Device Name as String> \
-tr <Other Device Name as String> \
-exec_cmds <List of commands as Strings> ]
Example:
keylset sendPorts port1.port 1/1/1
keylset sendPorts port1.streams {1 2 3}
keylset sendPorts port2.port 1/2/1
keylset sendPorts port2.streams {4 5 6}
keylset receivePorts port1.port 1/1/1
keylset receivePorts port2.port 1/2/1
set result [perfUtils::findNdr \
-tx_ports $sendPorts \
-rx_ports $receivePorts \
-max_rate 10000000 \
-min_rate 100000 \
-threshold 100000 \
-debug 1 \
-run_time 100 \
-latency 1 \
-uut $UUT ]
Arguments:
-tx_ports <Mandatory Argument> Keyed list in the following format
{port1 {{port 1/1/1} {streams {3 4 1}}}}
{port2 {{port 1/2/1} {streams {23 2 24 25}}}}
Example to define the keyed list:
keylset sendPorts port1.port 1/1/1
keylset sendPorts port1.streams {1 2 3}
keylset sendPorts port2.port 1/2/1
keylset sendPorts port2.streams {4 5 6}
Note: You have to give all the transmitting ports info
in a single keyed list as mentioned above in the
example. There is no limit on the number of
transmitting port that you may want to use as
long as all of them are of the same capacity.
e.g. all of them 10Gigs.
You MUST also include the multicast streams
in the tx stream list if you have mcast streams
-rx_port <Mandatory Argument> Keyed list in the following format
{port1 {{port 1/1/1}}} {port2 {{port 1/2/1}}}
Example to define the keyed list:
keylset receivePorts port1.port 1/1/1
keylset receivePorts port2.port 1/2/1
Note: You have to give all the receiving ports info
in a single keyed list as mentioned above in the
example. You can receive on any number of ports.
-mtx_ports <Optional Argument> Keyed list in the following format
{port2 {{port 1/2/1} {mcast_streams {5 6}}
{mcast_oifs {100 100}}}}
Example to define the keyed list:
keylset mcastPorts port2.port 1/2/1
keylset mcastPorts port2.mcast_streams {5 6}
keylset mcastPorts port2.mcast_oifs {100 100}
Note: You can have differnt replicas for differnt
streams. Therefore when you mention the multicast
streams you should also mention the number of
replicas you are expecting. If you have two
multicast streams defined you should also mention
the replicas (OIF) respectively. In the above
example stream 5 and 6 and multicast streams.
Each of them are supposed to replicate 100 times.
-max_rate <Optional Argument> This is the maximum rate the proc
is going to try on EACH PORT. So the rate you will
mention here will be per port rate in PPS. You should
account for packet size when mentioning the rate. The
procedure tries to find the NDR between the max_rate as
upper bound and min_rate as the lower bound. If you do
not define rate it will calculate the max rate based on
the port capacity and packet size used in the stream.
-min_rate <Optional Argument> This is the minimum rate in PPS
the proc is going to try, by default it is 1000
-threshold <Optional Argument> This is the thershold value in PPS.
The proc will not bother the differnce of this value
between the passing and failing NDR. By default is 1000
-run_time <Optional Argument> The proc runs the traffic for this
much amount of time. This is a vlue in seconds.
The default value is 120 seconds
-uds <Optional Argument> User can gather recieving traffic
stats on either UDS1 or UDS2. The user has to define
the right filters to cath the interesting traffic. By
default it looks for UDS1. If your traffic stats come
on UDS2 you can select uds2 and provide this argument
-tx_mode <Optional Argumnet> The API supports packet as well as
advanced streams. By default it is packet streams.
if your streams are advanced streams, use this optional
argument to define it is advanced. For advanced streams
the traffic rate will be devided over the number of
streams on each tx port
-debug <Optional Argument> by default the debug is OFF (0).
If you enable debug you can get additional log per port
to debug any issues. To enable set -debug value as 1
-latency <Optional Argument> By default the proc does not
calculate latency. If you enable latency by putting
-latency as 1 the proc will give you avg, min and max
latency. To obtain latency you should enable capture
filter and get a reasonable amount of packets in the
buffer (at least 2000)
-min_cap_pkts <Optional Arguments> By default the value is 20 packets
If this much amount of packet are not there capture
buffer the test is going to fail and will return error
-uut <Mandatory Argument> You must provide the UUT. On this
UUT you can run any commands at half of the run time
for stats or debug. The commands are supplied in the
-exec_cmds argument
-tr <Optional Argument> You can provide the TR. On this
RT you can run any commands at half of the run time
for stats or debug. The commands are supplied in the
-exec_cmds argument
-tgen_app <Optional Argument> By default its IxExplorer
-exec_cmds <Optional Argument> You can provide the list of
show commands to run at half run time. By default
it runs the follwoing three commands
console $uut
EnablePw [test_passwd enable]
$uut exec "show platform hardware qfp active datapath utilization"
$uut exec "show platform hardware qfp active infrastructure exmem statistics"
$uut exec "show platform software status control-processor brief"
$uut exec "show platform hardware qfp active statistics drop"
You should supply as a list e.g.
-exec_cmds {"sh plat hard qfp active data util"\
"sh plat hard qfp act infra exmem sta"\
"sh plat soft st control-processor br"}
-loss_rate <Optional Argument> loss_rate% number of packets lost
can be acceptable and regard as Non-drop.By default
it's 0.0, indicating the receiving ports shouldn't
lose packets compared with the sending ports.
Return Value:
Returns a keyed list with structure as follows:
status <1|0> - 1 for Pass 0 for Fail
<<if passes>>
ndr <NUMERIC> - in PPS
numPkts <NUMERIC> - Number of packets captured on UDS4 for latency.
If latency is not enabled or there is no capture it is 0
avgLatency <NUMERIC> - Averege latency in NanoSeconds
minLatency <NUMERIC> - Minimum Latency in NanoSeconds
maxLatency <NUMERIC> - Maximum Latency in NanoSeconds
cmd_outputs <STRINGS> - Based onm the arguments provided
output1
output2
...
..
.
<<in case it fails>>
log <STRING> - Message about failure
tclErr <STRING> - The error thrown by TCL
} ; # End of procDescr
#######################################################
#This proc finds the NDR and returns NDR along with latencies and other stats
#######################################################
proc perfUtils::findNdr {args} {
#mandatory args
set man_args {
-uut ANY
-tx_ports ANY
-rx_ports ANY
}
#optional_args
set opt_args {
-tr ANY
DEFAULT ""
-mtx_ports ANY
-mrx_ports ANY
-forceTxPorts NUMERIC
DEFAULT 0
-latency CHOICES 0 1
DEFAULT 0
-latency_rates NUMERIC
DEFAULT 95
-latency_detail CHOICES 0 1
DEFAULT 0
-min_cap_pkts NUMERIC
DEFAULT 20
-run_time NUMERIC
DEFAULT 120
-max_rate NUMERIC
DEFAULT 0
-min_rate NUMERIC
DEFAULT 1000
-threshold NUMERIC
DEFAULT 1000
-frame_size ANY
-tx_mode CHOICES packet advanced
DEFAULT packet
-exec_cmds ANY
DEFAULT {\
"show platform hardware qfp active datapath utilization"\
"show platform hardware qfp active infrastructure exmem statistics"\
"show platform software status control-processor brief"\
"show platform hardware qfp active statistics drop"}
-uds CHOICES uds1 uds2
DEFAULT uds1
-tgen_app CHOICES IxExplorer IxNetwork
DEFAULT IxNetwork
-ixnetwork_root ANY
-ixnetwork_traffic ANY
-debug CHOICES 0 1
DEFAULT 0
-loss_rate ANY
DEFAULT 0.0
}
#Parse the dashed arguments
parse_dashed_args -args $args \
-mandatory_args $man_args -optional_args $opt_args
ats_log -info "FindNdr args:$args"
#Define/initialize local variables
set SUCCESS 1
set FAILURE 0
set returnList ""
keylset returnList log ""
keylset returnList tclErr ""
append uds_count "$uds" "_count"
append uds_count2 "$uds" "_frame_count"
#debug 1
#Parse keyed lists
set txPorts ""; set txStreamSets ""; set txStreams ""; set numTxPorts 0
if {[_parse_tx_ports txPorts txStreamSets txStreams numTxPorts returnList \
$tx_ports $debug] != $SUCCESS} {
return $returnList
}
set rxPorts ""; set numRxPorts 0
if {[_parse_rx_ports rxPorts numRxPorts returnList $rx_ports $debug] \
!= $SUCCESS} {
return $returnList
}
set mtxPorts ""; set mtxStreamSets "";
set mtxOifSets ""; set mtxStreams ""; set mtxOifs ""
if {[info exists mtx_ports]} {
if {[_parse_mtx_ports mtxPorts mtxStreamSets mtxOifSets mtxStreams \
mtxOifs returnList $mtx_ports $debug] != $SUCCESS} {
return $returnList
}
} else {
set mtx_ports ""
}
set mrxPorts ""; set numMrxPorts 1
if {[info exists mrx_ports]} {
if {[_parse_mrx_ports mrxPorts numMrxPorts returnList $mrx_ports \
$debug] != $SUCCESS} {
return $returnList
}
} else {
set mrx_ports ""
}
if {[info exists max_rate] && $max_rate < 1} {
set maxRatePort [lindex $txPorts 0]
set stream_id [lindex [lindex $txStreamSets 0] 0]
#puts "_maxrate use: $stream_id"
set max_rate [_maxrate2 $maxRatePort $stream_id]
}
if {[info exists frame_size]} {} else {
set frame_size 0
if {$tgen_app == "IxExplorer"} {
set frameSizePort [lindex $txPorts 0]
set stream_id [lindex [lindex $txStreamSets 0] 0]
#puts "_framesize use: $stream_id"
set frame_size [_framesize $frameSizePort $stream_id]
}
}
#Initialize variables for results
set numPkts 0
set passNdr "NDR not found! Try using lower min_rate and threshold"
set passNumPkts 0
set passAvgLatency 0
set passMinLatency 0
set passMaxLatency 0
set passCmdOutputs "No Passed Run! All iterations FAILED"
set passCurRate 0
set everPass 0
#Initialize variables for while loop
set org_min_rate $min_rate
set nopass_threshold $min_rate
if { $nopass_threshold > $threshold } {
set nopass_threshold $threshold
}
set curRate $max_rate
set iteration 1
#start NDR binary search
set latency1 0
while {($max_rate - $threshold) >= $min_rate || \
( $org_min_rate == $min_rate && ($curRate - $nopass_threshold) > $org_min_rate) } {
# note: In original logic, if threshold is much larger than min_rate, and all former
# iteration FAIL, then the condition in while-loop "($max_rate - $threshold) >= $min_rate"
# will lead to break while and not try ~min_rate.
# e.g. min_rate=100, threshold=500, curRate=550 FAIL, set max_rate to 550, then
# max_rate 550 - threshold 500 = 50 < min_rate 100, break while. So only try rate 550,
# much bigger than the set min_rate value 100.
# So this mechanism to handle that if non of the iteration pass, go on try till near min_rate.
set diag "Iteration: $iteration"
ats_log -diag $diag
#Switch on tgen_app
switch $tgen_app {
IxExplorer {
#Run trafic @ curRate and get results - IxExplorer
if {[_run_IxExplorer_test txPkts rxPkts numPkts avgLatency \
minLatency maxLatency cmdOutputs returnList $txPorts $txStreams\
$txStreamSets $tx_mode $rxPorts $mtxPorts $mtxStreams \
$mtxStreamSets $mtxOifs $mtxOifSets $mtx_ports $run_time \
$curRate $uds_count $min_cap_pkts $numRxPorts $numMrxPorts \
$exec_cmds $uut $tr $latency1 0 $debug] != $SUCCESS} {
return $returnList
}
}
IxNetwork {
#Run trafic @ curRate and get results - IxNetwork
# if {[_run_IxNetwork_test txPkts rxPkts avgLatency minLatency \
# maxLatency ixNetworkStreamCount cmdOutputs $ixnetwork_root \
# $curRate $run_time $exec_cmds $uut $latency1 $debug] \
# != $SUCCESS} {
# return $returnList
# }
#set numPkts $rxPkts
if {[_run_IxNetwork_test2 txPkts rxPkts numPkts avgLatency \
minLatency maxLatency cmdOutputs returnList $txPorts $txStreams\
$txStreamSets $tx_mode $rxPorts $mtxPorts $mtxStreams \
$mtxStreamSets $mtxOifs $mtxOifSets $mtx_ports $run_time \
$curRate $uds_count2 $min_cap_pkts $numRxPorts $numMrxPorts \
$exec_cmds $uut $tr $latency1 0 $debug] != $SUCCESS} {
return $returnList
}
}
}
#Checks for binary search
# $txPkts != $rxPkts
set txPkts [expr {$txPkts*(100.0-$loss_rate)/100}]
if {$debug == 1} {
ats_log -info "loss rate:$loss_rate, txPkts:$txPkts"
}
if {$txPkts > $rxPkts || $rxPkts < $min_rate} {
set result "\n\nFAILED line rate $curRate pps (per port),\
loss_rate:$loss_rate"
ats_log -result $result
set max_rate $curRate
} else {
set result "\n\nPASSED line rate $curRate pps (per port),\
loss_rate:$loss_rate"
set everPass 1
ats_log -result $result
set min_rate $curRate
#NDR if this is the final successful run
if {$forceTxPorts > 0} {
if {$tx_mode == "advanced"} {
set passNdr [expr {$curRate * $numTxPorts * $txStreams}]
}
set passNdr [expr {$curRate * $numTxPorts}]
} else {
if {$tx_mode == "advanced"} {
#Added for IxNetwork
if {$tgen_app == "IxNetwork"} {
set passNdr [expr {$curRate * $numRxPorts}]
# set passNdr [expr {$curRate * $ixNetworkStreamCount}]
# set result "\nPassed line rate $curRate pps (per port),\
# NDR:$passNdr,ixNetworkStreamCount:$ixNetworkStreamCount"
} else {
set passNdr [expr {$curRate * $numRxPorts}]
}
} else {
set passNdr [expr {$curRate * $numRxPorts}]
}
}
set passNumPkts $numPkts
set passAvgLatency $avgLatency
set passMinLatency $minLatency
set passMaxLatency $maxLatency
set passCmdOutputs $cmdOutputs
set passCurRate $curRate
}
#Next traffic rate
set curRate [mpexpr ($max_rate+$min_rate)/2]
#Iteration counter
set iteration [expr {$iteration + 1}]
} ; # End of While
# Find latencies at latency_rates
if {$latency == 1} {
foreach rate $latency_rates {
set curRate [expr {($passCurRate*$rate)/100.00}]
if {$latency_detail > 0} {set latency_detail $rate}
switch $tgen_app {
IxExplorer {
#Run trafic @ curRate and get results - IxExplorer
set diag "Post NDR iteration - @ $rate % \
- $curRate pps (per port)..."
ats_log -diag $diag
if {[_run_IxExplorer_test txPkts rxPkts numPkts avgLatency \
minLatency maxLatency cmdOutputs returnList $txPorts \
$txStreams $txStreamSets $tx_mode $rxPorts $mtxPorts \
$mtxStreams $mtxStreamSets $mtxOifs $mtxOifSets $mtx_ports \
$run_time $curRate $uds_count $min_cap_pkts $numRxPorts \
$numMrxPorts $exec_cmds $uut $tr $latency $latency_detail\
$debug] != $SUCCESS} {
return $returnList
}
}
IxNetwork {
#Run trafic @ curRate and get results - IxNetwork
set diag "Post NDR iteration - @ $rate % \
- $curRate pps (per port)..."
# ats_log -diag $diag
# if {[_run_IxNetwork_test txPkts rxPkts avgLatency \
# minLatency maxLatency ixNetworkStreamCount cmdOutputs \
# $ixnetwork_root $curRate $run_time $exec_cmds $uut \
# $latency $debug] != $SUCCESS} {
# return $returnList
# }
if {[_run_IxNetwork_test2 txPkts rxPkts numPkts avgLatency\
minLatency maxLatency cmdOutputs returnList $txPorts \
$txStreams $txStreamSets $tx_mode $rxPorts $mtxPorts \
$mtxStreams $mtxStreamSets $mtxOifs $mtxOifSets $mtx_ports \
$run_time $curRate $uds_count2 $min_cap_pkts $numRxPorts \
$numMrxPorts $exec_cmds $uut $tr $latency $latency_detail \
$debug] != $SUCCESS} {
return $returnList
}
}
}
set numPkts $rxPkts
keylset returnList latency($rate) $avgLatency
keylset returnList latency(CUST) $avgLatency
}
}
#Return keyed list
keylset returnList status $everPass
keylset returnList ndr $passNdr
keylset returnList num_pkts $passNumPkts
keylset returnList latency(NDR) $passAvgLatency
keylset returnList min_latency $passMinLatency
keylset returnList max_latency $passMaxLatency
keylset returnList cmd_outputs $passCmdOutputs
keylset returnList run_time $run_time
keylset returnList frame_size $frame_size
keylset returnList loss_rate $loss_rate
return $returnList
} ; # End of Proc findNdr
######################################################################
##Procedure Header
# Name:
# perfUtils::_run_IxExplorer_test
#
# Purpose:
# run one iteration of IxExplorer.
#
# Synopsis:
# _run_IxExplorer_test args
#
# Arguments:
# too much to be listed
#
# Return Values:
# 1 - Success
# 0 - failure
#
# Description:
# This Proc runs IxExplorer test.
######################################################################
proc perfUtils::_run_IxExplorer_test {txPkts rxPkts numPkts avgLatency \
minLatency maxLatency cmdOutputs returnList txPorts txStreams txStreamSets \
tx_mode rxPorts mtxPorts mtxStreams mtxStreamSets mtxOifs mtxOifSets mtx_ports \
run_time curRate uds_count min_cap_pkts numRxPorts numMrxPorts exec_cmds uut \
tr latency latency_detail debug} {
set SUCCESS 1
upvar $txPkts txPktsLoc
upvar $rxPkts rxPktsLoc
upvar $numPkts numPktsLoc
upvar $avgLatency avgLatencyLoc
upvar $minLatency minLatencyLoc
upvar $maxLatency maxLatencyLoc
upvar $cmdOutputs cmdOutputsLoc
upvar $returnList returnListLoc
#Set Traffic Rate
if {[_set_curRate_IxExplorer $txPorts $txStreamSets $tx_mode $mtxPorts \
$mtxStreams $mtxOifs $mtx_ports $numMrxPorts $curRate] != $SUCCESS} {
return $returnList
}
#Run Traffic
set cmdOuputsLoc ""
if {[_run_traffic_IxExplorer cmdOutputsLoc $txPorts $rxPorts $run_time \
$exec_cmds $uut $tr] != $SUCCESS} {
return $returnList
}
#Get Tx Stats
set txPktsLoc [_get_txPkts_IxExplorer $txPorts $txStreamSets $mtxPorts \
$mtxStreamSets $mtxOifSets $mtx_ports $debug]
#Get Rx Stats
set rxPktsLoc [_get_rxPkts_IxExplorer $rxPorts $uds_count $debug]
#Get Latency Stats
set numPktsLoc 0;
set avgLatencyLoc 0; set minLatencyLoc 0; set maxLatencyLoc 0
if {$latency == 1} {
if {[_get_latency_IxExplorer numPktsLoc avgLatencyLoc minLatencyLoc \
maxLatencyLoc returnListLoc $rxPorts $min_cap_pkts $numRxPorts\
$debug $latency_detail] != $SUCCESS} {
return $returnList
}
}
return 1
} ; # End of Proc _run_IxExplorer_test
######################################################################
##Procedure Header
# Name:
# perfUtils::_run_IxNetwork_test
#
# Purpose:
# run one iteration of IxNetwork.
#
# Synopsis:
# _run_IxNetwork_test args
#
# Arguments:
# too much to be listed
#
# Return Values:
# 1 - Success
# 0 - failure
#
# Description:
# This Proc runs IxNetwork test.
######################################################################
proc perfUtils::_run_IxNetwork_test {txPkts rxPkts avgLatency minLatency \
maxLatency ixNetworkStreamCount cmdOutputs ixnetwork_root curRate run_time \
exec_cmds uut tr latency debug} {
set SUCCESS 1
upvar $txPkts txPktsLoc
upvar $rxPkts rxPktsLoc
upvar $avgLatency avgLatencyLoc
upvar $minLatency minLatencyLoc
upvar $maxLatency maxLatencyLoc
upvar $ixNetworkStreamCount ixNetworkStreamCountLoc
upvar $cmdOutputs cmdOutputsLoc
#Set Traffic Rate
if {[_set_curRate_IxNetwork $ixnetwork_root $curRate] != $SUCCESS} {
return $returnList
}
#Enable Stats
set txPkts [_enable_stats_IxNetwork $ixnetwork_root]
#Run Traffic
set cmdOutputsLoc ""
if {[_run_traffic_IxNetwork cmdOutputsLoc $ixnetwork_root $run_time \
$exec_cmds $uut $tr] != $SUCCESS} {
return $returnList
}
#Initialize Variables
set txPktsLoc 0; set rxPktsLoc 0;
set avgLatencyLoc 0; set minLatencyLoc 0; set maxLatencyLoc 0
if {0} {
#Get Tx Stats
if {[_get_txPkts_IxNetwork txPktsLoc ixNetworkStreamCountLoc \
$ixnetwork_root] != $SUCCESS} {
return $returnList
}
#Get Rx Stats
if {[_get_rxPkts_IxNetwork rxPktsLoc $ixnetwork_root] != $SUCCESS} {
return $returnList
}
}
# Adding new proc as a work around for Ixia Stats update error
sleep 5
if {[_get_txRxPkts_IxNetwork txPktsLoc rxPktsLoc ixNetworkStreamCountLoc \
$ixnetwork_root] != $SUCCESS} {
return $returnList
}
#Get Latency Stats
if {$latency == 1} {
if {[_get_latency_IxNetwork avgLatencyLoc minLatencyLoc maxLatencyLoc \
$ixnetwork_root $debug] != $SUCCESS} {
return $returnList
}
}
return 1
} ; # End of Proc _run_IxNetwork_test
######################################################################
##Procedure Header
# Name:
# perfUtils::_run_IxNetwork_test2
#
# Purpose:
# run one iteration of IxNetwork, using high-level api
#
# Synopsis:
# _run_IxNetwork_test2 args
#
# Arguments:
# too much to be listed
#
# Return Values:
# 1 - Success
# 0 - failure
#
# Description:
# This Proc runs IxNetwork test(2). using high-level api
######################################################################
proc perfUtils::_run_IxNetwork_test2 {txPkts rxPkts numPkts avgLatency \
minLatency maxLatency cmdOutputs returnList txPorts txStreams txStreamSets \
tx_mode rxPorts mtxPorts mtxStreams mtxStreamSets mtxOifs mtxOifSets \
mtx_ports run_time curRate uds_count2 min_cap_pkts numRxPorts numMrxPorts \
exec_cmds uut tr latency latency_detail debug} {
set SUCCESS 1
upvar $txPkts txPktsLoc
upvar $rxPkts rxPktsLoc
upvar $numPkts numPktsLoc
upvar $avgLatency avgLatencyLoc
upvar $minLatency minLatencyLoc
upvar $maxLatency maxLatencyLoc
upvar $cmdOutputs cmdOutputsLoc
upvar $returnList returnListLoc
#Set Traffic Rate
#Note: can use same _set_curRate proc with IxExplorer method
if {[_set_curRate_IxExplorer $txPorts $txStreamSets $tx_mode $mtxPorts \
$mtxStreams $mtxOifs $mtx_ports $numMrxPorts $curRate] != $SUCCESS} {
return $returnList
}
#Run Traffic
set cmdOuputsLoc ""
#Note: can use same _run_traffic proc with IxExplorer method
if {[_run_traffic_IxExplorer cmdOutputsLoc $txPorts $rxPorts $run_time \
$exec_cmds $uut $tr] != $SUCCESS} {
return $returnList
}
#sleep 20 second, since ixNetwork seems to have heavy time delay
after 20000
#Get Tx Stats
set txPktsLoc [_get_txPkts_IxNetwork2 $txPorts $txStreamSets $mtxPorts \
$mtxStreamSets $mtxOifSets $mtx_ports $debug]
#Get Rx Stats
set rxPktsLoc [_get_rxPkts_IxNetwork2 $rxPorts $uds_count2 $debug]
#Get Latency Stats
set numPktsLoc 0;
set avgLatencyLoc 0; set minLatencyLoc 0; set maxLatencyLoc 0
if {$latency == 1} {
if {[_get_latency_IxNetwork2 numPktsLoc avgLatencyLoc minLatencyLoc \
maxLatencyLoc returnListLoc $rxPorts $min_cap_pkts $numRxPorts\
$debug $latency_detail $txStreamSets $txPorts] != $SUCCESS} {
#return $returnList
#rupan note: here actually should return $returnList; yet if so,
#status of returnList is 0, and the Ndr will not get recorded in
#the script which uses findNdr method.
#so instead we return 1, so latency is 0 in the record, rather than
#expected value, and in the log there is note to explain rx_mode
#should be set capture_and_measure if wanting calculate latency.
return 1
}
}
return 1
} ; # End of Proc _run_IxNetwork_test2
######################################################################
##Procedure Header
# Name:
# _set_curRate_IxExplorer
#
# Purpose:
# set the traffic rate for the next iteration on IxExplorer.
#
# Synopsis:
# _set_curRate_IxExplorer args
#
# Arguments:
# too much to be listed
#
# Return Values:
# 1 - Success
# 0 - failure
#
# Description:
# This Proc sets the traffic rate for the next iteration on IxExplorer
######################################################################
proc _set_curRate_IxExplorer {txPorts txStreamSets tx_mode mtxPorts \
mtxStreams mtxOifs mtx_ports numMrxPorts curRate} {
#Set traffic rate for all streams
set tempRate $curRate; set SUCCESS 1
foreach port $txPorts txStreamSet $txStreamSets {
if {$tx_mode == "advanced"} {
set numStreams [llength $txStreamSet]
set curRate [expr {$tempRate/$numStreams}]
}
foreach stream $txStreamSet {
set traffic_status [ixia::traffic_config \
-mode modify \
-stream_id $stream \
-port_handle $port \
-rate_pps $curRate ]
if {[keylget traffic_status status] != $SUCCESS} {
set diag "Couldn't configure base stream on $port"
ats_log -error $diag
ats_log -error "[keylget traffic_status log]"
ats_results -result fail
}
}
}
if {[info exists mtx_ports]} {
set numMStreams [llength mtxStreams]
set curRate $tempRate
if {$tx_mode == "advanced"} {
set curRate [expr {$tempRate/$numMStreams}]
}
foreach port $mtxPorts {
foreach stream $mtxStreams oif $mtxOifs {
set traffic_status [ixia::traffic_config \
-mode modify \
-stream_id $stream \
-port_handle $port \
-rate_pps [expr {($curRate/$oif)*$numMrxPorts}]]
if {[keylget traffic_status status] != $SUCCESS} {
set diag "Couldn't configure base stream on $port"
ats_log -error $diag
ats_log -error "[keylget traffic_status log]"
ats_results -result fail
}
}
}
}
set diag "Now trying $curRate pps (per port @ each stream)... "
ats_log -diag $diag
return 1
} ; # End of Proc _set_curRate_IxExplorer
######################################################################
##Procedure Header
# Name:
# perfUtils::_get_txPkts_IxExplorer
#
# Purpose:
# get the traffic stats for IxExplorer and returns transmitted packets.
#
# Synopsis:
# _get_txPkts_IxExplorer args
#
# Arguments:
# too much to be listed
#
# Return Values:
# 1 - Success
# 0 - failure
#
# Description:
# This Proc gets the traffic stats for IxExplorer
# and returns transmitted packets
######################################################################
proc perfUtils::_get_txPkts_IxExplorer {txPorts txStreamSets mtxPorts \
mtxStreamSets mtxOifSets mtx_ports debug} {
#Initialize variables
set txPkts 0
set _txPkts 0
set mtxPkts 0
set _mtxPkts 0
set success 1
#Get the total number of packets sent
#here calculate the actual number of packets sent across all streams
foreach txPort $txPorts txStreamSet $txStreamSets {
foreach txStream $txStreamSet {
set txStats [ixia::traffic_stats -port_handle $txPort \
-mode stream -stream $txStream]
if {[keylget txStats status] != $success} {
set diag "Couldn't get TX stats on $txPort : $txStream"
ats_results -diag $diag
ats_log -diag $diag
if {$debug == 1} {
ats_log -diag "txStats: $txStats"
}
ats_results -result fail
}
if { [catch {
set txPkts [expr { 1.0*$txPkts + \
[keylget txStats $txPort.stream.$txStream.tx.total_pkts]}]
#For debug only
set _txPkts [expr {1.0*$_txPkts + \
[keylget txStats $txPort.stream.$txStream.tx.total_pkts]}]
} errmsg ] } {
ats_log -info "txStats: $txStats"
set diag "Couldn't get TX stats on $txPort : $txStream"
ats_results -result fail
}
}
if {$debug == 1} {
ats_log -diag "$txPort - txPkts (mtx pkts included) $_txPkts";
set _txPkts 0
}
}
#If multicast streams exists, adjust the total number of replicated packets
if {[info exists mtx_ports]} {
foreach mtxPort $mtxPorts mtxStreamSet $mtxStreamSets \
mtxOifSet $mtxOifSets {
foreach mtxStream $mtxStreamSet mtxOif $mtxOifSet {
set mtxStats [ixia::traffic_stats -port_handle $mtxPort \
-mode stream -stream $mtxStream]
if {[keylget mtxStats status] != $success} {
set diag "Couldn't get TX stats on $mtxPort : $mtxStream"
ats_results -diag $diag
ats_log -diag $diag