Chapter 2: Self messages
In this section, we will explore the simplest messages in OMNeT++: messages to "self". We will see how to create them, send and receive them. We will also do some exercises!
Creating and handling a self message
Creating and handling a self message In the last section, we have explored the code of our simpl...
Exercise 1: Play with the self message
Try to change the scheduled time for the message first to 20, then to 10000. Re-run the simulatio...
Exercise 1: Discussion
In fact, you should not see any difference. As explained in discrete event simulation, it doesn't...
Exercise 2: Resend the message
Now, let's us resend the message to ourselves. In handleMessage(), instead of deleting the messag...
Exercise 2: Discussion
The difference is obvious this time: the message keeps turning back and the simulation never stop...
State variables
State variables are a very handy tool to track the internal state of a module: for example, to co...
Different self messages
We can of course define and use also different self messages, for example, to switch to blue or t...
Random behavior
It is relatively simple to schedule a message randomly in OMNeT++. In fact, the kernel offers you...