Wireless Sensor Network Simulation Using NetSim

Tarun Krishna T., Shashikant Suman and Pranav Viswanathan

7932
 

Software tools
Following software tools have been used to develop and test this program:

1. ‘C’ compiler. The project has been tested with Visual Studio 2005, Cygwin and Mingw.
2. Python 2.7 (http://www.python.org/download/)
3. Matplotlib 1.1.1 compatible with Python 2.7 (http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.1/)
4. Numpy 1.6.2 compatible with Python 2.7 (http://sourceforge.net/projects/numpy/files/)

Project folders (INSN_SampleProject). The project contains following folders:

Configuration_Files_Division/. ‘Configuration.xml’ has been divided into several parts so that the user can create a custom XML file from ‘C’ code (Main.c) using the following parts which don’t vary.

Dll/. All the dlls needed for running simulation are kept in this directory (taken from NetSim 6.1).

Documents/. This directory has all the documents corresponding to the project, and also some good reference documents to understand IEEE 802.15.4 standard.

Main.c. This ‘C’ code loads the dlls in Dll directory. It also loads the functions (Sample_WSN_Project_NetSim) required for simulation, and declares the function (scenario) for creating ‘Configuration.xml’ files into ‘/NetSim_Temp_Files’ directory.

PlotAll.py. For analysing the results after simulation, Python script has been used to plot the graphs. Numpy, fundamental package for scientific computing with Python, and Matplotlib, plotting library for Python, are used for plots.

753_Fig_4
Fig. 5: Running python.exe from command line

NetSim_Temp_Files/. This directory is used as a temporary directory for storing the configuration, trace and metrics files obtained in simulation.

Debug/. This directory is used by Visual Studio to create the exe file.

Output/. After each simulation, the trace files, metrics files and other files that are needed for analysis are copied to this folder automatically by the program.

(The various files contained in each of these folders have been given in the Readme.pdf file in ‘Document’ folder.)

Testing procedure
CYGWIN/MINGW. The procedure for building in ‘Cygwin’ is as follows:
1. Open ‘SampleProject/Main.c,’ modify the code as per your requirement and save it.
2. Open ‘Cygwin/MinGW’ terminal. Now open ‘SampleProject’ directory and run the following commands to compile and run the simulation:
(i) gcc Main.c -o Main.exe
(ii) ./Main.exe

You can refer to Fig. 2 for ‘Cygwin/MinGW’ output.

Visual Studio. For building with Visual Studio, proceed as follows:
1. Open ‘SampleProject.sln’ located in ‘SampleProject’ folder with Visual Studio 2005 or higher version.
2. Modify the parameters as needed in ‘SampleProject/Main.c’ and save it.
3. Build the project using the menu ‘Build→Build Solution’ or use the shortcut F7 (see Fig. 3).
4. Run the project using the menu ‘Debug→Start without Debugging’ or use the shortcut Ctrl+F5 (see Fig. 4).

Python. After running the simulation, use the Python script (PlotAll.py) to plot the graphs as described in WhitePaper.pdf. Note that the script saves the plots into output directory.

Python script can be run by double-clicking PlotAll.py file or you can run it via command line.

To run from command line, proceed as follows:
1. Open ‘WSN_SampleProject’ folder.
2. Check where ‘python.exe’ is present and use that path to run ‘PlotAll.py.’ For example, if ‘python.exe’ is located in ‘C:\Python27,’ use the path as shown in Fig. 5.

After each simulation, if needed, copy the plots and metrics files and save them in another folder before running the next simulation, as these files will get overwritten.

Now open ‘Output’ folder mentioned above. You will find the plots for beta, Pdiscard and throughput. These plots will give you the overall idea and status of the network.


Pranav Viswanathan, a B.Tech from IIT Madras, is a business manager at TETCOS. His interests include modeling and simulation, and wireless communication. Shashikant Suman, a B.Tech from IIT Kharagpur, is a senior developer at TETCOS. His interests include cognitive radio and wireless sensor networks. Tarun Krishna is a final-year student, IIT Madras, with interests in wireless sensor networks

SHARE YOUR THOUGHTS & COMMENTS

Please enter your comment!
Please enter your name here