File: test-suite-satellite.tcl

package info (click to toggle)
ns2 2.35%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 78,120 kB
  • sloc: cpp: 172,923; tcl: 107,127; perl: 6,391; sh: 6,143; ansic: 5,846; makefile: 812; awk: 525; csh: 355
file content (815 lines) | stat: -rw-r--r-- 25,132 bytes parent folder | download | duplicates (8)
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
#
Agent/TCP set tcpTick_ 0.1
# The default for tcpTick_ is being changed to reflect a changing reality.
Agent/TCP set rfc2988_ false
# The default for rfc2988_ is being changed to true.
# FOR UPDATING GLOBAL DEFAULTS:
Agent/TCP set precisionReduce_ false ;   # default changed on 2006/1/24.
Agent/TCP set rtxcur_init_ 6.0 ;      # Default changed on 2006/01/21
Agent/TCP set updated_rttvar_ false ;  # Variable added on 2006/1/21
Agent/TCP set minrto_ 1
# default changed on 10/14/2004.
Agent/TCP set useHeaders_ false
# The default is being changed to useHeaders_ true.
Agent/TCP set windowInit_ 1
# The default is being changed to 2.
Agent/TCP set singledup_ 0
# The default is being changed to 1
Agent/TCP set SetCWRonRetransmit_ true
# Changing the default value.
#
# Copyright (c) 1999 Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
#    must display the following acknowledgement:
#       This product includes software developed by the MASH Research
#       Group at the University of California Berkeley.
# 4. Neither the name of the University nor of the Research Group may be
#    used to endorse or promote products derived from this software without
#    specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#    
# @(#) $Header: /cvsroot/nsnam/ns-2/tcl/test/test-suite-satellite.tcl,v 1.12 2006/01/24 23:00:07 sallyfloyd Exp $
#
# Contributed by Tom Henderson, UCB Daedalus Research Group, June 1999
#    
# This test suite is for validating the satellite extensions
#
# To run all tests:  test-all-satellite
#
# To run individual tests:
# ns test-suite-satellite.tcl mixed 
# ns test-suite-satellite.tcl mixed.legacy 
# ns test-suite-satellite.tcl repeater
# ns test-suite-satellite.tcl aloha
# ns test-suite-satellite.tcl aloha.collisions
# ns test-suite-satellite.tcl wired 
#
#
# To view a list of available tests to run with this script:
# ns test-suite-satellite.tcl
#
Agent/TCP set syn_ false
Agent/TCP set delay_growth_ false
# In preparation for changing the default values for syn_ and delay_growth_.

# Some OTcl bound variables
HandoffManager/Term set elevation_mask_ 8.2
HandoffManager/Term set term_handoff_int_ 10
HandoffManager set handoff_randomization_ "false"
Mac/Sat/UnslottedAloha set mean_backoff_ 1s 
Mac/Sat/UnslottedAloha set rtx_limit_ 3
Mac/Sat/UnslottedAloha set send_timeout_ 270ms

Class TestSuite

TestSuite instproc init {} {
	$self instvar ns_ test_ topo_ node_ 
	set ns_ [new Simulator]
	$ns_ rtproto Dummy

	global f
	set f [open temp.rands w]
	$ns_ trace-all $f

}

TestSuite instproc finish args {
	$self instvar ns_
	
	$ns_ flush-trace
	exit 0
}

proc usage {} {
	global argv0
	puts stderr "usage: ns $argv0 <tests> "
	puts stderr "Valid tests are:\t[get-subclasses TestSuite Test/]"
	exit 1
}

proc isProc? {cls prc} {
	if [catch "Object info subclass $cls/$prc" r] {
		global argv0
		puts stderr "$argv0: no such $cls: $prc"
		usage
	}
}

proc get-subclasses {cls pfx} {
	set ret ""
	set l [string length $pfx]

	set c $cls
	while {[llength $c] > 0} {
		set t [lindex $c 0]
		set c [lrange $c 1 end]
		if [string match ${pfx}* $t] {
			lappend ret [string range $t $l end]
		}
		eval lappend c [$t info subclass]
	}
	set ret
}

