Search code examples
c++omnet++inet

Unknown protocol: protocolId = 92, protocolName = CbdProto, servicePrimitive = REQUEST


I try to implement a Network Layer Protocol, using the INET SensorNode module. I properly extend the NED simple module as follow :

simple CbdProto extends NetworkProtocolBase like INetworkProtocol
{
    @class(inet::CbdProto);
}

This protocol is added to the list of the INET Procotol class (Protocol.cc) by extending that class :

In ProtocolNew.h

static const ProtocolNew CbdProto;

In ProtocolNew.cc

const ProtocolNew ProtocolNew::CbdProto("CbdProto","Network Protocol",ProtocolNew::NetworkLayer);

The C++ class is settled up accordingly. I register the protocol in initialize() method :

void inet::CbdProto::initialize(int stage) {
    if (stage == INITSTAGE_NETWORK_LAYER) {
        registerProtocol(ProtocolNew::CbdProto, gate("transportOut"), gate("transportIn"));
    }
}

The .ini file is as follow :

**.hasIpv4 = false
**.hasIpv6 = false
**.hasGn = true
**.generic.typename = "SimpleNetworkLayer"
**.generic.np.typename = "CbdProto"

But I keep having this error that I don't know to fix it.

 <!> handlePacket(): Unknown protocol: protocolId = 92, protocolName = CbdProto, servicePrimitive = REQUEST, pathStartGate = WsnCbd.s[0].udp.ipOut, pathEndGate = WsnCbd.s[0].tn.in[0] -- in module (inet::MessageDispatcher) WsnCbd.s[0].tn (id=18), at t=0s, event #6

Please, I will appreciate your input.

Thanks


Solution

    1. You don't have to create a new class. You just have to add your new protocol to the Protocol.cc and .h file, to the existing Protocol. (Don't forget to create an instance in the .cc file.
    2. Your new protocol provides a service to the upper layer so you have to use registerService() in your protocol's code.