Ns2中的节点创建错误

时间:2014-07-24 10:58:59

标签: protocols nodes ns2

我在ns-2.34中实现了一个名为TRLR的新路由协议。我正在使用fedora 13.我修改了ns-lib.tcl,ns-packet.tcl,priqueue.cc,packet.h,cmu-trace。{cc,h}。然后使清洁,制作和安装成功完成。然后我尝试使用trlr_2.tcl运行此协议,我得到了这个奇怪的错误。我不知道如何解决这个错误我也没有在任何地方找到这个问题的可接受的答案。请帮帮我。任何帮助,将不胜感激。在此先感谢!!!

[root@Care Desktop]# ns trlr_5.tcl 
num_nodes is set 5
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
INITIALIZE THE LIST xListHead

(_o17 cmd line 1)
    invoked from within
"_o17 cmd tracetarget _o31"
    invoked from within
"catch "$self cmd $args" ret"
    invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
    (procedure "_o17" line 2)
    (SplitObject unknown line 2)
    invoked from within
"$ragent tracetarget $T"
   (procedure "_o14" line 14)
   (Node/MobileNode agenttrace line 14)
    invoked from within
"$node agenttrace $tracefd"
   (procedure "_o3" line 106)
   (Simulator create-wireless-node line 106)
    invoked from within
"_o3 create-wireless-node"
    ("eval" body line 1)
    invoked from within
"eval $self create-wireless-node $args"
    (procedure "_o3" line 23)
    (Simulator node line 23)
    invoked from within
"$ns_ node"
    ("for" body line 2)
    invoked from within
"for {set i 0} {$i < $val(nn) } {incr i} {
    set node_($i) [$ns_ node]   
    $node_($i) random-motion 0      ;# disable random motion
}"
(file "trlr_5.tcl" line 97)

经过一些谷歌搜索后,我认为这个错误是由我的trlr.h和trlr.cc文件中的command()函数引起的。所以,我也在这些文件中添加了命令功能块。

&LT;&LT;&LT; trlr.h&gt;&gt;&gt;

#include <cmu-trace.h>
#include <agent.h>
#include <classifier/classifier-port.h>

class TRLR: public Agent 
{
private:
    routingTable rTable;
public:
    TRLR(nsaddr_t id);
    int  command(int, const char *const *);
protected:
    PortClassifier* dmux_;
    Trace* logtarget_;
    PriQueue* ifqueue;
};

&LT;&LT;&LT; trlr.cc&gt;&gt;&gt;

int TRLR::command(int argc, const char*const* argv) {
if(argc == 2) {
 Tcl& tcl = Tcl::instance();

if(strncasecmp(argv[1], "id", 2) == 0) {
  tcl.resultf("%d", index);
  return TCL_OK;
}

if(strncasecmp(argv[1], "start", 2) == 0) {
  rtimer.resched(0.0);
  return TCL_OK;
 }
}
else if(argc == 3) {
if(strcmp(argv[1], "index") == 0) {
  index = atoi(argv[2]);
  return TCL_OK;
}

else if (strcmp(argv[1], "port-dmux") == 0) {
    dmux_ = (PortClassifier *)TclObject::lookup(argv[2]);
if (dmux_ == 0) {
    fprintf (stderr, "%s: %s lookup of %s failed\n", __FILE__,
    argv[1], argv[2]);
    return TCL_ERROR;
}
return TCL_OK;
}

else if(strcmp(argv[1], "if-queue") == 0) {
ifqueue = (PriQueue*) TclObject::lookup(argv[2]);      
  if(ifqueue == 0)
return TCL_ERROR;
  return TCL_OK;
}

else if (strcmp(argv[1], "log-target") == 0 || strcmp(argv[1], "tracetarget") == 0) {
    logtarget_ = (Trace*)TclObject::lookup(argv[2]);
if (logtarget_ == 0)
    return TCL_ERROR;
    return TCL_OK;
}
  }
return Agent::command(argc, argv);
}

提前致谢。

0 个答案:

没有答案