Difference between revisions of "HOWTO use ns-3 on Windows with Visual Studio 2010"

From Nsnam
Jump to: navigation, search
(First Build)
 
(107 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''Installation & Usage for NS3 on Windows'''
+
This page covers installation and usage for ns-3 on Windows using Visual Studio 2010 only. Please see also see [[Windows Port of ns-3 using Visual Studio|information about the port]].
 +
 
 
= Requirements =
 
= Requirements =
 
* Microsoft Visual Studio 2010
 
* Microsoft Visual Studio 2010
 
* Microsoft Windows 7 or Microsoft Windows XP
 
* Microsoft Windows 7 or Microsoft Windows XP
 
+
* Mercurial
Note: By default the /MP compiler option is set to 30 reduce build time. However, this setting can significantly impact the performance of your system if processor and memory resources are limited. Please remove this option or reduce the number from 30 , based on your system's capabilities. For more on the MP option visit this [http://msdn.microsoft.com/en-us/library/bb385193.aspx link]
+
 
+
Here is a [http://www.youtube.com/watch?v=61wqGmcqnHs youtube video] showing how to locate the MP option
+
  
 
= Download =
 
= Download =
 +
Download via mercurial : "hg clone http://code.nsnam.org/jabraham3/ns-3-win"
 +
 
= First Build =
 
= First Build =
Currently the Visual Studio Solution is organized into two project. This organization is liable to change in the upcoming releases
 
  
# Main project: Containing the Windows GUI components, the examples folder and the folder where your scripts may go.The output of this project is the ns3Main.exe executable.
+
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').
# ns-3-dev-lib project: Containing the "src" folder from the parent ns-3 project.The output of this project is the "ns-3-dev-lib.lib" static library which the "Main" project will link into
+
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 [http://www.youtube.com/watch?v=br-WfAN3n8s youtube video] showing this.
 +
# If the build completes successfully, "MyExample.exe" will be created under the "ns-3-dev\windows\Debug" folder
  
The steps to build the ns3Main.exe executable are as follows
+
Note: The solution has "hello-simulator.cc" as the default example.
# Open the "ns-3-dev.sln" Visual studio 2010 solution file by double-clicking it.
+
To add your own example go to this link
# Once the entire solution is opened, right-click the "ns-3-dev-lib" project and select the "build" option.Here is a [http://www.youtube.com/watch?v=2QRbtax1j5Q youtube video] showing the previous two steps.
+
 
# After ensuring "ns-3-dev-lib.lib" is successfully built , right-click on the "Main" project and select build.Here is a [http://www.youtube.com/watch?v=ozA_6DvuLwI youtube video] showing this step.
+
= Running an example =
# Watch out linker errors (some are expected during the release of ns-3.10-Win-1.0 as several components are missing.Locate the "ns3Main.exe" file and double-click it.Here is a [youtube video] showing this step.
+
# 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 [http://www.youtube.com/watch?v=_1dYM3COCq4 youtube video] showing the above steps
  
= Adding your code =
 
 
= Debugging =
 
= 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 [http://www.youtube.com/watch?v=YmaJ53PSXWU youtube video] showing these steps.
 +
 +
= Using NetAnim on Windows =
 +
* Recommended IDE: [http://qt.nokia.com/products/developer-tools/ QT Creator]
 +
* Building the NetAnim executable:
 +
# Download the latest version of NetAnim for Windows [http://code.nsnam.org/jabraham3/ns3-on-windows/ns-3.10-Win-1.2/raw-file/78d716fec82a/NetAnim.zip 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
 +
<nowiki>
 +
CONFIG += network
 +
LIBS += -lwsock32
 +
</nowiki>
 +
 +
or if you use Visual C++ tool chain
 +
<nowiki>
 +
CONFIG += network
 +
LIBS += ws2_32.lib
 +
</nowiki>
 +
 +
 +
Here is a youtube [http://www.youtube.com/watch?v=Sl9Xwemg6ss video] showing the above steps.

Latest revision as of 16:32, 10 February 2013

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)

  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 "hello-simulator.cc" as the default example. To add your own example go to this link

Running an example

  1. 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")
  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

Debugging

  1. Set a break-point at a suitable location. Lets choose the "Insert" function in "map-scheduler.cc"
  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 NetAnim.pro file using Qt Creator.
  4. In Qt Creator , Select "Build All"
  5. 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.