HOWTO use ns-3 on Windows with Visual Studio 2010
This page covers installation and usage for ns-3 on Windows using Visual Studio 2010 only. Please see also see information about the port.
Requirements
- Microsoft Visual Studio 2010
- Microsoft Windows 7 or Microsoft Windows XP
- Mercurial
Download
Download via mercurial : "hg clone http://code.nsnam.org/jabraham3/ns-3-win"
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)
- Open the ns-3-dev solution file "ns-3-dev.sln" under the "ns-3-dev\windows" folder
- After the solution is opened, Right-click the solution "ns-3-dev" and select "Build Solution". Here is a youtube video showing this.
- If the build completes successfully, "MyExample.exe" will be created under the "ns-3-dev\windows\Debug" folder
Note: The solution has "hello-simulator.cc" as the default example. To add your own example go to this link
Running an example
- The solution has "hello-simulator.cc" as the default example. To add a new example, remove "hello-simulator.cc" from the "MyExample" project ( MyExample---> Right-click "hello-simulator.cc" --> Select "Remove")
- Then Right-click "MyExample"-->Add-->Existing item --> Your example file
- Build the solution as previously described
Here is a youtube video showing the above steps
Debugging
- Set a break-point at a suitable location. Lets choose the "Insert" function in "map-scheduler.cc"
- Hit the "debug" button at the top portion of your IDE.
- 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:
- Download the latest version of NetAnim for Windows here
- Unzip the contents of the zip file
- Open the NetAnim.pro file using Qt Creator.
- In Qt Creator , Select "Build All"
- NetAnim.exe will be available in the same directory as the NetAnim.pro file
If you get undefined reference to `WSAStartup` etc try adding the following lines to the "NetAnim.pro" 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.