1

I am simulating a scenario where vehicles send message to RSU as soon as they are generated.For this I tried to include the code for wsm message in my intialize method of the TraCIDemo11p.cc file but the messages are not sent as soon as the vehicle are generated in the network.How to solve this problem??

Tapu
  • 25
  • 5
  • 1
    While I don't know anything about `veins`, in most cases adding the source code you wrote to you questions helps other reades to understand your problem. So please edit your question and add the relevant lines of code. – ventiseis Mar 26 '17 at 19:00
  • Is this question answered? – Julian Heinovski Jul 22 '18 at 12:33

1 Answers1

1

The initialize method should only be used for initializing the module and its components. Modules might depend on other modules and you don't know the actual execution order of all those initialize methods for all modules in the simulation. Therefore, there might be not yet initialized modules which are needed to send messages to other vehicles.

You should rather schedule a self-message in initialize to the near future to send your message:

scheduleAt(selfMessage, simTime() + SimTime(1, SIMTIME_MS));

Thus, you can be absolutely sure that every module which is necessary to send messages actually is initialized. You might try different values for the scheduling time.

Julian Heinovski
  • 1,822
  • 3
  • 16
  • 27
  • Thanks for the reply but I don't understand the meaning of scheduling a self message in intialize method.Can you please elaborate your solution and also suggest some reading material for sending message to RSU?? – Tapu Mar 28 '17 at 10:27
  • You should make yourself familiar with the concept of self messages as it is a central concept of OMNeT++. You can do so by reading the [manual](https://omnetpp.org/doc/omnetpp/manual/) and doing the [TicToc-Tutorial](https://omnetpp.org/doc/omnetpp/manual/#sec:simple-modules:self-messages). – Julian Heinovski Mar 28 '17 at 10:38