TestSuite proc runTest {} {
	global argc argv

	switch $argc {
		1 {
			set test $argv
			isProc? Test $test

		}
		2 {
			set test [lindex $argv 0]
			isProc? Test $test
			set a [lindex $argv 1]
		}
		default {
			usage
		}
	}
	set t [new Test/$test]
	$t run
}

# Global configuration parameters

global opt
set opt(chan)           Channel/Sat
set opt(bw_up)          2Mb; # Uplink bandwidth
set opt(bw_down)        2Mb; # Downlink bandwidth
set opt(phy)            Phy/Sat
set opt(mac)            Mac/Sat
set opt(ifq)            Queue/DropTail
set opt(qlim)           50
set opt(ll)             LL/Sat

# Definition of test-suite tests
# Simple bent-pipe (repeater) satellite
# NOTE:  This test is identical to sat-repeater.tcl in ~ns/tcl/ex

Class Test/repeater -superclass TestSuite
Test/repeater instproc init {} {
	$self instvar test_ 
	set test_	repeater
	$self next
}

Test/repeater instproc run {} {
	$self instvar ns_ node_ 

	global opt f

	set opt(wiredRouting)   OFF

	# GEO satellite at 95 degrees longitude West
	$ns_ node-config -satNodeType geo-repeater \
			-llType $opt(ll) \
			-ifqType $opt(ifq) \
			-ifqLen $opt(qlim) \
			-macType $opt(mac) \
			-phyType $opt(phy) \
			-channelType $opt(chan) \
			-downlinkBW $opt(bw_down) \
			-wiredRouting $opt(wiredRouting)

	set n1 [$ns_ node]
	$n1 set-position -95

	# Two terminals: one in NY and one in SF 
	$ns_ node-config -satNodeType terminal
	set n2 [$ns_ node] 
	$n2 set-position 40.9 -73.9; # NY
	set n3 [$ns_ node] 
	$n3 set-position 37.8 -122.4; # SF

	# Add GSLs to geo satellites
	$n2 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) \
            $opt(phy) [$n1 set downlink_] [$n1 set uplink_]
	$n3 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up)  \
	    $opt(phy) [$n1 set downlink_] [$n1 set uplink_]

	# Add an error model to the receiving terminal node
	set em_ [new ErrorModel]
	$em_ unit pkt 
	$em_ set rate_ 0.02
	$em_ ranvar [new RandomVariable/Uniform] 
	$n3 interface-errormodel $em_

	$ns_ trace-all-satlinks $f

	# Attach agents for CBR traffic generator
	set udp0 [new Agent/UDP] 
	$ns_ attach-agent $n2 $udp0
	set cbr0 [new Application/Traffic/CBR]
	$cbr0 attach-agent $udp0
	$cbr0 set interval_ 6

	set null0 [new Agent/Null]
	$ns_ attach-agent $n3 $null0
 
	$ns_ connect $udp0 $null0

	# Attach agents for FTP
	set tcp1 [$ns_ create-connection TCP $n2 TCPSink $n3 0]
	set ftp1 [$tcp1 attach-app FTP]
	$ns_ at 7.0 "$ftp1 produce 100"

	# We use centralized routing
	set satrouteobject_ [new SatRouteObject]
	$satrouteobject_ compute_routes

	$ns_ at 1.0 "$cbr0 start"

	$ns_ at 100.0 "$self finish"   

	$ns_ run
}

# Testing a geo satellite and a plane of polar satellites
# NOTE:  This test is identical to sat-mixed.tcl in ~ns/tcl/ex

Class Test/mixed -superclass TestSuite
Test/mixed instproc init {} {
	$self instvar test_
	set test_       mixed 
	$self next

}

