Presentation is loading. Please wait.

Presentation is loading. Please wait.

Modeling and simulation [NETW707] Tutorial5 – Introduction to Omnet++

Similar presentations


Presentation on theme: "Modeling and simulation [NETW707] Tutorial5 – Introduction to Omnet++"— Presentation transcript:

1 Eng. Minar El-Aasser minar.elaasser@guc.edu.eg #C3.314
Modeling and simulation [NETW707] Tutorial5 – Introduction to Omnet++ Eng. Minar El-Aasser #C3.314

2 What Is Omnet++? Open Source =)
It’s not only a network simulator. It provides a base for network simulations A generalized framework for building 'network‘ simulations Communication networks Queuing networks Digital logic networks ' …. ' networks Open Source =)

3 How to Install Omnet++? Windows install
Self contained, simply follow directions: Download, unzip somewhere (no spaces in path) Double-click mingwenv.cmd If Windows 8 doesn't like this, click 'more info', then 'run anyway‘ Type: ./configure Type: make doc/InstallGuide.pdf

4 Simulation Model – Module Types
Structure: A simulation model consists of modules, which are grouped/ connected together. Modules that are grouped together are themselves modules Provides a module hierarchy where hierarchy depth is unlimited: Reflect logical structure of system being modeled Compound modules describe the structure of a simulation model. A network is itself a compound module Module at top of hierarchy = system module Modules below = submodules Submodules = compound or simple modules Modules at bottom of hierarchy = simple modules

5 Simulation Models in Omnet++
In Omnet++, a simulation model is also called a network A network (simulation model) is itself a module Components of your simulation model are defined as simple or compound modules (Simple modules group together to form compound modules.) Simple Modules are the Base building blocks They are the only active components and their behavior implemented in c++ files Declared in NED Files

6 Simulation Models in Omnet++ cont’d
Gates allow for Message passing Messages could represent packets, jobs, timers, timeout, etc. Messages Passes between gates using Connections Two gates can be directly linked via connection (Think wired communication network) Connections can also be used to directly pass a message to an unlinked gate (Think wireless communication network) Connections can be defined and reused: called Channels Defined in NED Files

7 FAMOUS TIC-TOC EXAMPLE
1. Define your model components ≡ Adding NED Files Network & 2 instances of Txc1 [Tic and Toc] Command: File > New > Network // creates the NED file for the network N.B: Omnet++ editor has 2 modes that you can switch between them: Design [edited graphically] and Source [edited as text].

8 Modules (simple or compound) can be placed in the same NED file as the network NED file or a separate one.

9 FAMOUS TIC-TOC EXAMPLE
2. Implement the functionality of each component ≡ Declaring Simple Modules NED files and Adding their C++ files File > New > Omnet++ Class // creates the NED file for the simple module as well as the associated C++ files to describe its behavior [2 file: Txc1.h and Txc1.cc] N.B: - the 2 files Txc1.h and Txc1.cc are both merged in the Txc1.cc of the tictoc tutorial in Omnet++ projects. However, its common practice to split the headers from the functions implementation when your project gets more complex. -Make sure that the code in C++ files is associated with their perspective NED components by placing the command “Define_Module (Txc1)” in your .cc file. Txc1:same name as that given to the NED component “case_sensitive” -The Omnet++ class created to declare the functionality of the simple module sub-classes from the public Omnet++ cSimpleModule and thus it has 2 “popular” functions that defines it and are automatically created in a simple Omnet++ class module. void initialize(); //called at the beginning of the simulation; only once! void handleMessage(cMessage *msg); // called whenever a message arrives

10 C++ functionality of the simple modules could be kept in 1 file or split on 2 file [.cc and .h]

11 FAMOUS TIC-TOC EXAMPLE
3. Create the configuration file ≡ Adding Omnet.ini File > New > INI N.B: -The configuration file tells the simulation program which network to simulate Through .ini files you can pass parameters to the model, explicitly specific seeds for RNG It has 2 modes that you can switch between them: Form and Source Same name as declared inside the NED file

