0
votes

I built a compound module which extends/inherits inet's AODVRouter. The compound module's NED file as follows:

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

The .h file as follows:

#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

The CC file as follows:

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

}

Next, I created a network compound module for the simulation. The code as follows:

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

}

So after rebuilding the project and running omnetpp.ini, I got this error immediately: "Error in module(SelfishBaseNode) VanetA.BadRNode1 (id=8) during network initialization: unknown parameter 'routing TableModule".

I checked the debugger and apparently it stopped at this line in AODVRouting.cc:

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

I was puzzled because I didn't override the initialize() function in SelfishBaseNode.cc. I thought the program had confused with the initialize() function between SelfishBaseNode.CC and AODVRouting.CC so I removed the initialize() function in SelfishBaseNode.h and .CC file but didn't help. Hopefully someone could shed some light on this problem. Thank you.

1

1 Answers

0
votes

Not sure what happened but after troubleshooting for 1 day, I have decided to update OMNET++ to version 5.1.1 and issue resolved.