Test/mixed instproc run {} {
	$self instvar ns_  

	global opt f
	
	# Change some of the options
	set opt(bw_down)        1.5Mb
	set opt(bw_up)          1.5Mb
	set opt(bw_isl)         25Mb

	set opt(alt)            780
	set opt(inc)            90
	set opt(wiredRouting)   OFF

	$ns_ node-config -satNodeType polar \
			 -llType $opt(ll) \
			 -ifqType $opt(ifq) \
			 -ifqLen $opt(qlim) \
			 -macType $opt(mac) \
			 -phyType $opt(phy) \
			 -channelType $opt(chan) \
			 -downlinkBW $opt(bw_down) \
			 -wiredRouting $opt(wiredRouting)

	set n0 [$ns_ node]; set n1 [$ns_ node]; set n2 [$ns_ node];
	set n3 [$ns_ node]; set n4 [$ns_ node]; set n5 [$ns_ node];
	set n6 [$ns_ node]; set n7 [$ns_ node]; set n8 [$ns_ node];
	set n9 [$ns_ node]; set n10 [$ns_ node]

	set plane 1
	$n0 set-position $opt(alt) $opt(inc) 0 0 $plane 
	$n1 set-position $opt(alt) $opt(inc) 0 32.73 $plane 
	$n2 set-position $opt(alt) $opt(inc) 0 65.45 $plane 
	$n3 set-position $opt(alt) $opt(inc) 0 98.18 $plane 
	$n4 set-position $opt(alt) $opt(inc) 0 130.91 $plane 
	$n5 set-position $opt(alt) $opt(inc) 0 163.64 $plane 
	$n6 set-position $opt(alt) $opt(inc) 0 196.36 $plane 
	$n7 set-position $opt(alt) $opt(inc) 0 229.09 $plane 
	$n8 set-position $opt(alt) $opt(inc) 0 261.82 $plane 
	$n9 set-position $opt(alt) $opt(inc) 0 294.55 $plane 
	$n10 set-position $opt(alt) $opt(inc) 0 327.27 $plane 

	# By setting the next_ variable on polar sats; handoffs can be optimized
	# This step must follow all polar node creation
	$n0 set_next $n10; $n1 set_next $n0; $n2 set_next $n1; $n3 set_next $n2
	$n4 set_next $n3; $n5 set_next $n4; $n6 set_next $n5; $n7 set_next $n6
	$n8 set_next $n7; $n9 set_next $n8; $n10 set_next $n9

	# GEO satellite:  above North America
	$ns_ node-config -satNodeType geo
	set n11 [$ns_ node]
	$n11 set-position -100

	# Terminals
	$ns_ node-config -satNodeType terminal
	set n100 [$ns_ node]; set n101 [$ns_ node]
	$n100 set-position 37.9 -122.3; # Berkeley
	$n101 set-position 42.3 -71.1; # Boston
	set n200 [$ns_ node]; set n201 [$ns_ node]
	$n200 set-position 0 10
	$n201 set-position 0 -10

	# Add any necessary ISLs or GSLs
	# GSLs to the geo satellite:
	$n100 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) \
	  $opt(phy) [$n11 set downlink_] [$n11 set uplink_]
	$n101 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) \
	  $opt(phy) [$n11 set downlink_] [$n11 set uplink_]
	# Attach n200 and n201 
	$n200 add-gsl polar $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) $opt(phy) [$n5 set downlink_] [$n5 set uplink_]
	$n201 add-gsl polar $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) $opt(phy) [$n5 set downlink_] [$n5 set uplink_]

	#ISL
	$ns_ add-isl intraplane $n0 $n1 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n1 $n2 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n2 $n3 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n3 $n4 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n4 $n5 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n5 $n6 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n6 $n7 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n7 $n8 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n8 $n9 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n9 $n10 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n10 $n0 $opt(bw_isl) $opt(ifq) $opt(qlim)

	# Trace all queues
	$ns_ trace-all-satlinks $f

	# Attach agents
	set udp0 [new Agent/UDP]
	$ns_ attach-agent $n100 $udp0
	set cbr0 [new Application/Traffic/CBR]
	$cbr0 attach-agent $udp0
	$cbr0 set interval_ 60.01

	set udp1 [new Agent/UDP]
	$ns_ attach-agent $n200 $udp1
	$udp1 set class_ 1
	set cbr1 [new Application/Traffic/CBR]
	$cbr1 attach-agent $udp1
	$cbr1 set interval_ 90.5

	set null0 [new Agent/Null]
	$ns_ attach-agent $n101 $null0
	set null1 [new Agent/Null]
	$ns_ attach-agent $n201 $null1

	$ns_ connect $udp0 $null0
	$ns_ connect $udp1 $null1

	set satrouteobject_ [new SatRouteObject]
	$satrouteobject_ compute_routes

	$ns_ at 1.0 "$cbr0 start"
	$ns_ at 305.0 "$cbr1 start"

	$ns_ at 9000.0 "$self finish"

	$ns_ run
}

