節錄使用 Hierarchical Addressing 片段
參考
ns-2/tcl/test/test-suite-WLtutorial.tcl
ns-2/tcl/test/test-suite-wireless-lan-aodv.tcl
ns-2/tcl/test/test-suite-wireless-lan-tora.tcl
case 1
[code]
$ns node-config -wiredRouting OFF
$ns node-config -addressType hierarchical
AddrParams set domain_num_ 2
lappend cluster_num 1 2
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel 1 2 2
AddrParams set nodes_num_ $eilastlevel
set n0 [$ns node 0.0.0]
$n0 random-motion 0
$n0 set X_ 301
$n0 set Y_ 399
$n0 set Z_ 0.0
$ns initial_node_pos $n0 20
set n1 [$ns node 1.0.0]
$n1 random-motion 0
$n1 base-station [AddrParams addr2id [$n0 node-addr]]
$n1 set X_ 480
$n1 set Y_ 544
$n1 set Z_ 0.0
$ns initial_node_pos $n1 20
[/code]
case 2
[code]
puts "Hierarchical Routing..."
set naddr {0.0.0 \
0.0.1 \
0.0.2 \
0.0.3 \
0.0.4 \
0.0.5 \
0.0.6 \
0.0.7 \
0.0.8 \
0.0.9 \
0.0.10 \
0.0.11 \
0.0.12 \
0.0.13 \
0.0.14 \
0.0.15 \
0.0.16 \
0.0.17 \
0.0.18 \
0.0.19}
# Create 20 nodes
for {set i 0} {$i < $opt(nn)} {incr i} {
set node($i) [$ns node [lindex $naddr $i]]
$node($i) random-motion 0
$node($i) base-station [AddrParams addr2id [$node(0) node-addr]]
}
[/code]
No comments:
Post a Comment