-1

I use OMNeT++-4.6, sumo-0.22.0 and Veins-4a2.

In my simulation, I need that all nodes send their messages when leaving the simulation to their destination which are RSU in my case. The problem that all nodes send their messages in finish() function but they are not receiving by RSU since every node should wait before it can access the channel and then it will be destroyed.

I need to make every node when leaving the simulation waits until receiving an ACK from the destination. Then, when it receives all ACK for all sending messages it can be destroyed.

So, how can I force every node in finish() function to wait for ACK? I need a help please to do this scenario.

Fariha
  • 497
  • 1
  • 5
  • 13

1 Answers1

2

According to OMNeT++ Simulation Manual:

finish() is called for all modules at the end of the simulation.

A message sending in finish() cannot be received by any module because the simulation is ending and handleMessage() will not be called.

I suggest introducing a selfmessage which (at specified moment) will involve actions you want to do.

Jerzy D.
  • 6,707
  • 2
  • 16
  • 22
  • Thank you for your response. I tried to use scheduleAt which I specified a delay in finish() function in order to wait until messages are sent and the corresponding node reveives an ACK but like you said handleMessage will not be called. Can you please tell me how can I use self-message in finish() function to wait until the node receives an ACK? I do not know what to do and really I need to do it in my work. – Fariha Mar 19 '17 at 19:13
  • 1
    You cannot use self messages in `finish()`. However, you can use selfmessages *earlier*. `finish()` is called at the end of simulation. The simulation ends when: 1) there are no more events (messages) to process, or 2) assumed simtime or cpu time from `omnetpp.ini` elapsed, or 3) user stops simulation manually. Could you indicate which condition occurs in your simulation? – Jerzy D. Mar 19 '17 at 19:46
  • In my simulation, the second condition occurs. So, finish() is called when all nodes reach their destination. What I need to do is that every node reachs the destination and before leaving the simulation send all the rest of their generated messages to the destination, I used sendMessage() function in finish() method and all messages are sent but they are not received by the destination. So as a solution, I need to force every node when sending each packet to wait until it receives an ACK from RSU. – Fariha Mar 19 '17 at 22:01
  • Your comment is not clear for me. The second condition means that you set for example `sim-time-limit=3600s` in `omnetpp.ini` - is it true? – Jerzy D. Mar 20 '17 at 08:28
  • My simulation ends when all nodes reach their destination according to the indicating path in .rou.xml file. The time of the last node that leaves the simulation and then the simulation ends is 1433s so I set [sim-time-limit=1450s] in omnetpp.ini. – Fariha Mar 20 '17 at 08:39
  • I explain otherwise my problem: in my simulation, each node creates a message, stores it in its buffer and after some delay it sends all its messages. I did two timers to specify the delay of created and sent messages. So, the message send may be receive by an other node or by the destination which is the RSU. In my results, I noticed that all nodes when leaving the simulation there are some messages created which are not sending. – Fariha Mar 20 '17 at 08:48
  • Yet, in my simulation scenario, I need that all messages will be send to the destination in order to have a delivery rate = 100%. What I did is that I added a call to sendMessage() function in finish() method, but I noticed that the messages are not receiving by the destination due to the delay to access channel. So, as a solution I need to force every node when sending the rest of its messages in finish() function to wait until it receives an ACK from the destination to leave the simulation. Do you have an idea how can I do this with self-messages please? – Fariha Mar 20 '17 at 08:50
  • You can just add a selfmessage at t=1430s for every node. When this selmessage expires, a node sends a message. When ACK will be received, a node can do what you want. – Jerzy D. Mar 20 '17 at 09:36
  • The problem that every node leaves the simulation at a given time. For example, the first node leaves the simulation at 123s against the last node leaves at 1433s. Should I add the self-message in handleLowerMsg() in BaseWaveApplLayer for every node? – Fariha Mar 20 '17 at 10:07
  • Sending a message when a vehicle leaves the simulation due to its route involves SuMO and TraCIScenarioManager. This is certainly a different problem than what you asked in the first place. Please open a different question. – Julian Heinovski Mar 20 '17 at 13:34
  • Thank you for your response. This is the link my new question can you reply me please if you know how to do it: http://stackoverflow.com/questions/42908752/sending-a-message-when-a-vehicle-leaves-the-simulation Thanks in advance. – Fariha Mar 20 '17 at 16:21