HOWTO use ns-3 on Windows with Visual Studio 2010

From Nsnam
Jump to: navigation, search

This page covers installation and usage for ns-3 on Windows using Visual Studio 2010 only. Please see also see information about the port.


  • Microsoft Visual Studio 2010
  • Microsoft Windows 7 or Microsoft Windows XP
  • Mercurial


Download via mercurial : "hg clone"

First Build

Currently the Visual Studio Solution is organized into around 30 projects. Each of these projects correspond to the modules in the ns-3-dev line up (example: 'aodv'). However,one project file is named "MyExample". This is the project that will carry the source code with the main function (typically your example source code)

  1. Open the ns-3-dev solution file "ns-3-dev.sln" under the "ns-3-dev\windows" folder
  2. After the solution is opened, Right-click the solution "ns-3-dev" and select "Build Solution". Here is a youtube video showing this.
  3. If the build completes successfully, "MyExample.exe" will be created under the "ns-3-dev\windows\Debug" folder

Note: The solution has "" as the default example. To add your own example go to this link

Running an example

  1. The solution has "" as the default example. To add a new example, remove "" from the "MyExample" project ( MyExample---> Right-click "" --> Select "Remove")
  2. Then Right-click "MyExample"-->Add-->Existing item --> Your example file
  3. Build the solution as previously described

Here is a youtube video showing the above steps


  1. Set a break-point at a suitable location. Lets choose the "Insert" function in ""
  2. Hit the "debug" button at the top portion of your IDE.
  3. Provide input to your application as you normally would.

Here is a youtube video showing these steps.

Using NetAnim on Windows

  • Recommended IDE: QT Creator
  • Building the NetAnim executable:
  1. Download the latest version of NetAnim for Windows here
  2. Unzip the contents of the zip file
  3. Open the file using Qt Creator.
  4. In Qt Creator , Select "Build All"
  5. NetAnim.exe will be available in the same directory as the file

If you get undefined reference to `WSAStartup` etc try adding the following lines to the "" file, if you use the MiniGW toolchain

CONFIG += network
LIBS += -lwsock32

or if you use Visual C++ tool chain

CONFIG += network
LIBS += ws2_32.lib

Here is a youtube video showing the above steps.