# Same as mixed, but with wired-satellite integration
# NOTE:  This test is identical to sat-wired.tcl in ~ns/tcl/ex

Class Test/wired -superclass TestSuite
Test/wired instproc init {} {
	$self instvar test_
	set test_       wired 
	$self next

}

Test/wired instproc run {} {
	$self instvar ns_  

	global opt f
	
	# Change some of the options
	set opt(bw_down)        1.5Mb
	set opt(bw_up)          1.5Mb
	set opt(bw_isl)         25Mb

	set opt(alt)            780
	set opt(inc)            90
	set opt(wiredRouting) 	ON

	$ns_ node-config -satNodeType polar \
			 -llType $opt(ll) \
			 -ifqType $opt(ifq) \
			 -ifqLen $opt(qlim) \
			 -macType $opt(mac) \
			 -phyType $opt(phy) \
			 -channelType $opt(chan) \
			 -downlinkBW $opt(bw_down) \
			 -wiredRouting $opt(wiredRouting)

	set n0 [$ns_ node]; set n1 [$ns_ node]; set n2 [$ns_ node];
	set n3 [$ns_ node]; set n4 [$ns_ node]; set n5 [$ns_ node];
	set n6 [$ns_ node]; set n7 [$ns_ node]; set n8 [$ns_ node];
	set n9 [$ns_ node]; set n10 [$ns_ node]

	set plane 1
	$n0 set-position $opt(alt) $opt(inc) 0 0 $plane 
	$n1 set-position $opt(alt) $opt(inc) 0 32.73 $plane 
	$n2 set-position $opt(alt) $opt(inc) 0 65.45 $plane 
	$n3 set-position $opt(alt) $opt(inc) 0 98.18 $plane 
	$n4 set-position $opt(alt) $opt(inc) 0 130.91 $plane 
	$n5 set-position $opt(alt) $opt(inc) 0 163.64 $plane 
	$n6 set-position $opt(alt) $opt(inc) 0 196.36 $plane 
	$n7 set-position $opt(alt) $opt(inc) 0 229.09 $plane 
	$n8 set-position $opt(alt) $opt(inc) 0 261.82 $plane 
	$n9 set-position $opt(alt) $opt(inc) 0 294.55 $plane 
	$n10 set-position $opt(alt) $opt(inc) 0 327.27 $plane 

	# By setting the next_ variable on polar sats; handoffs can be optimized
	# This step must follow all polar node creation
	$n0 set_next $n10; $n1 set_next $n0; $n2 set_next $n1; $n3 set_next $n2
	$n4 set_next $n3; $n5 set_next $n4; $n6 set_next $n5; $n7 set_next $n6
	$n8 set_next $n7; $n9 set_next $n8; $n10 set_next $n9

	# GEO satellite:  above North America
	$ns_ node-config -satNodeType geo
	set n11 [$ns_ node]
	$n11 set-position -100

	# Terminals
	$ns_ node-config -satNodeType terminal
	set n100 [$ns_ node]; set n101 [$ns_ node]
	$n100 set-position 37.9 -122.3; # Berkeley
	$n101 set-position 42.3 -71.1; # Boston
	set n200 [$ns_ node]; set n201 [$ns_ node]
	$n200 set-position 0 10
	$n201 set-position 0 -10

	# Add any necessary ISLs or GSLs
	# GSLs to the geo satellite:
	$n100 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) \
	  $opt(phy) [$n11 set downlink_] [$n11 set uplink_]
	$n101 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) \
	  $opt(phy) [$n11 set downlink_] [$n11 set uplink_]
	# Attach n200 and n201 
	$n200 add-gsl polar $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) $opt(phy) [$n5 set downlink_] [$n5 set uplink_]
	$n201 add-gsl polar $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) $opt(phy) [$n5 set downlink_] [$n5 set uplink_]

	#ISL
	$ns_ add-isl intraplane $n0 $n1 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n1 $n2 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n2 $n3 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n3 $n4 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n4 $n5 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n5 $n6 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n6 $n7 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n7 $n8 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n8 $n9 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n9 $n10 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n10 $n0 $opt(bw_isl) $opt(ifq) $opt(qlim)

	# Set up wired nodes
	# Connect $n300<->$n301<->$n302<->$n100<->$n11<->$n101<->$n303
	#                    ^               ^
	#                    |_______________|
	#
	# Packets from n303 to n300 should bypass n302 (node #18 in the trace)
	# (i.e., they should take the following path:  19,13,11,12,17,16)
	#
	$ns_ unset satNodeType_
	set n300 [$ns_ node]; # node 16 in trace
	set n301 [$ns_ node]; # node 17 in trace
	set n302 [$ns_ node]; # node 18 in trace
	set n303 [$ns_ node]; # node 19 in trace
	$ns_ duplex-link $n300 $n301 5Mb 2ms DropTail; # 16 <-> 17
	$ns_ duplex-link $n301 $n302 5Mb 2ms DropTail; # 17 <-> 18
	$ns_ duplex-link $n302 $n100 5Mb 2ms DropTail; # 18 <-> 11
	$ns_ duplex-link $n303 $n101 5Mb 2ms DropTail; # 19 <-> 13
	$ns_ duplex-link $n301 $n100 5Mb 2ms DropTail; # 17 <-> 11



	# Trace all queues
	$ns_ trace-all-satlinks $f

	# Attach agents
	set udp0 [new Agent/UDP]
	$ns_ attach-agent $n100 $udp0
	set cbr0 [new Application/Traffic/CBR]
	$cbr0 attach-agent $udp0
	$cbr0 set interval_ 60.01

	set udp1 [new Agent/UDP]
	$ns_ attach-agent $n200 $udp1
	$udp1 set class_ 1
	set cbr1 [new Application/Traffic/CBR]
	$cbr1 attach-agent $udp1
	$cbr1 set interval_ 90.5

	set null0 [new Agent/Null]
	$ns_ attach-agent $n101 $null0
	set null1 [new Agent/Null]
	$ns_ attach-agent $n201 $null1

	$ns_ connect $udp0 $null0
	$ns_ connect $udp1 $null1

	# Set up connection between wired nodes
	set udp2 [new Agent/UDP]
	$ns_ attach-agent $n303 $udp2
	set cbr2 [new Application/Traffic/CBR]
	$cbr2 attach-agent $udp2
	$cbr2 set interval_ 300
	set null2 [new Agent/Null]
	$ns_ attach-agent $n300 $null2

	$ns_ connect $udp2 $null2
	$ns_ at 10.0 "$cbr2 start"
 
	set satrouteobject_ [new SatRouteObject]
	$satrouteobject_ compute_routes

	$ns_ at 1.0 "$cbr0 start"
	$ns_ at 305.0 "$cbr1 start"

	$ns_ at 9000.0 "$self finish"

	$ns_ run
}

