Difference between revisions of "HOWTO use ns-3 in the ORBIT testbed environment"

From Nsnam
Jump to: navigation, search
 
(13 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
 +
 +
'''Note:''' Some of the ns-3 documentation is stale below, as it references a program emu-udp-echo-client
 +
and emu-udp-echo-server that are not part of ns-3.  The closest corresponding program in current ns-3
 +
(as of ns-3.22) is src/fd-net-device/examples/fd-emu-udp-echo.cc.
  
 
We provide a realtime emulation package that allows us to connect ns-3 to real
 
We provide a realtime emulation package that allows us to connect ns-3 to real
Line 7: Line 11:
 
emulator provides a large two-dimensional grid of 400 802.11 radio nodes as well as
 
emulator provides a large two-dimensional grid of 400 802.11 radio nodes as well as
 
a number of smaller "sandbox" testbeds to allow one to test without reserving the  
 
a number of smaller "sandbox" testbeds to allow one to test without reserving the  
main grid.  This  HOWTO shows how ns-3 scripts can be used to drive these radio nodes.
+
main grid.   
  
== HOWTO use ns-3 in the ORBIT testbed environment ==
+
In [[HOWTO use ns-3 directly on the ORBIT testbed hardware]] we showed how to use
 +
the ORBIT hardware as a basis for ns-3 experiments.  This HOWTO shows how one can
 +
use ORBIT tools to automate the process of getting an experiment run.
  
We assume that you have some experience with the ORBIT system.  If you are new to  
+
We assume that you have some experience with the ORBIT system and understand the
ORBIT, please take a look at http://www.orbit-lab.org/ and go through the "Basic
+
basic environment.  If you are new to ORBIT, please take a look at  
Tutorial" and the "Tutorials on controlling the testbed nodes" at a minimum.  We
+
http://www.orbit-lab.org/ and go through the "Basic Tutorial" and the "Tutorials  
will assume throughout this HOWTO that you have registered for an ORBIT account and
+
on controlling the testbed nodes" at a minimum.  We will assume throughout this  
have made a reservation on the ORBIT Scheduler for a testbed.  This HOWTO assumes
+
HOWTO that you have registered for an ORBIT account and have made a reservation
that you are on the sandbox one (sb1) testbed.
+
on the ORBIT Scheduler for a testbed.  This HOWTO assumes that you are on the  
 +
sandbox one (sb1) testbed. We further assume that you have at least read the
 +
[[HOWTO use ns-3 directly on the ORBIT testbed hardware]] and understand what it
 +
is we are trying to automate here.
 +
 
 +
== HOWTO use ns-3 in the ORBIT testbed environment ==
  
 
We provide a node image on the ORBIT system that includes everything you need to
 
We provide a node image on the ORBIT system that includes everything you need to
Line 22: Line 33:
 
GNU toolchain, a copy of a precompiled ns-3.3 repository, emacs editor, etc.  The
 
GNU toolchain, a copy of a precompiled ns-3.3 repository, emacs editor, etc.  The
 
first step is to get this environment up on the nodes in your testbed.  In ORBIT
 
first step is to get this environment up on the nodes in your testbed.  In ORBIT
terminology, we need to "image the nodes."
+
terminology, we need to "image the nodes."
  
 
1.  Connect to the sandbox console, image the sandbox nodes and power them up
 
1.  Connect to the sandbox console, image the sandbox nodes and power them up
 
     a.  ssh your-orbit-user-name@console.sb1.orbit-lab.org;
 
     a.  ssh your-orbit-user-name@console.sb1.orbit-lab.org;
     b.  orbit load all ns-3.3.ndz
+
     b.  orbit load all ns-3.5.ndz 1200
  
 
This is a somewhat time-consuming process since you are actually copying disk  
 
This is a somewhat time-consuming process since you are actually copying disk  
images to the sandbox nodes.  The example below took about seven and a half
+
images to the sandbox nodes.  We have a relatively large image since it contains the
minutes to complete.  You should see status messages appearing which indicate
+
entire GNU toolchain, ns-3, its reference traces, NSC, etc., and so we need to bump up
that the imaging process is proceeding as expected:  
+
the default timeout (with the 1200 second timeout specified in 1.a above).  The example
 +
below took almost seventeen minutes to complete, so you must have patience!  
  
        Imaging nodes: 'system:topo:all' with image 'ns-3.3.ndz'
+
You should see status messages appearing which indicate that the imaging process is
        (Domain:  default from hostname)
+
proceeding as expected: 
        (Timeout:  800 sec.)
+
 
        INFO init: NodeHandler Version 4.2.0 (1272)
+
      Imaging nodes: 'system:topo:all' with image 'ns-3.5.ndz'
        INFO init: Experiment ID: sb1_2008_12_30_21_25_31
+
      (Domain:  default from hostname)
        INFO Experiment: load system:exp:stdlib
+
      (Timeout:  1200 sec.)
        INFO prop.resetDelay: resetDelay = 210:Fixnum
+
      INFO init: NodeHandler Version 4.4.0 (1921)
        INFO prop.resetTries: resetTries = 1:Fixnum
+
      INFO init: Experiment ID: sb1_2009_07_10_01_07_20
        INFO Experiment: load system:exp:imageNode
+
      INFO NodeHandler: Shutdown Flag Set - Switching all nodes Off...
        INFO prop.nodes: nodes = "system:topo:all":String
+
      INFO Experiment: load system:exp:stdlib
        INFO prop.image: image = "ns-3.3.ndz":String
+
      INFO prop.resetDelay: resetDelay = 210:Fixnum
        INFO prop.pxe: pxe = "1.2.1-omf":String
+
      INFO prop.resetTries: resetTries = 1:Fixnum
        INFO prop.domain: domain = nil:NilClass
+
      INFO Experiment: load system:exp:imageNode
        INFO prop.timeout: timeout = 800:Fixnum
+
      INFO prop.nodes: nodes = "system:topo:all":String
        INFO Topology: Loading topology 'system:topo:all'.
+
      INFO prop.image: image = "ns-3.5.ndz":String
        INFO stdlib: Waiting for nodes (Up/Down/Total): 0/2/2 - (still down: n_1_2,n_1_1)
+
      INFO prop.domain: domain = nil:NilClass
        ...
+
      INFO prop.timeout: timeout = 1200:Fixnum
        INFO whenAll: *: 'status[@value='UP']' fires
+
      INFO Topology: Loading topology 'system:topo:all'.
        INFO exp: Progress(0/0/2): 0/0/0 min(n_1_2)/avg/max (91) - Timeout: 700 sec.
+
      INFO stdlib: Waiting for nodes (Up/Down/Total): 0/2/2 - (still down: n_1_1,n_1_2)
        ...
+
     
        INFO exp: Progress(2/0/2): 100/100/100 min()/avg/max (91) - Timeout: 358 sec.
+
      ...
        INFO exp:  -----------------------------
+
 
        INFO exp:  Imaging Process Done
+
      INFO whenAll: *: 'status[@value='UP']' fires
        INFO exp:  - 2 node(s) succesfully imaged - See the topology file: 'system_topo_active_sb1.rb'
+
      INFO exp: Progress(0/0/2): 0/0/0 min(n_1_2)/avg/max (82) - Timeout: 1110 sec.
        INFO exp:  -----------------------------
+
      INFO exp: Progress(0/0/2): 0/0/0 min(n_1_2)/avg/max (82) - Timeout: 1100 sec.
        INFO Experiment: DONE!
+
      INFO exp: Progress(0/0/2): 0/0/0 min(n_1_2)/avg/max (82) - Timeout: 1090 sec.
        INFO ExecApp: Application 'commServer' finished
+
           
        INFO run: Experiment sb1_2008_12_30_21_25_31 finished after 7:28
+
      ...
 +
     
 +
      INFO exp: Progress(1/0/2): 90/95/100 min(n_1_2)/avg/max (82) - Timeout: 225 sec.
 +
      INFO exp: Progress(1/0/2): 90/95/100 min(n_1_2)/avg/max (82) - Timeout: 215 sec.
 +
      INFO exp: Progress(2/0/2): 100/100/100 min()/avg/max (82) - Timeout: 205 sec.
 +
      INFO exp:  -----------------------------
 +
      INFO exp:  Imaging Process Done
 +
      INFO exp:  - 2 node(s) succesfully imaged - See the topology file: 'system_topo_active_sb1.rb'
 +
      INFO exp:  -----------------------------
 +
      INFO Experiment: DONE!
 +
      INFO ExecApp: Application 'commServer' finished
 +
      INFO run: Experiment sb1_2009_07_13_02_47_05 finished after 16:46   
  
 
You can now take a look at the status of the nodes.  Observe that they are in the  
 
You can now take a look at the status of the nodes.  Observe that they are in the  
Line 85: Line 108:
 
         ---------------------------------------------------
 
         ---------------------------------------------------
  
and see that the nodes are now powered up
+
and see that the nodes are now powered up (you may have to wait for a short time
 +
to see the state change happen)
  
 
     e.  orbit stat
 
     e.  orbit stat
Line 97: Line 121:
  
 
When you are done with this step, the sandbox nodes will have been powered up and
 
When you are done with this step, the sandbox nodes will have been powered up and
will be in the process of booting.  You now need to connect to the individual
+
will be in the process of booting.  You need to wait until this process has
nodes in the sandbox and configure themYou may find it convenient to open
+
completedOne way to do this is to ping the sandbox nodes.
a couple of terminal windows for this process.  I will assume you do this, and in
+
from now on, when I refer to [x,y] I mean the terminal window into which you you
+
connect to the ORBIT node of array position [x,y].
+
  
You may see a "No route to host" error, when you try to ssh, until the nodes are  
+
2.  Ping the sandbox nodes to make sure they are up.
actually up (done rebooting as a result of the power on step 1.d)Note that we
+
    a.  ping -c 1 node1-1
configure "ath0" on node [1,1] to be an access point, and "ath0" on node [1,2] to
+
be a station.  We have to place the cards in promiscuous mode for the emu net
+
device to work.
+
  
2. Connect to node [1,1] and configure its wireless
+
    PING node1-1.sb1.orbit-lab.org (10.11.1.1) 56(84) bytes of data.
     a.  ssh root@node1-1
+
     64 bytes from node1-1.sb1.orbit-lab.org (10.11.1.1): icmp_seq=1 ttl=64 time=0.422 ms
     b.  wlanconfig ath0 destroy
+
      
     c. wlanconfig ath0 create wlandev wifi0 wlanmode ap
+
     --- node1-1.sb1.orbit-lab.org ping statistics ---
     d. ifconfig ath0 promisc up
+
     1 packets transmitted, 1 received, 0% packet loss, time 0ms
 +
    rtt min/avg/max/mdev = 0.422/0.422/0.422/0.000 ms
  
3Connect to node [1,2] and configure its wireless
+
    bping -c 1 node1-2
    a.  ssh root@node1-2
+
    b.  wlanconfig ath0 destroy
+
    c.  wlanconfig ath0 create wlandev wifi0 wlanmode sta
+
    d.  ifconfig ath0 promisc up
+
  
Now that you have a working hardware configuration, you can go ahead and get
+
    PING node1-2.sb1.orbit-lab.org (10.11.1.2) 56(84) bytes of data.
ns-3 up and running. The image you loaded is of a vanilla ns-3.3 distribution.
+
    64 bytes from node1-2.sb1.orbit-lab.org (10.11.1.2): icmp_seq=1 ttl=64 time=3.62 ms
In that distro there are no example programs handy which can drive the two nodes
+
   
in the sandbox. We provide a couple of example progams on one of our developers'
+
    --- node1-2.sb1.orbit-lab.org ping statistics ---
private repositories to get you started.
+
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
 +
    rtt min/avg/max/mdev = 3.624/3.624/3.624/0.000 ms
  
6.  Pull the examples into [1,1] and build them
+
Now, you can write a simple ruby script to go out and pull the updated ns-3 code
    a.  cd /home/repos/ns-3.3
+
from the repositoryUsing your favorite editor, copy the following code into a
    bhg pull http://code.nsnam.org/craigdo/ns-3.3-orbit
+
file called "ns-3-prepare.rb":
    c. hg update
+
    d.  ./waf
+
  
7. Pull the examples into [1,2] and build them
+
    Experiment.name = "ns-3-prepare"
     a. cd /home/repos/ns-3.3
+
   
    b.  hg pull http://code.nsnam.org/craigdo/ns-3.3-orbit
+
    defGroup('server', [1,1]) { |node|
     chg update
+
      node.image = "ns-3.5.ndz"
     d.  ./waf
+
    }
 +
   
 +
    defGroup('client', [1,2]) { |node|
 +
      node.image = "ns-3.5.ndz"
 +
     }
 +
   
 +
    whenAllUp() { |node|
 +
      allGroups.exec("/usr/local/bin/wlanconfig ath0 destroy")
 +
      wait 2
 +
      group("server").exec("/usr/local/bin/wlanconfig ath0 create wlandev wifi0 wlanmode ap")
 +
      wait 2
 +
      group("client").exec("/usr/local/bin/wlanconfig ath0 create wlandev wifi0 wlanmode sta")
 +
      wait 2
 +
      allGroups.exec("ifconfig ath0 promisc up")
 +
      wait 2
 +
      allGroups.exec("cd /home/repos/ns-3.3; hg pull http://code.nsnam.org/craigdo/ns-3.3-orbit; hg update; ./waf")
 +
      wait 500
 +
      Experiment.done
 +
     }
 +
 
 +
    ''Sidebar:  Note the wait statements in the above codeThere is''
 +
     ''apparently no way to execute a command synchronously on multiple nodes''
 +
    ''using ORBIT toolsThus, we seem  faced with a tradeoff. Either ssh''
 +
    ''into the nodes and perform the actions manually and synchronously,''
 +
    ''or automate them and possibly wait longer than absolutely necessary.''
 +
    ''It seems safe to control-C out of the script after the compilations''
 +
    ''are done.''
 +
 
 +
2.  Execute the ns-3-prepare.rb command script.
 +
    a.  orbit exec ns-3-prepare
 +
 
 +
    INFO init: NodeHandler Version 4.2.0 (1272)
 +
    INFO init: Experiment ID: sb1_2009_01_12_20_34_55
 +
    INFO Experiment: load system:exp:stdlib
 +
    INFO prop.resetDelay: resetDelay = 210:Fixnum
 +
    INFO prop.resetTries: resetTries = 1:Fixnum
 +
    INFO Experiment: load ns-3-prepare
 +
    INFO stdlib: Waiting for nodes (Up/Down/Total): 0/2/2 - (still down: n_1_2,n_1_1)
 +
    ...
 +
    INFO whenAll: *: 'status[@value='UP']' fires
 +
    INFO whenAll: *: 'status[@value='UP']' fires
 +
    INFO exp: Request from Experiment Script: Wait for 10s....
 +
    Event DONE.OK (from /usr/local/bin/wlanconfig@n_1_2): status: 0
 +
    Event DONE.OK (from /usr/local/bin/wlanconfig@n_1_1): status: 0
 +
    INFO exp: Request from Experiment Script: Wait for 10s....
 +
    ...
 +
    INFO exp: Request from Experiment Script: Wait for 500s....
 +
    Message (from cd@n_1_2):  pulling from http://code.nsnam.org/craigdo/ns-3.3-orbit
 +
    Message (from cd@n_1_2):  searching for changes
 +
    Message (from cd@n_1_2):  no changes found
 +
    ...
 +
    familiar waf output from ns-3
 +
    ...
 +
    Event DONE.OK (from cd@n_1_1): status: 0
 +
    INFO Experiment: DONE!
 +
    INFO ExecApp: Application 'commServer' finished
 +
    INFO run: Experiment sb1_2009_01_12_20_34_55 finished after 10:35
 +
 
 +
Notice that this script has taken care of setting up the wireless devices
 +
for you.
  
 
Now you can run the example ns-3 client server scripts on the testbed.  We have  
 
Now you can run the example ns-3 client server scripts on the testbed.  We have  
Line 147: Line 220:
 
of the interfaces in the ns-3 simulation script.
 
of the interfaces in the ns-3 simulation script.
  
8.  Set the hardware address of the interface in the server script on node [1,1]
+
3.  Set the hardware address of the interface in the server script on node [1,1]
 
     a. ifconfig
 
     a. ifconfig
  
Line 168: Line 241:
 
you just found, for example,
 
you just found, for example,
  
        ed->SetAddress ("06:60:b3:ac:2b:f5");
+
    ed->SetAddress (Mac48Address::ConvertFrom (Mac48Address ("00:00:00:00:00:01")));
 +
 
 +
becomes
 +
 
 +
    ed->SetAddress (Mac48Address::ConvertFrom (Mac48Address ("06:60:b3:ac:2b:f5")))'
  
 
Save the changes and build
 
Save the changes and build
  
     d.  ./waf
+
     d.  cd ..
 +
    e.  ./waf
  
9.  Set the hardware address of the interface in the client script on node [1,2]
+
4.  Set the hardware address of the interface in the client script on node [1,2]
 
     a. ifconfig
 
     a. ifconfig
  
Line 195: Line 273:
 
you just found, for example,
 
you just found, for example,
  
          ed->SetAddress ("06:60:b3:b0:c6:a4");
+
    ed->SetAddress (Mac48Address::ConvertFrom (Mac48Address ("00:00:00:00:00:01")));
 +
 
 +
becomes
 +
 
 +
    ed->SetAddress (Mac48Address::ConvertFrom (Mac48Address ("06:60:b3:b0:c6:a4")))'
 +
 
  
 
Save the changes and build
 
Save the changes and build
  
     d.  ./waf
+
     d.  cd ..
 +
    e.  ./waf
  
 
In this simple example, we are just going to manually start one ns-3 simulation
 
In this simple example, we are just going to manually start one ns-3 simulation
Line 207: Line 291:
 
to dawdle after running the server -- it exits automatically after 60 seconds.
 
to dawdle after running the server -- it exits automatically after 60 seconds.
  
9.  Run the server on [1,1]
+
5.  Run the server on [1,1]
 
     a.  ./waf --run emu-udp-echo-server
 
     a.  ./waf --run emu-udp-echo-server
  
10.  Run the client on [1,2]
+
6.  Run the client on [1,2]
 
     a.  ./waf --run emu-udp-echo-client
 
     a.  ./waf --run emu-udp-echo-client
  
Line 220: Line 304:
 
node:
 
node:
  
11. Display the pcap trace on [1,2]
+
7. Display the pcap trace on [1,2]
 
     a. cd ..
 
     a. cd ..
 
     b. tcpdump -nn -tt -r emu-udp-echo-client-0-0.pcap  | more
 
     b. tcpdump -nn -tt -r emu-udp-echo-client-0-0.pcap  | more
 
== Bonus HOWTO better integrate ns-3 with ORBIT ==
 
 
There are a number of ways that ns-3 could be further integrated with the ORBIT
 
system.  Patches are always welcome.
 
 
1.  Use the ORBIT NodeHandler to drive your experiments:  http://www.orbit-lab.org/wiki/Tutorial/HowToCommand
 
 
The ORBIT NodeHandler allows you to send shell commands to the various nodes in
 
your experiment.  You can use this facility to automate the steps you did
 
manually in the HOWTO above.  To a first approximation, this would mean creating
 
a Ruby program called perhaps do_experiment.rb
 
 
    defGroup('ns3_nodes', [[1,1],[1,2]]) 
 
    whenAllUp() {
 
      allGroups.exec("/home/repos/ns-3.3/run.sh")
 
      wait 60
 
      Experiment.done
 
    }
 
 
You would execute this program on the grid console
 
 
    orbit exec do_experiment.rb
 
 
2.  Support the Orbit Measurement Library (OML): http://www.orbit-lab.org/wiki/Documentation/OML
 
 
Using OML, you need to write an XML description of the data you want to collect
 
and compile it.  You then get C code that you can link into your ns-3 script that
 
will write your measurement data to the ORBIT database.  This could be hooked
 
into the ns-3 tracing framework.  See http://www.orbit-lab.org/wiki/Tutorial/CollectingMeasurements
 
 
3.  Athstats:  http://www.orbit-lab.org/wiki/Documentation/Athstats
 
 
This is at its lowest level, a Linux program to query the device drivers on the
 
nodes.  You can use an ORBIT application to cause this information to be pulled
 
out and stored in the ORBIT OML database during ns-3 driven experiments.
 
 
    frames transmitted successfully (at senders)
 
    frames dropped due to excessive retries (at senders)
 
    frames dropped due to FIFO errors (at senders)
 
    frames dropped due to filtering (at senders)
 
    short retries (for 802.11 RTS frames) (at senders)
 
    long retries (for 802.11 DATA/MGMT frames) (at senders)
 
    frames received successfully (at receivers)
 
    frames dropped due to CRC errors (at receivers)
 
    frames dropped due to FIFO errors (at receivers)
 
    frames dropped due to PHY errors (at receivers)
 
 
4.  Use Aruba Sniffers http://www.orbit-lab.org/wiki/Documentation/ARuba
 
 
The ORBIT main grid has four Aruba sniffers at the four corners that can be
 
configured to sniff specific channels and report every sniffed packet to the
 
database. This gives the experimenters an independent framework to correlate
 
802.11 traffic during the course of the experiment for sanity checking as well
 
as verifying the expected outcome of the experiment.
 
 
5.  Write an ORBIT-specific net device
 
 
Right now we can control the settings of the node radios using the usual Linux
 
tools.  For example
 
 
  iwconfig ath0 txpower 30mW
 
 
There is a further level of integration with ORBIT available which would require
 
another (ORBIT-specific) device to be written.  The ORBIT folks have written a
 
user-space library (libnet + libpcap + API) to allow you to write Ethernet packets,
 
read full 802.11 frames, and get and set interface parameters.  See http://www.orbit-lab.org/wiki/Documentation/Libmac
 
 
A new net device that uses libmac calls could integrate with the ns-3 Attribute
 
System to allow control of the underlying ORBIT node hardware by the ns-3 script
 
directly.
 
  
 
----
 
----
  
[[User:Craigdo|Craigdo]] 21:52, 31 December 2008 (UTC)
+
[[User:Craigdo|Craigdo]] 19:30, 14 July 2009 (UTC)

Latest revision as of 21:57, 6 October 2014

Main Page - Current Development - Developer FAQ - Tools - Related Projects - Project Ideas - Summer Projects

Installation - Troubleshooting - User FAQ - HOWTOs - Samples - Models - Education - Contributed Code - Papers

Note: Some of the ns-3 documentation is stale below, as it references a program emu-udp-echo-client and emu-udp-echo-server that are not part of ns-3. The closest corresponding program in current ns-3 (as of ns-3.22) is src/fd-net-device/examples/fd-emu-udp-echo.cc.

We provide a realtime emulation package that allows us to connect ns-3 to real networks on real machines. Typically the real network will be a testbed of some kind. ORBIT is a two-tier laboratory emulator/field trial network project of WINLAB (Wireless Information Network Laboratory), at Rutgers. This wireless network emulator provides a large two-dimensional grid of 400 802.11 radio nodes as well as a number of smaller "sandbox" testbeds to allow one to test without reserving the main grid.

In HOWTO use ns-3 directly on the ORBIT testbed hardware we showed how to use the ORBIT hardware as a basis for ns-3 experiments. This HOWTO shows how one can use ORBIT tools to automate the process of getting an experiment run.

We assume that you have some experience with the ORBIT system and understand the basic environment. If you are new to ORBIT, please take a look at http://www.orbit-lab.org/ and go through the "Basic Tutorial" and the "Tutorials on controlling the testbed nodes" at a minimum. We will assume throughout this HOWTO that you have registered for an ORBIT account and have made a reservation on the ORBIT Scheduler for a testbed. This HOWTO assumes that you are on the sandbox one (sb1) testbed. We further assume that you have at least read the HOWTO use ns-3 directly on the ORBIT testbed hardware and understand what it is we are trying to automate here.

HOWTO use ns-3 in the ORBIT testbed environment

We provide a node image on the ORBIT system that includes everything you need to get an ns-3 environment up and running on your testbed nodes. This includes the GNU toolchain, a copy of a precompiled ns-3.3 repository, emacs editor, etc. The first step is to get this environment up on the nodes in your testbed. In ORBIT terminology, we need to "image the nodes."

1. Connect to the sandbox console, image the sandbox nodes and power them up

   a.  ssh your-orbit-user-name@console.sb1.orbit-lab.org;
   b.  orbit load all ns-3.5.ndz 1200

This is a somewhat time-consuming process since you are actually copying disk images to the sandbox nodes. We have a relatively large image since it contains the entire GNU toolchain, ns-3, its reference traces, NSC, etc., and so we need to bump up the default timeout (with the 1200 second timeout specified in 1.a above). The example below took almost seventeen minutes to complete, so you must have patience!

You should see status messages appearing which indicate that the imaging process is proceeding as expected:

      Imaging nodes: 'system:topo:all' with image 'ns-3.5.ndz'
     (Domain:  default from hostname)
     (Timeout:  1200 sec.)
      INFO init: NodeHandler Version 4.4.0 (1921)
      INFO init: Experiment ID: sb1_2009_07_10_01_07_20
      INFO NodeHandler: Shutdown Flag Set - Switching all nodes Off...
      INFO Experiment: load system:exp:stdlib
      INFO prop.resetDelay: resetDelay = 210:Fixnum
      INFO prop.resetTries: resetTries = 1:Fixnum
      INFO Experiment: load system:exp:imageNode
      INFO prop.nodes: nodes = "system:topo:all":String
      INFO prop.image: image = "ns-3.5.ndz":String
      INFO prop.domain: domain = nil:NilClass
      INFO prop.timeout: timeout = 1200:Fixnum
      INFO Topology: Loading topology 'system:topo:all'.
      INFO stdlib: Waiting for nodes (Up/Down/Total): 0/2/2 - (still down: n_1_1,n_1_2)
      
      ...
      INFO whenAll: *: 'status[@value='UP']' fires
      INFO exp: Progress(0/0/2): 0/0/0 min(n_1_2)/avg/max (82) - Timeout: 1110 sec.
      INFO exp: Progress(0/0/2): 0/0/0 min(n_1_2)/avg/max (82) - Timeout: 1100 sec.
      INFO exp: Progress(0/0/2): 0/0/0 min(n_1_2)/avg/max (82) - Timeout: 1090 sec.
           
      ...
      
      INFO exp: Progress(1/0/2): 90/95/100 min(n_1_2)/avg/max (82) - Timeout: 225 sec.
      INFO exp: Progress(1/0/2): 90/95/100 min(n_1_2)/avg/max (82) - Timeout: 215 sec.
      INFO exp: Progress(2/0/2): 100/100/100 min()/avg/max (82) - Timeout: 205 sec.
      INFO exp:  -----------------------------
      INFO exp:  Imaging Process Done
      INFO exp:  - 2 node(s) succesfully imaged - See the topology file: 'system_topo_active_sb1.rb'
      INFO exp:  -----------------------------
      INFO Experiment: DONE!
      INFO ExecApp: Application 'commServer' finished
      INFO run: Experiment sb1_2009_07_13_02_47_05 finished after 16:46     

You can now take a look at the status of the nodes. Observe that they are in the POWEROFF state

   c.  orbit stat
       -----------------------------------------------
        INFO Topology: Loading topology 'system:topo:all'.
        Testbed : sb1
        Node n_1_1 - State: POWEROFF
        Node n_1_2 - State: POWEROFF
       -----------------------------------------------

You can now power up the nodes in the sandbox

   d.  orbit tell on all
        INFO Topology: Loading topology 'system:topo:all'.
       ---------------------------------------------------
        Testbed : sb1 - Command: on
        Node n_1_2 - Ok
        Node n_1_1 - Ok
       ---------------------------------------------------

and see that the nodes are now powered up (you may have to wait for a short time to see the state change happen)

   e.  orbit stat
       -----------------------------------------------
        INFO Topology: Loading topology 'system:topo:all'.
        Testbed : sb1
        Node n_1_1 - State: POWERON
        Node n_1_2 - State: POWERON
       -----------------------------------------------

When you are done with this step, the sandbox nodes will have been powered up and will be in the process of booting. You need to wait until this process has completed. One way to do this is to ping the sandbox nodes.

2. Ping the sandbox nodes to make sure they are up.

   a.  ping -c 1 node1-1
   PING node1-1.sb1.orbit-lab.org (10.11.1.1) 56(84) bytes of data.
   64 bytes from node1-1.sb1.orbit-lab.org (10.11.1.1): icmp_seq=1 ttl=64 time=0.422 ms
   
   --- node1-1.sb1.orbit-lab.org ping statistics ---
   1 packets transmitted, 1 received, 0% packet loss, time 0ms
   rtt min/avg/max/mdev = 0.422/0.422/0.422/0.000 ms
   b.  ping -c 1 node1-2
   PING node1-2.sb1.orbit-lab.org (10.11.1.2) 56(84) bytes of data.
   64 bytes from node1-2.sb1.orbit-lab.org (10.11.1.2): icmp_seq=1 ttl=64 time=3.62 ms
   
   --- node1-2.sb1.orbit-lab.org ping statistics ---
   1 packets transmitted, 1 received, 0% packet loss, time 0ms
   rtt min/avg/max/mdev = 3.624/3.624/3.624/0.000 ms

Now, you can write a simple ruby script to go out and pull the updated ns-3 code from the repository. Using your favorite editor, copy the following code into a file called "ns-3-prepare.rb":

   Experiment.name = "ns-3-prepare"
   
   defGroup('server', [1,1]) { |node|
     node.image = "ns-3.5.ndz"
   }
   
   defGroup('client', [1,2]) { |node|
     node.image = "ns-3.5.ndz"
   }
   
   whenAllUp() { |node|
     allGroups.exec("/usr/local/bin/wlanconfig ath0 destroy")
     wait 2
     group("server").exec("/usr/local/bin/wlanconfig ath0 create wlandev wifi0 wlanmode ap")
     wait 2
     group("client").exec("/usr/local/bin/wlanconfig ath0 create wlandev wifi0 wlanmode sta")
     wait 2
     allGroups.exec("ifconfig ath0 promisc up")
     wait 2
     allGroups.exec("cd /home/repos/ns-3.3; hg pull http://code.nsnam.org/craigdo/ns-3.3-orbit; hg update; ./waf")
     wait 500
     Experiment.done
   }
   Sidebar:  Note the wait statements in the above code.  There is
   apparently no way to execute a command synchronously on multiple nodes
   using ORBIT tools.  Thus, we seem  faced with a tradeoff.  Either ssh
   into the nodes and perform the actions manually and synchronously,
   or automate them and possibly wait longer than absolutely necessary.
   It seems safe to control-C out of the script after the compilations
   are done.

2. Execute the ns-3-prepare.rb command script.

   a.  orbit exec ns-3-prepare
   INFO init: NodeHandler Version 4.2.0 (1272)
   INFO init: Experiment ID: sb1_2009_01_12_20_34_55
   INFO Experiment: load system:exp:stdlib
   INFO prop.resetDelay: resetDelay = 210:Fixnum
   INFO prop.resetTries: resetTries = 1:Fixnum
   INFO Experiment: load ns-3-prepare
   INFO stdlib: Waiting for nodes (Up/Down/Total): 0/2/2 - (still down: n_1_2,n_1_1)
   ...
   INFO whenAll: *: 'status[@value='UP']' fires
   INFO whenAll: *: 'status[@value='UP']' fires
   INFO exp: Request from Experiment Script: Wait for 10s....
   Event DONE.OK (from /usr/local/bin/wlanconfig@n_1_2): status: 0
   Event DONE.OK (from /usr/local/bin/wlanconfig@n_1_1): status: 0
   INFO exp: Request from Experiment Script: Wait for 10s....
   ...
   INFO exp: Request from Experiment Script: Wait for 500s....
   Message (from cd@n_1_2):  pulling from http://code.nsnam.org/craigdo/ns-3.3-orbit
   Message (from cd@n_1_2):  searching for changes
   Message (from cd@n_1_2):  no changes found
   ...
   familiar waf output from ns-3
   ...
   Event DONE.OK (from cd@n_1_1): status: 0
   INFO Experiment: DONE!
   INFO ExecApp: Application 'commServer' finished
   INFO run: Experiment sb1_2009_01_12_20_34_55 finished after 10:35

Notice that this script has taken care of setting up the wireless devices for you.

Now you can run the example ns-3 client server scripts on the testbed. We have configured [1,1] device "ath0" as an access point, and [1,2] device "ath0" as a station. Both devices must be in promiscuous mode. This can all be verified by using "ifconfig" and "iwconfig" on the appropriate console.

This is annoying, but for now we have got to manually set the hardware address of the interfaces in the ns-3 simulation script.

3. Set the hardware address of the interface in the server script on node [1,1]

   a. ifconfig

Locate the output for the device ath0 in the output of ifconfig

       ath0      Link encap:Ethernet  HWaddr 06:60:b3:ac:2b:f5
                 inet6 addr: fe80::460:b3ff:feac:2bf5/64 Scope:Link
                 UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
                 RX packets:1728 errors:0 dropped:0 overruns:0 frame:0
                 TX packets:42 errors:0 dropped:0 overruns:0 carrier:0
                 collisions:0 txqueuelen:0
                 RX bytes:1769806 (1.6 MiB)  TX bytes:2216 (2.1 KiB)

Copy the HWaddr to the clipboard (in this case, 06:60:b3:ac:2b:f5)

   b.  cd examples
   c.  emacs emu-udp-echo-server.cc     # or use your favorite editor

Search for the MAC address assigmnet and replace the string with the HWaddr you just found, for example,

   ed->SetAddress (Mac48Address::ConvertFrom (Mac48Address ("00:00:00:00:00:01")));

becomes

   ed->SetAddress (Mac48Address::ConvertFrom (Mac48Address ("06:60:b3:ac:2b:f5")))'

Save the changes and build

   d.  cd ..
   e.  ./waf

4. Set the hardware address of the interface in the client script on node [1,2]

   a. ifconfig

Locate the output for the device ath0 in the output of ifconfig

       ath0      Link encap:Ethernet  HWaddr 06:60:b3:b0:c6:a4
                 inet6 addr: fe80::460:b3ff:feb0:c6a4/64 Scope:Link
                 UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
                 RX packets:72 errors:0 dropped:0 overruns:0 frame:0
                 TX packets:851 errors:0 dropped:0 overruns:0 carrier:0
                 collisions:0 txqueuelen:0
                 RX bytes:1900 (1.8 KiB)  TX bytes:890770 (869.8 KiB)

Copy the HWaddr to the clipboard (in this case, 06:60:b3:b0:c6:a4)

   b.  cd examples
   c.  emacs emu-udp-echo-client.cc     # or use your favorite editor

Search for the MAC address assigmnet and replace the string with the HWaddr you just found, for example,

   ed->SetAddress (Mac48Address::ConvertFrom (Mac48Address ("00:00:00:00:00:01")));

becomes

   ed->SetAddress (Mac48Address::ConvertFrom (Mac48Address ("06:60:b3:b0:c6:a4")))'


Save the changes and build

   d.  cd ..
   e.  ./waf

In this simple example, we are just going to manually start one ns-3 simulation script to act as a server for a trivial UDP echo application. Once the server is started on [1,1] for example, you can then go to the console for [1,2] and run the UPD echo client script. Let's do it. Remember you don't have all day to dawdle after running the server -- it exits automatically after 60 seconds.

5. Run the server on [1,1]

   a.  ./waf --run emu-udp-echo-server

6. Run the client on [1,2]

   a.  ./waf --run emu-udp-echo-client

Congratulations, you have now run your ns-3 simulation scripts on a testbed. That was exciting, wasn't it.

You can now look at the trace files on the client [1,2] and server [1,1] nodes and see what you've done. For example, to look at the pcap traces on the client node:

7. Display the pcap trace on [1,2]

   a. cd ..
   b. tcpdump -nn -tt -r emu-udp-echo-client-0-0.pcap  | more

Craigdo 19:30, 14 July 2009 (UTC)