TICTOC
TICTOC
Ahmet Şekercioğlu∗
Contents
1 Introduction 1
1.1 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
3 Exercises 6
1 Introduction
This short tutorial to OMNeT++ guides you through an example of modeling and sim-
ulation, showing you along the way some of the commonly used OMNeT++ features.
1.1 Prerequisites
I assume you have downloaded OMNeT++ from its Web site [OMN96], and successfully
installed. I recommend that, to be sure that the installation is error-free, run at least a
couple of the examples bundled with the distribution. Also, I assume that you are going
to use the linux version of OMNeT++ for the experiments of this tutorial.
tictoc.tex,v1.2 1
Introduction to Network Simulation Using OMNeT++
In this file, we define a network called tictoc, which consists of a compound mod-
ule Tictoc. The compound module, in turn, consists of submodules tic and toc.
tic and toc are instances of the same simple module type called Txc1 . Txc has one
input gate (named in), and one output gate (named out). We connect tic’s output
gate to toc’s input gate, and vice versa.
3. We now need to implement the functionality of the simple module Txc. This is
achieved by writing two C++ files: txc.h and txc.cc:
with lowercase), and begin the submodule names with lowercase (i.e., tic and toc).
tictoc.tex,v1.2 2
Introduction to Network Simulation Using OMNeT++
tictoc.tex,v1.2 3
Introduction to Network Simulation Using OMNeT++
4. Then, we need to write the file omnetpp.ini which will tell the simulation tool
what to do:
5. We now create the Makefile which will help us to compile and link our program
to create the executable tictoc:
opp_makemake
This command should have now created a Makefile in the working directory
tictoc.
7. Let’s now compile and link our very first simulation by issuing the make com-
mand:
make
If there are compilation errors, you need to rectify those and repeat the make until
you get an error-free compilation and linking.
8. Once you complete the above steps, you launch the simulation by issuing this
command:
./tictoc
and, hopefully you should now get the OMNeT++ simulation window similar to
the one shown in Figure 1.
9. Press the “run” button to start the simulation. What you should see is that tic
and toc are exchanging messages with each other. This is the result of the send()
and receive() calls in the C++ code.
The main window behind displays text messages generated via the ev << ...
lines from these modules. Observe that the messages “Hello World! I’m tic.”
tictoc.tex,v1.2 4
Introduction to Network Simulation Using OMNeT++
and “Hello World! I’m toc.” are only printed once at the beginning of the sim-
ulation.
The main window toolbar displays the simulated time. This is “virtual” time, it
has nothing to do with the actual (or wall-clock) time that the program takes to
execute. Actually, how many seconds you can simulate in one real-world second
depends highly on the speed of your hardware and even more on the nature and
complexity of the simulation model itself (Exercise 2 will emphasize this issue).
Note that the toolbar also contains a simsec/sec gauge which displays you this
value.
10. In real life communication systems, the links carrying the packets do not transmit
a packet from one end to the other instantaneously. Instead, the packets experi-
ence “propagation delays”. Let’s now improve our model by introducing a more
realistic link which will delay the messages 0.5 sec. in both directions:
(a) Edit the tictoc.ned to insert the following lines after line 7:
channel TicTocLink
delay 0.5 // sec.
endchannel
(b) Then, modify the lines 16 and 17 of tictoc.ned as follows:
tictoc.tex,v1.2 5
Introduction to Network Simulation Using OMNeT++
We now have a link connecting modules tic and toc involving a 0.5 seconds prop-
agation delay.
11. Repeat the make command, and then run the tictoc to see the effects of the prop-
agation delay. In OMNeT++, communication link models can have quite sophisti-
cated properties. Explore the user manual [Var] to see what they are.
3 Exercises
1. Line 31 of txc.cc contains the wait(1.0); OMNeT++ kernel call. Find out what
does this call do by referring to the OMNeT++ user manual [Var].
2. Now, let a tictoc simulation running. Change the line 31 (wait(1.0);) of the
txc.cc to wait(100.0);. Then do a “make”, and run the new tictoc in another
window. Should we expect that the message exchange between tic and toc
slowed? If no, why?
3. Delete the communication link connecting tic and toc. Then, insert a third mod-
ule called tac between the modules tic and toc. This new module will be re-
sponsible for relaying messages bouncing between tic and toc by having direct
connections to both of them: tic → tac → toc (i.e., there will not be a direct com-
munication between tic and toc).
4. I have written the message handling mechanism of txc.cc by using the activity()
call. Rewrite the txc.cc, this time by using the handleMessage() mechanism of
OMNeT++. To do this, you need to study the examples presented in the Section
5.3.2 of the OMNeT++ user manual [Var].
References
[OMN96] OMNeT++ object-oriented discrete event simulation system. URL reference:
http://www.omnetpp.org, 1996.
tictoc.tex,v1.2 6