This repository has been archived by the owner on Jan 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwireless-myflooding.tcl~
94 lines (74 loc) · 2.47 KB
/
wireless-myflooding.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
#myflooding_wireless.tcl
#This file configures all network parameters and network topology
#Ted 05/13/2014
set val(chan) Channel/WirelessChannel ;#Channel Type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_11 ;# MAC type
set val(ifq) CMUPriQueue ;# interface queue type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(rp) DumbAgent ;# routing protocol
set val(nn) 3
set val(x) 200
set val(y) 200
puts "hello world111~~~~"
set ns [new Simulator]
set tracefd [open wireless-myflooding.tr w]
$ns trace-all $tracefd
set namtrace [open wireless-myflooding.nam w]
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
#$ns use-newtrace
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
set chan_1_ [new $val(chan)]
$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) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace OFF \
-channel $chan_1_
puts "hello world2222~~~~"
# create nodes
for {set i 0} {$i < $val(nn)} {incr i} {
set n($i) [$ns node]
$n($i) set Y_ [expr 100*$i + 100]
$n($i) set X_ [expr 100*$i + 200]
$n($i) set Z_ 0.0
}
######################################################
# attach a new Agent/MYFLOODING
puts "hello world3333"
for {set i 0} {$i < $val(nn)} {incr i} {
set a($i) [new Agent/MYFLOODING]
$n($i) attach $a($i)
}
puts "hello world444444444444"
# #set nodes information
for {set i 0} {$i < $val(nn)} {incr i} {
$a($i) set-addr $i
}
puts "hello world55555555555555"
# set up some events
#send_packet
$ns at 0.2 "$a(0) send_my_message"
$ns at 1.0 "finish"
proc finish {} {
global ns tracefd namtrace
$ns flush-trace
close $tracefd
close $namtrace
exec nam wireless-myflooding.nam &
exit 0
}
$ns run