# Testing unslotted aloha
# bent-pipe gka geo satellite and a plane of polar satellites
# NOTE:  This test is similar (fewer sources) to sat-aloha.tcl in ~ns/tcl/ex

Class Test/aloha -superclass TestSuite
Test/aloha instproc init {} {
	$self instvar test_
	set test_ 	aloha	
	$self next
}

Test/aloha instproc run {} {
    $self instvar ns_  
	
	global opt f 

	Mac/Sat set trace_drops_ false
	Mac/Sat set trace_collisions_ false

	set opt(bw_up)          2Mb
	set opt(bw_down)        2Mb
	set opt(mac)            Mac/Sat/UnslottedAloha 
	set opt(wiredRouting)   OFF

	$ns_ node-config -satNodeType geo-repeater \
			-llType $opt(ll) \
			-ifqType $opt(ifq) \
			-ifqLen $opt(qlim) \
			-macType $opt(mac) \
			-phyType $opt(phy) \
			-channelType $opt(chan) \
			-downlinkBW $opt(bw_down) \
			-wiredRouting $opt(wiredRouting)

	# GEO satellite at prime meridian
	set n1 [$ns_ node]
	$n1 set-position 0

	# Place 30 nodes at 30 different locations
	$ns_ node-config -satNodeType terminal
	set num_nodes           30
	for {set a 1} {$a <= $num_nodes} {incr a} {
		set n($a) [$ns_ node]
        	$n($a) set-position [expr -15 + $a ] [expr 15 - $a ]
        	$n($a) add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) \
		    $opt(bw_up) $opt(phy) [$n1 set downlink_] [$n1 set uplink_]
	}

	for {set a 1} {$a <= $num_nodes} {incr a} {
        	set b [expr int($a + (0.5 * $num_nodes))]
        	if {$b > 30} {
                	incr b -30 
        	}

        	set udp($a) [new Agent/UDP]
        	$ns_ attach-agent $n($a) $udp($a)
        	set exp($a) [new Application/Traffic/Exponential]
        	$exp($a) attach-agent $udp($a)
        	$exp($a) set rate_ 3Kb

        	set null($a) [new Agent/Null]
        	$ns_ attach-agent $n($b) $null($a)

        	$ns_ connect $udp($a) $null($a)
        	$ns_ at 1.0 "$exp($a) start"
	}

	$ns_ trace-all-satlinks $f

	# We use centralized routing
	set satrouteobject_ [new SatRouteObject]
	$satrouteobject_ compute_routes

	$ns_ at 50.0 "$self finish"

	$ns_ run
}

