Tcl"无法读取" ifqlen _":没有这样的变量"

时间:2017-11-09 21:15:02

标签: tcl ns2

我找不到解决这个问题的方法,当我改变时

for {set i 0} {$i < $opt(row)} {incr i} {
for {set j 0} {$j < $opt(col)} {incr j} {  

for {set i 1} {$i < $opt(row)} {incr i} {
for {set j 1} {$j < $opt(col)} {incr j} {

我发现另一个问题是&#34;无法读取&#34; node_(0)&#34;:没有这样的变量

set opt(netif) Phy/WirlessPhy ;#network interface type
set opt(chan) Channel/WirelessChannel ;#channel type
set opt(prop) Propagation/TwoRayGround ;#radio-propagation model
set opt(ant) Antenna/OmniAntenna ;#antenna model 
set opt(mac) Mac/802_11 ;#mac type
set opt(ifq) Queue/DropTail/PriQueue ;#interface queue type
set opt(ll) LL ;#link layer type
set opt(ifqlen) 10 ;#max packet
set opt(nn) 2 ;#nombre de noeud
set opt(rp) DSDV ;#protocol
set opt(MaxX) 500 ;#longueur
set opt(MaxY) 500 ;#longuer 
set opt(row) 2;
set opt(col) 1;        
######################
set ns_  [new Simulator] 
#####################
set nf   [open TP2.nam w]
$ns_ namtrace-all $nf
$ns_ namtrace-all-wireless $nf $opt(MaxX) $opt(MaxY)
############################
set tracefile [open TP2.tr w]
$ns_ trace-all $tracefile
##########################
set topo [new Topography]
$topo load_flatgrid $opt(MaxX) $opt(MaxY)
########################
set god [create-god $opt(nn)]
##################
$ns_ color 1 Green
$ns_ color 2 Red
########################
$ns_ node-config   -adhocRouting $opt(rp) \
                   -llType $opt(ll) \
                   -macType $opt(mac) \
                   -ifqType $opt(ifq) \
                   -ifqlen $opt(ifqlen)\
                   -antType $opt(ant) \
                   -propType $opt(prop) \
                   -phyType $opt(netif) \
                   -channelType $opt(chan) \
                   -topoInstance $topo \
                   -agentTrace ON \
                   -routerTrace ON \
                   -macTrace ON\
                   -movementTrace ON 
##################
 for {set i 0} {$i < $opt(row)} {incr i} {
 for {set j 0} {$j < $opt(col)} {incr j} {

                     set nodenum [expr ($i*$opt(col))+($j)]
                     set nodenum_($nodenum) [$ns_ node $nodenum]

                     set xpos[expr ($i+1)*$opt(dist)]
                     set ypos[expr ($j+1)*$opt(dist)]

                     $node_($nodenum) set X_$xpos
                     $node_($nodenum) set Y_$ypos

                     $node_($nodenum) random-motion 0
                     $ns_ initial_node_pos $node_($nodenum) 20 }}    
###################################
$node_(0) Color Red
$node_(0) shape circle
$node_([expr $opt(nn)-1]) color Green
$ns_ at 0.0"$node_(0) color red"
$ns_ at 0.0"$node_(0) label Emetteur"
$ns_ at 0.0"$node_([expr$opt(nn)-1]) color blue"
$ns_ at 0.0"$node_([expr$opt(nn)-1]) label Recepteur"
################################
set tcp [new Agent/TCP]
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 0.01 "$ftp start"
############################
proc finish{}{
  global ns_tracefile
  $ns_ flush-trace 
  close $tracefile
  puts "simulation terminée"
  exit 0
}
for {set i 0} {$i < $opt(nn)}{incr i}{
   $ns_at$opt(stop) "\$node_($i) reset"
}
$ns_ at $opt(stop) "finish"
$ns_ at $opt(stop) "put\"done\";$ns_halt"
$ns_ run

帮助

1 个答案:

答案 0 :(得分:1)

  

&#34;无法读取&#34; node_(0)&#34;:没有这样的变量

没有定义节点:文件中缺少用于节点配置的行。

  

&#34;无法阅读&#34; ifqlen _&#34;:没有这样的变量&#34;

由第1行的拼写错误引起:Phy / WirlessPhy→必须是Phy / Wir e lessPhy

当修复~100拼写错误时,你的文件到目前为止工作,创建文件TP2.nam 9.2kB,TP2.tr 5.2kB。文件大小非常小可能是由此错误引起的:--- Classfier::no-slot{} default handler (tcl/lib/ns-lib.tcl) ---

编辑:得到了结果,没有错误:其他节点位置→跟踪文件现在是24MB / 13MB。

$node_(0) set X_ 299
$node_(0) set Y_ 248
$node_(1) set X_ 297
$node_(1) set Y_ 496

$ nam TP2.nam:一个OK动画。

编辑过的文件:不完美....但是要处理的事情...... (file.diff:Original vs edited https://www.dropbox.com/s/98wxqbgttyj8arv/Priority-Queue.tar.gz?dl=0

set opt(netif) Phy/WirelessPhy          ;#network interface type
set opt(chan) Channel/WirelessChannel   ;#channel type
set opt(prop) Propagation/TwoRayGround  ;#radio-propagation model
set opt(ant) Antenna/OmniAntenna        ;#antenna model 
set opt(mac) Mac/802_11                 ;#mac type
set opt(ifq) Queue/DropTail/PriQueue    ;#interface queue type
set opt(ll) LL              ;#link layer type
set opt(ifqlen) 10          ;#max packet
set opt(dist)   250
set opt(nn) 2               ;#nombre de noeud
set opt(rp) DSDV            ;#protocol
set opt(MaxX) 500           ;#longueur
set opt(MaxY) 500           ;#longuer 
set opt(row) 2;
set opt(flow)       3
set opt(col) 1;
set opt(stop) 100        
######################
set ns_  [new Simulator] 
#####################
set nf   [open TP2.nam w]
$ns_ namtrace-all $nf
$ns_ namtrace-all-wireless $nf $opt(MaxX) $opt(MaxY)
############################
set tracefile [open TP2.tr w]
$ns_ trace-all $tracefile
##########################
set topo [new Topography]
$topo load_flatgrid $opt(MaxX) $opt(MaxY)
########################
set god [create-god $opt(nn)]
##################
$ns_ color 1 Green
$ns_ color 2 Red
########################
set ifqlen_ 10

$ns_ node-config   -adhocRouting $opt(rp) \
                   -llType $opt(ll) \
                   -macType $opt(mac) \
                   -ifqType $opt(ifq) \
                   -ifqLen $opt(ifqlen) \
                   -antType $opt(ant) \
                   -propType $opt(prop) \
                   -phyType $opt(netif) \
                   -channelType $opt(chan) \
                   -topoInstance $topo \
                   -agentTrace ON \
                   -routerTrace ON \
                   -macTrace ON \
                   -movementTrace ON

set node_(0) [$ns_ node]
set node_(1) [$ns_ node]


##################
 for {set i 0} {$i < $opt(row)} {incr i} {
 for {set j 0} {$j < $opt(col)} {incr j} {

                     set nodenum [expr ($i*$opt(col))+($j)]
                     set nodenum_($nodenum) [$ns_ node $nodenum]

#                     set xpos[expr ($i+1)*$opt(dist)]
#                     set ypos[expr ($j+1)*$opt(dist)]

#                     $node_($nodenum) set X_$xpos
#                     $node_($nodenum) set Y_$ypos

$node_(0) set X_ 299
$node_(0) set Y_ 248
$node_(1) set X_ 297
$node_(1) set Y_ 496

                     $node_($nodenum) random-motion 0
                     $ns_ initial_node_pos $node_($nodenum) 20 }}    
###################################
$node_(0) color red
$node_(0) shape circle
$node_([expr $opt(nn)-1]) color green
$ns_ at 0.0 "$node_(0) color red"
$ns_ at 0.0 "$node_(0) label Emetteur"
$ns_ at 0.0 "$node_(1) color blue"
$ns_ at 0.0 "$node_(1) label Recepteur"
################################
set tcp [new Agent/TCP]
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 0.01 "$ftp start"
############################
proc finish {} {
  global ns_tracefile
  $ns_ flush-trace 
  close $tracefile
  puts "simulation terminée"
  exit 0
}
for {set i 0} {$i < $opt(nn)} {incr i} {
   $ns_ at $opt(stop) "\$node_($i) reset"
}
$ns_ at $opt(stop) "finish"
$ns_ at $opt(stop) "put\"done\";$ns_ halt"
$ns_ run
相关问题