How to Build Networks
The purpose of this tutorial is to show you how to build network models from existing components with the INET framework, a simulation model suite for TCP/IP and Internet-related protocols, written for the OMNeT++/OMNEST simulation environment.
To follow the tutorial, you need a binary (executable) version of the INET framework. The easiest is to download and install the Windows demo for INET. Alternatively (or if your platform is Linux or some other OS), you may download and compile the OMNeT++ and INET source packages.
The OMNeT++ (OMNEST) simulation framework follows a layered approach. Model components which implement protocols, application behaviour, shared media and suchlike are programmed in C++. These components are then combined into larger components (models of routers, hosts) using the NED language. Networks, subnetworks are assembled from hosts and routers exactly the same ways as hosts and routers from protocols, using the NED language.
Components programmed in C++ are termed simple modules, and larger components assembled from them are compound modules. Network models to be simulated are just instances of a compound module representing the network.
The INET.exe program (part of the demo, or a product of the build process) contains all C++ components of the INET framework as well as the simulation kernel and the graphical user interface. NED files are loaded dynamically by INET.exe when it starts -- which means you can add you own NED files, that is, you can create your own networks to be simulated. You'll only need a text editor for that (Notepad will suffice, but you're better off with a programmer's editor like UltraEdit or MED).
Models defined via NED file usually contain a large number of unbound parameters. These parameters will be assigned from the config file omnetpp.ini; this file can be kept short by using wildcards (*, **) to assign several parameters at once.
So far the theory, let's see the practice!
To jump-start, we'll start by copying and modifying an existing simulation. This way we'll have something working right from the beginning. Let's start with the NClients demo simulation in the INET folder.
The INET/NClients directory contains the following files:
README NClients.bat NClients.ned omnetpp.ini basicHTTP.ini filetransfer.ini
Create a working directory somewhere on your hard disk (e.g. C:\work\TryINET) and copy there all the above files. Then let's see what we have.
README contains a short description of the NClients model -- you can read it once, but we won't need it any further.
NClients.bat is a batch file to start the simulation. Its contents reads like this:
..\..\bin\INET.cmd %*
... which instantly makes you open it in your text editor (or as the last resort, Notepad), and adjust the path to the directory where you actually have INET installed. For example:
C:\INET-Demo\bin\INET.cmd %*
The batch file calls INET.cmd (and not directly INET.exe) because the executable needs a few environment variables (PATH, OMNETPP_BITMAP_PATH, TCL_LIBRARY) which are set by INET.cmd before launching INET.exe. %* just passes on any command-line arguments you might have given NClients.bat.
In case you don't have INET.cmd somehow (e.g. because you compiled INET yourself), here's what it contains:
@echo off set PATH=%PATH%;%~dp0\..\RESOURCES\bin set OMNETPP_BITMAP_PATH=%~dp0\..\RESOURCES\bitmaps set TCL_LIBRARY=%~dp0\..\RESOURCES\lib\tcl8.4 %~dp0\INET.exe %*
The %~dp0 magic stands for drive+path of %0, where %0 is the full path of the cmd file itself. Thus, %~dp0\INET.exe for example simply means "the INET.exe in the same directory as the cmd file." The cmd file extends the path to include the location of the necessary DLLs, sets OMNETPP_BITMAP_PATH to point to the location of the model icons, and sets TCL_LIBRARY to point to the directory which contains init.tcl, then launches the executable. If the locations are OK, you don't need to modify the cmd file.
NClients.ned contains the simulation model.
I hope you've found this tutorial useful. If you have questions, comments or suggestions to improve it, please write to andras at omnetpp org.