NS2 - TORA协议修正

问题描述

NS2.35中自带了经典的TORA路由协议,但是无法正常运行,需要对其C++源文件进行修改。

TORA修改

需要修改3个C++源文件:ns/ns-2.35/tora/tora.h, ns/ns-2.35/tora/tora.cc, ns/ns-2.35/imep/imep.cc


  • 修改 ns/ns-2.35/tora/tora.h

添加头文件:

#include <classifier/classifier-port.h>

在最后添加:

//added for the port -dmux, for passing packets up to agents
protected:
    PortClassifier  *dmux_;

  • 修改 ns/ns-2.35/tora/tora.cc

在 int toraAgent::command(int argc, const char*const* argv) 函数的最后一个 else if 后 添加:

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;
}

  • 修改 ns/ns-2.35/imep/imep.cc

将 void imepAgent::handlerReXmitTimer() 函数中的 rexmitTimer.start(rexat - CURRENT_TIME); 替换为:

if (rexat-CURRENT_TIME<0.000001) // Preventing eternal loop.
   rexmitTimer.start(0.000001);
else
   rexmitTimer.start(rexat - CURRENT_TIME);

注意

如果没有修改 imep.cc 可能会出现死循环。

猜你喜欢

转载自blog.csdn.net/sinat_37367944/article/details/79376450