Class Test/aloha.collisions -superclass TestSuite
Test/aloha.collisions instproc init {} {
	$self instvar test_
	set test_ 	aloha	
	$self next
}

Test/aloha.collisions instproc run {} {
    $self instvar ns_  
	
	global opt f 

	Mac/Sat set trace_drops_ true
	Mac/Sat set trace_collisions_ true

	set opt(bw_up)          2Mb
	set opt(bw_down)        2Mb
	set opt(mac)            Mac/Sat/UnslottedAloha 
	set opt(wiredRouting)   OFF

	$ns_ node-config -satNodeType geo-repeater \
			-llType $opt(ll) \
			-ifqType $opt(ifq) \
			-ifqLen $opt(qlim) \
			-macType $opt(mac) \
			-phyType $opt(phy) \
			-channelType $opt(chan) \
			-downlinkBW $opt(bw_down) \
			-wiredRouting $opt(wiredRouting)

	# GEO satellite at prime meridian
	set n1 [$ns_ node]
	$n1 set-position 0

	# Place 30 nodes at 30 different locations
	$ns_ node-config -satNodeType terminal
	set num_nodes           30
	for {set a 1} {$a <= $num_nodes} {incr a} {
		set n($a) [$ns_ node]
        	$n($a) set-position [expr -15 + $a ] [expr 15 - $a ]
        	$n($a) add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) \
		    $opt(bw_up) $opt(phy) [$n1 set downlink_] [$n1 set uplink_]
	}

	for {set a 1} {$a <= $num_nodes} {incr a} {
        	set b [expr int($a + (0.5 * $num_nodes))]
        	if {$b > 30} {
                	incr b -30 
        	}

        	set udp($a) [new Agent/UDP]
        	$ns_ attach-agent $n($a) $udp($a)
        	set exp($a) [new Application/Traffic/Exponential]
        	$exp($a) attach-agent $udp($a)
        	$exp($a) set rate_ 3Kb

        	set null($a) [new Agent/Null]
        	$ns_ attach-agent $n($b) $null($a)

        	$ns_ connect $udp($a) $null($a)
        	$ns_ at 1.0 "$exp($a) start"
	}

	$ns_ trace-all-satlinks $f

	# We use centralized routing
	set satrouteobject_ [new SatRouteObject]
	$satrouteobject_ compute_routes

	$ns_ at 50.0 "$self finish"

	$ns_ run
}

# Backward compatibility syntax (legacy code) for "mixed"
Class Test/mixed.legacy -superclass TestSuite
Test/mixed.legacy instproc init {} {
	$self instvar test_
	set test_       mixed.legacy 
	$self next

}

