Tcl“无法读取”ifqlen_2;:没有这样的变量”

Tcl“无法读取”ifqlen_2;:没有这样的变量”,tcl,ns2,Tcl,Ns2,我找不到解决这个问题的方法,当我改变时 for {set i 0} {$i < $opt(row)} {incr i} { for {set j 0} {$j < $opt(col)} {incr j} { 到 我发现另一个问题是无法读取节点0:没有这样的变量 set opt(netif) Phy/WirlessPhy ;#network interface type set opt(chan) Channel/WirelessChannel ;#channel type se

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

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

我发现另一个问题是无法读取节点0:没有这样的变量

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
帮助

无法读取节点\u 0:没有此类变量

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
未定义节点:节点配置文件中缺少行

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

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行中的输入错误引起:物理层/无线层→ 必须是物理层/无线层

当~100个打字错误被修复后,您的文件工作到创建文件TP2.nam 9.2kB、TP2.tr 5.2kB为止。非常小的文件大小可能是由以下错误引起的:--Classfier::无插槽{}默认处理程序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动画

编辑的文件:不完美。。。。但是要做的事情。。。 .diff文件:原始与已编辑


请参阅编辑后的答案:更好的节点位置。模拟工作正常,但不存在NAM如果您的意思是没有NAM跟踪文件,则TP2.NAM:。。。。。获取仿真文件.tcl和文件TP2.nam、TP2.tr的工作副本→