ns2.34中Bug一例

来源:互联网 发布:淘宝兼职怎么找 编辑:程序博客网 时间:2024/06/04 18:17

在ns2.34下扩展安装LEACH协议,编译时显示错误:

 

mac/wireless-phy.cc: In member function ‘virtual void WirelessPhy::sendDown(Packet*)’:
mac/wireless-phy.cc:278: error: ‘class Node’ has no member named ‘getLoc’
mac/wireless-phy.cc: In member function ‘virtual int WirelessPhy::sendUp(Packet*)’:
mac/wireless-phy.cc:501: error: ‘class Node’ has no member named ‘getLoc’
make: *** [mac/wireless-phy.o] Error 1

 

错误提示在wireless-phy.cc的第278, 501行,类node的getLoc函数不存在。

 

通过查看源代码, 发现函数getLoc是类MobileNode的一个内联函数,而MobileNode是类Node的子类。再次查看,发现Wireless-phy.h中有一行加了注释:


    // Why phy has a node_ and this guy has it all over again??
    //  MobileNode* node_;             // Mobile Node to which interface is attached .

 

看来更新ns2代码的这个人没有注意到这个问题,这里的node_看似与Node类中的成员node_重复。但实际上还是有差别。找到问题了,打开注释,同时修改wireless-phy.cc中的236行代码:

else if (strcasecmp(argv[1], "node") == 0) {
            assert(node_ == 0);
            node_ = (Node *)obj;          //这一行改为node_=(MobileNode*)obj;
            return TCL_OK;
        }

 

问题解决。