Integrating Real World Applications Into OMNeT++ PDF
Integrating Real World Applications Into OMNeT++ PDF
Integrating Real World Applications Into OMNeT++ PDF
TM-2008-2
ISSN 1613-849X
http://doc.tm.uka.de/tr/
2. The build environment for the real world application 3.4 Conclusions
has to be reconstructed in the OMNeT++ build envi- The solution using shared libraries includes all advantages of
ronment. This includes compiler and linker flags. the direct source code integration but heavily simplifies the
problems regarding management of both OMNeT++ and
3. External application dependencies have to be integrated real application build environments. The solution based on
into the OMNeT++ build environment. socket connections, is the easiest one but shows synchro-
4. Features like timers and threads that are used in real nization problems that may bias simulation results and ad-
world applications cannot be seamlessly integrated into ditionally, does only work if simulation speed is faster than
OMNeT++. real time. We hence consider the shared library approach
the best choice for the integration of real world applications
into OMNeT++. The rest of the paper will focus on this
Problems (1) to (3) concern the software build environment: integration technique. Section 4 will explain in more de-
Reconstructing the application’s build environment within tail how to integrate real world applications using shared
the OMNeT++ build environment involves integrating all libraries. Section 5 finally focuses on emerging problems
source files and applying all compile and link time switches and gives solutions.
that are needed by the real world application. This can re-
sult in incompatibilities and unstable code: Compile time
switches for character set, exception handling and thread- 4. INTEGRATION STEPS
ing, for example, can result in incompatibilities, break the This section focuses on the integration of real world appli-
build or produce runtime failures. Adding external depen- cations using the shared library approach introduced in sec-
dencies into the OMNeT++ build environment (3) can fur- tion 3.3. Section 4.1 will detail on the required adapta-
ther complicate the build or even make it impossible due to tions on real world application and OMNeT++. The nec-
link time incompatibilities between the external dependen- essary OMNeT++ NED environment will be explained in
cies and OMNeT++. section 4.2.
4.1 Preparing the application
Application Simple module
The first step of preparing the real world application for in-
tegration into OMNeT++ involves creating a simple module Application logic
using the base OMNeT++ class cSimpleModule. The func-
PayloadPacket
tionality of the application’s regular main method has to be
encapsulated into this simple module. The actual code of TcpPacket
the main method will be split into the simple modules con- IpPacket
structor and destructor as well as initialize and finish
Frame
methods. An initialization based on multiple stages can
be implemented using the simple module’s numInitStages Network abstraction and conversion
method.
cMessage
As next steo the network abstraction has to be built. Appli- IPDatagram
cations like intrusion detection systems or network analyzers TCPSegment
parse all protocol layers of a packet. Most often such appli-
cations provide their own parsers to access protocol con-
OMNeT++
tents. These parse the binary network packet and represent
the contents in a structured and easily accessible way. The
intrusion detection systems Bro [11] and Snort [10], for ex- Figure 2: Abstraction layer for OMNeT++/INET
ample, employ such structured protocol parsers. protocol representation and application-specific pro-
tocol representation.
OMNeT++ uses protocol classes that are transmitted within
the simulation model as objects in the simulation process
space. The OMNeT++/INET protocol classes, however,
are different from real binary network data. It is thus not
If the first approach can not be applied the serialization
possible to use the OMNeT++ protocol objects directly for
functions in OMNeT++/INET can be used to serialize the
protocol parsing based on RFC-conform protocol parsers.
protocol objects into a binary Pcap [7] structure (2). This
Figure 1 compares a binary IP packet format which is RFC-
way a Pcap interface can be emulated that provides generic
conform and a binary representation of an IP packet used by
access to all network data including all protocol layers for
OMNeT++/INET. The binary representation for the OM-
the real world application. This approach can e. g. be used
NeT++/INET IP packet was derived from the IPDatagram
when the real world application does not employ protocol
message definition in the IPDatagram.msg file. It can be
parsers but accesses protocol contents through the use of
easily seen that the binary formats are different and that
simple offsets into the binary packet data.
normal protocol parsers can not be used for both formats.
Thus, it is not possible to transparently operate the original
The packet delivery model in the application may differ
protocol parsers of the real world application.
from the event driven approach used in OMNeT++. In an
OMNeT++ simulation packets are delivered through a call-
Integrating a real world application including the applica-
back function, i. e. in a push-based manner. Network ac-
tion’s original parsers is possible by using an abstraction
cess interfaces like Pcap allow pull-based mechanisms to be
layer for the network data. This involves converting the
used instead. If the application uses a pull-based method
OMNeT++-specific protocol objects into structures that are
to access network packets additional buffers must be im-
used inside the application. There exist two different ways
plemented to emulate pull-based network packet access in
to achieve this:
OMNeT++.
Insert e Insert e
Us Us
TCPSegment Func1
UDPPacket Func2
... ...
bol space that are currently needed and thus, unresolved. during runtime, e. g., when the application loads a plugin
Symbols that are not needed at this moment are discarded that depends on func1 or func2.
and not mapped into the symbol space. A plugin that may
get dynamically loaded by the application at a later time The nonexistence of C++ namespaces in OMNeT++ can
may rely on this functionality. Because the functionality has cause further problems that need to be considered. Every
not been mapped into the symbol space at startup loading class in the real world application is compiled into a symbol.
the plugin will fail. This symbol is mapped into the process space and represents
the entry point for the usage of the actual functionality. Two
Figure 3 shows an exemplary scenario where OMNeT++ classes having the same name compete against the symbol
dynamically loads the real world application’s shared library. space entry and will swap one another. This results in the
All symbols that the real world application depends on, e. g. wrong class being instantiated and actually used at runtime.
TCPSegment, are resolved and thus, can be used by the real Function calls on the class will result in the wrong memory
world application. All symbols in the real world application location being executed and fail with access violation errors.
that are currently needed are resolved, too. All symbols that The problem can be resolved by using C++ namespaces in
are currently not needed are not inserted into the symbol the real world application or taking care that no class name
cache. This results in func1 and func2 not being inserted in OMNeT++ and the real world application clash.
into the symbol cache. If the application loads a plugin that
relies on func1 or func2 this functionality – which resides
in the application – is not accessibly by the plugin. 5.4 Process space issues
When deploying several instances of the same application
The solution to this problem is quite easy but requires a on the same machine using e. g. Linux, every instance re-
change in the OMNeT++ code itself. The OMNeT++ code sides in its own process space. Under an OMNeT++ simula-
for loading shared libraries is located in the file loadlib.h tion multiple instantiations of the same application’s simple
at include/platdep/. The method opp_loadlibrary uses module result in the fact that all instances reside in the same
the dlopen method to load shared libraries dynamically at process space. This means that using the real world applica-
runtime. This method call needs to get extended using the tion on several nodes in the simulation network results in all
RTLD_GLOBAL option. Thus, the resulting function call looks application instances sharing the same process space. Every
as follows: static variable or object is thus shared between all instances.
Therefore, special care is needed if static variables and static
dlopen (libfname.c_str(), RTLD_NOW | RTLD_GLOBAL) objects like singletons are used.
The shared process space, however, can also have positive ef-
This causes all symbols in the application shared library to fects on the simulation performance: Shared memory pools,
be mapped into the symbol space when loaded by e. g. by using the Boost Pool Library [3], or the usage of
OMNeT++. This includes symbols that are currently not singleton objects result in smaller overall memory usage and
needed. Thus, symbols that are needed by plugins can be less CPU time consumption. This may speed up simulation
resolved successfully, even at a later point of time. execution.
Based on the changes described above all symbols in our
example that are available in the real world application are 6. CONCLUSIONS
inserted into the symbol cache and available for later usage Integrating real world applications into a simulation environ-
by plugins. This means that func1 and func2 are inserted ment like OMNeT++ enables an evaluation of their behavior
into the symbol cache at the time the shared library of the in large simulated networks. Furthermore, it is possible to
real world application is loaded. Thus, they are available design and evaluate the behavior of distributed real world
Table 2: Advantages and disadvantages of discussed integration techniques.
Integration technique Advantages Disadvantages
Socket connection Applications like servers and clients can be CPU and timing issues make this integration
integrated without changes to the application technique unstable, inefficient or even impos-
source code. sible to perform.
Source code integration No CPU or time domain issues, thus no bias. Need to reconstruct application build envi-
Straightforward integration method. Easy to ronment with OMNeT++. Applications with
integrate small and simple applications. special compiler and linker settings can not be
integrated due to incompatibilities with OM-
NeT++. Source code adaptations needed.
Shared library integration All advantages of source code integration. Source code adaptations needed.
Avoids problems of build environment and in-
compatibilities.
applications more easily and cost-efficient than in real net- [5] T. Gamer and M. Scharf. Realistic Simulation
works. We presented several techniques that can be used to Environments for IP-based Networks. In Proceedings
integrate existing real world applications into OMNeT++ of the OMNeT++ Workshop, Marseille, France,
and discussed their pros and cons. Focusing on the ap- March 2008.
proach to use shared libraries for integration we presented [6] T. Gamer, M. Scharf, and M. Schöller. Collaborative
detailed instructions how to realize this solution. Addition- Anomaly-based Attack Detection. In Proceedings of
ally, emerging challenges are explained and solutions are IWSOS, pages 280–287. Springer, August 2007.
provided. Table 2 gives a concluding overview of advantages [7] V. Jacobson, C. Leres, and S. McCanne. Tcpdump
and disadvantages of the different integration techniques dis- Pcap. http://www.tcpdump.org, 2000.
cussed in this paper. [8] S. Jansen and A. McGregor. Simulation with real
world network stacks. In Proceedings of the 2005
A well designed network application can be integrated into Winter Simulation Conference, pages 2454–2463,
OMNeT++ more easily than badly structured code. Any- December 2005.
way the integration can be time consuming and complex. It [9] PlanetLab. PlanetLab: An open platform for
would be desirable to have better support by OMNeT++ developing, deploying, and accessing planetary-scale
for the integration of real world applications. Future work services. http://www.planet-lab.org, 2002.
should focus on OMNeT++ extensions that can easily de- [10] M. Roesch. Snort. http://www.snort.org, 2001.
ploy existing real world applications without the need for [11] R. Sommer. Bro: An Open Source Network Intrusion
major adaptations on the application side. Detection System. In Proceedings of the 17.
DFN-Arbeitstagung über Kommunikationsnetze, pages
7. REFERENCES 273–288, June 2003.
[1] I. Baumgart, B. Heep, and S. Krause. OverSim: A [12] R. M. Stallman and R. McGrath. GNU make.
Flexible Overlay Network Simulation Framework. In http://www.gnu.org/software/make, 1988.
Proceedings of 10th IEEE Global Internet Symposium [13] A. Varga. The OMNeT++ Discrete Event Simulation
(GI), pages 79–84, May 2007. System. In Proceedings of the European Simulation
[2] R. Bless and M. Doll. Integration of the FreeBSD Multiconference, pages 319–324, June 2001.
TCP/IP Stack into the discrete event simulator [14] A. Varga. How to extend INET with your own C++
OMNeT++. In Proceedings of the 2004 Winter code. http://www.omnetpp.org, June 2005.
Simulation Conference, pages 1556–1561, December
[15] A. Varga. OMNeT++ Discrete Event Simulation
2004.
System User Manual, 2005. Version 3.2.
[3] S. Cleary. Boost Pool Library.
[16] W. Willinger, M. S. Taqqu, R. Sherman, and D. V.
http://www.boost.org/libs/pool, 2000.
Wilson. Self-similarity through high-variability:
[4] D. Dittrich. The ”Tribe Flood Network” distributed statistical analysis of ethernet LAN traffic at the
denial of service attack tool. source level. In Proceedings of ACM SIGCOMM,
http://staff.washington.edu/dittrich/misc/tfn.analysis, pages 100–113, February 1995.
October 1999.