Showing posts with label OMNet. Show all posts
Showing posts with label OMNet. Show all posts

Tuesday, April 10, 2007

OMNet++ Development in Windows

I use OMNet++ for research purposes mostly in Linux but recently I needed to run it on a Windows environment. The instructions on how to install OMNet++ on Windows are not so useful and it took me a while to get it right. Here are the instructions I followed to get OMNet++ on Windows 2000 and Windows XP.

Windows 2000 preparations

To get an OMNet++ development environment on Windows 2000 it is necessary to have the most recent service pack SP4Express_EN.exe. If you don't have it simply download and install it.

You also need at least version 6.0 SP1 of Internet Explorer that you can download for free here.

If you are using Windows XP make sure you have the newest service pack installed too.

Setting up the development environment

To compile OMNet++ itself and our own models we need a compiler. Fortunately Microsoft is offering free versions of their IDE's (Integrated Development Environments). I will use Visual C++ Express Edition to develop OMNet++ in Windows.

Download and install it from this url. You also need to register your copy that is free and easy to do if you already have a hotmail.com account.

Next Download and install the Platform SDK that contains some needed header files.

Installing OMNet++ binary in Windows

(optional): To get support for images in Neddoc you need to install Ghostscript before installing OMNet++ . Download and install it from here.

Get the OMNeT++ 3.3 win32 binary (exe) from http://www.omnetpp.org/filemgmt/viewcat.php?cid=2 and install it.

(caution1): For some reason the binary available at the OMNet++ web page gives me a CRC error when I execute it. To bypass the CRC check run the installation binary from the command prompt with the /NCRC switch:

c:\> omnetpp-3.3-win32.exe /NCRC

(caution2): When asked for the installation directory make sure to choose a path that has no blank spaces as this may cause some problems when compiling.

During the installation you will be asked for the Ghostscript binary. Select the path were you installed Ghostscript or simply skip if you do not have it installed. Then you will be asked to choose the Visual C++ release you are going to use. If you followed this instructions then you must have Visual C++ 2005 installed so choose vc-81. If you have Visual C++ 2003 (aka 7.1) then choose the vc-71 release. Visual C++ 6.0 is known to have problems when compiling OMNet++ models so upgrade to a newer version of Visual C++ is recommended.

Create a quick launch link (optional)

I like to create a .bat file that sets up the necessary environment variables for OMNet++ development. To do this I simply create an batch file "omnetenv.bat" on the C:\ root that contains the following:

call "C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat"

SET PATH=%PATH%;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin
SET INCLUDE=%INCLUDE%;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include
SET LIB=%LIB%;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib

The first command is a call to the vcvarsall.bat script that comes with the Visual C++ that sets up all the environment variables needed for C++ development. We also need to add the Platform SDK bin, include and lib directories to the respective environment variables. Make sure to change the directory paths to reflect your installation paths.

To call this omnetenv.bat script I create a desktop shortcut by selecting "Create new shortcut" in the Desktop context menu (i.e. right click) and filling the following items:

Command = %comspec% /k C:\omnetenv.bat
Name = OMNeT++ Development

Clicking on this new shortcut will open a Command Prompt windows (cmd.exe) call the omnetenv.bat script and stay there waiting for input. From this point on we can start developing OMNet++ models. If you are new to OMNet++ then I recommend you to follow the TicToc tutorial.

If you do not have a text editor to code consider using SCiTe.

Mobility Framework in Windows

Once OMNet++ is installed you may consider using the Mobility Framework to develop sensor network and ad hoc network models.

Simply download the Mobility Framework (mobility-fw2.0p3.zip) source code and uncompress it somewhere. Make sure the directory path you choose has no blank spaces in it (i.e. Program Files).

Enter the source directory and edit the mkmk.cmd file and make sure the OMNET_ROOT variable points to the root directory where you installed OMNet++. Make sure you have the OMNet++ development environment setup (i.e. run omnetenv.bat) and run the following commands:

mkmk.cmd
nmake -f Makefile.vc all

This will setup and compile the Mobility Framework. Once it finishes you can proceed to create Mobility Framework models using the template files and the Makefile.gen file as described in the documentation.