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