0

I am trying to send Ack to nodes when I receive the message. I am able to get the frame id, not able to figure it out how do I include this frame id in my message and broadcast it? Any pointer? it will be helpful. Thanks.

Update: Here is what I am trying to do, When a message is received at RSU in the function BaseWaveApplLayer::handleLowerMsg, I am extracting frame ID and sending Ack. Issue I am facing is while using sendDown, I am getting error that already a Event is scheduled to be sent. How to correctly schedule the message? I am using sendDown(msg).

I am not getting correct frame id, I used encapsulatedFrame id but it gives different value, how do I get frameid from BasicSafetyMessage or cMessage?

Code:

void BaseWaveApplLayer::handleLowerMsg(cMessage* msg) {
WaveShortMessage* wsm = dynamic_cast<WaveShortMessage*>(msg);
ASSERT(wsm);
if (BasicSafetyMessage* bsm = dynamic_cast<BasicSafetyMessage*>(wsm)) {
    receivedBSMs++;
    onBSM(bsm);
    if(isBaseStation())
    {
        BasicSafetyMessage* Ack= new BasicSafetyMessage();
        populateWSM(Ack);
        Ack->setWsmData(getFrameId(bsm));
        EV<<" Sending Ack Frame ID"<<getFrameId(bsm);
        sendDown(Ack);
    }
    else
    {
        EV<<"Received FrameId"<<bsm->getWsmData();
        std::string str( bsm->getWsmData());
        int FrameId= std::atoi(str.c_str());
        checkIds(FrameId);
    }

}}
Sam1324
  • 387
  • 2
  • 13

1 Answers1

0

You need to create a new message type which adds the frameId as a parameter to acknowledge as a parameter. On the receiver you then can compare it's value to the your sent packets. See the OMNeT++ user manual to find out how to create new messages. Also see this post for some hints.

Community
  • 1
  • 1
Julian Heinovski
  • 1,822
  • 3
  • 16
  • 27
  • Hi @julian-heinovski, as I am using Veins, I am calling populateWSM(wsm) function and I am changing wsm data to the received frameId. Issue I am facing is in sending this message. After creating this message I calling sendDown but my application crashes when I click Run. – Sam1324 Apr 16 '17 at 09:40
  • Please update your post with this information and corresponding code and error message snippets. – Julian Heinovski Apr 16 '17 at 10:20
  • Hi, Here is what I am trying to do, When a message is received at RSU in the function BaseWaveApplLayer::handleLowerMsg I am extracting frame ID and sending back the message. Issue I am facing is while using sendDown I am getting error that already a message is scheduled to be sent. How to correctly schedule the message? I am usng sendDown(msg). – Sam1324 Apr 17 '17 at 07:38
  • any comments on this? – Sam1324 Apr 17 '17 at 10:56
  • Please post the actual code you are using as well so we can see what is going on. Most probably you need to create a new message or duplicate the old one, since a message can be scheduled only once. Also please post the actual error message from the output. Add everything to your question not to the comments ;-) – Julian Heinovski Apr 17 '17 at 16:26