-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIxia_NetNgpfTester.tcl
More file actions
1710 lines (1526 loc) · 47.9 KB
/
Ixia_NetNgpfTester.tcl
File metadata and controls
1710 lines (1526 loc) · 47.9 KB
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
# Copyright (c) Ixia technologies 2010-2011, Inc.
# Release Version 1.23
#===============================================================================
# Change made
# Version 1.0
# 1. Create
# Version 1.1.1.7
# 2. Enable hardware capture on all port in Tester::start_capture
# Version 1.2.1.10
# 3. Enable software capture on all port in Tester::start_capture
# 4. Show all control plane packet on all port in Tester::stop_capture
# Version 1.3.2.2
# 5. Add arguments in start capture: portList
# Version 1.4.2.3
# 6. Remove all filter after stopping capture
# Version 1.5.2.5
# 7. Set Tester::cleanup -release_port default value to false
# Version 1.6.2.6
# 8. Change the cleanup way to newconfig and Connect port to hardware
# Version 1.7.2.10
# 9. Catch the stop traffic command in case the traffic stop by itself
# Version 1.8.2.12
# 10.Add -reboot_port argument in cleanup to reboot port
# Version 1.9.2.14
# 11. Change default value of release_port to false in Tester::cleanup
# Version 1.10.2.19
# 12. Add clear Capture buffer in start_capture
# Version 1.11.2.23
# 13. Add Traffic state condition
# Version 1.12.2.26
# 14. Add Tester.clear_traffic_stats
# 15. Add Tester.get_log
# Version 1.13.3.1
# 16. Add Tester.flap_router -times -duration -a2w -w2a -end_up_dn -router
# Version 1.14.4.19
# 17. Wait start traffic state ready
# Version 1.15.4.19-patch
# Version 1.16.4.22
# 18. Stop capture before apply traffic in Tester::start_traffic
# Version 1.17.4.27
# 19. reduce waiting time of Tester::start_traffic
# Version 1.18.4.44
# 20. add -apply in start_traffic
# Version 1.19.4.47
# 21. add save_config proc
# Version 1.20.4.49
# 22. add -new_config in cleanup
# Version 1.21.4.59
# 23. add remove_all_stream proc
# Version 1.22.7.28
# 24. add Tester::delete_pppoe
# Version 1.23.1.29
# 25. add Tester::tester_config_file
class Tester {
proc constructor {} {}
proc apply_traffic {} {}
proc start_traffic { { restartCaptureJudgement 1 } } {}
proc stop_traffic {} {}
proc start_router { args } {}
proc stop_router { args } {}
proc start_capture { args } {}
proc stop_capture { { wait 3000} args } {}
proc save_capture { args } {}
proc clear_capture {} {}
proc cleanup { args } {}
proc delete_pppoe {} {}
proc synchronize {} {}
proc save_config { args } {}
proc reboot {} {}
proc clear_traffic_stats {} {}
proc get_log { { file default } } {}
proc getAllTx {} {}
proc isLossFrames { { streams "" } } {}
proc saveResults { args } {}
proc set_stats_mode { args } {}
proc tester_config_file { filedir } {}
proc run_testcomposer {} {}
proc start_arp_nd {} {}
proc port_map { args } { }
proc assign_all { args } {}
proc save_result { args } {}
}
proc Tester::getAllTx {} {
set tag "proc Tester::getAllTx [info script]"
Deputs "----- TAG: $tag -----"
set allObj [ find objects ]
set allTx 0
foreach obj $allObj {
if { [ $obj isa Port ] } {
Deputs "port obj:$obj"
set tx [ GetStatsFromReturn [ $obj get_stats ] tx_frame_count ]
Deputs "port tx:$tx"
incr allTx $tx
}
}
return $allTx
}
proc Tester::start_traffic { args } {
set tag "proc Tester::start_traffic [info script]"
Deputs "----- TAG: $tag -----"
set restartCaptureJudgement 1
set apply 0
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-capture_check {
set restartCaptureJudgement $value
}
-apply {
set apply $value
}
}
}
if { $apply } {
Tester::apply_traffic
} else {
set root [ixNet getRoot]
set restartCapture 0
set suspendList [list]
if { $restartCaptureJudgement } {
set version [ixNet getVersion]
Deputs "The ixNetwork version is: $version"
set portList [ ixNet getL $root vport ]
foreach hPort $portList {
if {[string match 6.0* $version]} {
if { [ ixNet getA $hPort/capture -hardwareEnabled ] } {
set restartCapture 1
break
}
} else {
if { [ ixNet getA $hPort/capture -isCaptureRunning ] } {
set restartCapture 1
break
}
}
# if { [ ixNet getA $hPort/capture -isCaptureRunning ] } {
# set restartCapture 1
# break
# }
}
}
if { $restartCapture } {
catch {
#Tester::stop_capture 1000
ixNet exec stopCapture
foreach item [ ixNet getL $root/traffic trafficItem ] {
lappend suspendList [ ixNet getA $item -suspend ]
if { [ixNet getA $item -enabled] == "true" } {
catch {
ixNet exec generate $item
#Deputs "Wait for generate traffic"
}
}
}
ixNet exec apply $root/traffic
#Tester::start_capture
after 1000
ixNet exec closeAllTabs
ixNet exec startCapture
}
} else {
foreach item [ ixNet getL $root/traffic trafficItem ] {
lappend suspendList [ ixNet getA $item -suspend ]
if { [ixNet getA $item -enabled] == "true" } {
catch {
ixNet exec generate $item
#Deputs "Wait for generate traffic"
}
}
}
ixNet exec apply $root/traffic
}
if { [ llength $suspendList ] > 0 } {
foreach suspend $suspendList item [ ixNet getL $root/traffic trafficItem ] {
ixNet setA $item -suspend $suspend
}
}
ixNet commit
ixNet exec start $root/traffic
set timeout 30
set stopflag 0
while { 1 } {
if { !$timeout } {
break
}
set state [ ixNet getA $root/traffic -state ]
if { $state != "started" } {
Deputs "start state:$state"
if { [string match startedWaiting* $state ] } {
set stopflag 1
} elseif {[string match stopped* $state ] && ($stopflag == 1)} {
break
}
after 1000
} else {
Deputs "start state:$state"
break
}
incr timeout -1
Deputs "start timeout:$timeout state:$state"
}
}
return [ GetStandardReturnHeader ]
}
proc Tester::stop_traffic {} {
set tag "proc Tester::stop_traffic [info script]"
Deputs "----- TAG: $tag -----"
set root [ixNet getRoot]
if { [ catch {
ixNet exec stop $root/traffic
} err ] } {
Deputs "Stop traffic error:$err"
}
set timeout 30
while { 1 } {
if { !$timeout } {
break
}
set state [ ixNet getA $root/traffic -state ]
if { ( $state != "stopped" ) && ( $state != "unapplied" ) } {
after 1000
} else {
break
}
incr timeout -1
Deputs "stop timeout:$timeout"
}
return [ GetStandardReturnHeader ]
}
proc Tester::start_router { args } {
set tag "proc Tester::start_router [info script]"
Deputs "----- TAG: $tag -----"
set device_type ""
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-device_type {
set device_type [string tolower $value]
}
}
}
# ixTclNet::StartProtocols
if { $device_type == ""} {
ixNet exec startAllProtocols
} else {
set device_list ""
set root [ixNet getRoot]
set vport_list [ixNet getL $root vport]
foreach vport_handle $vport_list {
set vport_protocols [ixNet getL $vport_handle protocols]
set vport_protocolStack [ixNet getL $vport_handle protocolStack]
switch -exact -- $device_type {
bgp {
set bgpH [ixNet getL $vport_protocols bgp]
if {[ixNet getA $bgpH -enabled] == "true" } {
lappend device_list $bgpH
}
}
isis {
set isisH [ixNet getL $vport_protocols isis]
if {[ixNet getA $isisH -enabled] == "true" } {
lappend device_list $isisH
}
}
ldp {
set ldpH [ixNet getL $vport_protocols ldp]
if {[ixNet getA $ldpH -enabled] == "true" } {
lappend device_list $ldpH
}
}
igmp {
set igmpH [ixNet getL $vport_protocols igmp]
if {[ixNet getA $igmpH -enabled] == "true" } {
lappend device_list $igmpH
}
}
mld {
set mldH [ixNet getL $vport_protocols mld]
if {[ixNet getA $mldH -enabled] == "true" } {
lappend device_list $mldH
}
}
rip {
set ripH [ixNet getL $vport_protocols rip]
if {[ixNet getA $ripH -enabled] == "true" } {
lappend device_list $ripH
}
}
ripng {
set ripngH [ixNet getL $vport_protocols ripng]
if {[ixNet getA $ripngH -enabled] == "true" } {
lappend device_list $ripngH
}
}
ospf -
ospfv2 {
set ospfH [ixNet getL $vport_protocols ospf]
if {[ixNet getA $ospfH -enabled] == "true" } {
lappend device_list $ospfH
}
}
ospfv3 {
set ospfV3H [ixNet getL $vport_protocols ospfV3]
if {[ixNet getA $ospfV3H -enabled] == "true" } {
lappend device_list $ospfV3H
}
}
bfd {
set bfdH [ixNet getL $vport_protocols bfd]
if {[ixNet getA $bfdH -enabled] == "true" } {
lappend device_list $bfdH
}
}
rsvp {
set rsvpH [ixNet getL $vport_protocols rsvp]
if {[ixNet getA $rsvpH -enabled] == "true" } {
lappend device_list $rsvpH
}
}
dhcp {
set ethernetH_list [ixNet getL $vport_protocolStack ethernet ]
if {$ethernetH_list != "" } {
foreach ethernetH $ethernetH_list {
set dhcpH [ixNet getL $ethernetH dhcpEndpoint]
if { $dhcpH != "" } {
lappend device_list $ethernetH
}
}
}
}
pppox {
set ethernetH_list [ixNet getL $vport_protocolStack ethernet ]
if {$ethernetH_list != "" } {
foreach ethernetH $ethernetH_list {
set pppoxH [ixNet getL $ethernetH pppoxEndpoint]
if { $pppoxH != "" } {
lappend device_list $ethernetH
}
}
}
}
l2tp {
set ethernetH_list [ixNet getL $vport_protocolStack ethernet ]
if {$ethernetH_list != "" } {
foreach ethernetH $ethernetH_list {
set ipH [ixNet getL $ethernetH ip]
if { $ipH != "" } {
set l2tpH [ixNet getL $ipH l2tpEndpoint]
if { $l2tpH !="" } {
lappend device_list $ethernetH
}
}
}
}
}
pim {
set pimH [ixNet getL $vport_protocols pimsm]
if { [ ixNet getA $pimH -enabled ] == "true" } {
lappend device_list $pimH
}
}
}
}
switch -exact -- $device_type {
dhcp -
l2tp -
pppox {
ixNet exec start $device_list
}
default {
foreach deviceH $device_list {
ixNet exec start $deviceH
}
}
}
# foreach deviceH $device_list {
# ixNet exec start $deviceH
# }
}
return [ GetStandardReturnHeader ]
}
proc Tester::stop_router { args } {
set tag "proc Tester::stop_router [info script]"
Deputs "----- TAG: $tag -----"
#ixTclNet::StopProtocols
#ixNet exec stopAllProtocols
set device_type ""
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-device_type {
set device_type [string tolower $value]
}
}
}
# ixTclNet::StartProtocols
if { $device_type == ""} {
ixNet exec stopAllProtocols
} else {
set device_list ""
set root [ixNet getRoot]
set vport_list [ixNet getL $root vport]
foreach vport_handle $vport_list {
set vport_protocols [ixNet getL $vport_handle protocols]
set vport_protocolStack [ixNet getL $vport_handle protocolStack]
switch -exact -- $device_type {
bgp {
set bgpH [ixNet getL $vport_protocols bgp]
if {[ixNet getA $bgpH -enabled] == "true" } {
lappend device_list $bgpH
}
}
isis {
set isisH [ixNet getL $vport_protocols isis]
if {[ixNet getA $isisH -enabled] == "true" } {
lappend device_list $isisH
}
}
ldp {
set ldpH [ixNet getL $vport_protocols ldp]
if {[ixNet getA $ldpH -enabled] == "true" } {
lappend device_list $ldpH
}
}
igmp {
set igmpH [ixNet getL $vport_protocols igmp]
if {[ixNet getA $igmpH -enabled] == "true" } {
lappend device_list $igmpH
}
}
mld {
set mldH [ixNet getL $vport_protocols mld]
if {[ixNet getA $mldH -enabled] == "true" } {
lappend device_list $mldH
}
}
rip {
set ripH [ixNet getL $vport_protocols rip]
if {[ixNet getA $ripH -enabled] == "true" } {
lappend device_list $ripH
}
}
ripng {
set ripngH [ixNet getL $vport_protocols ripng]
if {[ixNet getA $ripngH -enabled] == "true" } {
lappend device_list $ripngH
}
}
ospf -
ospfv2 {
set ospfH [ixNet getL $vport_protocols ospf]
if {[ixNet getA $ospfH -enabled] == "true" } {
lappend device_list $ospfH
}
}
ospfv3 {
set ospfV3H [ixNet getL $vport_protocols ospfV3]
if {[ixNet getA $ospfV3H -enabled] == "true" } {
lappend device_list $ospfV3H
}
}
bfd {
set bfdH [ixNet getL $vport_protocols bfd]
if {[ixNet getA $bfdH -enabled] == "true" } {
lappend device_list $bfdH
}
}
rsvp {
set rsvpH [ixNet getL $vport_protocols rsvp]
if {[ixNet getA $rsvpH -enabled] == "true" } {
lappend device_list $rsvpH
}
}
dhcp {
set ethernetH_list [ixNet getL $vport_protocolStack ethernet ]
if {$ethernetH_list != "" } {
foreach ethernetH $ethernetH_list {
set dhcpH [ixNet getL $ethernetH dhcpEndpoint]
if { $dhcpH != "" } {
lappend device_list $ethernetH
}
}
}
}
pppox {
set ethernetH_list [ixNet getL $vport_protocolStack ethernet ]
if {$ethernetH_list != "" } {
foreach ethernetH $ethernetH_list {
set pppoxH [ixNet getL $ethernetH pppoxEndpoint]
if { $pppoxH != "" } {
lappend device_list $ethernetH
}
}
}
}
}
}
switch -exact -- $device_type {
dhcp -
l2tp -
pppox {
ixNet exec stop $device_list
}
default {
foreach deviceH $device_list {
ixNet exec stop $deviceH
}
}
}
# foreach deviceH $device_list {
# ixNet exec stop $deviceH
# }
}
return [ GetStandardReturnHeader ]
}
proc Tester::abort_router { args } {
set tag "proc Tester::abort_router [info script]"
Deputs "----- TAG: $tag -----"
#ixTclNet::StopProtocols
#ixNet exec stopAllProtocols
set device_type ""
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-device_type {
set device_type [string tolower $value]
}
}
}
# ixTclNet::StartProtocols
if { $device_type == ""} {
ixNet exec stopAllProtocols
} else {
set device_list ""
set root [ixNet getRoot]
set vport_list [ixNet getL $root vport]
foreach vport_handle $vport_list {
set vport_protocols [ixNet getL $vport_handle protocols]
set vport_protocolStack [ixNet getL $vport_handle protocolStack]
switch -exact -- $device_type {
bgp {
set bgpH [ixNet getL $vport_protocols bgp]
if {[ixNet getA $bgpH -enabled] == "true" } {
lappend device_list $bgpH
}
}
isis {
set isisH [ixNet getL $vport_protocols isis]
if {[ixNet getA $bgpH -enabled] == "true" } {
lappend device_list $isisH
}
}
ldp {
set ldpH [ixNet getL $vport_protocols ldp]
if {[ixNet getA $ldpH -enabled] == "true" } {
lappend device_list $ldpH
}
}
igmp {
set igmpH [ixNet getL $vport_protocols igmp]
if {[ixNet getA $igmpH -enabled] == "true" } {
lappend device_list $igmpH
}
}
mld {
set mldH [ixNet getL $vport_protocols mld]
if {[ixNet getA $mldH -enabled] == "true" } {
lappend device_list $mldH
}
}
rip {
set ripH [ixNet getL $vport_protocols rip]
if {[ixNet getA $ripH -enabled] == "true" } {
lappend device_list $ripH
}
}
ripng {
set ripngH [ixNet getL $vport_protocols ripng]
if {[ixNet getA $ripngH -enabled] == "true" } {
lappend device_list $ripngH
}
}
ospf -
ospfv2 {
set ospfH [ixNet getL $vport_protocols ospf]
if {[ixNet getA $ospfH -enabled] == "true" } {
lappend device_list $ospfH
}
}
ospfv3 {
set ospfV3H [ixNet getL $vport_protocols ospfV3]
if {[ixNet getA $ospfV3H -enabled] == "true" } {
lappend device_list $ospfV3H
}
}
dhcp {
set ethernetH_list [ixNet getL $vport_protocolStack ethernet ]
if {$ethernetH_list != "" } {
foreach ethernetH $ethernetH_list {
set dhcpH [ixNet getL $ethernetH dhcpEndpoint]
if { $dhcpH != "" } {
lappend device_list $ethernetH
}
}
}
}
pppox {
set ethernetH_list [ixNet getL $vport_protocolStack ethernet ]
if {$ethernetH_list != "" } {
foreach ethernetH $ethernetH_list {
set pppoxH [ixNet getL $ethernetH pppoxEndpoint]
if { $pppoxH != "" } {
lappend device_list $ethernetH
}
}
}
}
}
}
switch -exact -- $device_type {
dhcp -
l2tp -
pppox {
ixNet exec stop $device_list
}
default {
foreach deviceH $device_list {
ixNet exec stop $deviceH
}
}
}
# foreach deviceH $device_list {
# ixNet exec abort $deviceH
# }
}
return [ GetStandardReturnHeader ]
}
proc Tester::start_routers { router } {
set tag "proc Tester::start_routers [info script]"
Deputs "----- TAG: $tag -----"
foreach rt $router {
if { [ $rt isa EmulationNgpfObject ] == 0 } {
return [ GetErrorReturnHeader "$rt is not a valid object." ]
}
}
foreach rt $router {
$rt start
}
return [ GetStandardReturnHeader ]
}
proc Tester::stop_routers { router } {
set tag "proc Tester::stop_routers [info script]"
Deputs "----- TAG: $tag -----"
foreach rt $router {
if { [ $rt isa EmulationNgpfObject ] == 0 } {
return [ GetErrorReturnHeader "$rt is not a valid object." ]
}
}
foreach rt $router {
$rt stop
}
return [ GetStandardReturnHeader ]
}
proc Tester::start_capture { args } {
set tag "proc Tester::start_capture [info script]"
Deputs "----- TAG: $tag -----"
set close_captures ""
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-ports {
set portList $value
}
-close_captures {
set close_captures $value
}
}
}
if { [ info exists portList ] == 0 } {
set root [ixNet getRoot]
set portList [ ixNet getL $root vport ]
} else {
set hPortList [ list ]
foreach port $portList {
set hPort [ $port cget -handle ]
lappend hPortList $hPort
}
set portList $hPortList
}
Deputs "capture port handle list:$portList"
foreach hPort $portList {
set hardwareEnb [ixNet getA $hPort/capture -hardwareEnabled]
set softwareEnb [ixNet getA $hPort/capture -softwareEnabled]
if {$hardwareEnb == "False" && $softwareEnb == "False"} {
ixNet setA $hPort/capture -hardwareEnabled True
}
ixNet commit
Deputs "Port rx mode on $hPort : [ ixNet getA $hPort -rxMode ]"
if { [ ixNet getA $hPort -rxMode ] == "captureAndMeasure" } {
continue
}
ixNet setA $hPort -rxMode capture
ixNet commit
Deputs "Port rx mode on $hPort : [ ixNet getA $hPort -rxMode ]"
while { [ixNet getA $hPort -state] != "up" } {
after 1000
}
}
# clear all the captuer content
foreach obj [ find objects ] {
set isCaptureObj [ $obj isa Capture ]
if { $isCaptureObj } {
$obj configure -content [list]
}
}
if { $close_captures == "" } {
ixNet exec closeAllTabs
} else {
ixNet exec closeAllTabs $close_captures
}
Deputs "start capture..."
ixNet exec startCapture
after 3000
return [ GetStandardReturnHeader ]
}
proc Tester::stop_capture { { wait 3000 } args } {
set tag "proc Tester::stop_capture [info script]"
Deputs "----- TAG: $tag -----"
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-ports {
set portList $value
}
}
}
if { [ info exists portList ] != 0 } {
set savelist ""
foreach obj [ find objects ] {
if { [$obj isa Capture] } {
if { [lsearch $portList [$obj cget -portObj]] != -1 } {
ixNet exec stop [$obj cget -handle]
if { [$obj cget -capfile] != "" } {
lappend savelist $obj
}
}
}
}
after $wait
foreach cap $savelist {
$cap save_file
}
} else {
ixNet exec stopCapture
# set root [ixNet getRoot]
# set portList [ ixNet getL $root vport ]
# foreach hPort $portList {
# Deputs "hPort:$hPort"
# # ixNet setA $hPort/capture/filter -captureFilterDA anyAddr
# # ixNet setA $hPort/capture/filter -captureFilterSA anyAddr
# # ixNet setA $hPort/capture/filter -captureFilterPattern anyPattern
# # ixNet setA $hPort/capture/filter -captureFilterFrameSizeEnable False
# ixNet setA $hPort/capture -hardwareEnabled False
# # ixNet setA $hPort/capture -softwareEnabled False
# ixNet commit
# # after 1000
# }
after $wait
set caplist ""
foreach obj [ find objects ] {
if { [$obj isa Capture] } {
if { [$obj cget -capfile] != "" } {
lappend caplist $obj
}
}
}
Deputs "caplist: $caplist"
if { $caplist != "" } {
foreach cap $caplist {
$cap save_file
}
}
# catch { show_control_capture }
}
return [ GetStandardReturnHeader ]
}
#--
# Save Capture
#--
# Parameters: |key, value|
# - capture_dir: Directory which we'll put the capture files
# - suffix: Suffix name appended to capture file name
# Return:
# 0 if got success
# raise error if failed
#--
proc Tester::save_capture { args } {
set tag "proc Tester::stop_capture [info script]"
Deputs "----- TAG: $tag -----"
set capture_dir [ pwd ]
set suffix ""
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-capture_dir {
set capture_dir $value
}
-suffix {
set suffix $value
}
}
}
if { ![ file exists $capture_dir ] } {
file mkdir $capture_dir
}
if { $suffix == "" } {
ixNet exec saveCapture $capture_dir
} else {
ixNet exec saveCapture $capture_dir $suffix
}
return [ GetStandardReturnHeader ]
}
proc Tester::clear_capture {} {
set tag "proc Tester::clear_capture [info script]"
Deputs "----- TAG: $tag -----"
ixNet exec closeAllTabs
return [ GetStandardReturnHeader ]
}
proc Tester::show_control_capture {} {
set tag "proc Tester::show_control_capture [info script]"
Deputs "----- TAG: $tag -----"
set root [ixNet getRoot]
set portList [ ixNet getL $root vport ]
Deputs "==SHOW CONTROL CAPTURE CONTENT=="
foreach hPort $portList {
set pktCount [ ixNet getA $hPort/capture -controlPacketCounter ]
if { [ string is integer $pktCount ] == 0 } {
continue
}
if { $pktCount } {
Deputs "PORT = [ixNet getA $hPort -connectionInfo], Packet Count = $pktCount"
} else {
continue
}
#-- round robin the frame
for { set index 0 } { $index < $pktCount } { incr index } {
Deputs "PACKET INDEX = # $index"
ixNet exec getPacketFromControlCapture $hPort/capture/currentPacket $index
#-- round robin the stack
foreach hStack [ ixNet getL $hPort/capture/currentPacket stack ] {
Deputs "Protocol = [ixNet getA $hStack -displayName]"
#-- round robin the field
foreach hField [ixNet getL $hStack field] {
Deputs "\tField = [ixNet getA $hField -displayName], Value = [ixNet getA $hField -fieldValue]"
}
}
}
}
}
proc Tester::cleanup { args } {
# IxDebugOn
set tag "proc Tester::cleanup [info script]"
Deputs "----- TAG: $tag -----"
set release_port 0
set reboot_port 0
set new_config 1
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-release_port {
set trans [ BoolTrans $value ]
if { $trans == "1" || $trans == "0" } {
set release_port $value
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-reboot_port {
set trans [ BoolTrans $value ]
if { $trans == "1" || $trans == "0" } {
set reboot_port $value
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-new_config {
set trans [ BoolTrans $value ]
if { $trans == "1" || $trans == "0" } {
set new_config $value
} else {
error "$errNumber(1) key:$key value:$value"
}
}
default {
error "$errNumber(3) key:$key value:$value"
}
}
}
#############################
ixNet exec stopAllProtocols
after 3000
##############################
if { $new_config } {
ixNet exec newConfig
}