12 FAMOUS TIC-TOC EXAMPLE
4. Launching the simulation program ≡ Build and Run your program Building and compiling your project: Project > Build Project Building, compiling and running your project from the IDE : N.B: Main Window shows simulation time. i.e. It has nothing to do with the actual time it took to run the simulation. How many seconds you can simulate in 1 real world second depends on: the speed of your hardware Nature and complexity of simulation model

13 FAMOUS TIC-TOC EXAMPLE
Visualizing on a sequence chart In the configuration file : record-eventlog = true A “.elog” file is created in the Results folder in your project folder

14 Enhancing the 2-node Tic Toc Tutorial
Adding Icons : Making GUI looks prettier Adding Logging : Add log statements in your C++ code using “EV”command. Adding State Variables: EX.: Add a counter to the module and delete after 10 messages. The Command “WATCH(counter)” in the source makes it possible to see the counter value in the graphical runtime environment Adding Parameters: Ex. Turn the "magic number" 10 into a parameter and add a boolean parameter to decide whether the module should send out the first message in its initialization code First module parameters have to be declared in the NED file. The data type can be numeric, string or bool. Then the C++ code has to be modified to read the parameter. N.B: we can assign the parameters in the NED file or from omnetpp.ini.

15 Enhancing the 2-node Tic Toc Tutorial
Modeling Processing Delay: Ex. Instead of immediately sent back the received message. Let tic and toc hold the message for 1 simulated second before sending it back. In OMNeT++ such timing is achieved by the module sending a message to itself. Such messages are called self-messages (but only because of the way they are used, otherwise they are ordinary message objects). We "send" the self-messages with the scheduleAt() function, specifying when it should be delivered back to the module “scheduleAt(simTime()+1.0, event);” In handleMessage() we differentiate whether a new message has arrived via the input gate or the self-message came back (timer expired) by either comparing the message with timer name: if (msg == event) or using if (msg->isSelfMessage())

16 Enhancing the 2-node Tic TocTutorial
Random Numbers and Parameters: Ex. Change the delay from 1s to a random value which can be set from the NED files or from omnet.ini. Module parameters are able to return random variables; however, to make use of this feature we have to read the parameter in handleMessage() every time we use it. - No matter how many times you re-run the simulation or restart it, you'll get exactly the same results. - This is because OMNeT++ uses a deterministic algorithm (by default the Mersenne Twister RNG) to generate random numbers, and initializes it to the same seed. This is important for reproducible simulations. You can experiment with different seeds if you add the following lines to omnetpp.ini: [General] seed-0-mt= # or any other 32-bit value - OMNeT++ supports more than one RNGs.

17 Milestone 1 – Introduction to Omnet++
Deadline: Thursday 21st March, 2019. Carry out the tic-toc tutorial Choose a different distribution for Tic and Toc 2.1 Plot the first 100 arrival delays for each 2.2 Change the seed of your simulation and repeat step 2.1 Modify your C++ code so that Toc "loses" (delete) the message with a 50% probability. 3.1 Record the message Success rate for each of the 2 nodes Hints to use: finish() method of cSimpleModule and recordScalar() function.

18 Project Groups of 2 Register your group on the google sheet
kLt6kj7tSD_w5FDtwO1WaXmuJsi29HxiEHw Zip and send your zipped project folder, along with the required output to:

19 Other Milestones Detailed description: to be updated
Milestone 2 – Modeling a Network Protocol Deadline: 11th of April, 2019 Milestone 3 – Modeling a Real Network Deadline: 25th of April, 2019

20 References https://doc.omnetpp.org/omnetpp/manual/
Tic Toc Tutorial in Omnet++ Help


Download ppt "Modeling and simulation [NETW707] Tutorial5 – Introduction to Omnet++"

Similar presentations


Ads by Google