-
Notifications
You must be signed in to change notification settings - Fork 0
/
phr_scenario.tcl
461 lines (383 loc) · 12.2 KB
/
phr_scenario.tcl
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
# This is a simple scenario to show how PHR work as a routing layer
# This topology is configured as 802.11p VANET environment.
# This code is writen by Awos Kh. Ali (a.k.ali@uomosul.edu.iq)
Phy/WirelessPhyExt set CPThresh_ 0.0
Phy/WirelessPhyExt set CSThresh_ 3.162e-12 ;#-85 dBm Wireless interface sensitivity (sensitivity defined in the standard)
Phy/WirelessPhyExt set Pt_ 0.002 ;# 0.28183815 ;#0.001
Phy/WirelessPhyExt set freq_ 5.9e+9
Phy/WirelessPhyExt set noise_floor_ 1.26e-13 ;#-99 dBm for 10MHz bandwidth
Phy/WirelessPhyExt set L_ 1.0 ;#default radio circuit gain/loss
Phy/WirelessPhyExt set PowerMonitorThresh_ 6.310e-14 ;#-102dBm power monitor sensitivity
Phy/WirelessPhyExt set HeaderDuration_ 0.000040 ;#40 us
Phy/WirelessPhyExt set BasicModulationScheme_ 0
Phy/WirelessPhyExt set PreambleCaptureSwitch_ 1
Phy/WirelessPhyExt set DataCaptureSwitch_ 0
Phy/WirelessPhyExt set SINR_PreambleCapture_ 2.5118; ;# 4 dB
Phy/WirelessPhyExt set SINR_DataCapture_ 100.0; ;# 10 dB
Phy/WirelessPhyExt set trace_dist_ 1e6 ;# PHY trace until distance of 1 Mio. km ("infinty")
Phy/WirelessPhyExt set bandwidth_ 100e6
Phy/WirelessPhyExt set PHY_DBG_ 0
Mac/802_11Ext set CWMin_ 15
Mac/802_11Ext set CWMax_ 1023
Mac/802_11Ext set SlotTime_ 0.000013
Mac/802_11Ext set SIFS_ 0.000032
Mac/802_11Ext set ShortRetryLimit_ 7
Mac/802_11Ext set LongRetryLimit_ 4
Mac/802_11Ext set HeaderDuration_ 0.000040
Mac/802_11Ext set SymbolDuration_ 0.000008
Mac/802_11Ext set BasicModulationScheme_ 0
Mac/802_11Ext set use_802_11a_flag_ true
Mac/802_11Ext set RTSThreshold_ 2346
Mac/802_11Ext set MAC_DBG 0
# Nakagami parameters for urban scenario
#Propagation/Nakagami set gamma0_ 2.0
#Propagation/Nakagami set gamma1_ 2.0
#Propagation/Nakagami set gamma2_ 2.0
# Generated by Topology Generator for Network Simulator (c) Elmurod Talipov
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/Nakagami ;# radio-propagation model
set val(netif) Phy/WirelessPhyExt ;# network interface type
set val(mac) Mac/802_11Ext ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 100 ;# max packet in ifq
set val(nn) 100 ;#169 for grid ;# number of mobilenodes
set val(rp) PHR ;# protocol type
set val(x) 3000 ;# X dimension of topography
set val(y) 3000 ;# Y dimension of topography
set val(stop) 300.1 ;# simulation period
set val(sc) "random.tcl";#"grid.tcl" ; # Czone model
set val(cp) "CONNECTIONS/50.tcl" ; #
set ns_ [new Simulator]
set tracefd [open phr_grid_mobile.tr w]
set namtrace [open phr_grid_mobile.nam w]
$ns_ use-newtrace
$ns_ trace-all $tracefd
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
# configure the nodes
$ns_ node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channel [new $val(chan)] \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-phyTrace OFF \
-movementTrace OFF \
#-IncomingErrProc MultistateErrorProc \
#######For brobabilistic forwarding###########
Agent/PHR set known_prob_ 0.99
Agent/PHR set unknown_prob_ 0.5
#######################################
#-OutgoingErrProc MultistateErrorProc
for {set i 0} {$i < $val(nn) } { incr i } {
set node_($i) [$ns_ node]
}
set X 0
set Y 0
set YY 250
set I 250
set j 0
set k 0
# build grid network by locating nodes' positions
for {set i 0} {$i < 10 } { incr i } {
#set j [expr 1000/13.2]
#set Y [expr {$Y+ $j}]
$node_($i) set X_ $X
$node_($i) set Y_ $Y
$node_($i) set Z_ 0.0
#set I 250
set X [expr {$X+ $I}]
}
set X 0
set Y [expr {$Y+$YY}]
for {set i 10} {$i < 20 } { incr i } {
$node_($i) set X_ $X
$node_($i) set Y_ $Y
$node_($i) set Z_ 0.0
#set I 250
set X [expr {$X+ $I}]
}
set X 0
set Y [expr {$Y+$YY}]
for {set i 20} {$i < 30 } { incr i } {
$node_($i) set X_ $X
$node_($i) set Y_ $Y
$node_($i) set Z_ 0.0
#set I 250
set X [expr {$X+ $I}]
}
set X 0
set Y [expr {$Y+$YY}]
for {set i 30} {$i < 40 } { incr i } {
$node_($i) set X_ $X
$node_($i) set Y_ $Y
$node_($i) set Z_ 0.0
set X [expr {$X+ $I}]
}
set X 0
set Y [expr {$Y+$YY}]
for {set i 40} {$i < 50 } { incr i } {
$node_($i) set X_ $X
$node_($i) set Y_ $Y
$node_($i) set Z_ 0.0
set X [expr {$X+ $I}]
}
set X 0
set Y [expr {$Y+$YY}]
for {set i 50} {$i < 60 } { incr i } {
$node_($i) set X_ $X
$node_($i) set Y_ $Y
$node_($i) set Z_ 0.0
set X [expr {$X+ $I}]
}
set X 0
set Y [expr {$Y+$YY}]
for {set i 60} {$i < 70 } { incr i } {
$node_($i) set X_ $X
$node_($i) set Y_ $Y
$node_($i) set Z_ 0.0
set X [expr {$X+ $I}]
}
set X 0
set Y [expr {$Y+$YY}]
for {set i 70} {$i < 80 } { incr i } {
$node_($i) set X_ $X
$node_($i) set Y_ $Y
$node_($i) set Z_ 0.0
set X [expr {$X+ $I}]
}
set X 0
set Y [expr {$Y+$YY}]
for {set i 80} {$i < 90 } { incr i } {
$node_($i) set X_ $X
$node_($i) set Y_ $Y
$node_($i) set Z_ 0.0
set X [expr {$X+ $I}]
}
set X 0
set Y [expr {$Y+$YY}]
for {set i 90} {$i < 100 } { incr i } {
$node_($i) set X_ $X
$node_($i) set Y_ $Y
$node_($i) set Z_ 0.0
set X [expr {$X+ $I}]
}
#source $val(sc)
puts "Loading scenario file..."
#source $val(cp)
#set dest $mnode_(2)
#$ns at 1.1 "[$mnode_(1) set ragent_ ] broadcast 2"
#$ns at 3.0 "[$mnode_(1) set ragent_] stop-broadcast"
#$ns at 3.5 "[$mnode_(1) set ragent_ ] broadcast 0"
#$ns at 5.0 "[$mnode_(1) set ragent_] stop-broadcast"
for {set i 0} {$i < $val(nn)} { incr i } {
$ns_ initial_node_pos $node_($i) 50
}
$node_(4) color red
$ns_ at 0.0 "$node_(4) color red"
#$node_(4) label S
#$node_($i) shape box
#$ns_ at 0.0 "$node_($i) shape box"
$ns_ at 0.0 "$node_(4) add-mark MARK red hexagon"
$node_(89) color red
$ns_ at 0.0 "$node_(89) color red"
#$node_(89) label D
#$node_($i) shape box
#$ns_ at 0.0 "$node_($i) shape box"
$ns_ at 0.0 "$node_(89) add-mark MARK red hexagon"
################set up TCP connection######
set tcp1 [new Agent/TCP/Newreno]
$ns_ attach-agent $node_(4) $tcp1
set sink1 [new Agent/TCPSink/DelAck]
$ns_ attach-agent $node_(89) $sink1
$ns_ connect $tcp1 $sink1
$tcp1 set fid_ 1
$tcp1 set window_ 8000
$tcp1 set packetSize_ 100
#TCP N0 and N4
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
$ftp1 set type_ FTP
set tcp2 [new Agent/TCP/Newreno]
$ns_ attach-agent $node_(89) $tcp2
set sink2 [new Agent/TCPSink/DelAck]
$ns_ attach-agent $node_(4) $sink2
$ns_ connect $tcp2 $sink2
$tcp2 set fid_ 2
$tcp2 set window_ 8000
$tcp2 set packetSize_ 100
#TCP N0 and N4
set ftp2 [new Application/FTP]
$ftp2 attach-agent $tcp2
$ftp2 set type_ FTP
#$ns_ at 0.1 "$ftp1 start"
#$ns_ at 1.0 "$ftp2 start"
#$ns_ at 200.0 "$ftp1 stop"
#$ns_ at 201.0 "$ftp2 stop"
##########################################
#$mnode_(81) label "Dest_1"
#Setup a UDP connection
set udp [new Agent/UDP]
$ns_ attach-agent $node_(4) $udp
set udp1 [new Agent/UDP]
$ns_ attach-agent $node_(89) $udp1
set sink [new Agent/Null]
$ns_ attach-agent $node_(89) $sink
set sink1 [new Agent/Null]
$ns_ attach-agent $node_(4) $sink1
$ns_ connect $udp $sink
$ns_ connect $udp1 $sink1
$udp set fid_ 1
$udp1 set fid_ 2
set udp2 [new Agent/UDP]
$ns_ attach-agent $node_(3) $udp2
set udp3 [new Agent/UDP]
$ns_ attach-agent $node_(27) $udp3
set sink2 [new Agent/Null]
$ns_ attach-agent $node_(27) $sink2
set sink3 [new Agent/Null]
$ns_ attach-agent $node_(3) $sink3
$ns_ connect $udp2 $sink2
$ns_ connect $udp3 $sink3
#Setup a CBR over UDP connection
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
#$udp set dst_addr_ -1
#$udp set dst_port_ 10
$cbr set type_ CBR
$cbr set packet_size_ 100
$cbr set maxpkts_ 10
#$cbr set rate_ 0.1Mb
$cbr set interval_ 0.5
#$udp set dst_addr_ -1
#$udp set dst_port_ 0
#$cbr set random_ false
##########here
$ns_ at 0.2 "$cbr start"
$ns_ at 220.4 "$cbr stop" ;#[expr $val(stop) - 5] "$cbr stop"
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
#$udp set dst_addr_ -1
#$udp set dst_port_ 10
$cbr1 set type_ CBR
$cbr1 set packet_size_ 100
$cbr1 set maxpkts_ 50
#$cbr1 set rate_ 0.1Mb
$cbr1 set interval_ 0.5
$cbr1 set random_ false
#$ns at 20.0 "$mnode_(0) setdest 100.00 100.00 10.00"
$ns_ at 0.4 "$cbr1 start"
$ns_ at 230.7 "$cbr1 stop"
###########################
########end of here
set cbr7 [new Application/Traffic/CBR]
$cbr7 attach-agent $udp
#$udp set dst_addr_ -1
#$udp set dst_port_ 10
$cbr7 set type_ CBR
$cbr7 set packet_size_ 100
$cbr7 set maxpkts_ 50
$cbr7 set rate_ 0.1Mb
$cbr7 set interval_ 0.1
#$ns_ at 4.2 "$cbr7 start"
#$ns_ at 4.4 "$cbr7 stop"
#######################
set cbr2 [new Application/Traffic/CBR]
$cbr2 attach-agent $udp2
#$udp set dst_addr_ -1
#$udp set dst_port_ 10
$cbr2 set type_ CBR
$cbr2 set packet_size_ 100
$cbr2 set maxpkts_ 1
$cbr2 set rate_ 0.1Mb
$cbr2 set interval_ 0.1
$cbr2 set random_ false
#$ns at 20.0 "$mnode_(0) setdest 100.00 100.00 5"
#$ns_ at 3.10 "$cbr2 start"
#$ns_ at 3.13 "$cbr2 stop"
###############################
set cbr3 [new Application/Traffic/CBR]
$cbr3 attach-agent $udp3
#$udp set dst_addr_ -1
#$udp set dst_port_ 10
$cbr3 set type_ CBR
$cbr3 set packet_size_ 100
$cbr3 set maxpkts_ 1
$cbr3 set rate_ 0.1Mb
$cbr3 set interval_ 0.1
$cbr3 set random_ false
#$ns at 20.0 "$mnode_(0) setdest 100.00 100.00 5"
#$ns_ at 5.6 "$cbr3 start"
#$ns_ at 5.8 "$cbr3 stop"
set cbr4 [new Application/Traffic/CBR]
$cbr4 attach-agent $udp2
#$udp set dst_addr_ -1
#$udp set dst_port_ 10
$cbr4 set type_ CBR
$cbr4 set packet_size_ 100
$cbr4 set maxpkts_ 1
$cbr4 set rate_ 0.1Mb
$cbr4 set interval_ 0.1
$cbr4 set random_ false
#$ns at 20.0 "$mnode_(0) setdest 100.00 100.00 5"
#$ns_ at 10.10 "$cbr4 start"
#$ns_ at 10.13 "$cbr4 stop"
###############################
set cbr5 [new Application/Traffic/CBR]
$cbr5 attach-agent $udp3
#$udp set dst_addr_ -1
#$udp set dst_port_ 10
$cbr5 set type_ CBR
$cbr5 set packet_size_ 100
$cbr5 set maxpkts_ 1
$cbr5 set rate_ 0.1Mb
$cbr5 set interval_ 0.1
$cbr5 set random_ false
#$ns at 20.0 "$mnode_(0) setdest 100.00 100.00 5"
#$ns_ at 12.6 "$cbr5 start"
#$ns_ at 12.8 "$cbr5 stop"
#####################################
set cbr6 [new Application/Traffic/CBR]
$cbr6 attach-agent $udp2
#$udp set dst_addr_ -1
#$udp set dst_port_ 10
$cbr6 set type_ CBR
$cbr6 set packet_size_ 100
$cbr6 set maxpkts_ 1
$cbr6 set rate_ 0.1Mb
$cbr6 set interval_ 0.1
$cbr6 set random_ false
#$ns at 20.0 "$mnode_(0) setdest 100.00 100.00 5"
#$ns_ at 15.6 "$cbr6 start"
#$ns_ at 15.8 "$cbr6 stop"
######################################
#source "$val(cp)"
#source "$val(sc)"
$ns_ at 0.123 "$node_(89) setdest 1.1000 2099.00 15.3735" ;#X.Y.SPEED
# Telling nodes when the simulation ends
for {set i 0} {$i < $val(nn) } { incr i } {
$ns_ at $val(stop) "$node_($i) reset;"
}
# ending nam and the simulation
$ns_ at $val(stop) "$ns_ nam-end-wireless $val(stop)"
$ns_ at $val(stop) "stop"
$ns_ at [expr $val(stop) + 0.01] "puts \"end simulation\"; $ns_ halt"
proc stop {} {
global ns_ tracefd namtrace
$ns_ flush-trace
close $tracefd
close $namtrace
}
$ns_ run