Search code examples
omnet++

Defining Node Connections in .cc file rather that .ned file in Omenet++


Is it possible to make new node connections in .cc file? I mean can I leave the connection part in .ned file empty and define connections in .cc file according to my algorithm?


Solution

  • Sure. Take a look at the manual. It's as easy as:

    srcGate->connectTo(destGate);
    

    or a bit more code if you need to use channels:

    cGate *outGate, *inGate;
    ...
    
    // find factory object and create a channel
    cChannelType *channelType = cChannelType::get("foo.util.Channel");
    cChannel *channel = channelType->create("channel");
    
    // create connecting
    outGate->connectTo(inGate, channel);