我正在尝试运行此TCL脚本,即DCCP实现,
set val(chan) Channel/WirelessChannel
set val(prop) Propagation/TwoRayGround
set val(netif) Phy/WirelessPhy
set val(mac) Mac/802_11
set val(ifq) Queue/DropTail/PriQueue
set val(ll) LL
set val(ant) Antenna/OmniAntenna
set val(ifqlen) 50
set val(nn) 3
set val(rp) AODV
set val(x) 500
set val(y) 500
set val(stop) 150
#-------Event scheduler object creation--------#
set ns [new Simulator]
#creating trace file and nam file
set tracefd [open dccp1.tr w]
#set windowVsTime2 [open cp1.tr w]
set namtrace [open dccp1.nam w]
$ns use-newtrace
$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
# configure the nodes
$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
-movementTrace ON
for {set i 0} {$i < $val(nn) } { incr i } {
set node_($i) [$ns node]
}
# Provide initial location of mobilenodes
$node_(0) set X_ 5.0
$node_(0) set Y_ 5.0
$node_(0) set Z_ 0.0
$node_(1) set X_ 490.0
$node_(1) set Y_ 285.0
$node_(1) set Z_ 0.0
$node_(2) set X_ 150.0
$node_(2) set Y_ 240.0
$node_(2) set Z_ 0.0
# Generation of movements
$ns at 10.0 "$node_(0) setdest 250.0 250.0 3.0"
$ns at 15.0 "$node_(1) setdest 45.0 285.0 5.0"
$ns at 19.0 "$node_(2) setdest 480.0 300.0 5.0"
# Set a DCCP connection between node_(0) and node_(1)
# DCCP agent
set dccp [new Agent/DCCP/TCPlike]
$dccp set class_ 2
set dccpsink [new Agent/DCCP/TCPlike]
$ns attach-agent $node_(0) $dccp
$ns attach-agent $node_(1) $dccpsink
$ns connect $dccp $dccpsink
#set cbr1 [new Application/Traffic/CBR]
#$cbr1 attach-agent $dccp
#$cbr1 set packetSize_ 1024
#$cbr1 set rate_ 1024Kb
#$cbr1 set random_ rng
#$ns at 10.0 "$cbr1 start"
set ftp [new Application/FTP]
$ftp attach-agent $dccp
$ftp set packetSize_ 1024Kb
$ftp set rate_ 1024Kb
$ns at 10.0 "$ftp start"
set dccp1 [new Agent/DCCP/TCPlike]
$dccp1 set class_ 2
set dccpsink1 [new Agent/DCCP/TCPlike]
$ns attach-agent $node_(1) $dccp1
$ns attach-agent $node_(2) $dccpsink1
$ns connect $dccp1 $dccpsink1
#set cbr1 [new Application/Traffic/CBR]
#$cbr1 attach-agent $dccp
#$cbr1 set packetSize_ 1024
#$cbr1 set rate_ 1024Kb
#$cbr1 set random_ rng
#$ns at 10.0 "$cbr1 start"
set ftp1 [new Application/FTP]
$ftp1 attach-agent $dccp1
$ftp1 set packetSize_ 1024Kb
$ftp1 set rate_ 1024Kb
$ns at 10.0 "$ftp1 start"
$ns at 0.0 "$dccpsink listen"
$ns at 0.0 "$dccpsink1 listen"
# Define node initial position in nam
for {set i 0} {$i < $val(nn)} { incr i } {
# 30 defines the node size for nam
$ns initial_node_pos $node_($i) 150
}
# Telling nodes when the simulation ends
for {set i 0} {$i < $val(nn) } { incr i } {
$ns at $val(stop) "$node_($i) reset";
}
# ending nam and the simulation
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "stop"
$ns at 150.01 "puts "end simulation" ; $ns halt"
proc stop {} {
global ns tracefd namtrace
$ns flush-trace
close $tracefd
close $namtrace
exec nam dccp1.nam &
}
$ns run
在运行此代码时,我的终端显示了一个中止的(核心倾倒)错误。确切的错误是
num_nodes is set 3
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
INITIALIZE THE LIST xListHead
*** buffer overflow detected ***: ns terminated
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f07f6c3f7e5]
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x5c)[0x7f07f6ce056c]
/lib/x86_64-linux-gnu/libc.so.6(+0x116570)[0x7f07f6cde570]
/lib/x86_64-linux-gnu/libc.so.6(+0x1158c2)[0x7f07f6cdd8c2]
ns(_ZN8CMUTrace10nam_formatEP6Packeti+0x92)[0x5c9842]
ns(_ZN8CMUTrace6formatEP6PacketPKc+0x45)[0x5ca065]
ns(_ZN8CMUTrace4recvEP6PacketP7Handler+0x33)[0x5ca243]
ns(_ZN9DCCPAgent6outputEb+0x257)[0x5550a7]
ns(_ZN5Agent7commandEiPKPKc+0x4a2)[0x518362]
/usr/lib/x86_64-linux-gnu/libotcl.so.1(+0x263d)[0x7f07f7be363d]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeStringCommand+0x76)[0x7f07f786ab96]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclNRRunCallbacks+0x47)[0x7f07f786cfa7]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeObjectCommand+0x102)[0x7f07f786acc2]
/usr/lib/x86_64-linux-gnu/libotcl.so.1(+0x276d)[0x7f07f7be376d]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeStringCommand+0x76)[0x7f07f786ab96]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclNRRunCallbacks+0x47)[0x7f07f786cfa7]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeObjectCommand+0x102)[0x7f07f786acc2]
/usr/lib/x86_64-linux-gnu/libotcl.so.1(+0x263d)[0x7f07f7be363d]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeStringCommand+0x76)[0x7f07f786ab96]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclNRRunCallbacks+0x47)[0x7f07f786cfa7]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(+0x3bd15)[0x7f07f786dd15]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(Tcl_EvalEx+0x13)[0x7f07f786d5f3]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(Tcl_Eval+0x15)[0x7f07f786e7f5]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(Tcl_GlobalEval+0x23)[0x7f07f786f8e3]
/usr/lib/x86_64-linux-gnu/libtclcl.so.1(_ZN3Tcl4evalEPc+0x12)[0x7f07f7df3342]
ns(_ZN9AtHandler6handleEP5Event+0x12)[0x504012]
ns(_ZN9Scheduler3runEv+0x36)[0x504a16]
ns(_ZN9Scheduler7commandEiPKPKc+0x38c)[0x5055bc]
/usr/lib/x86_64-linux-gnu/libotcl.so.1(+0x263d)[0x7f07f7be363d]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeStringCommand+0x76)[0x7f07f786ab96]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclNRRunCallbacks+0x47)[0x7f07f786cfa7]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeObjectCommand+0x102)[0x7f07f786acc2]
/usr/lib/x86_64-linux-gnu/libotcl.so.1(+0x276d)[0x7f07f7be376d]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeStringCommand+0x76)[0x7f07f786ab96]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclNRRunCallbacks+0x47)[0x7f07f786cfa7]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeObjectCommand+0x102)[0x7f07f786acc2]
/usr/lib/x86_64-linux-gnu/libotcl.so.1(+0x263d)[0x7f07f7be363d]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeStringCommand+0x76)[0x7f07f786ab96]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclNRRunCallbacks+0x47)[0x7f07f786cfa7]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(+0x3bd15)[0x7f07f786dd15]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(Tcl_FSEvalFileEx+0x258)[0x7f07f7926ca8]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(Tcl_MainEx+0x257)[0x7f07f792e417]
ns(nslibmain+0x22)[0x6a7a12]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f07f6be8830]
ns[0x4fb9de]
======= Memory map: ========
00400000-007aa000 r-xp 00000000 08:06 1836802 /usr/bin/ns
009aa000-009ab000 r--p 003aa000 08:06 1836802 /usr/bin/ns
009ab000-00a2a000 rw-p 003ab000 08:06 1836802 /usr/bin/ns
00a2a000-00a36000 rw-p 00000000 00:00 0
01464000-019cd000 rw-p 00000000 00:00 0 [heap]
7f07f5a75000-7f07f5a80000 r-xp 00000000 08:06 2498347 /lib/x86_64-linux-gnu/libnss_files-2.23.so
7f07f5a80000-7f07f5c7f000 ---p 0000b000 08:06 2498347 /lib/x86_64-linux-gnu/libnss_files-2.23.so
7f07f5c7f000-7f07f5c80000 r--p 0000a000 08:06 2498347 /lib/x86_64-linux-gnu/libnss_files-2.23.so
7f07f5c80000-7f07f5c81000 rw-p 0000b000 08:06 2498347 /lib/x86_64-linux-gnu/libnss_files-2.23.so
7f07f5c81000-7f07f5c87000 rw-p 00000000 00:00 0
7f07f5c87000-7f07f5c92000 r-xp 00000000 08:06 2498327 /lib/x86_64-linux-gnu/libnss_nis-2.23.so
7f07f5c92000-7f07f5e91000 ---p 0000b000 08:06 2498327 /lib/x86_64-linux-gnu/libnss_nis-2.23.so
7f07f5e91000-7f07f5e92000 r--p 0000a000 08:06 2498327 /lib/x86_64-linux-gnu/libnss_nis-2.23.so
7f07f5e92000-7f07f5e93000 rw-p 0000b000 08:06 2498327 /lib/x86_64-linux-gnu/libnss_nis-2.23.so
7f07f5e93000-7f07f5ea9000 r-xp 00000000 08:06 2498338 /lib/x86_64-linux-gnu/libnsl-2.23.so
7f07f5ea9000-7f07f60a8000 ---p 00016000 08:06 2498338 /lib/x86_64-linux-gnu/libnsl-2.23.so
7f07f60a8000-7f07f60a9000 r--p 00015000 08:06 2498338 /lib/x86_64-linux-gnu/libnsl-2.23.so
7f07f60a9000-7f07f60aa000 rw-p 00016000 08:06 2498338 /lib/x86_64-linux-gnu/libnsl-2.23.so
7f07f60aa000-7f07f60ac000 rw-p 00000000 00:00 0
7f07f60ac000-7f07f60b4000 r-xp 00000000 08:06 2498339 /lib/x86_64-linux-gnu/libnss_compat-2.23.so
7f07f60b4000-7f07f62b3000 ---p 00008000 08:06 2498339 /lib/x86_64-linux-gnu/libnss_compat-2.23.so
7f07f62b3000-7f07f62b4000 r--p 00007000 08:06 2498339 /lib/x86_64-linux-gnu/libnss_compat-2.23.so
7f07f62b4000-7f07f62b5000 rw-p 00008000 08:06 2498339 /lib/x86_64-linux-gnu/libnss_compat-2.23.so
7f07f62b5000-7f07f658d000 r--p 00000000 08:06 1835929 /usr/lib/locale/locale-archive
7f07f658d000-7f07f65a5000 r-xp 00000000 08:06 2498337 /lib/x86_64-linux-gnu/libpthread-2.23.so
7f07f65a5000-7f07f67a4000 ---p 00018000 08:06 2498337 /lib/x86_64-linux-gnu/libpthread-2.23.so
7f07f67a4000-7f07f67a5000 r--p 00017000 08:06 2498337 /lib/x86_64-linux-gnu/libpthread-2.23.so
7f07f67a5000-7f07f67a6000 rw-p 00018000 08:06 2498337 /lib/x86_64-linux-gnu/libpthread-2.23.so
7f07f67a6000-7f07f67aa000 rw-p 00000000 00:00 0
7f07f67aa000-7f07f67c3000 r-xp 00000000 08:06 2495741 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f07f67c3000-7f07f69c2000 ---p 00019000 08:06 2495741 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f07f69c2000-7f07f69c3000 r--p 00018000 08:06 2495741 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f07f69c3000-7f07f69c4000 rw-p 00019000 08:06 2495741 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f07f69c4000-7f07f69c7000 r-xp 00000000 08:06 2498330 /lib/x86_64-linux-gnu/libdl-2.23.so
7f07f69c7000-7f07f6bc6000 ---p 00003000 08:06 2498330 /lib/x86_64-linux-gnu/libdl-2.23.so
7f07f6bc6000-7f07f6bc7000 r--p 00002000 08:06 2498330 /lib/x86_64-linux-gnu/libdl-2.23.so
7f07f6bc7000-7f07f6bc8000 rw-p 00003000 08:06 2498330 /lib/x86_64-linux-gnu/libdl-2.23.so
7f07f6bc8000-7f07f6d87000 r-xp 00000000 08:06 2498331 /lib/x86_64-linux-gnu/libc-2.23.so
7f07f6d87000-7f07f6f87000 ---p 001bf000 08:06 2498331 /lib/x86_64-linux-gnu/libc-2.23.so
7f07f6f87000-7f07f6f8b000 r--p 001bf000 08:06 2498331 /lib/x86_64-linux-gnu/libc-2.23.so
7f07f6f8b000-7f07f6f8d000 rw-p 001c3000 08:06 2498331 /lib/x86_64-linux-gnu/libc-2.23.so
7f07f6f8d000-7f07f6f91000 rw-p 00000000 00:00 0
7f07f6f91000-7f07f6fa7000 r-xp 00000000 08:06 2495588 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f07f6fa7000-7f07f71a6000 ---p 00016000 08:06 2495588 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f07f71a6000-7f07f71a7000 rw-p 00015000 08:06 2495588 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f07f71a7000-7f07f7319000 r-xp 00000000 08:06 1837190 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f07f7319000-7f07f7519000 ---p 00172000 08:06 1837190 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f07f7519000-7f07f7523000 r--p 00172000 08:06 1837190 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f07f7523000-7f07f7525000 rw-p 0017c000 08:06 1837190 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f07f7525000-7f07f7529000 rw-p 00000000 00:00 0
7f07f7529000-7f07f7631000 r-xp 00000000 08:06 2498336 /lib/x86_64-linux-gnu/libm-2.23.so
7f07f7631000-7f07f7830000 ---p 00108000 08:06 2498336 /lib/x86_64-linux-gnu/libm-2.23.so
7f07f7830000-7f07f7831000 r--p 00107000 08:06 2498336 /lib/x86_64-linux-gnu/libm-2.23.so
7f07f7831000-7f07f7832000 rw-p 00108000 08:06 2498336 /lib/x86_64-linux-gnu/libm-2.23.so
7f07f7832000-7f07f79d1000 r-xp 00000000 08:06 1845656 /usr/lib/x86_64-linux-gnu/libtcl8.6.so
7f07f79d1000-7f07f7bd1000 ---p 0019f000 08:06 1845656 /usr/lib/x86_64-linux-gnu/libtcl8.6.so
7f07f7bd1000-7f07f7bdf000 r--p 0019f000 08:06 1845656 /usr/lib/x86_64-linux-gnu/libtcl8.6.so
7f07f7bdf000-7f07f7be0000 rw-p 001ad000 08:06 1845656 /usr/lib/x86_64-linux-gnu/libtcl8.6.so
7f07f7be0000-7f07f7be1000 rw-p 00000000 00:00 0
7f07f7be1000-7f07f7beb000 r-xp 00000000 08:06 1835928 /usr/lib/x86_64-linux-gnu/libotcl.so.1.14
7f07f7beb000-7f07f7dea000 ---p 0000a000 08:06 1835928 /usr/lib/x86_64-linux-gnu/libotcl.so.1.14
7f07f7dea000-7f07f7deb000 r--p 00009000 08:06 1835928 /usr/lib/x86_64-linux-gnu/libotcl.so.1.14
7f07f7deb000-7f07f7dec000 rw-p 0000a000 08:06 1835928 /usr/lib/x86_64-linux-gnu/libotcl.so.1.14
7f07f7dec000-7f07f7df9000 r-xp 00000000 08:06 1836475 /usr/lib/x86_64-linux-gnu/libtclcl.so.1.20
7f07f7df9000-7f07f7ff9000 ---p 0000d000 08:06 1836475 /usr/lib/x86_64-linux-gnu/libtclcl.so.1.20
7f07f7ff9000-7f07f7ffa000 r--p 0000d000 08:06 1836475 /usr/lib/x86_64-linux-gnu/libtclcl.so.1.20
7f07f7ffa000-7f07f802a000 rw-p 0000e000 08:06 1836475 /usr/lib/x86_64-linux-gnu/libtclcl.so.1.20
7f07f802a000-7f07f802c000 rw-p 00000000 00:00 0
7f07f802c000-7f07f8052000 r-xp 00000000 08:06 2495505 /lib/x86_64-linux-gnu/ld-2.23.so
7f07f822d000-7f07f8235000 rw-p 00000000 00:00 0
7f07f824e000-7f07f8251000 rw-p 00000000 00:00 0
7f07f8251000-7f07f8252000 r--p 00025000 08:06 2495505 /lib/x86_64-linux-gnu/ld-2.23.so
7f07f8252000-7f07f8253000 rw-p 00026000 08:06 2495505 /lib/x86_64-linux-gnu/ld-2.23.so
7f07f8253000-7f07f8254000 rw-p 00000000 00:00 0
7ffd24410000-7ffd24432000 rw-p 00000000 00:00 0 [stack]
7ffd245a2000-7ffd245a4000 r--p 00000000 00:00 0 [vvar]
7ffd245a4000-7ffd245a6000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Aborted (core dumped)
.tr和.nam文件是空的。我试图使用NAM运行简单的TCL脚本,并且它们都可以很好地执行。请检查我是否缺少某些内容,或者我安装NS的问题。我尝试安装Mannasim,但没有成功。请说明清晰的步骤以纠正我的软件安装或校正代码。
好吧,崩溃正在发生在C库中(似乎在系统上没有调试符号,使猜测是错误的棘手),但是呼叫者是NS的代码。堆栈跟踪的关键行是:
ns(_ZN8CMUTrace10nam_formatEP6Packeti+0x92)[0x5c9842]
现在,这是括号内的C 杂乱无章的名称(很明显,经验很少)。在在线服务的一些帮助下,可以解码为:
CMUTrace::nam_format(Packet*, int)
是0x92(= 146)字节中的其他呼叫是;您可以拆卸东西以找出那里发生的事情,但应该是通话到C库。可能是sprintf
或类似的东西。
NS的堆栈上的其他功能是:
CMUTrace::format(Packet*, char const*)
CMUTrace::recv(Packet*, Handler*)
DCCPAgent::output(bool)
Agent::command(int, char const* const*)
那么,OTCL中必须有一个thunk函数,然后您进入了TCL自己的代码。现在,您使用的是TCL 8.6,因此该跟踪不是很有用(由于非恢复执行引擎),但我猜想它正在从模拟器核心中处理回调(由于_ZN9AtHandler6handleEP5Event
,因此被翻译为AtHandler::handle(Event*)
- 在at
上注册的更直接堆栈)。很难确切地说发生了什么。
您需要一个调试器和完整的源代码来进一步搜寻。这超出了您通常从堆栈溢出答案中获得的。
您可以尝试的其他便宜的东西…
您可以尝试在代码的早期进行此操作,以确保崩溃不会使您失去输出。(它有点慢了一点,但是没有什么比崩溃慢了,所以谁在乎?)
fconfigure stdout -buffering none
您可能仍然没有任何有用的输出(但是如果您在回调中添加大量调试puts
调用电话),但至少崩溃不会消除您本来会有的。
还请注意,stderr
是始终所采用的,正是您可以在事情崩溃时轻松避免输出输出。
我在一定程度上解决了问题。问题是我已经安装了旧版本的NS2版本。因此,较新的NS2.35无法工作。我使用此命令卸载了先前安装的NS。
rishabh@Rishabh:~$ sudo apt-get purge --auto-remove ns
仍然,最后发生了分割故障,但是NAM输出良好。