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

From Nsnam
Jump to: navigation, search
(Download)
(Using NetAnim on Windows)
Line 65: Line 65:
 
# NetAnim can be used in two modes  
 
# NetAnim can be used in two modes  
 
## Mode 1: Post-simulation Animation using Capture files:
 
## Mode 1: Post-simulation Animation using Capture files:
### First a routine simulation is run which captures the traffic to a trace file. One example of this is "Examples\dumbbell-animation_win.cc"
+
### First a routine simulation is run which captures the traffic to a trace file. One example of this is "Examples\dumbbell-animation.cc"
 
### If the location of NetAnim.exe is not yet set, please click "Set NetAnim Location".Once the simulation is complete, click "Read Trace File" and point NetAnim to the Location of the trace file. (if these steps complain about missing dlls ensure that PATH system Environment variable is correctly set.A video of the above steps is [http://www.youtube.com/watch?v=w7WsJH7Be7o here]
 
### If the location of NetAnim.exe is not yet set, please click "Set NetAnim Location".Once the simulation is complete, click "Read Trace File" and point NetAnim to the Location of the trace file. (if these steps complain about missing dlls ensure that PATH system Environment variable is correctly set.A video of the above steps is [http://www.youtube.com/watch?v=w7WsJH7Be7o here]
 
## Mode 2: In-simulation Animation via a TCP connection between Ns3 and NetAnim:
 
## Mode 2: In-simulation Animation via a TCP connection between Ns3 and NetAnim:

Revision as of 00:14, 24 May 2011

Installation & Usage for NS3 on Windows (Visual Studio Only)

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.


  • Using NetAnim.exe along with NS3Main.exe:
  1. Ensure that the Path to qmake and the Qt dlls are added to the PATH system Environment variable. For example:C:\Qt\2010.05\qt\qmake;C:\Qt\2010.05\qt\bin. (Skipping this step might result in errors such as "*.dll is missing" when you run NetAnim.exe)
  2. Open NS3Main.exe, and Click "Set NetAnim Location" to point NS3Main.exe to the location of NetAnim.exe. If things went well, this step needs to be done only once for each version of NS3.
  3. NetAnim can be used in two modes
    1. Mode 1: Post-simulation Animation using Capture files:
      1. First a routine simulation is run which captures the traffic to a trace file. One example of this is "Examples\dumbbell-animation.cc"
      2. If the location of NetAnim.exe is not yet set, please click "Set NetAnim Location".Once the simulation is complete, click "Read Trace File" and point NetAnim to the Location of the trace file. (if these steps complain about missing dlls ensure that PATH system Environment variable is correctly set.A video of the above steps is here
    2. Mode 2: In-simulation Animation via a TCP connection between Ns3 and NetAnim:
      1. In this mode, NS3 transfers information to be plotted to NetAnim.exe via a TCP connection. NS3Main.exe will have to listen for incoming connections from NetAnim via a suitable port. This port can be specified via the Application argument "--port=5006" for example in the case of dumbbell-animation.
      2. Once the listening port is specified, run the simulation like you would do normally.
      3. Specify the port to which NetAnim should connect to via the "Port" Text box in the "NetAnim" group control.
      4. Click on "Start NetAnim" to connect it to NS3Main.exe
      5. If everything goes well, NetAnim should be able to create a visualization as the simulation progresses.A video of the above steps is here