ios-simulatorsimulationiotomnet++fog

I need to define 3 kinds of messages in omnet


I want to define 3 kinds of messages in omnet I know I have to use messagekind but I couldnt please help me I want help message, control message and jobs, which jobs should be processed thank you so much


Solution

  • After creating the three message classes, in a class, say DemoLayer, you need 2 changes in .h file and 1 in .cc file.

    In .h file, under the public specifier add

    enum DemoMessageKinds {
        SEND_DATA-MESSAGE,
        SEND_CONTROL-MESSAGE,
        SEND_JOB-MESSAGE
    };
    

    and under protected specifier add

    void handleSelfMsg(cMessage* msg) override;
    

    In .cc file, add

    void DemoLayer::handleSelfMsg(cMessage* msg)
    {   
       switch (msg->getKind()) 
       {
          case SEND_DATA-MESSAGE: 
          {
            ControlMessage* cm = new ControlMessage();
            ....//
    

    For an example, check this https://github.com/sommer/veins/tree/master/src/veins/modules/application/ieee80211p