Вы находитесь на странице: 1из 43

See

discussions, stats, and author profiles for this publication at: https://www.researchgate.net/publication/307446661

Instructions to install ns3 (version 3.25) on native Windows


platform and Eclipse IDE.

Method · July 2016


DOI: 10.13140/RG.2.2.13607.75683

CITATIONS READS

0 1,235

1 author:

Sanjeev Sondur
Temple University
10 PUBLICATIONS 4 CITATIONS

SEE PROFILE

All content following this page was uploaded by Sanjeev Sondur on 30 August 2016.

The user has requested enhancement of the downloaded file.


Download, Install, Config “ns3”
network simulation tool on native
Windows OS with Eclipse IDE
sanjeev.sondur@temple.edu

Legal Disclaimer: These are my personal views & experiences. Use it at your own discretion.

All legal disclaimers, Use at your own discretion 1


Notes before starting
• Time durations are given as an
approximate reference only
• You would most likely be running
Windows 64 bit OS (double check
this on your computer properties).
• So you have download all 64 bit
software components. Mix &
match 32/64 bit components will
not work and is very hard to debug.
• I have given all 64 bit examples
here. Follow given URLs.
• Best practice: I suggest create
directory structure as shown to
store all downloads and another
sub-dir to install all software

All legal disclaimers, Use at your own discretion 2


Download components
• cygwin
• eclipse C++ IDE
• ns3 simulation tool (latest version) [1, 2]
• qt-creator C++ IDE
• Note:
– No source code control: I’m assuming you are the lone developer (or at least
have a small team with other code sharing means) <you do not need any
source control system, this is confusing, adds one more layer. Everything will
still work fine.
– Difference components/ software use different IDE & compilers etc to build the
projects.
– You will find multiple installs of MinGW (another gcc compiler), but we will not
be using any version of this

All legal disclaimers, Use at your own discretion 3


