官方淘宝店 易迪拓培训 旧站入口
首页 > 无线通信 > 通信技术学习讨论 > NS2.27,编写wireless通信例子一问

NS2.27,编写wireless通信例子一问

12-10
$ns node-config -addressType flat
会报错,是不是最新版本不能设置addressType?还是我的错误?
改成def也不能通过
设置propType是Propagation/TwoRayGrouund
运行的时候满屏在飙
mobile/tworayground.cc: TwoRayGround propagation model assume flat ground
请问为什么啊?

     41 set topo       [new Topography]
     42
     43 $topo load_flatgrid $val(x) $val(y)

代码如下,你说的那一段我有写
改成def,这次编译通过了
不过还是有
mobile/tworayground.cc: TwoRayGround propagation model assume flat ground
的问题
一屏一屏的
set val(chan)           Channel/WirelessChannel
set val(prop)           Propagation/TwoRayGround
set val(netif)  Phy/WirelessPhy
set val(mac)            Mac/802_11
set val(rp)                     AODV
set val(ifq)            Queue/DropTail/PriQueue
set val(ifqlen) 50
set val(ll)                     LL
set val(ant)            Antenna/OmniAntenna
set val(nn)                     2
set val(x)                      500
set val(y)                      500
set ns [new Simulator]
set tracefd [open Supperfox.tr w]
$ns trace-all $tracefd
set namtracefd [open Supperfox.nam w]
$ns namtrace-all-wireless $namtracefd $val(x) $val(y)
proc finish {} {
        global ns tracefd namtracefd
        $ns flush-trace
        close $tracefd
        close $namtracefd
#       exec nam Supperfox.nam &
        exit 0
}
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
set channel_(0) [new $val(chan)]
$ns node-config -addressType def \
        -channel                        $channel_(0) \
        -propType                       $val(prop) \
        -phyType                        $val(netif) \
        -macType                        $val(mac) \
        -adhocRouting   $val(rp) \
        -ifqType                        $val(ifq) \
        -ifqLen                         $val(ifqlen) \
        -llType                         $val(ll) \
        -antType                        $val(ant) \
        -topoInstance   $topo \
        -agentTrace             ON \
        -routerTrace    ON \
        -macTrace                       OFF \
        -movementTrace  OFF \
for {set i 0} {$i<$val(nn)} {incr i} {
        set node_($i) [$ns node]
        $node_($i) random-motion 0;
}
$node_(0) set X_ 5.0
$node_(0) set Y_ 2.0
$node_(0) set Z_ 2.0
$node_(1) set X_ 390.0
$node_(1) set Y_ 385.0
$node_(1) set Z_ 0.0
$ns at 50.0             "$node_(1) setdest 25.0 20.0 15.0"
$ns at 10.0             "$node_(0) setdest 20.0 18.0 1.0"
$ns at 100.0    "$node_(1) setdest 490.0 480.0 15.0"
set tcp [new Agent/TCP]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $node_(0) $tcp
$ns attach-agent $node_(1) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 10.0 "$ftp start"
for {set i 0} {$i<$val(nn)} {incr i} {
        $ns at 150.0 "$node_($i) reset";
}
$ns at 150.0 "finish"
$ns run

Top