Debian Codegraph @

tcl/scenario-generation/scen-lib/rmcc-4.tcl

raw
1 # Multiple RM flows scenario competing with multiple TCP scenario
2 #
3 # RM sender 1
4 # topology: . o o RM recv 1
5 # . \ 0 1 /
6 # RM send N o---o-----------o--o RM recv N
7 # /| B/N link |\
8 # / | | \
9 # o o o o TCP recv 1
10 # TCP sender 1
11 # ... TCP receiver N
12 # TCP sender N
13 #
14 # start N number of rm flows and TCP flows randomly
15 # after steady state is attained measure thruput ans compare
16 #
17 # usage: ns rmcc-4.tcl
18
19 source rmcc.tcl
20
21 proc get_rand_time {first last number} {
22 set times ""
23 set interval [expr $last - $first]
24 set maxrval [expr pow(2,31)]
25 set intrval [expr $interval/$maxrval]
26
27 for { set i 0 } { $i < $number } { incr i } {
28 set randtime [expr ([ns-random] * $intrval) + $first]
29 # XXX include only 6 decimals (i.e. usec)
30 lappend times [format "%.1f" $randtime]
31 }
32 return $times
33 }
34
35
36 ScenLib/RM instproc random_start_rm {start stop} {
37 global ns n num
38 #create mcast trees
39 set i [expr $num*2]
40 set t [expr $num * 3]
41 while {$i < $t} {
42 lappend R $i
43 incr i
44 }
45 for {set i 0} {$i < $num} {incr i} {
46 set time [get_rand_time $start $stop 1]
47 set st [expr $time - 1]
48 if {$st < 0} { set st 0}
49 set sw [expr $st - 0.7]
50 if {$sw < 0} { set sw 0}
51 #puts "time = $time"
52 eval $self create_mcast $i $sw $st $time $R
53 #puts "mcast $i to $R"
54 }
55 }
56
57 ScenLib/RM instproc random_start_tcp {start stop} {
58 global ns n num
59 set start [expr $num*2]
60 set end [expr $num*4]
61 set i $num
62 set j [expr $num*3]
63 while {$i < $start || $j < $end} {
64 set time [get_rand_time $start $stop 1]
65 $self create_tcp $i $j $time
66 #puts "$self create_tcp $i $j $time"
67 incr i
68 incr j
69 }
70 }
71
72
73 ScenLib/RM instproc make_topo3 {} {
74 global ns tcp_model num n opts
75 #make the bottleneck link
76 set n(l) [$ns node]
77 set n(r) [$ns node]
78 set num $opts(clientNum) ;#N actual number flows setup
79 $ns duplex-link $n(l) $n(r) [expr $num * 0.5]Mbps \
80 $opts(bottleneckDelay) DropTail
81 $ns queue-limit $n(l) $n(r) [expr $num * 10]
82
83 #make N number of TCP connections
84 #set seed 12345
85 #set params "-print-drop-rate 1 -debug 0 -trace-filename out"
86 #set p1 "-bottle-queue-length $opts(bottleneckQSize) \
87 #-bottle-queue-method DropTail"
88 #set p2 "-client-arrival-rate 120 \
89 # -bottle-bw $opts(bottleneckBW) \
90 #-bottle-delay $opts(bottleneckDelay) \
91 #-ns-random-seed $seed"
92 #set p2a "-source-tcp-method TCP/Reno -sink-ack-method \
93 # TCPSink/DelAck"
94 #set p3 "-client-mouse-chance 90 -client-mouse-packets 10"
95 #set p4 "-client-bw 100Mb -node-number $num -client-reverse-chance 10"
96 #set p5 "-initial-client-count 0"
97 #set p6 "-duration 10 graph-results 1 graph-join-queueing 0 -graph-scale 2"
98 #set tcp_model [eval new TrafficGen/ManyTCP $params $p1 $p2 \
99 # $p2a $p3 $p4 $p5 $p6]
100
101
102 #now create client nodes on left of bottleneck
103 for {set i 0} {$i < [expr $num*2]} {incr i} {
104 set n($i) [$ns node]
105 $ns duplex-link $n($i) $n(l) 10Mb 5ms DropTail
106 }
107
108 # do same for right of B/N link
109 for {set i [expr $num*2]} {$i < [expr $num * 4]} {incr i} {
110 set n($i) [$ns node]
111 $ns duplex-link $n(r) $n($i) [expr $num * 5]Mb \
112 5ms DropTail
113 }
114
115 }
116
117 ScenLib/RM instproc add_flowmon { time } {
118 global num n t
119 #make sure the flow monitors are dumped at the right time
120 $self make_flowmon $time $n(r) $n([expr $num*2]) flowStats_1_$num.$t \
121 $n(r) $n([expr $num * 3]) \
122 flowStats_1_[expr $num + 1].$t \
123
124 }
125
126
127
128
129 proc run {} {
130 global ns n num
131 set test_scen [new ScenLib/RM]
132 $test_scen make_topo3
133 #random start tcp and rm connections between 0 and 10s.
134 $test_scen random_start_tcp 0.0 10.0
135 $test_scen random_start_rm 0.0 10.0
136 $test_scen add_flowmon 30.0
137 $test_scen dump_flowmon $n(r) $n([expr $num*2]) 60.0 ;# rm flow
138 $test_scen dump_flowmon $n(r) $n([expr $num*3]) 60.0 ;#tcp flow
139 $ns at 60.0 "finish"
140 $ns run
141 }
142
143 global argv prog opts t mflag
144 set mflag 0
145 if [string match {*.tcl} $argv0] {
146 set prog [string range $argv0 0 [expr [string length $argv0] - 5]]
147 } else {
148 set prog $argv0
149 }
150
151 process_args $argv
152 set t $prog
153 run
154
155