Time taken:
cygwin (#1) 2hrs to download
5min to config
• Install cygwin:: download 64 bit
• Install instructions: Make sure you select “devel” and “python” options.
• At end of installation: you will have a cygwin64 ‘terminal’ on your desktop
• Note: cygwin is a linux like shell (but you don’t have to worry too much)
• Append $cygwin_home$\bin to Windows PATH env variable
• Check on Windows (DOS) command prompt that “gcc” & “g++”
executables are reachable.

All legal disclaimers, Use at your own discretion 4


cygwin (#2)
• Rename python executable file.
• Python is a softlink file in cygwin/bin (you will need to start cygbin64 shell
with administrator rights)
• mv python python_old
• cp python.3.4.m.exe python.exe (exe extension is important)
• Check that “python” executable is reachable from Windows shell.

All legal disclaimers, Use at your own discretion 5


Time taken:
eclipse (#1) 30min to download
30min to config
• Install eclipse:: download 64 bit
• Note: Get the 64 bit installer from
above link, do not use direct C++
IDE download links or other links.
It’s not clear which version you get.
Also do not take direct zip files.
• Use the eclipse-inst-win64.exe to
get the correct software.
• Install eclipse.

All legal disclaimers, Use at your own discretion 6


eclipse (#2)
• Configure eclipse to use cygwin compiler
• Test run a small c++ helloWorld program (very important).
• Writing your 1st C++ program and test it.
• Important follow steps to overcome “unresolved inclusion errors”
• Export all your path settings as shown below for later use.

All legal disclaimers, Use at your own discretion 7


Any other software?
• Source code control: I’m assuming you are the lone developer (or at least
have a small team with other code sharing means) <you do not need any
source control system, this is confusing, adds one more layer. Everything
will still work fine.
• So, I am NOT installing mercurial or MinGW or other..
• Installing on a VMWare image/ Linux has its own limitations and
advantages (as is Windows platform- BSOD vs additional layers)

All legal disclaimers, Use at your own discretion 8


Time taken:
ns3 simulator (#1) 5min to download
2hrs to build
• Install latest release of ns3 software:: (example: ns3.25)
• Note: After the download, be careful. All further operations need you to
execute under ‘cygwin64’ shell (not Windows/DOS shell)
• Open cygwin64 shell and follow instructions to unzip the ns3 software in
its own directory (there is no separate install routine)
• I suggest you “selectively” follow the PDF document to build ns3 on
windows + cygwin platform.
• Skip “bake download” , “waf configure” etc. You can directly start building
ns3 as given below. (go to correct sub-directory).
– ./build.py --enable-examples --enable-tests OR
– ./waf --build-profile=optimized --enable-examples --enable-tests configure
• Note: If you get any errors or gcc/g++ crash (segmentation fault), then you
have a 32/64 bit version mixed. [1, 2]

All legal disclaimers, Use at your own discretion 9


configure eclipse for ns3 (#1)
• Do NOT use/install/configure “Mercurial”. This is a source code control
software for team collaboration. As given earlier, I did these steps without
using it.
• I have given screen shots to help you follow the instructions in these links
[1, 2, 3, 4].
• As earlier, first test your small helloWorld C++ (not C) program before
proceeding to ns3 parts.
• Summary of steps are given next with screen shots, follow above
documents for complete instructions.

Time taken:
5min to download
All legal disclaimers, Use at your own discretion 10
30min to configure
configure eclipse for ns3 (#2)
• Add new C++ project in eclipse
• (Use existing source directory from ns-3)

All legal disclaimers, Use at your own discretion 11


configure eclipse for ns3 (#3)
• After creating the project, set project properties
• Right click on project properties.
• Set build directory, build command

All legal disclaimers, Use at your own discretion 12


configure eclipse for ns3 (#4)
• Set build behavior and build commands

All legal disclaimers, Use at your own discretion 13


configure eclipse for ns3 (#5)
• Set environment variable ($path$)
• Note: see image: cygwin/bin path is appended at beginning and $project$
path is appended at end.

All legal disclaimers, Use at your own discretion 14


configure eclipse for ns3 (#6)
• Set Tool Chain Editor for correct compiler

All legal disclaimers, Use at your own discretion 15


configure eclipse for ns3 (#7)
• Set the path for libraries
• Import earlier setting from helloWorld project

All legal disclaimers, Use at your own discretion 16


configure eclipse for ns3 (#8)
• After import (or manual set), verify path and libraries for both GNU C &
GNU C++

All legal disclaimers, Use at your own discretion 17


configure eclipse for ns3 (#9)
• Set debug configurations, I have shown this for debug only.
• Optional: you can set these same settings for release.
• Menu Run Debug configurations

All legal disclaimers, Use at your own discretion 18


configure eclipse for ns3 (#10)
• Set the executable file (note: ns3 uses waf to execute your program, and
further takes an argument).
• Your argument will be shown as string prompt during start of run

All legal disclaimers, Use at your own discretion 19


configure eclipse for ns3 (#11)
• Set the LD_LIBRARAY_PATH variable
• Use exact syntax, does not take variables.

All legal disclaimers, Use at your own discretion 20


configure eclipse for ns3 (#12)
• After your project configuration, and when you are ready with your
test/example program, you can run it using Run command.
• This will run your program using ns3:waf (as identified by string prompt).
• Results will appear in eclipse ‘console’ output panel.

All legal disclaimers, Use at your own discretion 21


netamin & qt-creator (#1)
• Install and configure Qt-creator (yet another C++ IDE) to compile netamin
(ns3 animator)
• Download qt-creator (open-source or in-house/ student distribution)
• Note: During install “donot” associate common file types with QT
(uncheck the box) to avoid c++/c files opening in QT.
• Note: Uncheck “Enterprise Services” and “QT Cloud Services” and
“Purchasing” before install.
• Simple download, execute setup file, follow instructions, register login,
and straight forward to install.

Time taken:
30min to download
All legal disclaimers, Use at your own discretion
15min to build 22
netamin & qt-creator (#2)
• Double click on ‘netamin.pro’ file under netamin directory to directly open
project in qt-creator.
• Check project setting. (Create your own sub-dir to place all interim build
files as shown below).

All legal disclaimers, Use at your own discretion 23


netamin & qt-creator (#3)
• Build the project. I used ‘release’
version since it is compact and we
don’t need debug options on
netamin.
• netamin.exe should be ready soon.
Copy it from build/release sub-dir to
ns3 parent directory (optional: just
easy to find it later)
• Optionally you can “run” netanim
from qt-creator and verify it runs and
the net-animator program executes.

All legal disclaimers, Use at your own discretion 24


netamin & qt-creator (#4)
• You are almost done. To make netamin.exe work independently, I suggest
you create a ‘bin’ sub-dir and copy the relevant files.
• mkdir (sub-dir) ‘bin’ under “netamin” folder
• Copy the built netamin.exe and all its required dll files to the sub-bin
directory.
• These dependent dll files are located in multiple places. Be careful while
looking for these files & notice their size (important).
• Dependent dll files: libgcc_s_dw2-1.dll, libstdc++-6.dll, libwinpthread-1.dll,
Qt5Core.dll, Qt5Gui.dll, Qt5PrintSupport.dll, Qt5Widgets.dll, NetAnim.exe
• (search for above files & copy to “bin” subdir, if multiple files found –
compare size (prefer: take from mingw* directory).
• Will this create a good executable? Read on….
• What will happen when free qt-creator license expires?

All legal disclaimers, Use at your own discretion 25


netamin.exe (#1)
• Copy netamin.exe and dependent files into separate ‘bin’ subdir and test
from windows prompt
• But this will NOT work since there are hidden (more?) dependencies

All legal disclaimers, Use at your own discretion 26


netamin.exe (#2)
• Executing netamin.exe with the dlls in the right directory will NOT give you
the correct application with all the ICONs enabled.
• See image below

All legal disclaimers, Use at your own discretion 27


netamin.exe (#3)
• Solution: open qt-creator and copy the path variable as shown below
• Create a new netamin.bat batch file and set the path (as copied from qt-
creator)., and add netamin.exe in the next line

All legal disclaimers, Use at your own discretion 28


netamin.exe (#4)
• Creating the batch file with correct (full) path and executing
netamin.exe gets the correct/ complete application with all
icons/ operations

All legal disclaimers, Use at your own discretion 29


ns3 open source
• I guess this exposes the complexity of using an open source system.
• As seen- there are too many hidden dependencies and varieties of
systems involved.
• In its current version – you have to be an expert in development platform
to work with. Not productive enough for average user.
• Lots of future work is need to make this cleaner and more friendly.
• Better work would be port everything to eclipse without cygwin shell,
python and other non-C++ parts (such as removing qt-creator).
• Make this a strict C++ project portable across eclipse & gcc on Win/Linux
• Of course, devil is in the details – to recommend is easy / to implement is
yet another story.

All legal disclaimers, Use at your own discretion 30


Write & test some custom code (#1)
• We will copy an existing example, add the ns3::netanim animation.
• Compile it and execute it. View results graphically in netanim tool
• Using eclipse  Open <yourRoot>\ns-allinone-3.25\ns-
3.25\examples\tutorial\third.cc
• “Save as” your own file under <yourRoot>\ns-allinone-3.25\ns-
3.25\build\scratch\yourfilenamehere.cc
• Now using cygwin64 shell and the waf command, compile and run it.

All legal disclaimers, Use at your own discretion 31


Write & test some custom code (#2)
• Now add netamin code, AnimationInterface details.
• Following all tutorial and desperate help in forums is tiring & discouraging.
• Notes:
– In the beginning of the file, add headers as given in following images.
– Add AnimationInterface as shown in following images.
– Overcome execution time errors (not compile) by adding next few lines.
– Now using eclipse UI, compile, build and run it.

All legal disclaimers, Use at your own discretion 32


Write custom code (#1)
• Part 1 of code at
start of file.
• Add as given.

All legal disclaimers, Use at your own discretion 33


Write custom code (#2)
• Part 2 of code at end of file. Add as given.

All legal disclaimers, Use at your own discretion 34


Compile & run custom code (#1)
• Run project from “eclipse”.
• This will call waf build program and execute it

All legal disclaimers, Use at your own discretion 35


Compile & run custom code (#1)
• Watch project execution within “eclipse”.
• Watch console panel for messages (and for errors/ ignore warnings)
• Note: the netamin interface will create an output file ‘my1.xml’

All legal disclaimers, Use at your own discretion 36


View animation in netanim
• Open netanim using the batch file (created earlier)
• Open the my1.xml file (located under ns3:build directory)
• Run animation and view results

All legal disclaimers, Use at your own discretion 37


Native execution in windows
• Should I always use waf? cygwin?
• No, with little understanding – your code is a windows executable, It can
run natively.
In windows shell, run it from ‘build’ directory’

All legal disclaimers, Use at your own discretion 38


Native execution in cygwin
• In cygwin shell, set LD_LIBRARY_PATH (remember from earlier exercise)
In cygwin shell, run it from ‘build’ directory’

All legal disclaimers, Use at your own discretion 39


ns3 & netanim on Ubuntu
• Easy, straight forward, just follow instructions.
– Download and install: vmplayer, ubunto disk iso image.
– Start vmplayer Ubunto instance.
– Inside ubunto: download & install: eclipse & qt-creator & ns3 packages
– build & execute ns3 & netanim.
– Install missing library for Qt-creator.

Time taken:
2 hrs total for
All legal disclaimers, Use at your own discretion 40
download & build
Learn ns3/netanim
• Good tutorial, walks you with clarity

All legal disclaimers, Use at your own discretion 41


Conclusion
• Am I done? Is this all?
• No way – we are just scratching the surface
• ns3 & netanim are powerful tools, with lot of contribution from well
versed teams.
• It needs a very good understanding, clean organization, documentation to
make full use of its power.
• And it has a long way to go… and lots of things to achieve.
• GOOD LUCK

All legal disclaimers, Use at your own discretion 42


View publication stats

Вам также может понравиться