Tutorial: Install ns-3 in Windows 7 using cygwin

  • Posted April 15, 2010. Last modified April 4, 2011 by

Ns-3 is one of the most popular simulation tools for network simulation. See the website: http://www.nsnam.org/. It is the successor to the popular ns-2 simulator. The tool is written in c++ / python, but I manage to get by using mostly only c++ (as opposed to ns-2 which uses c/c++ and tcl). One major difference between ns-3 and ns-2 is that this version has been designed for wireless network simulation from the ground up. (There is support for many types of 802.11 networks including 802.11s mesh networks which interest me).

The following instructions explain how to install the latest stable version of ns3 (as of April 14th, 2010 as of March 22nd 2011 with ns-3.10) on windows 7 with cygwin. It should work with newer releases as they come out, but if not leave me a message and I will update the instructions. I will try to include any common problems I have encountered, or those of users who comment on the post experience in order to make your install easier.

Step 1:
Download & install cygwin. (note: I install it in the recommended directory “{System Root}/cygwin/”). Make sure you select “install” for python and devel. This will ensure you have python and gcc/g++ as well as all of the dependencies. You can do this by clicking on the word default in the list of packages. I left all of the other package options on default for the install.

Step 2:
Download ns3.7.1Download the most recent version of ns3 from their website (you will likely want the all-in-one version if you are just starting out. Save the file to “{System Root}/cygwin/home/{your-username}”. Alternatively, you can try downloading the file directly within cygwin using something like “wget http://http://www.nsnam.org/releases/” where filename is the name of the release you wish to install.

Step 3:
Start cygwin. At the cygwin prompt type: “tar xvf ns-allinone-3.7.1.tar.bz2” (or whatever the filename is depending on the version you downloaded). This will unpack the ns3 archive so you can use it.

Step 4:
After it has unpacked, change directory to the new ns3 directory with the following: “cd ns-allinone-3.7.1”. Then build ns3 by typing the following: “./build.py”. You can probably grab a coffee or tea while it compiles.

ns3 cygwin windows 7

ns3 on windows 7 with cygwin

Step 5:
You should be good to go. You can validate the install by changing directory again to the ns-3.7.1 directory (“cd ns-3.7.1”) and running “./test.py”. It will let you know with a PASS / FAIL for each test case. You can now edit the files yourself. The scenario files are located in “” and the source files are located in “”. Good luck!

Note: For those getting remapping errors, I have finally had the same trouble. This is what worked for me: Open command prompt, change to your /cygwin/bin directory. Type: ‘ash’. Then type ‘/bin/rebaseall’. You can now try cygwin again and it may work. If it still does not work (this happened to me), you can apply this fix to the rebaseall script. (you can edit it using some tool like notepad within windows).

64 comments on “Tutorial: Install ns-3 in Windows 7 using cygwin”

  1.  

    when i use
    ./build in in ns-3-17 & 19

    ../src/fd-net-device/model/fd-net-device.cc:41:26: fatal error: net/ethernet.h: No such file or directory #include ^compilation terminated…/src/fd-net-device/model/fd-net-device.cc:41:26: fatal error: net/ethernet.h: No such file or directory #include ^compilation terminated…/src/fd-net-device/model/fd-net-device.cc:41:26: fatal error: net/ethernet.h: No such file or directory #include ^compilation terminated.

    and when use ns3-7 i find these mesage
    ^
    ../src/core/unix-system-wall-clock-ms.cc:78:55: error: ‘sysconf’ was not declared in this scope
    static int64_t ticksPerSecond = sysconf (_SC_CLK_TCK);
    ^
    Waf: Leaving directory `/home/nasr/workspace/ns-allinone-3.7/ns-3.7/build’
    Build failed
    -> task failed (err #1):
    {task: cxx unix-system-wall-clock-ms.cc -> unix-system-wall-clock-ms_1.o}
    Traceback (most recent call last):
    File “./build.py”, line 117, in
    sys.exit(main(sys.argv))
    File “./build.py”, line 108, in main
    build_ns3(config)
    File “./build.py”, line 56, in build_ns3
    run_command([“python”, “waf”])
    File “/home/nasr/workspace/ns-allinone-3.7/util.py”, line 24, in run_command
    raise CommandError(“Command %r exited with code %i” % (argv, retval))
    util.CommandError: Command [‘python’, ‘waf’] exited with code 1

    what is the problem

  2. Pingback: Post #1 Get start by standing upon the shoulders of Giants

  3. Pingback: Post #1 Get start by standing upon the shoulders of Giants

  4.  

    Dear Jason,
    When i install NS3.9 with this method.
    I got the following error:
    /src/core/unix-system-wall-clock-ms.cc:78:55: error: ‘sysconf’ was not declared in this scope
    static int64_t ticksPerSecond = sysconf (_SC_CLK_TCK);
    Then the build process stop and exit.
    The GCC version of the cygwin is 4.8.3
    Can you give me some advice on how to solve this problem?
    Thanks.

    •  

      Hi Everyone, the command ‘./build.py’ doesnt work if you dont have python installed. So install python in windows and set the environment path appropriately, and when u run the command it will execute.

  5. Pingback: Fix Cygwin Make Error 53 Windows XP, Vista, 7, 8 [Solved]

  6.  

    [ 929/1706] Compiling src\stats\model\gnuplot-aggregator.cc
    ..\src\topology-read\model\rocketfuel-topology-reader.cc:25:19: fatal error: reg ex.h: No such file or directory

    compilation terminated.

    Waf: Leaving directory `D:\ns-allinone-3.25\ns-3.25\build’
    Build failed
    -> task in ‘ns3-topology-read’ failed (exit status 1):
    {task 2973928701568: cxx rocketfuel-topology-reader.cc -> rocketfuel-top ology-reader.cc.1.o}
    [‘C:\\TDM-GCC-64\\bin\\g++.exe’, ‘-O0’, ‘-ggdb’, ‘-g3’, ‘-Wall’, ‘-Werror’, ‘-Wn o-error=deprecated-declarations’, ‘-fstrict-aliasing’, ‘-Wstrict-aliasing’, ‘-pt hread’, ‘-I.’, ‘-I..’, ‘-DNS3_BUILD_PROFILE_DEBUG’, ‘-DNS3_ASSERT_ENABLE’, ‘-DNS 3_LOG_ENABLE’, ‘..\\src\\topology-read\\model\\rocketfuel-topology-reader.cc’, ‘ -c’, ‘-o’, ‘D:\\ns-allinone-3.25\\ns-3.25\\build\\src\\topology-read\\model\\roc ketfuel-topology-reader.cc.1.o’]
    # Skip NetAnim (platform not supported)
    # Build NS-3
    Entering directory `.\ns-3.25′
    => D:\anacondnew\python.exe waf configure –with-pybindgen ..\pybindgen-0.17.0 .post49+ng0e4e3bc
    => D:\anacondnew\python.exe waf build
    Traceback (most recent call last):
    File “./build.py”, line 171, in
    sys.exit(main(sys.argv))
    File “./build.py”, line 162, in main
    build_ns3(config, build_examples, build_tests, args, build_options)
    File “./build.py”, line 82, in build_ns3
    run_command([sys.executable, “waf”, “build”] + build_options)
    File “D:\ns-allinone-3.25\util.py”, line 25, in run_command
    raise CommandError(“Command %r exited with code %i” % (argv, retval))
    util.CommandError: Command [‘D:\\anacondnew\\python.exe’, ‘waf’, ‘build’] exited with code 1

    this is the error i am getting while doing ./build.py

  7.  

    [ 929/1706] Compiling src\stats\model\gnuplot-aggregator.cc
    ..\src\topology-read\model\rocketfuel-topology-reader.cc:25:19: fatal error: reg ex.h: No such file or directory

    compilation terminated.

    Waf: Leaving directory `D:\ns-allinone-3.25\ns-3.25\build’
    Build failed
    -> task in ‘ns3-topology-read’ failed (exit status 1):
    {task 2973928701568: cxx rocketfuel-topology-reader.cc -> rocketfuel-top ology-reader.cc.1.o}
    [‘C:\\TDM-GCC-64\\bin\\g++.exe’, ‘-O0’, ‘-ggdb’, ‘-g3’, ‘-Wall’, ‘-Werror’, ‘-Wn o-error=deprecated-declarations’, ‘-fstrict-aliasing’, ‘-Wstrict-aliasing’, ‘-pt hread’, ‘-I.’, ‘-I..’, ‘-DNS3_BUILD_PROFILE_DEBUG’, ‘-DNS3_ASSERT_ENABLE’, ‘-DNS 3_LOG_ENABLE’, ‘..\\src\\topology-read\\model\\rocketfuel-topology-reader.cc’, ‘ -c’, ‘-o’, ‘D:\\ns-allinone-3.25\\ns-3.25\\build\\src\\topology-read\\model\\roc ketfuel-topology-reader.cc.1.o’]
    # Skip NetAnim (platform not supported)
    # Build NS-3
    Entering directory `.\ns-3.25′
    => D:\anacondnew\python.exe waf configure –with-pybindgen ..\pybindgen-0.17.0 .post49+ng0e4e3bc
    => D:\anacondnew\python.exe waf build
    Traceback (most recent call last):
    File “./build.py”, line 171, in
    sys.exit(main(sys.argv))
    File “./build.py”, line 162, in main
    build_ns3(config, build_examples, build_tests, args, build_options)
    File “./build.py”, line 82, in build_ns3
    run_command([sys.executable, “waf”, “build”] + build_options)
    File “D:\ns-allinone-3.25\util.py”, line 25, in run_command
    raise CommandError(“Command %r exited with code %i” % (argv, retval))
    util.CommandError: Command [‘D:\\anacondnew\\python.exe’, ‘waf’, ‘build’] exited with code 1

    this is error i get while compiling build.py in cygwin

Previous Comments

Leave a Reply

Your email address will not be published. Required fields are marked *