|
Main /
OMNeT++ in a NutshellThis page is for those who are somewhat familiar with network simulators, and would like to find out in a few minutes what OMNeT++ is about. It is probably a good idea to keep the User Manual and the API open in other browser tabs, so that you can search for more info there when you find something interesting in this text. How do those simulation models and frameworks mentioned on omnetpp.org relate to OMNeT++?OMNeT++ provides the basic machinery and tools to write simulations, but itself it does not provide any components specifically for computer network simulations, queueing network simulations, system architecture simulations or any other area. Instead, these application areas are supported by various simulation models and frameworks such as INET/INETMANET, MiXiM or Castalia. These models are developed completely independent of OMNeT++, and follow their own release cycles. What does OMNeT++ provide then?A C++ class library which consists of the simulation kernel and utility classes (for random number generation, statistics collection, topology discovery etc) -- this one you will use to create simulation components (simple modules and channels); infrastructure to assemble simulations from these components and configure them (NED language, ini files); runtime user interfaces or environments for simulations (Tkenv, Cmdenv); an Eclipse-based simulation IDE for designing, running and evaluating simulations; extension interfaces for real-time simulation, emulation, MRIP, parallel distributed simulation, database connectivity and so on. OK. What does an OMNeT++ simulation model look like?OMNeT++ provides a component architecture. Models are assembled from reusable components, modules. Well-written modules are truly reusable and can be combined in various ways like LEGO blocks. Modules can be connected with each other via gates (other systems would call them ports), and combined to form compound modules. Connections are created within a single level of module hierarchy: a submodule can be connected with another, or with the containing compound module. Every simulation model is an instance of a compound module type. This level (components and topology) is dealt with in NED files. To give you an idea, a component named //
// Ethernet CSMA/CD MAC
//
simple EtherMAC {
parameters:
string address; // others omitted for brevity
gates:
input phyIn; // to physical layer or the network
output phyOut; // to physical layer or the network
input llcIn; // to EtherLLC or higher layer
output llcOut; // to EtherLLC or higher layer
}
And it could be used in the model of an Ethernet station like this: //
// Host with an Ethernet interface
//
module EtherStation {
parameters: ...
gates: ...
input in; // for connecting to switch/hub, etc
output out;
submodules:
app: EtherTrafficGen;
llc: EtherLLC;
mac: EtherMAC;
connections:
app.out --> llc.hlIn;
app.in <-- llc.hlOut;
llc.macIn <-- mac.llcOut;
llc.macOout --> mac.llcIn;
mac.phyIn <-- in;
mac.phyOut --> out;
}
Comments are useful for generated documentation; see an example here). Simple modules which, like network EtherLAN {
... (submodules of type EtherStation, etc) ...
}
NED files can be edited both graphically and in text mode in the Simulation IDE. NED only defines the model structure (topology), and leaves behaviour and a subset of module parameters open. As mentioned above, behaviour is added via C++ code behind simple modules, and module parameters which are left unassigned in NED files will get their values from ini files -- we'll cover these topics later. The OMNeT++ manual has a chapter about the NED language. How do I run this thing?Provided that you're lucky enough to have Building the simulation program is usually quite straighforward. In the simplest case, when everything is in one directory (and OMNeT++ is properly set up), you just need to type opp_makemake --deep make opp_makemake creates a makefile with the appropriate settings, so you don't have to do anything else. If you have sources in several directories, such as when you use some model framework like the Mobility Framework or the INET Framework, then this simple method of generating the makefile won't work, because the simulation will need to link with code from other directories as well. Then you'll need to pass additional options to opp_makemake such as To run the executable, you need an $ ./etherlan OMNeT++/OMNEST Discrete Event Simulation (C) 1992-2005 Andras Varga [....] <!> Error during startup: Cannot open ini file `omnetpp.ini' One function of the ini file is to tell which network to simulate (there might be more than one [General] network = etherLAN *.numStations = 20 **.frameLength = normal(200,1400) **.station[0].numFramesToSend = 5000 **.station[1-5].numFramesToSend = 1000 **.station[*].numFramesToSend = 0 As you can see you can use wildcards when assigning module parameters. Parameter assignments in the NED file take place first, and those left unassigned can be assigned in the ini file. (That is, parameter values in NED cannot be overwritten from the ini file.) If there are still parameters without a value, those ones will be asked interactively at runtime. Why do we have separate NED and ini files, why isn't everything contained in a single model file? Simulation is about creating a model, experimenting with it, and drawing conclusions. In OMNeT++, C++ and the NED files represent the model, and experiments are described in ini files: parameter values, results to collect, seeds etc. Ini files let you keep the model unchanged while you're exploring the parameter space. (Note that parameters can also affect the topology, e.g. can denote the number of nodes in the network). To load an ini file with a different name, pass the file name as command-line argument. More than one ini file can also be loaded, with the effect of their contents getting merged. $ ./etherlan common-settings.ini params15.ini seeds3.ini Ini files also support inclusion, which is useful if you have common settings to factor out. The manual describes the ini file facility in detail, including a complete list of ini file options supported. By default, the simulation executable builds with the graphical user interface, Tkenv. To run the simulation under the command-line (batch) user interface Cmdenv, specify the $ ./etherlan -u Cmdenv It is also very easy to link the simulation with only Tkenv or Cmdenv. Since it's this easy to switch to a different UI, you could create your own GUI as well if you wanted. This is easier than you think -- reading How to use the Tkenv GUI? Here we don't go into details -- please explore it by clicking and right-clicking everywhere, looking into the menus, etc. There are also resources in the Wiki's Omnetpp4 section. What is the output of the simulation?The simulation results are recorded into output vector ( An output vector file contains several output vectors, each being a named series of (timestamp, value) pairs. Output vectors can store things like queue length over time, end-to-end delay of received packets, packet drops or channel throughput -- whatever the simple modules in the simulation have been programmed to record. You can configure output vectors from Output vectors capture behaviour over time. Output scalar files, on the other hand, contain summary statistics: number of packets sent, number of packet drops, average end-to-end delay of received packets, peak throughput. To check output scalars in the C++ code, look for Simulation results can be visualized in the Analysis Editor of the OMNeT++ IDE. What about random numbers?OMNeT++'s default random number generator is Mersenne Twister. (A legacy LCG generator with a 231-1 long sequence is also available and can be configured in Several distributions are supported (in the 3.2 version 14 continuous and 6 discrete distributions, see the API doc), and they are available from both NED and C++. Non- Can I do MRIP, parallel distributed simulation, network emulation, or feature X with OMNeT++?Yes. OMNeT++ is very extensible, plus you have all of the source code, so the sky is the limit. Several features are supported out of the box, and it is easier and cleaner to implement others than you think. Ask for guidance on the mailing list if you have such plans. MRIP stands for multiple replications in parallel, and Akaroa is an excellent tools for that. You'll need to download and install it separately, then configure and recompile OMNeT++ with Akaroa support enabled (see Very large simulations may benefit from the parallel distributed simulation (PDES) feature, either by getting speedup, or distributing memory requirements. If your simulation requires a few Gigabytes of memory, distributing it over a cluster may be the only way to run it. For getting speedup (and not actually slowdown, which is also easily possible), the hardware or cluster should have low latency and the model should have inherent parallelism. Partitioning and other configuration can be configured in Network emulation, together with real-time simulation and hardware-in-the-loop like functionality, is available because the event scheduler in the simulation kernel is pluggable. The OMNeT++ distribution contains a demo of real-time simulation and a simplistic example of network emulation, enough to give you hints if you're into this area. Real network emulation with the INET Framework is in the queue. Interfacing OMNeT++ with other simulators (hybrid operation) or HLA is also largely a matter of implementing one's own scheduler class. Once you get the idea you'll find that it's much easier to do than you would have thought. It is possible to replace And again, since you have the full source code, and it's structured and documented, you can implement pretty much all your ideas. If you contact me on the mailing list or directly, I'll be happy to give you some initial directions. OK! Now, how do I program a model in C++?Simple modules are C++ classes. You'll subclass from Modules primarily communicate via message passing, and timers (timeouts) are also handled with messages the module sends to itself (self-messages). Messages are either of class You can read about activity() as an alternative to handleMessage(), but in practice there are several good reasons to avoid using it.
You can send messages to other modules using the The basic message NetworkPacket {
fields:
int srcAddr;
int destAddr;
}
OMNeT++ is often used to simulate network protocol stacks, and Other A simple module's NED parameters can be read using the Message exchange is not always the most suitable way of interaction between modules. For example, if you have a designated module for statistics collection (very much preferred over global variables!!!), then instead of sending the statistics updates to it via messages, it is more convenient to regard the statistics module as a C++ object and call a public member function of it created for this purpose (e.g. Direct method calls have a few tricky details. First you have to find the other module: the INET's For debugging, it is essential that modules print some info about what they're doing. Instead of To record output vectors, you'd add a NED files describe static topology, but it is also possible to create modules and connections dynamically. This can be useful when you have the network topology in some other form than a NED file (plain text file, Excel sheet, database etc), or you truly want to create and delete modules dynamically during runtime. In the former case, often it is an easier solution to convert the data into NED by using Awk, Perl, Python, Ruby, Tcl or a series of regex find/replace operations in a text editor; however, if you're deciding for using dynamic module creation from C++, then invoking nedtool on a sample NED file and looking at the generated
Hope you've found this page useful. Suggestions, fixes, questions are welcome -- you can post them on the mailing list, or just add them below by editing the page. --Andras |