这个方法我亲测可行的,
借鉴了http://blog.csdn.net/piyajee/article/details/6083913
网上的方法还是可行的,我按照网上的方法成功仿真了,不知道你是不是没有编译通过
以下是我的做法:修正tora路由协议错误
tora.cc
int
toraAgent::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;
}
}
else if(argc == 3) {
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;
}
else if(strcmp(argv[1], "drop-target") == 0) {
int stat = rqueue.command(argc,argv);
if (stat != TCL_OK) return stat;
return Agent::command(argc, argv);
}
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], "imep-agent") == 0) {
imepagent = (imepAgent*) TclObject::lookup(argv[2]);
if(imepagent == 0)
return TCL_ERROR;
imepagent->imepRegister((rtAgent*) this);
return TCL_OK;
}
//******************************************************************************
//======Extra coding to introduce port-dmux=======
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]);
printf("%s lookup of %s failed/n", argv[1], argv[2]);
return TCL_ERROR;
}
return TCL_OK;
}
//====================================
//*******************************************************************************
}
return Agent::command(argc, argv);
tora.h的修改
在最后添加以下内容:
//added for the port -dmux, for passing packets up to agents
protected:
PortClassifier *dmux_;
并在开始添加以下头文件,这个很重要,要不然编译不成功
#include <classifier/classifier-port.h>