OMNET ++复合模块返回“未知参数”路由TableModule'“

时间:2017-07-23 16:26:49

标签: omnet++ inet

我构建了一个复合模块,它扩展/继承了inet的AODVRouter。复合模块的NED文件如下:

package project1;

import inet.node.aodv.AODVRouter;

module snode extends AODVRouter
{
parameters:
    //@networkNode;
    @display("i=device/wifilaptop");
    @labels(wireless-node);
   @class(SelfishBaseNode);

   submodules:
        bad: SelfishBaseNode {
        @display("p=273,350");
    }
}

.h文件如下:

#ifndef __PROJECT1_SELFISHBASENODE_H_
#define __PROJECT1_SELFISHBASENODE_H_

#include <omnetpp.h>
#include "AODVRouting.h"
#include "inet/routing/aodv/AODVControlPackets_m.h"


using namespace inet;

class SelfishBaseNode : public AODVRouting
{

protected:
  //  void initialize();
void sendAODVPacket(AODVControlPacket *packet, const L3Address& destAddr, unsigned int timeToLive, double delay)override;

};

#endif

CC文件如下:

#include "SelfishBaseNode.h"
#include <INetworkProtocolControlInfo.h>
#include "inet/networklayer/ipv4/IPv4Route.h"
#include "inet/linklayer/ideal/IdealMacFrame_m.h"
#include "AODVRouting.h"
#include <string.h>
#include <omnetpp.h>


using namespace inet;


Define_Module(SelfishBaseNode);

void SelfishBaseNode::sendAODVPacket(AODVControlPacket *packet, const L3Address& destAddr, unsigned int timeToLive, double delay)
{

 ASSERT(timeToLive != 0);

    INetworkProtocolControlInfo *networkProtocolControlInfo = addressType->createNetworkProtocolControlInfo();

    networkProtocolControlInfo->setHopLimit(timeToLive);

    networkProtocolControlInfo->setTransportProtocol(IP_PROT_MANET);
    networkProtocolControlInfo->setDestinationAddress(destAddr);
    networkProtocolControlInfo->setSourceAddress(getSelfIPAddress());

    // TODO: Implement: support for multiple interfaces
    InterfaceEntry *ifEntry =  interfaceTable->getInterfaceByName("wlan0");
      networkProtocolControlInfo->setInterfaceId(ifEntry->getInterfaceId());

    UDPPacket *udpPacket = new UDPPacket(packet->getName());
    udpPacket->encapsulate(packet);
    udpPacket->setSourcePort(aodvUDPPort);
    udpPacket->setDestinationPort(aodvUDPPort);
    udpPacket->setControlInfo(dynamic_cast<cObject *>(networkProtocolControlInfo));

    if (destAddr.isBroadcast())
        lastBroadcastTime = simTime();

delete packet;

}

接下来,我为模拟创建了一个网络复合模块。代码如下:

package project1;

@namespace(inet);
import inet.common.figures.DelegateSignalConfigurator;
import inet.networklayer.configurator.ipv4.IPv4NetworkConfigurator;
import inet.node.inet.INetworkNode;
import inet.physicallayer.contract.packetlevel.IRadioMedium;
import inet.visualizer.integrated.IntegratedCanvasVisualizer;

network VanetA
{
parameters:
    string hostType = default("AODVRouter");

    @display("bgb=855.264,620.912;bgg=50,2,grey95;bgu=m");

    @figure[rcvdPkText](type=indicatorText; pos=420,20; anchor=w; font=,20; textFormat="packets received: %g"; initialValue=0);
    @statistic[rcvdPk](source=DestinationNode_rcvdPk; record=figure(count); targetFigure=rcvdPkText);
    @signal[DestinationNode_rcvdPk];
    @delegatesignal[rcvdPk](source=DestinationNode.udpApp[0].rcvdPk; target=DestinationNode_rcvdPk);

submodules:
    visualizer: IntegratedCanvasVisualizer {
        @display("p=59,103");
    }
    configurator: IPv4NetworkConfigurator {
        @display("p=59,164");
    }
    radioMedium: <"IdealRadioMedium"> like IRadioMedium {
        @display("p=60,50");
    }
    figureHelper: DelegateSignalConfigurator {
        @display("p=60.399998,292.336");
    }

    SourceNode: <hostType> like INetworkNode {
        @display("i=device/pocketpc;p=445.536,198.432");
    }

    DestinationNode: <hostType> like INetworkNode {
        @display("i=device/pc4;p=329.47202,102.336");
    }

    BadRNode1: snode {
        @display("i=device/satellite;p=385.632,159.744");
    }

}

因此,在重建项目并运行omnetpp.ini之后,我立即收到此错误:“网络初始化期间模块(SelfishBaseNode)VanetA.BadRNode1(id = 8)出错:未知参数'路由TableModule”。

我检查了调试器,显然它在AODVRouting.cc中停在了这一行:

void AODVRouting::initialize(int stage)
{
.....
.....
routingTable = getModuleFromPar<IRoutingTable>(par("routingTableModule"), this);
}

我很困惑,因为我没有覆盖SelfishBaseNode.cc中的initialize()函数。我认为该程序与SelfishBaseNode.CC和AODVRouting.CC之间的initialize()函数混淆,所以我删除了SelfishBaseNode.h和.CC文件中的initialize()函数但没有帮助。希望有人可以解释这个问题。谢谢。

1 个答案:

答案 0 :(得分:0)

不确定发生了什么,但经过1天的故障排除后,我决定将OMNET ++更新到版本5.1.1并解决问题。