Test/mixed.legacy instproc run {} {
	$self instvar ns_  

	global opt f
	
	# Change some of the options
	set opt(bw_down)        1.5Mb
	set opt(bw_up)          1.5Mb
	set opt(bw_isl)         25Mb
	set opt(mac)            Mac/Sat 

	set opt(alt)            780
	set opt(inc)            90

	set linkargs "$opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_down) $opt(phy)"
	set alt $opt(alt)
	set inc $opt(inc)
	set chan $opt(chan)
	set plane 1
	set n0 [$ns_ satnode-polar $alt $inc 0 0 $plane $linkargs $chan]
	set n1 [$ns_ satnode-polar $alt $inc 0 32.73 $plane $linkargs $chan]
	set n2 [$ns_ satnode-polar $alt $inc 0 65.45 $plane $linkargs $chan]
	set n3 [$ns_ satnode-polar $alt $inc 0 98.18 $plane $linkargs $chan]
	set n4 [$ns_ satnode-polar $alt $inc 0 130.91 $plane $linkargs $chan]
	set n5 [$ns_ satnode-polar $alt $inc 0 163.64 $plane $linkargs $chan]
	set n6 [$ns_ satnode-polar $alt $inc 0 196.36 $plane $linkargs $chan]
	set n7 [$ns_ satnode-polar $alt $inc 0 229.09 $plane $linkargs $chan]
	set n8 [$ns_ satnode-polar $alt $inc 0 261.82 $plane $linkargs $chan]
	set n9 [$ns_ satnode-polar $alt $inc 0 294.55 $plane $linkargs $chan]
	set n10 [$ns_ satnode-polar $alt $inc 0 327.27 $plane $linkargs $chan]

	# By setting the next_ variable on polar sats; handoffs can be optimized
	# This step must follow all polar node creation
	$n0 set_next $n10; $n1 set_next $n0; $n2 set_next $n1; $n3 set_next $n2
	$n4 set_next $n3; $n5 set_next $n4; $n6 set_next $n5; $n7 set_next $n6
	$n8 set_next $n7; $n9 set_next $n8; $n10 set_next $n9

	# GEO satellite:  above North America
	set n11 [$ns_ satnode-geo -100 $linkargs $opt(chan)]

	# Terminals
	set n100 [$ns_ satnode-terminal 37.9 -122.3]; # Berkeley
	set n101 [$ns_ satnode-terminal 42.3 -71.1]; # Boston
	set n200 [$ns_ satnode-terminal 0 10]
	set n201 [$ns_ satnode-terminal 0 -10]

	# Add any necessary ISLs or GSLs
	# GSLs to the geo satellite:
	$n100 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) \
	  $opt(phy) [$n11 set downlink_] [$n11 set uplink_]
	$n101 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) \
	  $opt(phy) [$n11 set downlink_] [$n11 set uplink_]
	# Attach n200 and n201 
	$n200 add-gsl polar $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) $opt(phy) [$n5 set downlink_] [$n5 set uplink_]
	$n201 add-gsl polar $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) $opt(phy) [$n5 set downlink_] [$n5 set uplink_]

	#ISL
	$ns_ add-isl intraplane $n0 $n1 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n1 $n2 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n2 $n3 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n3 $n4 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n4 $n5 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n5 $n6 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n6 $n7 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n7 $n8 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n8 $n9 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n9 $n10 $opt(bw_isl) $opt(ifq) $opt(qlim)
	$ns_ add-isl intraplane $n10 $n0 $opt(bw_isl) $opt(ifq) $opt(qlim)

	# Trace all queues
	$ns_ trace-all-satlinks $f

	# Attach agents
	set udp0 [new Agent/UDP]
	$ns_ attach-agent $n100 $udp0
	set cbr0 [new Application/Traffic/CBR]
	$cbr0 attach-agent $udp0
	$cbr0 set interval_ 60.01

	set udp1 [new Agent/UDP]
	$ns_ attach-agent $n200 $udp1
	$udp1 set class_ 1
	set cbr1 [new Application/Traffic/CBR]
	$cbr1 attach-agent $udp1
	$cbr1 set interval_ 90.5

	set null0 [new Agent/Null]
	$ns_ attach-agent $n101 $null0
	set null1 [new Agent/Null]
	$ns_ attach-agent $n201 $null1

	$ns_ connect $udp0 $null0
	$ns_ connect $udp1 $null1

	set satrouteobject_ [new SatRouteObject]
	$satrouteobject_ compute_routes

	$ns_ at 1.0 "$cbr0 start"
	$ns_ at 305.0 "$cbr1 start"

	$ns_ at 9000.0 "$self finish"

	$ns_ run
}

TestSuite runTest