-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIxia_NetNgpfOspf.tcl
More file actions
2861 lines (2516 loc) · 91.1 KB
/
Ixia_NetNgpfOspf.tcl
File metadata and controls
2861 lines (2516 loc) · 91.1 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 2020-2021, Inc.
# Release Version 1.1
#===============================================================================
# Change made
# Version 1.0
# 1. Create
# 2. Update
# Version 1.1.4.34
# 3. Add reborn in Ospfv2Session.config Ospfv3Session.config
class OspfSession {
inherit RouterNgpfEmulationObject
public variable hNetworkRange
public variable hNetworkGroup
public variable OspfVersion
public variable deviceHandle
public variable view
set devicehandle ""
global devicehandle
constructor { port { hOspfSession NULL } } {
global errNumber
set tag "body OspfvSession::ctor [info script]"
Deputs "----- TAG: $tag -----"
set portObj [ GetObject $port ]
set handle ""
set ospfRtHandle ""
set view ""
}
method reborn {} {
set tag "body OspfSession::reborn [info script]"
Deputs "----- TAG: $tag -----"
if { [ catch {
Deputs "portObj is: $portObj"
set hPort [ $portObj cget -handle ]
Deputs "hPort is: $hPort"
} ] } {
error "$errNumber(1) Port Object in DhcpHost ctor"
}
set ospfV2Hndle [ixNet getA [ixNet getRoot]/globals/topology/ospfv2Router -enableDrBdr]
set ospfV3Hndle [ixNet getA [ixNet getRoot]/globals/topology/ospfv3Router -enableDrBdr]
set value2Obj [ixNet setA $ospfV2Hndle/singleValue -value True]
set value3Obj [ixNet setA $ospfV3Hndle/singleValue -value True]
ixNet commit
set rb_interface [ ixNet getL $hPort interface ]
Deputs "rb_interface is: $rb_interface"
array set interface [ list ]
}
method config { args } {}
method set_topo { args } {}
method unset_topo { args } {}
method advertise_topo {} {}
method withdraw_topo {} {}
method flapping_topo { args } {}
method enable {} {
set tag "body OspfSession::enable [info script]"
Deputs "----- TAG: $tag -----"
ixNet setA [ixNet getA $handle -active]/singleValue -value True
ixNet commit
}
method disable {} {
set tag "body OspfSession::disable [info script]"
Deputs "----- TAG: $tag -----"
ixNet setA [ixNet getA $handle -active]/singleValue -value False
ixNet commit
}
method get_status {} {}
method get_stats {} {}
method generate_interface { args } {
set tag "body OspfSession::generate_interface [info script]"
Deputs "----- TAG: $tag -----"
Deputs "handle:$handle"
# The below code not required for NGPF so commented
if {0} {
foreach int $rb_interface {
if { [ ixNet getA $int -type ] == "routed" } {
continue
Deputs "inside:$int"
}
set hInt [ ixNet add $handle interface ]
ixNet setM $hInt -interfaces $int -enabled True -connectedToDut True
ixNet commit
set hInt [ ixNet remapIds $hInt ]
set interface($int) $hInt
Deputs "hInt:$hInt"
Deputs "interface($int):$interface($int)"
}
}
}
}
body OspfSession::config { args } {
global errorInfo
global errNumber
set area_id "0.0.0.0"
set hello_interval 10
set if_cost 1
set network_type "native"
set options "v6bit | rbit | ebit"
set router_dead_interval 40
set intf_num 1
set tag "body OspfSession::config [info script]"
#param collection
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-router_id {
set router_id $value
}
-area_id {
set area_id $value
}
-hello_interval {
set hello_interval $value
}
-if_cost {
set if_cost $value
}
-network_type {
set value [string toupper $value]
set network_type $value
}
-options {
set options $value
}
-router_dead_interval -
-dead_interval {
set dead_interval $value
}
-retransmit_interval {
set retransmit_interval $value
}
-priority {
set priority $value
}
}
}
if { $handle == "" } {
reborn
}
ixNet setM $handle -enabled True
if { [ info exists router_id ] } {
Deputs "router_id:$router_id"
set deviceGroup [GetDependentNgpfProtocolHandle $handle "deviceGroup"]
set routeObj [ixNet getL $deviceGroup routerData]
set ipPattern [ixNet getA [ixNet getA $routeObj -routerId] -pattern]
SetMultiValues $routeObj "-routerId" $ipPattern $router_id
Deputs "router_idpost:$router_id"
}
if { [ info exists area_id ] } {
set id_hex [IP2Hex $area_id]
set area_id [format %i 0x$id_hex]
set ipPattern [ixNet getA [ixNet getA $handle -areaId] -pattern]
SetMultiValues $handle "-areaId" $ipPattern $area_id
#set valueObj [ ixNet getA $handle -areaId]
#set value [ixNet setA $valueObj/singleValue -value $area_id]
#ixNet commit
}
if { [ info exists hello_interval ] } {
set ipPattern [ixNet getA [ixNet getA $handle -helloInterval] -pattern]
SetMultiValues $handle "-helloInterval" $ipPattern $hello_interval
#set valueObj [ ixNet getA $handle -helloInterval]
#set value [ixNet setA $valueObj/singleValue -value $hello_interval]
#ixNet commit
}
if { [ info exists if_cost ] } {
set version [GetOspfNgpfRouterHandle $handle 1]
if {$version == 2} {
set ipPattern [ixNet getA [ixNet getA $handle -metric] -pattern]
SetMultiValues $handle "-metric" $ipPattern $if_cost
#ixNet setA [ixNet getA $handle -metric]/singleValue -value $if_cost
#ixNet commit
} elseif {$version == 3} {
set ipPattern [ixNet getA [ixNet getA $handle -linkMetric] -pattern]
SetMultiValues $handle "-linkMetric" $ipPattern $if_cost
#ixNet setA [ixNet getA $handle -linkMetric]/singleValue -value $if_cost
}
}
# v3 -interfaceType pointToPoint, -interfaceType broadcast
# v2 -networkType pointToPoint, -networkType broadcast, -networkType pointToMultipoint
if { [ info exists network_type ] } {
set network_type [string toupper $network_type]
switch $network_type {
NATIVE {
set network_type pointtomultipoint
}
BROADCAST {
set network_type broadcast
}
P2P {
set network_type pointtopoint
}
}
set ipPattern [ixNet getA [ixNet getA $handle -networkType] -pattern]
SetMultiValues $handle "-networkType" $ipPattern $network_type
#ixNet setA [ixNet getA $handle -networkType]/singleValue -value $network_type
ixNet commit
}
# v3 -routerOptions
# v2 -options
if { [ info exists options ] } {
foreach int $rb_interface {
set options [split $options |]
if {[string match *dcbit* $options]} {
set dcbit 1
} else {
set dcbit 0
}
if {[string match *rbit* $options]} {
set rbit 1
} else {
set rbit 0
}
if {[string match *nbit* $options]} {
set nbit 1
} else {
set nbit 0
}
if {[string match *mcbit* $options]} {
set mcbit 1
} else {
set mcbit 0
}
if {[string match *ebit* $options]} {
set ebit 1
} else {
set ebit 0
}
if {[string match *v6bit* $options]} {
set v6bit 1
} else {
set v6bit 0
}
set opt_val "00$dcbit$rbit$nbit$mcbit$ebit$v6bit"
set opt_val [BinToDec $opt_val]
# set opt_val [Int2Hex $opt_val]
ixNet setA $interface($int) -routerOptions $opt_val
ixNet commit
}
}
if { [ info exists dead_interval ] } {
set ipPattern [ixNet getA [ixNet getA $handle -deadInterval] -pattern]
SetMultiValues $handle "-deadInterval" $ipPattern $dead_interval
#ixNet setA [ixNet getA $handle -deadInterval]/singleValue -value $dead_interval
#ixNet commit
}
# v3
# v2 -lsaRetransmitTime
if { [ info exists retransmit_interval ] } {
set ospfRtHandle [GetOspfNgpfRouterHandle $handle]
Deputs "ospfRtHandle:$ospfRtHandle"
set ipPattern [ixNet getA [ixNet getA $ospfRtHandle -lsaRetransmitTime] -pattern]
SetMultiValues $ospfRtHandle "-lsaRetransmitTime" $ipPattern $retransmit_interval
#ixNet setA [ixNet getA $ospfRtHandle -lsaRetransmitTime]/singleValue -value $retransmit_interval
#ixNet commit
}
if { [ info exists priority ] } {
set ipPattern [ixNet getA [ixNet getA $handle -priority] -pattern]
SetMultiValues $handle "-priority" $ipPattern $priority
#ixNet setA [ixNet getA $handle -priority]/singleValue -value $priority
#ixNet commit
}
return [GetStandardReturnHeader]
}
body OspfSession::advertise_topo {} {
set tag "body OspfSession::advertise_topo [info script]"
Deputs "----- TAG: $tag -----"
set deviceGroupObj [$this cget -deviceHandle]
foreach route [ ixNet getL $deviceGroupObj networkGroup ] {
set ipPattern [ixNet getA [ixNet getA $route -enabled] -pattern]
SetMultiValues $route "-enabled" $ipPattern True
#ixNet setA [ixNet getA $route -enabled]/singleValue -value True
}
ixNet commit
return [GetStandardReturnHeader]
}
body OspfSession::withdraw_topo {} {
set tag "body OspfSession::withdraw_topo [info script]"
Deputs "----- TAG: $tag -----"
set deviceGroupObj [$this cget -deviceHandle]
foreach route [ ixNet getL $deviceGroupObj networkGroup ] {
set ipPattern [ixNet getA [ixNet getA $route -enabled] -pattern]
SetMultiValues $route "-enabled" $ipPattern False
#ixNet setA [ixNet getA $route -enabled]/singleValue -value False
}
ixNet commit
return [GetStandardReturnHeader]
}
body OspfSession::flapping_topo { args } {
set tag "body OspfSession::flapping_topo [info script]"
Deputs "----- TAG: $tag -----"
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-times {
set times $value
}
-interval {
set interval $value
}
}
}
set deviceGroupObj [$this cget -deviceHandle]
for { set index 0 } { $index < $times } { incr index } {
foreach route [ ixNet getL $deviceGroupObj networkGroup ] {
ixNet setA [ixNet getA $route -enabled]/singleValue -value True
}
ixNet commit
after [ expr $interval * 1000 ]
foreach route [ ixNet getL $deviceGroupObj networkGroup ] {
ixNet setA [ixNet getA $route -enabled]/singleValue -value False
}
ixNet commit
}
ixNet commit
return [GetStandardReturnHeader]
}
body OspfSession::set_topo {args} {
set tag "body OspfSession::set_topo [info script]"
Deputs "----- TAG: $tag -----"
set deviceGroupObj [$this cget -deviceHandle]
set hRouter $handle
set hNetworkGroup [ixNet add $deviceGroupObj networkGroup]
ixNet commit
set hNetworkRange [ixNet add $hNetworkGroup networkTopology]
ixNet commit
set hNetworkRange [ ixNet remapIds $hNetworkRange ]
set hNetworkGroup [ ixNet remapIds $hNetworkGroup ]
#Available options are netTopologyCustom netTopologyFatTree netTopologyGrid netTopologyHubNSpoke netTopologyLinear netTopologyMesh netTopologyRing netTopologyTree
ixNet commit
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-topo {
set topo $value
}
}
}
# Need clarification on topo argument value
if { [ info exists topo ] } {
if { $topo == "" || [ $topo isa Topology ] == 0 } {
return [GetErrorReturnHeader "No valid object found...-topo $topo"]
}
set typeList {netTopologyCustom netTopologyFatTree netTopologyGrid netTopologyHubNSpoke netTopologyLinear netTopologyMesh netTopologyRing netTopologyTree}
set type [$topo cget -type]
foreach netType $typeList {
if {[string first $type [string tolower $netType]] != -1 } {
set type $netType
set netTopology [ixNet add $hNetworkRange $netType]
ixNet commit
break
}
}
set sim_rtr_num [$topo cget -sim_rtr_num]
set row_num [$topo cget -row_num]
set column_num [$topo cget -column_num]
set attach_row [$topo cget -attach_row]
set attach_column [$topo cget -attach_column]
if { [info exists netTopology] } {
ixNet setM $netTopology -rows $row_num -columns $column_num
ixNet commit
}
set routerId [$topo cget -router_id_start]
if { [info exists routerId] } {
set simRouteObj [ixNet getL $hNetworkRange simRouter]
set ipPattern [ixNet getA [ixNet getA $simRouteObj -routerId] -pattern]
SetMultiValues $simRouteObj "-routerId" $ipPattern $routerId
}
# The below arguments not present in NGPF
#-entryRow $attach_row \
#-entryColumn $attach_column
} else {
return [GetErrorReturnHeader "Madatory parameter needed...-topo"]
}
ixNet commit
return [GetStandardReturnHeader]
}
body OspfSession::unset_topo {} {
set tag "body OspfSession::unset_topo [info script]"
Deputs "----- TAG: $tag -----"
puts "Stopping All Protocols"
ixNet exec stopAllProtocols
after 30000
ixNet remove $hNetworkGroup networkGroup
ixNet commit
}
class Ospfv2Session {
inherit OspfSession
constructor { port { hOspfSession NULL } } { chain $port $hOspfSession } {
set tag "body Ospfv2Session::ctor [info script]"
Deputs "----- TAG: $tag -----"
set view ""
if { [ catch {
set hPort [ $portObj cget -handle ]
} ] } {
error "$errNumber(1) Port Object in OspfSession ctor"
}
if { $hOspfSession == "NULL" } {
set hOspfSession [GetObjNameFromString $this "NULL"]
}
Deputs "----- hOspfSession: $hOspfSession, hPort: $hPort, portObj is: $portObj, port is: $port -----"
if { $hOspfSession != "NULL" } {
set handle [GetValidHandleObj "ospfv2" $hOspfSession $hPort]
Deputs "----- ospfhandle: $handle -----"
if { $handle != "" } {
set handleName [ ixNet getA $handle -name ]
Deputs "----- ospfhandle2: $handleName -----"
} else {
set handleName $this
set handle ""
reborn
}
} else {
set handleName $this
set handle ""
set view ""
reborn
}
}
method reborn {} {
set tag "body Ospfv2Session::reborn [info script]"
Deputs "----- TAG: $tag -----"
chain
set topoObjList [ixNet getL [ixNet getRoot] topology]
Deputs "topoObjList: $topoObjList"
set vportList [ixNet getL [ixNet getRoot] vport]
#set vport [ lindex $vportList end ]
if {[llength $topoObjList] != [llength $vportList]} {
foreach topoObj $topoObjList {
set vportObj [ixNet getA $topoObj -vports]
foreach vport $vportList {
if {$vportObj != $vport && $vport == $hPort} {
set vportTopoList ""
foreach topoObj $topoObjList {
set vportObj [ixNet getA $topoObj -vports]
lappend vportTopoList $vportObj
}
if {[string first $hPort $vportTopoList] == -1} {
set topoObj [ixNet add [ixNet getRoot] topology -vports $hPort]
ixNet commit
set deviceGroupObj [ixNet add $topoObj deviceGroup]
ixNet commit
ixNet setA $deviceGroupObj -multiplier 1
ixNet commit
set ethernetObj [ixNet add $deviceGroupObj ethernet]
ixNet commit
set ipv4Obj [ixNet add $ethernetObj ipv4]
ixNet commit
}
}
}
break
}
}
set topoObjList [ixNet getL [ixNet getRoot] topology]
if { [ llength $topoObjList ] == 0 } {
set topoObj [ixNet add [ixNet getRoot] topology -vports $hPort]
ixNet commit
set deviceGroupObj [ixNet add $topoObj deviceGroup]
ixNet commit
set deviceGroupObj [ ixNet remapIds $deviceGroupObj ]
ixNet setA $deviceGroupObj -multiplier 1
ixNet commit
set ethObj [ixNet add $deviceGroupObj ethernet]
ixNet commit
set ipv4Obj [ixNet add $ethObj ipv4]
ixNet commit
set ospfObj [ixNet add $ipv4Obj ospfv2]
ixNet commit
} else {
foreach topoObj $topoObjList {
set vportObj [ixNet getA $topoObj -vports]
if {$vportObj == $hPort} {
set deviceGroupList [ixNet getL $topoObj deviceGroup]
foreach deviceGroupObj $deviceGroupList {
set ethernetList [ixNet getL $deviceGroupObj ethernet]
if {$ethernetList != ""} {
foreach ethernetObj $ethernetList {
set ipv4Obj [ixNet getL $ethernetObj ipv4]
if {$ipv4Obj != ""} {
set ospfObj [ixNet getL $ipv4Obj ospfv2]
if {$ospfObj == ""} {
set ospfObj [ixNet add $ipv4Obj ospfv2]
ixNet commit
}
} else {
set ipv4Obj [ixNet add $ethernetObj ipv4]
set ospfObj [ixNet add $ipv4Obj ospfv2]
ixNet commit
}
}
} else {
set ethObj [ixNet add $deviceGroupObj ethernet]
ixNet commit
set ipv4Obj [ixNet getL $ethObj ipv4]
if {$ipv4Obj != ""} {
set ospfObj [ixNet getL $ipv4Obj ospfv2]
if {$ospfObj == ""} {
set ospfObj [ixNet add $ipv4Obj ospfv2]
ixNet commit
}
} else {
set ipv4Obj [ixNet add $ethObj ipv4]
set ospfObj [ixNet add $ipv4Obj ospfv2]
ixNet commit
}
}
}
}
}
}
set ospfRtHandle [ ixNet getL $deviceGroupObj ospfv2Router ]
ixNet setA [ ixNet getA $ospfRtHandle -active]/singleValue -value True
ixNet commit
set handle [ ixNet remapIds $ospfObj ]
ixNet setA $handle -name $this
ixNet commit
Deputs "handleospf:$handle"
set protocol ospf
$this configure -deviceHandle $deviceGroupObj
}
method config { args } {}
method get_status {} {}
method get_stats {} {}
}
body Ospfv2Session::get_status {} {
set tag "body OspfSession::get_status [info script]"
Deputs "----- TAG: $tag -----"
set root [ixNet getRoot]
Deputs "root $root"
set protocol "OSPFv2-RTR"
puts "Starting All Protocols"
ixNet exec startAllProtocols
puts "Sleep 30sec for protocols to start"
after 50000
if {$view == ""} {
set view [CreateNgpfProtocolView $protocol]
}
ixNet execute refresh $view
set captionList [ ixNet getA $view/page -columnCaptions ]
set name_index [ lsearch -exact $captionList {Port} ]
set down_index [ lsearch -exact $captionList {Down State Count} ]
set attempt_index [ lsearch -exact $captionList {Attempted State Count} ]
set init_index [ lsearch -exact $captionList {Init State Count} ]
set twoway_index [ lsearch -exact $captionList {Twoway State Count} ]
set exstart_index [ lsearch -exact $captionList {ExStart State Count} ]
set exchange_index [ lsearch -exact $captionList {Exchange State Count} ]
set loading_index [ lsearch -exact $captionList {Loading State Count} ]
set full_index [ lsearch -exact $captionList {Full State Count} ]
set stats [ ixNet getA $view/page -rowValues ]
set portFound 0
foreach row $stats {
Deputs "row:$row"
Deputs "port index:$name_index"
eval {set row} $row
set rowPortName [ lindex $row $name_index ]
Deputs "row port name:$rowPortName"
set portName [ ixNet getA $hPort -name ]
Deputs "portName:$portName"
if { [ regexp $portName $rowPortName ] } {
set portFound 1
break
}
}
set status "down"
# down��attempt��init��two_ways��exstart��exchange��loading��full
if { $portFound } {
Deputs "inside"
set down [ lindex $row $down_index ]
set attempt [ lindex $row $attempt_index ]
set init [ lindex $row $init_index ]
set twoways [ lindex $row $twoway_index ]
set exstart [ lindex $row $exstart_index ]
set exchange [ lindex $row $exchange_index ]
set loading [ lindex $row $loading_index ]
set full [ lindex $row $full_index ]
if { $down } {
Deputs "insided"
set status "down"
}
if { $attempt } {
Deputs "insidea"
set status "attempt"
}
if { $init } {
Deputs "insidei"
set status "init"
}
if { $twoways } {
Deputs "insidet"
set status "two_ways"
}
if { $exstart } {
Deputs "insideee"
set status "exstart"
}
if { $exchange } {
Deputs "insideeee"
set status "exchange"
}
if { $loading } {
Deputs "insidel"
set status "loading"
}
if { $full } {
Deputs "insidef"
set status "full"
}
}
Deputs "status:$status"
set ret [ GetStandardReturnHeader ]
Deputs "ret :$ret"
set ret $ret[ GetStandardReturnBody "status" $status ]
Deputs "ret1 :$ret"
return $ret
}
body Ospfv2Session::get_stats {} {
set tag "body OspfSession::get_status [info script]"
Deputs "----- TAG: $tag -----"
set root [ixNet getRoot]
Deputs "root $root"
puts "Starting All Protocols"
ixNet exec startAllProtocols
puts "Sleep 30sec for protocols to start"
after 50000
set protocol "OSPFv2-RTR"
if {$view == ""} {
set view [CreateNgpfProtocolView $protocol]
}
set captionList [ ixNet getA $view/page -columnCaptions ]
set name_index [ lsearch -exact $captionList {Port} ]
set rx_ack_index [ lsearch -exact $captionList {LS Ack Rx} ]
set tx_ack_index [ lsearch -exact $captionList {LS Ack Tx} ]
set rx_dd_index [ lsearch -exact $captionList {DBD Rx} ]
set tx_dd_index [ lsearch -exact $captionList {DBD Tx} ]
set rx_hello_index [ lsearch -exact $captionList {Hellos Rx} ]
set tx_hello_index [ lsearch -exact $captionList {Hellos Tx} ]
set rx_network_lsa_index [ lsearch -exact $captionList {Network LSA Rx} ]
set tx_network_lsa_index [ lsearch -exact $captionList {Network LSA Tx} ]
set rx_nssa_lsa_index [ lsearch -exact $captionList {NSSA LSA Rx} ]
set tx_nssa_lsa_index [ lsearch -exact $captionList {NSSA LSA Tx } ]
set rx_request_index [ lsearch -exact $captionList {LS Request Rx} ]
set tx_request_index [ lsearch -exact $captionList {LS Request Tx} ]
set rx_router_lsa_index [ lsearch -exact $captionList {Router LSA Rx} ]
set tx_router_lsa_index [ lsearch -exact $captionList {Router LSA Tx} ]
set rx_summary_lsa_index [ lsearch -exact $captionList {Summary IP LSA Rx} ]
set tx_summary_lsa_index [ lsearch -exact $captionList {Summary IP LSA Tx} ]
set rx_as_external_lsa_index [ lsearch -exact $captionList {External LSA Rx} ]
set tx_as_external_lsa_index [ lsearch -exact $captionList {External LSA Tx} ]
set rx_asbr_summary_lsa_index [ lsearch -exact $captionList {Link State Advertisement Rx} ]
set tx_asbr_summary_lsa_index [ lsearch -exact $captionList {LinkState Advertisement Tx} ]
set rx_update_index [ lsearch -exact $captionList {LS Update Rx} ]
set tx_update_index [ lsearch -exact $captionList {LS Update Tx} ]
set stats [ ixNet getA $view/page -rowValues ]
set portFound 0
foreach row $stats {
eval {set row} $row
Deputs "row:$row"
Deputs "port index:$name_index"
set rowPortName [ lindex $row $name_index ]
Deputs "row port name:$rowPortName"
set portName [ ixNet getA $hPort -name ]
Deputs "portName:$portName"
if { [ regexp $portName $rowPortName ] } {
set portFound 1
break
}
}
set ret "Status : true\nLog : \n"
if { $portFound } {
set statsItem "rx_ack"
set statsVal [ lindex $row $rx_ack_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_ack"
set statsVal [ lindex $row $tx_ack_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_dd"
set statsVal [ lindex $row $rx_dd_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_dd"
set statsVal [ lindex $row $tx_dd_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_hello"
set statsVal [ lindex $row $rx_hello_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_hello"
set statsVal [ lindex $row $tx_hello_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_network_lsa"
set statsVal [ lindex $row $rx_network_lsa_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_network_lsa"
set statsVal [ lindex $row $tx_network_lsa_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_nssa_lsa"
set statsVal [ lindex $row $rx_nssa_lsa_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_nssa_lsa"
set statsVal [ lindex $row $tx_nssa_lsa_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_request"
set statsVal [ lindex $row $rx_request_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_request"
set statsVal [ lindex $row $tx_request_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_router_lsa"
set statsVal [ lindex $row $rx_router_lsa_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_router_lsa"
set statsVal [ lindex $row $tx_router_lsa_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_summary_lsa"
set statsVal [ lindex $row $rx_summary_lsa_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_summary_lsa"
set statsVal [ lindex $row $tx_summary_lsa_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_as_external_lsa"
set statsVal [ lindex $row $rx_as_external_lsa_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_as_external_lsa"
set statsVal [ lindex $row $tx_as_external_lsa_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_asbr_summary_lsa"
set statsVal [ lindex $row $rx_asbr_summary_lsa_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_asbr_summary_lsa"
set statsVal [ lindex $row $tx_asbr_summary_lsa_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_update"
set statsVal [ lindex $row $rx_update_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_update"
set statsVal [ lindex $row $tx_update_index ]
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_te_lsa"
set statsVal "NA"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_te_lsa"
set statsVal "NA"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
}
Deputs "ret:$ret"
return $ret
}
body Ospfv2Session::config { args } {
global errorInfo
global errNumber
set ipv4_prefix_len 24
set ipv4_gw 1.1.1.1
set loopback_ipv4_gw 1.1.1.1
set ipv4_addr_step 0.0.0.1
set outer_vlan_step 1
set inner_vlan_step 1
set outer_vlan_num 1
set inner_vlan_num 1
set outer_vlan_priority 0
set inner_vlan_priority 0
set count 1
set enabled True
set tag "body Ospfv2Session::config [info script]"
Deputs "----- TAG: $tag -----"
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-ipv4_addr {
set ipv4_addr $value
}
-ipv4_prefix_len {
if { [ string is integer $value ] && $value <= 32 } {
set ipv4_prefix_len $value
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-ipv4_gw {
set ipv4_gw $value
}
-outer_vlan_id {
if { [ string is integer $value ] && ( $value >= 0 ) && ( $value < 4096 ) } {
set outer_vlan_id $value
set flagOuterVlan 1
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-outer_vlan_step {
if { [ string is integer $value ] && ( $value >= 0 ) && ( $value < 4096 ) } {
set outer_vlan_step $value
set flagOuterVlan 1
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-outer_vlan_num {
if { [ string is integer $value ] && ( $value >= 0 ) } {
set outer_vlan_num $value
set flagOuterVlan 1
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-outer_vlan_priority {
if { [ string is integer $value ] && ( $value >= 0 ) && ( $value < 8 ) } {
set outer_vlan_priority $value
set flagOuterVlan 1
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-inner_vlan_id {
if { [ string is integer $value ] && ( $value >= 0 ) && ( $value < 4096 ) } {
set inner_vlan_id $value
set flagInnerVlan 1
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-inner_vlan_step {
if { [ string is integer $value ] && ( $value >= 0 ) && ( $value < 4096 ) } {
set inner_vlan_step $value
set flagInnerVlan 1
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-inner_vlan_num {
if { [ string is integer $value ] && ( $value >= 0 ) } {
set inner_vlan_num $value
set flagInnerVlan 1
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-inner_vlan_priority {
if { [ string is integer $value ] && ( $value >= 0 ) && ( $value < 8 ) } {
set inner_vlan_priority $value
set flagInnerVlan 1
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-outer_vlan_cfi {
set outer_vlan_cfi $value
}
-inner_vlan_cfi {
set inner_vlan_cfi $value
}
-loopback_ipv4_addr {
set loopback_ipv4_addr $value
}
-loopback_ipv4_gw {
set loopback_ipv4_gw $value
}
}
}
if { $handle == "" } {
Deputs "beforereborn:$handle"
reborn
Deputs "afterreborn:$handle"
}
set topoObjList [ixNet getL [ixNet getRoot] topology]
foreach topoObj $topoObjList {
set vportObj [ixNet getA $topoObj -vports]
if {$vportObj == $hPort} {
set deviceGroupObj [ixNet getL $topoObj deviceGroup]
foreach devObj $deviceGroupObj {
set ethernetObj [ixNet getL $devObj ethernet]
if { [ info exists ipv4_addr ] } {
Deputs "ipv4: [ixNet getL $ethernetObj ipv4]"
set ipv4Obj [ixNet getL $ethernetObj ipv4]
ixNet setA [ixNet getA $ipv4Obj -address]/singleValue -value $ipv4_addr
ixNet setA [ixNet getA $ipv4Obj -gatewayIp]/singleValue -value $ipv4_gw
ixNet setA [ixNet getA $ipv4Obj -prefix]/singleValue -value $ipv4_prefix_len
ixNet commit
generate_interface
}
if {[ info exists outer_vlan_id ]} {
for { set index 0 } { $index < $count } { incr index } {
if { [ info exists outer_vlan_id ] } {
set vlanId $outer_vlan_id
ixNet setA $ethernetObj -vlanCount 1
ixNet setA [ixNet getA $ethernetObj -enableVlans]/singleValue -value True
set oVlanObj [lindex [ixNet getL $ethernetObj vlan] 0]
ixNet setA [ixNet getA $oVlanObj -vlanId]/singleValue -value $vlanId
ixNet setA [ixNet getA $oVlanObj -priority]/singleValue -value $outer_vlan_priority