PBM - Position-Based Multicast for Mobile Ad hoc Networks

        
Home
Info
Publications
Download
ns-2
SPBM
Contact
Links
Sitemap

Load tracing with ns-2 and MAC 802.11

This extension to ns-2 adds support for tracing the MAC load over the simultation time. When installed and activated, every node traces the percentage of time in which the medium has been busy during the last sampling period (by default the last 200ms).

To add it to your existing ns-2 installation, copy the following patch file into your NS_HOME/ns-allinone/ directory:

Now enter the following command:

  patch -p0 -b < patch.ltr

You should get the following output:

  patching file ns-2.1b9a/tcl/lib/ns-default.tcl
  patching file ns-2.1b9a/mac/mac-timers.h
  patching file ns-2.1b9a/mac/mac-timers.cc
  patching file ns-2.1b9a/mac/mac-802_11.h
  patching file ns-2.1b9a/mac/mac-802_11.cc

Next, change into your ns-2.1b9a directory and re-run make:

  cd ns-2.1b9a
  make

If everything works fine, you will now have the load-trace-capable version of the IEEE802.11 MAC for ns-2. To create load trace files of your simulations, you have to adopt your tcl-script in which you run ns-2. Add something like the following:

  set val(lt)        "filename.ltr"       ;# write load trace to this file
  set val(smooth_cc) "0"                  ;# smooth MAC load?
  set val(nn)        "400"                ;# number of nodes
  set val(mac)       "Mac/802_11"         ;# load trace only works with Mac/802_11!

  # create trace object for MAC load - MT
  if { $val(mac) == "Mac/802_11" } {
      if { $val(lt) != "" } {
          set loadTrace  [open $val(lt) w]
          puts $loadTrace "# x=$val(x), y=$val(y), n=$val(nn), stop=$val(stop)"
      } else {
          set loadTrace  $val(lt)
      }
  }

  # set up MAC load scanning - MT
  if { $val(lt) != "" } {
      Mac/802_11 set scan_int_    0.001   ;# scanning interval
      Mac/802_11 set scan_len_    200     ;# scan count for each probe
      if { $val(smooth_cc) == "1" } {
          Mac/802_11 set smooth_scan_ 1   ;# smooth the scanned values
      }
  }

  if { $val(mac) == "Mac/802_11" } {
      for {set i 0} {$i < $val(nn) } {incr i} {
          # bind MAC load trace file - MT
          [$node_($i) set mac_(0)] load-trace $loadTrace
      }
  }

The essential commands within this example are:

  set loadTrace [open "filename.ltr" w]
  puts $loadTrace "# x=$val(x), y=$val(y), n=$val(nn), stop=$val(stop)"
for opening the load trace file and
  [$node_($i) set mac_(0)] load-trace $loadTrace
once for every node to tell the MAC instances where to write their data to.

The first line of the load trace file with the ending .ltr contains information about the simulated scenario: the length and width, the number of nodes and the duration in seconds. Each sampling period is represented by a block in the file where the position and load value of all nodes are written in the form:

  ML <time> _<node>_ (<pos.x>/<pos.y>) <load>

The following example shows the mentioned first line and one frame for a scenario of five nodes:

  # x=1000, y=1000, n=5, stop=30
  ML 0.200000 _0_ (100.00/100.00) 0.0100
  ML 0.200000 _1_ (100.00/300.00) 0.0100
  ML 0.200000 _2_ (100.00/500.00) 0.0100
  ML 0.200000 _3_ (100.00/700.00) 0.0100
  ML 0.200000 _4_ (100.00/900.00) 0.0100

For the visualization of this data you can use the program PlotLTR. It is written in C using OpenGL, GLUT and the GTS library. The source file can be downloaded here.