setdest 和cbrgen工具的使用,出现的错误

在路径 ~/ns-2.34/indep-utils/cmu-scen-gen/setdest下运行

./setdest -n 250 -p 0.0 -M 10.0 -t 10 -x 1500 -y 1500 > S250

在路径~/ns-2.34/indep-utils/cmu-scen-gen下运行
ns cbrgen.tcl -type tcp -nn 250  -seed 1.0 -mc 100 > T250
会得到s250和T250两个文件,把这两个文件拷到下面tcl文件的通路径下,运行tcl文件
# ======================================================================
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)            Queue/DropTail/PriQueue    ;# 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(nn)             250                        ;# number of mobilenodes
set val(rp)             AODV                       ;# routing protocol
set val(cp)             T250        
set val(sc)             S250                

# ==================================================== =================
# Main Program
# ======================================================================

set ns_    [new Simulator]
set tracefd     [open out.tr w]
set winfile  [open winFile w]
#global ns_

$ns_ trace-all $tracefd
set namtrace    [open out.nam w]
$ns_ namtrace-all-wireless $namtrace 1500 1500

set topo    [new Topography]
$topo load_flatgrid 1500 1500
set god_ [create-god $val(nn)]
#create-god $val(nn)

$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) 
                 -channelType $val(chan) 
         -topoInstance $topo 
         -agentTrace ON 
                 -routerTrace ON 
                 -macTrace OFF 
          -mvementTrace ON 

for {set i 0} {$i < $val(nn) } {incr i} {
    set node_($i) [$ns_ node]
}
puts "Loading scenario file..."
source $val(sc)

puts "Loading connection pattern..."
source $val(cp)

# Tell nodes when the simulation ends

for {set i 0} {$i < $val(nn) } {incr i} {
    $ns_ at 10.0 "$node_($i) reset";
}

$ns_ at 10.0 "stop"
$ns_ at 10.01 "puts "NS EXITING..." ; $ns_ halt"
proc stop {} {

    global ns_ tracefd
    $ns_ flush-trace
    close $tracefd
        exec nam out.nam &
        exit 0
}

puts "Starting Simulation..."
$ns_ run

注意两点: setdest产生的文件用到了node_数组变量和god_变量 ,这里要在提出了文件中给出:

  1. set ns_    [new Simulator]
  2. set god_ [create-god $val(nn)]      ;#这里把create-god $val(nn)换成了左边这样,为了防止出现

    can't read "god_": no such variable
    while executing
    "$god_ set-dist 0 1 8"
    (file "S250" line 1004)

...这样的错误

哈哈哈哈好开心,自己解决的~~~~

原文地址:https://www.cnblogs.com/wang-130213/p/8603688.html