File: rmcc-1.tcl

package info (click to toggle)
ns2 2.35%2Bdfsg-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 78,808 kB
  • sloc: cpp: 172,923; tcl: 107,130; perl: 6,391; sh: 6,143; ansic: 5,846; makefile: 816; awk: 525; csh: 355
file content (183 lines) | stat: -rw-r--r-- 4,503 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
# Correlated and Uncorrelated Loss Scenario:

# Topology:

#           0 0 Source
#             |
#           1 0 
#            / \
#           /   \
#       2  0   3 0 
#         / \     \
#      4 0 5 0   6 0
#       R1   R2    R3
#

# 
# Simulation A : All links have 1Mbps BW. There is 10% loss in link 0-1
# No loss in other links.

# Simulation B: Similar to setup of A except that 10% loss now takes 
# place in links 1-2 and 1-3. No loss in other links. 

# Simulation C: 10% loss in link 1-3. and 5% loss in link 1-2. No 
# loss in other links. 
# Flow monitors measure thruput at link 2-4, 2-5 and 3-6.

#usage: ns rmcc-1.tcl -test <#test no>
#test number options: 1,2, 3 or 4


source ../../mcast/srm-nam.tcl		;#to separate control messages
source rmcc.tcl


ScenLib/RM instproc make_topo1 { at } {
    global ns n prog t
    $self make_nodes 7
    #color them
    $n(0) color "red"
    $n(4) color "orchid"
    $n(5) color "orchid"
    $n(6) color "orchid"
    
    #now setup topology
    $ns duplex-link $n(0) $n(1) 1Mb 10ms DropTail
    $ns duplex-link $n(1) $n(2) 1Mb 10ms DropTail
    $ns duplex-link $n(1) $n(3) 1Mb 10ms DropTail
    $ns duplex-link $n(2) $n(4) 1Mb 10ms DropTail
    $ns duplex-link $n(2) $n(5) 1Mb 10ms DropTail
    $ns duplex-link $n(3) $n(6) 1Mb 10ms DropTail
    
    $ns duplex-link-op $n(0) $n(1) orient down
    $ns duplex-link-op $n(1) $n(2) orient left-down
    $ns duplex-link-op $n(1) $n(3) orient right-down
    $ns duplex-link-op $n(2) $n(4) orient left-down
    $ns duplex-link-op $n(2) $n(5) orient right-down
    $ns duplex-link-op $n(3) $n(6) orient right-down
    
    $self make_flowmon $at $n(2) $n(4) flowStats_2_4.$t \
	    $n(2) $n(5) flowStats_2_5.$t \
	    $n(3) $n(6) flowStats_3_6.$t
    # $self make_flowmon $n(2) $n(5) flowStats_2_5.$t
    # $self make_flowmon $n(3) $n(6) flowStats_3_6.$t
}



#ScenLib/RM instproc setup_mcast {} {
 #   global ns n opts srmStats srmEvents

    # mproto options : 5
    # CtrMcast, DM, detailedDM, dynamicDM, pimDM
  #  set mrthandle [$ns mrtproto $opts(routingProto) {}]
    
   # set fid 0
   # set dest [Node allocaddr]
   # $ns at 0.3 "$mrthandle switch-treetype $dest"
    
   # set src [new Agent/$opts(srmSimType)]
   # $src set dst_ $dest
   # $src set fid_ [incr fid]
   # $src trace $srmEvents
   # $src log $srmStats
   # $ns at 1.0 "$src start"
   # $ns attach-agent $n(0) $src
    
   # for {set i 4} {$i < 7} {incr i} {
#	set rcvr($i) [new Agent/$opts(srmSimType)]
#	$rcvr($i) set dst_ $dest
#	$rcvr($i) set fid_ [incr fid]
#	$rcvr($i) trace $srmEvents
#	$rcvr($i) log $srmStats
#	$ns attach-agent $n($i) $rcvr($i)
#	$ns at 1.0 "$rcvr($i) start"
#    }
    
    #setup source
 #   set cbr [new Agent/CBR]
 #   $cbr set packetSize_ 1000
 #   $src traffic-source $cbr
 #   $src set packetSize_ 1000  ;#so repairs are correct
 #   $cbr set fid_ 0
 #   $ns at 3.0 "$src start-source"
#}



#ScenLib/RM instproc attach-tcp {} {
 #   global ns n
    #Attach a TCP flow between src and recvr1
 #   set tcp [new Agent/TCP]
 #   $tcp set fid_ 2
 #   $tcp set packetSize_ 1000
 #   $ns attach-agent $n(0) $tcp
    
 #   set sink [new Agent/TCPSink]
 #   $ns attach-agent $n(4) $sink
 #   $ns connect $tcp $sink
    
 #   set ftp [new Application/FTP]
 #   $ftp attach-agent $tcp
 #   $ns at 1.5 "$ftp start"
    
#}



proc test {num } {
    global ns n prog
    puts "running test$num"
    set test_scen [new ScenLib/RM]
    switch $num {
	"1" { 
	    $test_scen make_topo1 6.0
	    $test_scen create_mcast 0 0.3 1.0 3.0 4 5 6 
	    $test_scen loss-model-case1 2.52 0 1
	    #$ns at 6.0 "$flowmon dump"
	    $ns at 6.0 "finish" 
	}
	"2" {
	    $test_scen make_topo1 12.0
	    $test_scen create_mcast 0 0.3 1.0 3.0 4 5 6
	    $test_scen loss-model-case2 2.52 2.52 1 2 1 3
	    #$ns at 12.0 "$flowmon dump"
	    $ns at 12.0 "finish"
	}
	"3" {
	    $test_scen make_topo1 18.0
	    $test_scen create_mcast 0 0.3 1.0 3.0 4 5 6
	    $test_scen loss-model-case3 2.52 2.52 1 2 1 3
	    #$ns at 18.0 "$flowmon dump"
	    $ns at 18.0 "finish"
	}
	default {
	    puts "Unknown test number $num"
	    usage $prog
	}
    }
    $test_scen create_tcp 0 4 1.5
    $ns run
}

global argv prog mflag
set mflag 0
if [string match {*.tcl} $argv0] {
    set prog [string range $argv0 0 [expr [string length $argv0] - 5]]
} else {
    set prog $argv0
}

if {[llength $argv] < 1} {
    puts "Insufficient number of arguments"
    usage $prog
}

global opts t
process_args $argv
set t $prog.$opts(test)
test $opts(test)