c++omnet++veinssumo

How to send a message after a defined time?


Upon receiving a message, I want to broadcast it after a defined waiting time.

For example when node[8] receives the message wsm at time t=109s, it rebroadcasts it at a defined time T, so I used:

scheduleAt(simTime()+T,wsm->dup());

as a result I had from t=109s, it broadcasts a message after each second.

So I tried with this method:

scheduleAt(Ts, wsm->dup()); // Ts=109+T

It gives me this error at runtime:

Cannot schedule message (veins::Mwsm) to the past, 
t=0 -- in module (DissApp) Net.node[8].appl (id=56), 
at t=109.000243213075s, event #176

Error message


Solution

  • The error clearly says that a message is tried to schedule in the past: in t=109 s the message is scheduled for t=0 (what is impossible).
    If you use scheduleAt(Ts, wsm->dup()); be sure that Ts is larger than current simulation time.