merge with HEAD
authorMathieu Lacage <mathieu.lacage@inria.fr>
Fri, 15 Apr 2011 20:50:42 +0200
changeset 7053 22bf40a43ab3
parent 7052 1ed66ad04ef6 (current diff)
parent 7027 169e09e9428d (diff)
child 7054 61db80a6f882
merge with HEAD
samples/main-attribute-value.cc
samples/main-callback.cc
samples/main-grid-topology.cc
samples/main-packet-header.cc
samples/main-packet-tag.cc
samples/main-propagation-loss.cc
samples/main-ptr.cc
samples/main-random-topology.cc
samples/main-random-variable.cc
samples/main-random-walk.cc
samples/main-simple.cc
samples/main-test-sync.cc
samples/sample-random-variable.cc
samples/sample-rng-plot.py
samples/sample-simulator.cc
samples/sample-simulator.py
samples/waf
samples/wscript
src/wscript
--- a/CHANGES.html	Fri Apr 15 13:35:08 2011 +0200
+++ b/CHANGES.html	Fri Apr 15 20:50:42 2011 +0200
@@ -48,17 +48,17 @@
 
 <h2>Changes to build system:</h2>
 <ul>
-<li><b>Tests are no longer built by default in ns-3</b>
+<li><b>Examples and tests are no longer built by default in ns-3</b>
 <p>
-You can now make tests be built in ns-3 in two ways.
+You can now make examples and tests be built in ns-3 in two ways.
 <ol>
 <li> Using build.py when ns-3 is built for the first time:
 <pre>
-    ./build.py --enable-tests
+    ./build.py --enable-examples --enable-tests
 </pre>
 <li> Using waf once ns-3 has been built:
 <pre>
-    ./waf configure --enable-tests
+    ./waf configure --enable-examples --enable-tests
 </pre>
 </ol>
 </p></li>
--- a/doc/build.txt	Fri Apr 15 13:35:08 2011 +0200
+++ b/doc/build.txt	Fri Apr 15 20:50:42 2011 +0200
@@ -36,8 +36,8 @@
 
 Other waf usages include:
 
- 1. ./waf configure --enable-tests
-    Turn on unit tests.
+ 1. ./waf configure --enable-examples --enable-tests
+    Turn on examples and tests.
 
  2. ./waf --doxygen
     Run doxygen to generate documentation
--- a/doc/doxygen.conf	Fri Apr 15 13:35:08 2011 +0200
+++ b/doc/doxygen.conf	Fri Apr 15 20:50:42 2011 +0200
@@ -637,7 +637,7 @@
 # directories that contain example code fragments that are included (see
 # the \include command).
 
-EXAMPLE_PATH           = samples
+EXAMPLE_PATH           = 
 
 # If the value of the EXAMPLE_PATH tag contains directories, you can use the
 # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
--- a/doc/manual/source/attributes.rst	Fri Apr 15 13:35:08 2011 +0200
+++ b/doc/manual/source/attributes.rst	Fri Apr 15 20:50:42 2011 +0200
@@ -278,7 +278,7 @@
 +++++++++++++++++++++++++++++++++++++++++
 
 Let's look at how a user script might access these values.  
-This is based on the script found at ``samples/main-attribute-value.cc``,
+This is based on the script found at ``src/core/examples/main-attribute-value.cc``,
 with some details stripped out.::
 
     //
@@ -768,7 +768,7 @@
     sudo apt-get install libgtk2.0-0 libgtk2.0-dev
 
 To check whether it is configured or not, check the output of the
-./waf configure --enable-tests step:::
+./waf configure --enable-examples --enable-tests step:::
 
     ---- Summary of optional NS-3 features:
     Threading Primitives          : enabled
@@ -776,7 +776,7 @@
     GtkConfigStore                : not enabled (library 'gtk+-2.0 >= 2.12' not found)
 
 In the above example, it was not enabled, so it cannot be used until a suitable
-version is installed and ./waf configure --enable-tests; ./waf is rerun.
+version is installed and ./waf configure --enable-examples --enable-tests; ./waf is rerun.
 
 Usage is almost the same as the non-GTK-based version, but there
 are no ConfigStore attributes involved:::
--- a/doc/manual/source/click.rst	Fri Apr 15 13:35:08 2011 +0200
+++ b/doc/manual/source/click.rst	Fri Apr 15 20:50:42 2011 +0200
@@ -73,7 +73,7 @@
 Once Click has been built successfully, change into the ns-3 directory and 
 configure ns-3 with Click Integration support::
 
-  $: ./waf configure --enable-tests --with-nsclick=/path/to/click/source
+  $: ./waf configure --enable-examples --enable-tests --with-nsclick=/path/to/click/source
 
 If it says 'enabled' beside 'NS-3 Click Integration Support', then you're good to go.
 
--- a/doc/manual/source/distributed.rst	Fri Apr 15 13:35:08 2011 +0200
+++ b/doc/manual/source/distributed.rst	Fri Apr 15 20:50:42 2011 +0200
@@ -118,7 +118,7 @@
 
 Configure |ns3| with the --enable-mpi option:::
 
-    ./waf -d debug configure --enable-tests --enable-mpi
+    ./waf -d debug configure --enable-examples --enable-tests --enable-mpi
 
 Ensure that MPI is enabled by checking the optional features shown from the
 output of configure.
--- a/doc/manual/source/openflow-switch.rst	Fri Apr 15 13:35:08 2011 +0200
+++ b/doc/manual/source/openflow-switch.rst	Fri Apr 15 20:50:42 2011 +0200
@@ -143,7 +143,7 @@
 link to an ns-3 build with this OpenFlow switch module, run from the ns-3-dev
 (or whatever you have named your distribution):::
 
-  $ ./waf configure --enable-tests --with-openflow=path/to/openflow
+  $ ./waf configure --enable-examples --enable-tests --with-openflow=path/to/openflow
 
 #3 Under ``---- Summary of optional NS-3 features:`` you should see:::
 
--- a/doc/manual/source/packets.rst	Fri Apr 15 13:35:08 2011 +0200
+++ b/doc/manual/source/packets.rst	Fri Apr 15 20:50:42 2011 +0200
@@ -488,7 +488,7 @@
 Sample programs
 ***************
 
-See ``samples/main-packet.cc`` and ``samples/main-packet-tag.cc``.
+See ``src/network/examples/main-packet-header.cc`` and ``src/network/examples/main-packet-tag.cc``.
 
 Implementation details
 **********************
--- a/doc/manual/source/tcp.rst	Fri Apr 15 13:35:08 2011 +0200
+++ b/doc/manual/source/tcp.rst	Fri Apr 15 20:50:42 2011 +0200
@@ -164,7 +164,7 @@
 default unless the platform does not support it. To disable it when building
 |ns3|, type:::
 
-./waf configure --enable-tests --disable-nsc
+./waf configure --enable-examples --enable-tests --disable-nsc
 
 Building and validating
 +++++++++++++++++++++++
--- a/doc/release_steps.txt	Fri Apr 15 13:35:08 2011 +0200
+++ b/doc/release_steps.txt	Fri Apr 15 20:50:42 2011 +0200
@@ -48,7 +48,7 @@
    - cd ns-3.x
    - ./test.py
    - ./test.py -g
-   - ./waf -d optimized --enable-tests configure
+   - ./waf -d optimized --enable-examples --enable-tests configure
    - ./waf
    - ./test.py
    - ./test.py -g
--- a/doc/testing/source/testing-framework.rst	Fri Apr 15 13:35:08 2011 +0200
+++ b/doc/testing/source/testing-framework.rst	Fri Apr 15 20:50:42 2011 +0200
@@ -64,11 +64,12 @@
 ``test.py`` is very flexible in allowing the user to specify the number
 and kind of tests to run; and also the amount and kind of output to generate.
 
-Before running ``test.py``, make sure that ns3's tests have been built by doing the following
+Before running ``test.py``, make sure that ns3's examples and tests
+have been built by doing the following
 
 ::
 
-  ./waf configure --enable-tests
+  ./waf configure --enable-examples --enable-tests
   ./waf
 
 By default, ``test.py`` will run all available tests and report status
--- a/doc/tutorial/source/conceptual-overview.rst	Fri Apr 15 13:35:08 2011 +0200
+++ b/doc/tutorial/source/conceptual-overview.rst	Fri Apr 15 20:50:42 2011 +0200
@@ -155,10 +155,10 @@
 
 ::
 
-  AUTHORS       doc/       README         src/     waf.bat*
-  bindings/     examples/  RELEASE_NOTES  utils/   wscript
-  build/        LICENSE    samples/       VERSION  wutils.py
-  CHANGES.html  ns3/       scratch/       waf*     wutils.pyc
+  AUTHORS       doc/       README         utils/   wscript   
+  bindings/     examples/  RELEASE_NOTES  VERSION  wutils.py  
+  build/        LICENSE    scratch/       waf*     wutils.pyc 
+  CHANGES.html  ns3/       src            waf.bat*  
 
 Change into the ``examples/tutorial`` directory.  You should see a file named 
 ``first.cc`` located there.  This is a script that will create a simple
@@ -249,10 +249,10 @@
 
 ::
 
-  ./waf -d debug --enable-tests configure
+  ./waf -d debug --enable-examples --enable-tests configure
 
 in order to configure the project to perform debug builds that include 
-tests.  You will also have done a
+examples and tests.  You will also have done a
 
 ::
 
@@ -805,7 +805,6 @@
   drwxr-xr-x                               doc              files
   drwxr-xr-x                               examples         files
   drwxr-xr-x                               ns3              files
-  drwxr-xr-x                               samples          files
   drwxr-xr-x                               scratch          files
   drwxr-xr-x                               src              files
   drwxr-xr-x                               utils            files
--- a/doc/tutorial/source/getting-started.rst	Fri Apr 15 13:35:08 2011 +0200
+++ b/doc/tutorial/source/getting-started.rst	Fri Apr 15 20:50:42 2011 +0200
@@ -207,10 +207,10 @@
 
 ::
 
-  AUTHORS       examples/  RELEASE_NOTES  utils/   wscript
-  bindings/     LICENSE    samples/       VERSION  wutils.py
-  CHANGES.html  ns3/       scratch/       waf*
-  doc/          README     src/           waf.bat*
+  AUTHORS       examples/  RELEASE_NOTES  VERSION   wutils.py
+  bindings/     LICENSE    scratch/       waf*	    
+  CHANGES.html  ns3/       src/           waf.bat*
+  doc/          README     utils/         wscript
 
 You are now ready to build the |ns3| distribution.
 
@@ -264,12 +264,12 @@
 
 ::
 
-  ./build.py --enable-tests
+  ./build.py --enable-examples --enable-tests
 
-Because we are working with tests in this tutorial, and because they
-are not built by default in |ns3|, the argument for build.py tells it
-to build them for us.  In the future you can build |ns3| without tests
-if you wish.
+Because we are working with examples and tests in this tutorial, and
+because they are not built by default in |ns3|, the arguments for
+build.py tells it to build them for us.  In the future you can build
+|ns3| without examples and tests if you wish.
 
 You will see lots of typical compiler output messages displayed as the build
 script builds the various pieces you downloaded.  Eventually you should see the
@@ -300,12 +300,12 @@
 build the optimized version of the code.  By default you have configured
 your project to build the debug version.  Let's tell the project to 
 make an optimized build.  To explain to Waf that it should do optimized
-builds that include the tests, you will need to execute the 
+builds that include the examples and tests, you will need to execute the 
 following command,
 
 ::
 
-  ./waf -d optimized --enable-tests configure
+  ./waf -d optimized --enable-examples --enable-tests configure
 
 This runs Waf out of the local directory (which is provided as a convenience
 for you).  As the build system checks for various dependencies you should see
@@ -367,7 +367,7 @@
   Python Bindings               : enabled
   Python API Scanning Support   : enabled
   Use sudo to set suid bit      : not enabled (option --enable-sudo not selected)
-  Build examples and samples    : enabled
+  Build examples                : enabled
   Static build                  : not enabled (option --enable-static not selected)
   'configure' finished successfully (2.870s)
 
@@ -379,11 +379,11 @@
 a feature to use the program ``sudo`` to set the suid bit of certain programs.
 This is not enabled by default and so this feature is reported as "not enabled."
 
-Now go ahead and switch back to the debug build that includes the tests.
+Now go ahead and switch back to the debug build that includes the examples and tests.
 
 ::
 
-  ./waf -d debug --enable-tests configure
+  ./waf -d debug --enable-examples --enable-tests configure
 
 The build system is now configured and you can build the debug versions of 
 the |ns3| programs by simply typing,
@@ -396,11 +396,11 @@
 in the configuration phase.  For example, if you wanted to use the emulation 
 features of |ns3|, you might want to enable setting the suid bit using
 sudo as described above.  This turns out to be a configuration-time command, and so 
-you could reconfigure using the following command that also includes the tests
+you could reconfigure using the following command that also includes the examples and tests
 
 ::
 
-  ./waf -d debug --enable-sudo --enable-tests configure
+  ./waf -d debug --enable-sudo --enable-examples --enable-tests configure
 
 If you do this, waf will have run sudo to change the socket creator programs of the
 emulation code to run as root.  There are many other configure- and build-time options
@@ -499,10 +499,10 @@
 
 ::
 
-  ./waf -d debug --enable-tests configure
+  ./waf -d debug --enable-examples --enable-tests configure
 
 to tell ``waf`` to build the debug versions of the |ns3| 
-programs that includes the tests.  You must still build 
+programs that includes the examples and tests.  You must still build 
 the actual debug version of the code by typing,
 
 ::
--- a/samples/main-attribute-value.cc	Fri Apr 15 13:35:08 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2008 University of Washington
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Tom Henderson <tomh@tomh.org>
- */
-
-#include "ns3/log.h"
-#include "ns3/command-line.h"
-#include "ns3/ptr.h"
-#include "ns3/config.h"
-#include "ns3/uinteger.h"
-#include "ns3/string.h"
-#include "ns3/pointer.h"
-#include "ns3/simulator.h"
-
-#include "ns3/node.h"
-#include "ns3/queue.h"
-#include "ns3/drop-tail-queue.h"
-#include "ns3/point-to-point-net-device.h"
-
-using namespace ns3;
-
-NS_LOG_COMPONENT_DEFINE ("AttributeValueSample");
-
-//
-// This is a basic example of how to use the attribute system to
-// set and get a value in the underlying system; namely, an unsigned
-// integer of the maximum number of packets in a queue
-//
-
-int 
-main (int argc, char *argv[])
-{
-  LogComponentEnable ("AttributeValueSample", LOG_LEVEL_INFO);
-
-  // By default, the MaxPackets attribute has a value of 100 packets
-  // (this default can be observed in the function DropTailQueue::GetTypeId)
-  // 
-  // Here, we set it to 80 packets.  We could use one of two value types:
-  // a string-based value or a UintegerValue value
-  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("80"));
-  // The below function call is redundant
-  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (80));
-
-  // Allow the user to override any of the defaults and the above
-  // SetDefaults() at run-time, via command-line arguments
-  CommandLine cmd;
-  cmd.Parse (argc, argv);
-
-  // Now, we will create a few objects using the low-level API
-  Ptr<Node> n0 = CreateObject<Node> ();
-
-  Ptr<PointToPointNetDevice> net0 = CreateObject<PointToPointNetDevice> ();
-  n0->AddDevice (net0);
-
-  Ptr<Queue> q = CreateObject<DropTailQueue> ();
-  net0->SetQueue(q);
-
-  // At this point, we have created a single node (Node 0) and a 
-  // single PointToPointNetDevice (NetDevice 0) and added a 
-  // DropTailQueue to it.
-
-  // Now, we can manipulate the MaxPackets value of the already 
-  // instantiated DropTailQueue.  Here are various ways to do that.
-
-  // We assume that a smart pointer (Ptr) to a relevant network device
-  // is in hand; here, it is the net0 pointer. 
-
-  // 1.  Pointer-based access
-  //
-  // One way to change the value is to access a pointer to the
-  // underlying queue and modify its attribute.
-  // 
-  // First, we observe that we can get a pointer to the (base class)
-  // queue via the PointToPointNetDevice attributes, where it is called
-  // TxQueue 
-  PointerValue ptr;
-  net0->GetAttribute ("TxQueue", ptr);
-  Ptr<Queue> txQueue = ptr.Get<Queue> ();
-
-  // Using the GetObject function, we can perform a safe downcast
-  // to a DropTailQueue, where MaxPackets is a member
-  Ptr<DropTailQueue> dtq = txQueue->GetObject <DropTailQueue> ();
-  NS_ASSERT (dtq);
-
-  // Next, we can get the value of an attribute on this queue
-  // We have introduced wrapper "Value" classes for the underlying
-  // data types, similar to Java wrappers around these types, since
-  // the attribute system stores values and not disparate types.
-  // Here, the attribute value is assigned to a Uinteger, and
-  // the Get() method on this value produces the (unwrapped) uint32_t.
-  UintegerValue limit;
-  dtq->GetAttribute ("MaxPackets", limit);
-  NS_LOG_INFO ("1.  dtq limit: " << limit.Get () << " packets");
-  
-  // Note that the above downcast is not really needed; we could have
-  // done the same using the Ptr<Queue> even though the attribute
-  // is a member of the subclass
-  txQueue->GetAttribute ("MaxPackets", limit);
-  NS_LOG_INFO ("2.  txQueue limit: " << limit.Get () << " packets");
-
-  // Now, let's set it to another value (60 packets)
-  txQueue->SetAttribute("MaxPackets", UintegerValue (60));
-  txQueue->GetAttribute ("MaxPackets", limit);
-  NS_LOG_INFO ("3.  txQueue limit changed: " << limit.Get () << " packets");
-
-  // 2.  Namespace-based access
-  //
-  // An alternative way to get at the attribute is to use the configuration
-  // namespace.  Here, this attribute resides on a known path in this
-  // namespace; this approach is useful if one doesn't have access to
-  // the underlying pointers and would like to configure a specific
-  // attribute with a single statement.  
-  Config::Set ("/NodeList/0/DeviceList/0/TxQueue/MaxPackets", UintegerValue (25));
-  txQueue->GetAttribute ("MaxPackets", limit); 
-  NS_LOG_INFO ("4.  txQueue limit changed through namespace: " << 
-               limit.Get () << " packets");
-
-  // we could have also used wildcards to set this value for all nodes
-  // and all net devices (which in this simple example has the same
-  // effect as the previous Set())
-  Config::Set ("/NodeList/*/DeviceList/*/TxQueue/MaxPackets", UintegerValue (15));
-  txQueue->GetAttribute ("MaxPackets", limit); 
-  NS_LOG_INFO ("5.  txQueue limit changed through wildcarded namespace: " << 
-               limit.Get () << " packets");
-
-  Simulator::Destroy ();
-}
--- a/samples/main-callback.cc	Fri Apr 15 13:35:08 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-#include "ns3/callback.h"
-#include "ns3/assert.h"
-#include <iostream>
-
-using namespace ns3;
-
-static double 
-CbOne (double a, double b)
-{
-  std::cout << "invoke cbOne a=" << a << ", b=" << b << std::endl;
-  return a;
-}
-
-class MyCb {
-public:
-  int CbTwo (double a) {
-      std::cout << "invoke cbTwo a=" << a << std::endl;
-      return -5;
-  }
-};
-
-
-int main (int argc, char *argv[])
-{
-  // return type: double
-  // first arg type: double
-  // second arg type: double
-  Callback<double, double, double> one;
-  // build callback instance which points to cbOne function
-  one = MakeCallback (&CbOne);
-  // this is not a null callback
-  NS_ASSERT (!one.IsNull ());
-  // invoke cbOne function through callback instance
-  double retOne;
-  retOne = one (10.0, 20.0);
-
-  // return type: int
-  // first arg type: double
-  Callback<int, double> two;
-  MyCb cb;
-  // build callback instance which points to MyCb::cbTwo
-  two = MakeCallback (&MyCb::CbTwo, &cb);
-  // this is not a null callback
-  NS_ASSERT (!two.IsNull ());
-  // invoke MyCb::cbTwo through callback instance
-  int retTwo;
-  retTwo = two (10.0);    
-
-  two = MakeNullCallback<int, double> ();
-  // invoking a null callback is just like
-  // invoking a null function pointer:
-  // it will crash.
-  //int retTwoNull = two (20.0);
-  NS_ASSERT (two.IsNull ());
-
-#if 0
-  // The below type mismatch between CbOne() and callback two will fail to 
-  // compile if enabled in this program.
-  two = MakeCallback (&CbOne);
-#endif
-
-#if 0
-  // This is a slightly different example, in which the code will compile
-  // but because callbacks are type-safe, will cause a fatal error at runtime 
-  // (the difference here is that Assign() is called instead of operator=)
-  Callback<void, float> three;
-  three.Assign (MakeCallback (&CbOne));
-#endif
-
-  return 0;
-}
--- a/samples/main-grid-topology.cc	Fri Apr 15 13:35:08 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-
-#include "ns3/core-module.h"
-#include "ns3/network-module.h"
-#include "ns3/mobility-module.h"
-
-
-using namespace ns3;
-
-int main (int argc, char *argv[])
-{
-  CommandLine cmd;
-  cmd.Parse (argc, argv);
-
-  NodeContainer nodes;
-
-  // create an array of empty nodes for testing purposes 
-  nodes.Create (120);
-
-  MobilityHelper mobility;
-  // setup the grid itself: objects are layed out
-  // started from (-100,-100) with 20 objects per row, 
-  // the x interval between each object is 5 meters
-  // and the y interval between each object is 20 meters
-  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
-                                 "MinX", DoubleValue (-100.0),
-                                 "MinY", DoubleValue (-100.0),
-                                 "DeltaX", DoubleValue (5.0),
-                                 "DeltaY", DoubleValue (20.0),
-                                 "GridWidth", UintegerValue (20),
-                                 "LayoutType", StringValue ("RowFirst"));
-  // each object will be attached a static position.
-  // i.e., once set by the "position allocator", the
-  // position will never change.
-  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
-
-  // finalize the setup by attaching to each object
-  // in the input array a position and initializing
-  // this position with the calculated coordinates.
-  mobility.Install (nodes);
-
-  // iterate our nodes and print their position.
-  for (NodeContainer::Iterator j = nodes.Begin ();
-       j != nodes.End (); ++j)
-    {
-      Ptr<Node> object = *j;
-      Ptr<MobilityModel> position = object->GetObject<MobilityModel> ();
-      NS_ASSERT (position != 0);
-      Vector pos = position->GetPosition ();
-      std::cout << "x=" << pos.x << ", y=" << pos.y << ", z=" << pos.z << std::endl;
-    }
-
-  return 0;
-}
--- a/samples/main-packet-header.cc	Fri Apr 15 13:35:08 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,125 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-#include "ns3/ptr.h"
-#include "ns3/packet.h"
-#include "ns3/header.h"
-#include <iostream>
-
-using namespace ns3;
-
-/* A sample Header implementation
- */
-class MyHeader : public Header 
-{
-public:
-
-  MyHeader ();
-  virtual ~MyHeader ();
-
-  void SetData (uint16_t data);
-  uint16_t GetData (void) const;
-
-  static TypeId GetTypeId (void);
-  virtual TypeId GetInstanceTypeId (void) const;
-  virtual void Print (std::ostream &os) const;
-  virtual void Serialize (Buffer::Iterator start) const;
-  virtual uint32_t Deserialize (Buffer::Iterator start);
-  virtual uint32_t GetSerializedSize (void) const;
-private:
-  uint16_t m_data;
-};
-
-MyHeader::MyHeader ()
-{
-  // we must provide a public default constructor, 
-  // implicit or explicit, but never private.
-}
-MyHeader::~MyHeader ()
-{}
-
-TypeId 
-MyHeader::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::MyHeader")
-    .SetParent<Header> ()
-    .AddConstructor<MyHeader> ()
-    ;
-  return tid;
-}
-TypeId 
-MyHeader::GetInstanceTypeId (void) const
-{
-  return GetTypeId ();
-}
-
-void 
-MyHeader::Print (std::ostream &os) const
-{
-  // This method is invoked by the packet printing
-  // routines to print the content of my header.
-  //os << "data=" << m_data << std::endl;
-  os << "data=" << m_data;
-}
-uint32_t
-MyHeader::GetSerializedSize (void) const
-{
-  // we reserve 2 bytes for our header.
-  return 2;
-}
-void
-MyHeader::Serialize (Buffer::Iterator start) const
-{
-  // we can serialize two bytes at the start of the buffer.
-  // we write them in network byte order.
-  start.WriteHtonU16 (m_data);
-}
-uint32_t
-MyHeader::Deserialize (Buffer::Iterator start)
-{
-  // we can deserialize two bytes from the start of the buffer.
-  // we read them in network byte order and store them
-  // in host byte order.
-  m_data = start.ReadNtohU16 ();
-
-  // we return the number of bytes effectively read.
-  return 2;
-}
-
-void 
-MyHeader::SetData (uint16_t data)
-{
-  m_data = data;
-}
-uint16_t 
-MyHeader::GetData (void) const
-{
-  return m_data;
-}
-
-
-
-int main (int argc, char *argv[])
-{
-  // instantiate a header.
-  MyHeader sourceHeader;
-  sourceHeader.SetData (2);
-
-  // instantiate a packet
-  Ptr<Packet> p = Create<Packet> ();
-
-  // and store my header into the packet.
-  p->AddHeader (sourceHeader);
-
-  // print the content of my packet on the standard output.
-  p->Print (std::cout);
-  std::cout << std::endl;  
-
-  // you can now remove the header from the packet:
-  MyHeader destinationHeader;
-  p->RemoveHeader (destinationHeader);
-
-  // and check that the destination and source
-  // headers contain the same values.
-  NS_ASSERT (sourceHeader.GetData () == destinationHeader.GetData ());
-
-  return 0;
-}
--- a/samples/main-packet-tag.cc	Fri Apr 15 13:35:08 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2006,2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#include "ns3/tag.h"
-#include "ns3/packet.h"
-#include "ns3/uinteger.h"
-#include <iostream>
-
-using namespace ns3;
-
-// define this class in a public header
-class MyTag : public Tag
-{
-public:
-  static TypeId GetTypeId (void);
-  virtual TypeId GetInstanceTypeId (void) const;
-  virtual uint32_t GetSerializedSize (void) const;
-  virtual void Serialize (TagBuffer i) const;
-  virtual void Deserialize (TagBuffer i);
-  virtual void Print (std::ostream &os) const;
-  
-  // these are our accessors to our tag structure
-  void SetSimpleValue (uint8_t value);
-  uint8_t GetSimpleValue (void) const;
-private:
-  uint8_t m_simpleValue;
-};
-
-TypeId 
-MyTag::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::MyTag")
-    .SetParent<Tag> ()
-    .AddConstructor<MyTag> ()
-    .AddAttribute ("SimpleValue",
-                   "A simple value",
-                   EmptyAttributeValue (),
-                   MakeUintegerAccessor (&MyTag::GetSimpleValue),
-                   MakeUintegerChecker<uint8_t> ())
-    ;
-  return tid;
-}
-TypeId 
-MyTag::GetInstanceTypeId (void) const
-{
-  return GetTypeId ();
-}
-uint32_t 
-MyTag::GetSerializedSize (void) const
-{
-  return 1;
-}
-void 
-MyTag::Serialize (TagBuffer i) const
-{
-  i.WriteU8 (m_simpleValue);
-}
-void 
-MyTag::Deserialize (TagBuffer i)
-{
-  m_simpleValue = i.ReadU8 ();
-}
-void 
-MyTag::Print (std::ostream &os) const
-{
-  os << "v=" << (uint32_t)m_simpleValue;
-}
-void 
-MyTag::SetSimpleValue (uint8_t value)
-{
-  m_simpleValue = value;
-}
-uint8_t 
-MyTag::GetSimpleValue (void) const
-{
-  return m_simpleValue;
-}
-
-
-int main (int argc, char *argv[])
-{
-  // create a tag.
-  MyTag tag;
-  tag.SetSimpleValue (0x56);
-
-  // store the tag in a packet.
-  Ptr<Packet> p = Create<Packet> (100);
-  p->AddPacketTag (tag);
-
-  // create a copy of the packet
-  Ptr<Packet> aCopy = p->Copy ();
-
-  // read the tag from the packet copy
-  MyTag tagCopy;
-  p->PeekPacketTag (tagCopy);
-
-  // the copy and the original are the same !
-  NS_ASSERT (tagCopy.GetSimpleValue () == tag.GetSimpleValue ());
-
-  aCopy->PrintPacketTags (std::cout);
-  std::cout << std::endl;
-
-  return 0;
-}
--- a/samples/main-propagation-loss.cc	Fri Apr 15 13:35:08 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,312 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2008 Timo Bingmann
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Timo Bingmann <timo.bingmann@student.kit.edu>
- */
-
-#include "ns3/propagation-loss-model.h"
-#include "ns3/jakes-propagation-loss-model.h"
-#include "ns3/constant-position-mobility-model.h"
-
-#include "ns3/config.h"
-#include "ns3/string.h"
-#include "ns3/boolean.h"
-#include "ns3/double.h"
-#include "ns3/gnuplot.h"
-#include "ns3/simulator.h"
-
-#include <map>
-
-using namespace ns3;
-
-/// Round a double number to the given precision. e.g. dround(0.234, 0.1) = 0.2
-/// and dround(0.257, 0.1) = 0.3
-static double dround(double number, double precision)
-{
-  number /= precision;
-  if (number >= 0)
-    {
-      number = floor(number + 0.5);
-    }
-  else
-    {
-      number = ceil(number - 0.5);
-    }
-  number *= precision;
-  return number;
-}
-
-static Gnuplot
-TestDeterministic (Ptr<PropagationLossModel> model)
-{
-  Ptr<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
-  Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
-
-  Gnuplot plot;
-
-  plot.AppendExtra("set xlabel 'Distance'");
-  plot.AppendExtra("set ylabel 'rxPower (dBm)'");
-  plot.AppendExtra("set key top right");
-
-  double txPowerDbm = +20; // dBm
-
-  Gnuplot2dDataset dataset;
-
-  dataset.SetStyle(Gnuplot2dDataset::LINES);
-
-  {
-    a->SetPosition (Vector (0.0, 0.0, 0.0));
-
-    for (double distance = 0.0; distance < 2500.0; distance += 10.0)
-      {
-        b->SetPosition (Vector (distance, 0.0, 0.0));
-
-        // CalcRxPower() returns dBm.
-        double rxPowerDbm = model->CalcRxPower (txPowerDbm, a, b);
-
-        dataset.Add(distance, rxPowerDbm);
-
-        Simulator::Stop (Seconds (1.0));
-        Simulator::Run ();
-      }
-  }
-
-  std::ostringstream os;
-  os << "txPower " << txPowerDbm << "dBm";
-  dataset.SetTitle(os.str());
-
-  plot.AddDataset(dataset);
-
-  plot.AddDataset( Gnuplot2dFunction("-94 dBm CSThreshold", "-94.0") );
-
-  return plot;
-}
-
-static Gnuplot
-TestProbabilistic (Ptr<PropagationLossModel> model, unsigned int samples = 100000)
-{
-  Ptr<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
-  Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
-
-  Gnuplot plot;
-
-  plot.AppendExtra("set xlabel 'Distance'");
-  plot.AppendExtra("set ylabel 'rxPower (dBm)'");
-  plot.AppendExtra("set zlabel 'Probability' offset 0,+10");
-  plot.AppendExtra("set view 50, 120, 1.0, 1.0");
-  plot.AppendExtra("set key top right");
-
-  plot.AppendExtra("set ticslevel 0");
-  plot.AppendExtra("set xtics offset -0.5,0");
-  plot.AppendExtra("set ytics offset 0,-0.5");
-  plot.AppendExtra("set xrange [100:]");
-
-  double txPowerDbm = +20; // dBm
-
-  Gnuplot3dDataset dataset;
-
-  dataset.SetStyle("with linespoints");
-  dataset.SetExtra("pointtype 3 pointsize 0.5");
-  
-  typedef std::map<double, unsigned int> rxPowerMapType;
-
-  // Take given number of samples from CalcRxPower() and show probability
-  // density for discrete distances.
-  {
-    a->SetPosition (Vector (0.0, 0.0, 0.0));
-
-    for (double distance = 100.0; distance < 2500.0; distance += 100.0)
-      {
-        b->SetPosition (Vector (distance, 0.0, 0.0));
-
-        rxPowerMapType rxPowerMap;
-
-        for (unsigned int samp = 0; samp < samples; ++samp)
-          {
-            // CalcRxPower() returns dBm.
-            double rxPowerDbm = model->CalcRxPower (txPowerDbm, a, b);
-            rxPowerDbm = dround(rxPowerDbm, 1.0);
-
-            rxPowerMap[ rxPowerDbm ] ++;
-
-            Simulator::Stop (Seconds (0.01));
-            Simulator::Run ();
-          }
-
-        for (rxPowerMapType::const_iterator i = rxPowerMap.begin();
-             i != rxPowerMap.end(); ++i)
-          {
-            dataset.Add(distance, i->first, (double)i->second / (double)samples);
-          }
-        dataset.AddEmptyLine();
-      }
-  }
-
-  std::ostringstream os;
-  os << "txPower " << txPowerDbm << "dBm";
-  dataset.SetTitle(os.str());
-
-  plot.AddDataset(dataset);
-
-  return plot;
-}
-
-static Gnuplot
-TestDeterministicByTime (Ptr<PropagationLossModel> model,
-                         Time timeStep = Seconds(0.001),
-                         Time timeTotal = Seconds(1.0),
-                         double distance = 100.0)
-{
-  Ptr<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
-  Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
-
-  Gnuplot plot;
-
-  plot.AppendExtra("set xlabel 'Time (s)'");
-  plot.AppendExtra("set ylabel 'rxPower (dBm)'");
-  plot.AppendExtra("set key center right");
-
-  double txPowerDbm = +20; // dBm
-
-  Gnuplot2dDataset dataset;
-
-  dataset.SetStyle(Gnuplot2dDataset::LINES);
-
-  {
-    a->SetPosition (Vector (0.0, 0.0, 0.0));
-    b->SetPosition (Vector (distance, 0.0, 0.0));
-
-    Time start = Simulator::Now();
-    while( Simulator::Now() < start + timeTotal )
-      {
-        // CalcRxPower() returns dBm.
-        double rxPowerDbm = model->CalcRxPower (txPowerDbm, a, b);
-
-        Time elapsed = Simulator::Now() - start;
-        dataset.Add(elapsed.GetSeconds(), rxPowerDbm);
-
-        Simulator::Stop (timeStep);
-        Simulator::Run ();
-      }
-  }
-
-  std::ostringstream os;
-  os << "txPower " << txPowerDbm << "dBm";
-  dataset.SetTitle(os.str());
-
-  plot.AddDataset(dataset);
-
-  plot.AddDataset( Gnuplot2dFunction("-94 dBm CSThreshold", "-94.0") );
-
-  return plot;
-}
-
-int main (int argc, char *argv[])
-{
-  GnuplotCollection gnuplots("main-propagation-loss.pdf");
-
-  {
-    Ptr<FriisPropagationLossModel> friis = CreateObject<FriisPropagationLossModel> ();
-
-    Gnuplot plot = TestDeterministic(friis);
-    plot.SetTitle("ns3::FriisPropagationLossModel (Default Parameters)");
-    gnuplots.AddPlot(plot);
-  }
-
-  {
-    Ptr<LogDistancePropagationLossModel> log = CreateObject<LogDistancePropagationLossModel> ();
-    log->SetAttribute("Exponent", DoubleValue (2.5));
-
-    Gnuplot plot = TestDeterministic(log);
-    plot.SetTitle("ns3::LogDistancePropagationLossModel (Exponent = 2.5)");
-    gnuplots.AddPlot(plot);
-  }
-
-  {
-    Ptr<RandomPropagationLossModel> random = CreateObject<RandomPropagationLossModel> ();
-    random->SetAttribute("Variable", RandomVariableValue(ExponentialVariable(50.0)));
-
-    Gnuplot plot = TestDeterministic(random);
-    plot.SetTitle("ns3::RandomPropagationLossModel with Exponential Distribution");
-    gnuplots.AddPlot(plot);
-  }
-
-  {
-    Ptr<JakesPropagationLossModel> jakes = CreateObject<JakesPropagationLossModel> ();
-
-    // doppler frequency shift for 5.15 GHz at 100 km/h
-    jakes->SetAttribute("DopplerFreq", DoubleValue(477.9));
-
-    Gnuplot plot = TestDeterministicByTime (jakes, Seconds(0.001), Seconds(1.0));
-    plot.SetTitle("ns3::JakesPropagationLossModel (with 477.9 Hz shift and 1 millisec resolution)");
-    gnuplots.AddPlot(plot);
-  }
-
-  {
-    Ptr<JakesPropagationLossModel> jakes = CreateObject<JakesPropagationLossModel> ();
-
-    // doppler frequency shift for 5.15 GHz at 100 km/h
-    jakes->SetAttribute("DopplerFreq", DoubleValue(477.9));
-
-    Gnuplot plot = TestDeterministicByTime (jakes, Seconds(0.0001), Seconds(0.1));
-    plot.SetTitle("ns3::JakesPropagationLossModel (with 477.9 Hz shift and 0.1 millisec resolution)");
-    gnuplots.AddPlot(plot);
-  }
-
-  {
-    Ptr<ThreeLogDistancePropagationLossModel> log3 = CreateObject<ThreeLogDistancePropagationLossModel> ();
-
-    Gnuplot plot = TestDeterministic(log3);
-    plot.SetTitle("ns3::ThreeLogDistancePropagationLossModel (Defaults)");
-    gnuplots.AddPlot(plot);
-  }
-
-  {
-    Ptr<ThreeLogDistancePropagationLossModel> log3 = CreateObject<ThreeLogDistancePropagationLossModel> ();
-    // more prominent example values:
-    log3->SetAttribute("Exponent0", DoubleValue(1.0));
-    log3->SetAttribute("Exponent1", DoubleValue(3.0));
-    log3->SetAttribute("Exponent2", DoubleValue(10.0));
-
-    Gnuplot plot = TestDeterministic(log3);
-    plot.SetTitle("ns3::ThreeLogDistancePropagationLossModel (Exponents 1.0, 3.0 and 10.0)");
-    gnuplots.AddPlot(plot);
-  }
-
-  {
-    Ptr<NakagamiPropagationLossModel> nak = CreateObject<NakagamiPropagationLossModel> ();
-
-    Gnuplot plot = TestProbabilistic(nak);
-    plot.SetTitle("ns3::NakagamiPropagationLossModel (Default Parameters)");
-    gnuplots.AddPlot(plot);
-  }
-
-  {
-    Ptr<ThreeLogDistancePropagationLossModel> log3 = CreateObject<ThreeLogDistancePropagationLossModel> ();
-
-    Ptr<NakagamiPropagationLossModel> nak = CreateObject<NakagamiPropagationLossModel> ();
-    log3->SetNext(nak);
-
-    Gnuplot plot = TestProbabilistic(log3);
-    plot.SetTitle("ns3::ThreeLogDistancePropagationLossModel and ns3::NakagamiPropagationLossModel (Default Parameters)");
-    gnuplots.AddPlot(plot);
-  }
-
-  gnuplots.GenerateOutput(std::cout);
-
-  return 0;
-}
--- a/samples/main-ptr.cc	Fri Apr 15 13:35:08 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-#include "ns3/ptr.h"
-#include "ns3/object.h"
-#include <iostream>
-
-using namespace ns3;
-
-class A : public Object
-{
-public:
-  A ();
-  ~A ();
-  void Method (void);
-};
-A::A ()
-{
-  std::cout << "A constructor" << std::endl;
-}
-A::~A()
-{
-  std::cout << "A destructor" << std::endl;
-}
-void
-A::Method (void)
-{
-  std::cout << "A method" << std::endl;
-}
-
-static Ptr<A> g_a = 0;
-
-static Ptr<A>
-StoreA (Ptr<A> a)
-{
-  Ptr<A> prev = g_a;
-  g_a = a;
-  return prev;
-}
-
-static void
-ClearA (void)
-{
-  g_a = 0;
-}
-
-
-
-int main (int argc, char *argv[])
-{
-  {
-    // Create a new object of type A, store it in global 
-    // variable g_a
-    Ptr<A> a = CreateObject<A> ();
-    a->Method ();
-    Ptr<A> prev = StoreA (a);
-    NS_ASSERT (prev == 0);
-  }
-
-  {
-    // Create a new object of type A, store it in global 
-    // variable g_a, get a hold on the previous A object.
-    Ptr<A> a = CreateObject<A> ();
-    Ptr<A> prev = StoreA (a);
-    // call method on object
-    prev->Method ();
-    // Clear the currently-stored object
-    ClearA ();
-    // get the raw pointer and release it.
-    A *raw = GetPointer (prev);
-    prev = 0;
-    raw->Method ();
-    raw->Unref ();
-  }
-
-
-  return 0;
-}
--- a/samples/main-random-topology.cc	Fri Apr 15 13:35:08 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-
-#include "ns3/core-module.h"
-#include "ns3/mobility-module.h"
-
-using namespace ns3;
-
-static void 
-CourseChange (std::string context, Ptr<const MobilityModel> position)
-{
-  Vector pos = position->GetPosition ();
-  std::cout << Simulator::Now () << ", pos=" << position << ", x=" << pos.x << ", y=" << pos.y
-            << ", z=" << pos.z << std::endl;
-}
-
-int main (int argc, char *argv[])
-{
-  CommandLine cmd;
-  cmd.Parse (argc, argv);
-
-
-  NodeContainer c;
-  c.Create (10000);
-
-  MobilityHelper mobility;
-  mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator",
-                                 "X", StringValue ("100.0"),
-                                 "Y", StringValue ("100.0"),
-                                 "Rho", StringValue ("Uniform:0:30"));
-  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
-  mobility.Install (c);
-
-  Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
-                              MakeCallback (&CourseChange));
-  
-  Simulator::Stop (Seconds (100.0));
-
-  Simulator::Run ();
-  
-  return 0;
-}
--- a/samples/main-random-variable.cc	Fri Apr 15 13:35:08 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,377 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2008 Timo Bingmann
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Timo Bingmann <timo.bingmann@student.kit.edu>
- */
-#include "ns3/random-variable.h"
-#include "ns3/gnuplot.h"
-#include <map>
-#include <cmath>
-
-using namespace ns3;
-
-/// Round a double number to the given precision. e.g. dround(0.234, 0.1) = 0.2
-/// and dround(0.257, 0.1) = 0.3
-double dround(double number, double precision)
-{
-  number /= precision;
-  if (number >= 0)
-    number = std::floor(number + 0.5);
-  else
-    number = std::ceil(number - 0.5);
-  number *= precision;
-  return number;
-}
-
-static GnuplotDataset
-Histogramm (RandomVariable rndvar, unsigned int probes, double precision, const std::string& title, bool notcontinous = false)
-{
-  typedef std::map<double, unsigned int> histogramm_maptype;
-  histogramm_maptype histogramm;
-
-  for(unsigned int i = 0; i < probes; ++i)
-    {
-      double val = dround( rndvar.GetValue(), precision );
-
-      ++histogramm[val];
-    }
-
-  Gnuplot2dDataset data;
-  data.SetTitle(title);
-
-  if (notcontinous)
-    {
-      data.SetStyle(Gnuplot2dDataset::IMPULSES);
-    }
-
-  for(histogramm_maptype::const_iterator hi = histogramm.begin();
-      hi != histogramm.end(); ++hi)
-    {
-      data.Add(hi->first, (double)hi->second / (double)probes / precision);
-    }
-
-  return data;
-}
-
-int main (int argc, char *argv[])
-{
-  unsigned int probes = 1000000;
-  double precision = 0.01;
-
-  GnuplotCollection gnuplots("main-random-variables.pdf");
-  gnuplots.SetTerminal("pdf enhanced");
-
-  {
-    Gnuplot plot;
-    plot.SetTitle("UniformVariable");
-    plot.AppendExtra("set yrange [0:]");
-
-    plot.AddDataset( Histogramm(UniformVariable(0.0, 1.0), probes, precision,
-                                "UniformVariable [0.0 .. 1.0)") );
-
-    plot.AddDataset( Gnuplot2dFunction("0.1",
-                                       "0 <= x && x <= 1 ? 1.0 : 0") );
-
-    gnuplots.AddPlot(plot);
-  }
-
-  {
-    Gnuplot plot;
-    plot.SetTitle("ExponentialVariable");
-    plot.AppendExtra("set xrange [0:8]");
-    plot.AppendExtra("ExpDist(x,l) = 1/l * exp(-1/l * x)");
-
-    plot.AddDataset( Histogramm(ExponentialVariable(0.5), probes, precision,
-                                "ExponentialVariable m=0.5") );
-
-    plot.AddDataset( Gnuplot2dFunction("ExponentialDistribution mean 0.5",
-                                       "ExpDist(x, 0.5)") );
-
-    plot.AddDataset( Histogramm(ExponentialVariable(1.0), probes, precision,
-                                "ExponentialVariable m=1") );
-
-    plot.AddDataset( Gnuplot2dFunction("ExponentialDistribution mean 1.0",
-                                       "ExpDist(x, 1.0)") );
-
-    plot.AddDataset( Histogramm(ExponentialVariable(1.5), probes, precision,
-                                "ExponentialVariable m=1.5") );
-
-    plot.AddDataset( Gnuplot2dFunction("ExponentialDistribution mean 1.5",
-                                       "ExpDist(x, 1.5)") );
-
-    gnuplots.AddPlot(plot);
-  }
-
-  {
-    Gnuplot plot;
-    plot.SetTitle("ParetoVariable");
-    plot.AppendExtra("set xrange [0:2]");
-
-    plot.AddDataset( Histogramm(ParetoVariable(1.0, 1.5), probes, precision,
-                                "ParetoVariable m=1.0 s=1.5") );
-
-    plot.AddDataset( Histogramm(ParetoVariable(1.0, 2.0), probes, precision,
-                                "ParetoVariable m=1.0 s=2.0") );
-
-    plot.AddDataset( Histogramm(ParetoVariable(1.0, 2.5), probes, precision,
-                                "ParetoVariable m=1.0 s=2.5") );
-
-    gnuplots.AddPlot(plot);
-  }
-
-  {
-    Gnuplot plot;
-    plot.SetTitle("WeibullVariable");
-    plot.AppendExtra("set xrange [0:3]");
-
-    plot.AddDataset( Histogramm(WeibullVariable(1.0, 1.0), probes, precision,
-                                "WeibullVariable m=1.0 s=1.0") );
-
-    plot.AddDataset( Histogramm(WeibullVariable(1.0, 2.0), probes, precision,
-                                "WeibullVariable m=1.0 s=2.0") );
-
-    plot.AddDataset( Histogramm(WeibullVariable(1.0, 3.0), probes, precision,
-                                "WeibullVariable m=1.0 s=3.0") );
-
-    gnuplots.AddPlot(plot);
-  }
-
-  {
-    Gnuplot plot;
-    plot.SetTitle("NormalVariable");
-    plot.AppendExtra("set xrange [-3:3]");
-    plot.AppendExtra("NormalDist(x,m,s) = 1 / (s * sqrt(2*pi)) * exp(-1.0 / 2.0 * ((x-m) / s)**2)");
-
-    plot.AddDataset( Histogramm(NormalVariable(0.0, 1.0), probes, precision,
-                                "NormalVariable m=0.0 v=1.0") );
-
-    plot.AddDataset( Gnuplot2dFunction("NormalDist {/Symbol m}=0.0 {/Symbol s}=1.0",
-                                       "NormalDist(x,0.0,1.0)") );
-
-    plot.AddDataset( Histogramm(NormalVariable(0.0, 2.0), probes, precision,
-                                "NormalVariable m=0.0 v=2.0") );
-
-    plot.AddDataset( Gnuplot2dFunction("NormalDist {/Symbol m}=0.0 {/Symbol s}=sqrt(2.0)",
-                                       "NormalDist(x,0.0,sqrt(2.0))") );
-
-    plot.AddDataset( Histogramm(NormalVariable(0.0, 3.0), probes, precision,
-                                "NormalVariable m=0.0 v=3.0") );
-
-    plot.AddDataset( Gnuplot2dFunction("NormalDist {/Symbol m}=0.0 {/Symbol s}=sqrt(3.0)",
-                                       "NormalDist(x,0.0,sqrt(3.0))") );
-
-    gnuplots.AddPlot(plot);
-  }
-
-  {
-    Gnuplot plot;
-    plot.SetTitle("EmpiricalVariable");
-    plot.AppendExtra("set xrange [*:*]");
-
-    EmpiricalVariable emp1;
-    emp1.CDF(0.0,  0.0 / 15.0);
-    emp1.CDF(0.2,  1.0 / 15.0);
-    emp1.CDF(0.4,  3.0 / 15.0);
-    emp1.CDF(0.6,  6.0 / 15.0);
-    emp1.CDF(0.8, 10.0 / 15.0);
-    emp1.CDF(1.0, 15.0 / 15.0);
-
-    plot.AddDataset( Histogramm(emp1, probes, precision,
-                                "EmpiricalVariable (Stairs)") );
-
-    gnuplots.AddPlot(plot);
-  }
-
-  {
-    Gnuplot plot;
-    plot.SetTitle("DeterministicVariable");
-    plot.AppendExtra("set xrange [*:*]");
-
-    double values[] = { 0.0, 0.2, 0.2, 0.4, 0.2, 0.6, 0.8, 0.8, 1.0 };
-    DeterministicVariable det1 (values, sizeof(values) / sizeof(values[0]));
-
-    plot.AddDataset( Histogramm(det1, probes, precision,
-                                "DeterministicVariable", true) );
-
-    gnuplots.AddPlot(plot);
-  }
-
-  {
-    Gnuplot plot;
-    plot.SetTitle("LogNormalVariable");
-    plot.AppendExtra("set xrange [0:3]");
-
-    plot.AppendExtra("LogNormalDist(x,m,s) = 1.0/x * NormalDist(log(x), m, s)");
-
-    plot.AddDataset( Histogramm(LogNormalVariable(0.0, 1.0), probes, precision,
-                                "LogNormalVariable m=0.0 s=1.0") );
-
-    plot.AddDataset( Gnuplot2dFunction("LogNormalDist(x, 0.0, 1.0)",
-                                       "LogNormalDist(x, 0.0, 1.0)") );
-
-    plot.AddDataset( Histogramm(LogNormalVariable(0.0, 0.5), probes, precision,
-                                "LogNormalVariable m=0.0 s=0.5") );
-
-    plot.AddDataset( Histogramm(LogNormalVariable(0.0, 0.25), probes, precision,
-                                "LogNormalVariable m=0.0 s=0.25") );
-
-    plot.AddDataset( Gnuplot2dFunction("LogNormalDist(x, 0.0, 0.25)",
-                                       "LogNormalDist(x, 0.0, 0.25)") );
-
-    plot.AddDataset( Histogramm(LogNormalVariable(0.0, 0.125), probes, precision,
-                                "LogNormalVariable m=0.0 s=0.125") );
-
-    plot.AddDataset( Histogramm(LogNormalVariable(0.0, 2.0), probes, precision,
-                                "LogNormalVariable m=0.0 s=2.0") );
-
-    plot.AddDataset( Gnuplot2dFunction("LogNormalDist(x, 0.0, 2.0)",
-                                       "LogNormalDist(x, 0.0, 2.0)") );
-
-    plot.AddDataset( Histogramm(LogNormalVariable(0.0, 2.5), probes, precision,
-                                "LogNormalVariable m=0.0 s=2.5") );
-
-    gnuplots.AddPlot(plot);
-  }
-
-  {
-    Gnuplot plot;
-    plot.SetTitle("TriangularVariable");
-    plot.AppendExtra("set xrange [*:*]");
-
-    plot.AddDataset( Histogramm(TriangularVariable(0.0, 1.0, 0.5), probes, precision,
-                                "TriangularVariable [0.0 .. 1.0) m=0.5") );
-
-    plot.AddDataset( Histogramm(TriangularVariable(0.0, 1.0, 0.4), probes, precision,
-                                "TriangularVariable [0.0 .. 1.0) m=0.4") );
-
-    plot.AddDataset( Histogramm(TriangularVariable(0.0, 1.0, 0.65), probes, precision,
-                                "TriangularVariable [0.0 .. 1.0) m=0.65") );
-
-    gnuplots.AddPlot(plot);
-  }
-
-  {
-    Gnuplot plot;
-    plot.SetTitle("GammaVariable");
-    plot.AppendExtra("set xrange [0:10]");
-    plot.AppendExtra("set yrange [0:1]");
-    plot.AppendExtra("GammaDist(x,a,b) = x**(a-1) * 1/b**a * exp(-x/b) / gamma(a)");
-
-    plot.AppendExtra("set label 1 '{/Symbol g}(x,{/Symbol a},{/Symbol b}) = x^{/Symbol a-1} e^{-x {/Symbol b}^{-1}} ( {/Symbol b}^{/Symbol a} {/Symbol G}({/Symbol a}) )^{-1}' at 0.7, 0.9");
-
-    plot.AddDataset( Histogramm(GammaVariable(1.0, 1.0), probes, precision,
-                                "GammaVariable a=1.0 b=1.0") );
-
-    plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 1.0, 1.0)",
-                                       "GammaDist(x, 1.0, 1.0)") );
-
-    plot.AddDataset( Histogramm(GammaVariable(1.5, 1.0), probes, precision,
-                                "GammaVariable a=1.5 b=1.0") );
-
-    plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 1.5, 1.0)",
-                                       "GammaDist(x, 1.5, 1.0)") );
-
-    plot.AddDataset( Histogramm(GammaVariable(2.0, 1.0), probes, precision,
-                                "GammaVariable a=2.0 b=1.0") );
-
-    plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 2.0, 1.0)",
-                                       "GammaDist(x, 2.0, 1.0)") );
-
-    plot.AddDataset( Histogramm(GammaVariable(4.0, 1.0), probes, precision,
-                                "GammaVariable a=4.0 b=1.0") );
-
-    plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 4.0, 1.0)",
-                                       "GammaDist(x, 4.0, 1.0)") );
-
-    plot.AddDataset( Histogramm(GammaVariable(2.0, 2.0), probes, precision,
-                                "GammaVariable a=2.0 b=2.0") );
-
-    plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 2.0, 2.0)",
-                                       "GammaDist(x, 2.0, 2.0)") );
-
-    plot.AddDataset( Histogramm(GammaVariable(2.5, 3.0), probes, precision,
-                                "GammaVariable a=2.5 b=3.0") );
-
-    plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 2.5, 3.0)",
-                                       "GammaDist(x, 2.5, 3.0)") );
-
-    plot.AddDataset( Histogramm(GammaVariable(2.5, 4.5), probes, precision,
-                                "GammaVariable a=2.5 b=4.5") );
-
-    plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 2.5, 4.5)",
-                                       "GammaDist(x, 2.5, 4.5)") );
-
-    gnuplots.AddPlot(plot);
-  }
-
-  {
-    Gnuplot plot;
-    plot.SetTitle("ErlangVariable");
-    plot.AppendExtra("set xrange [0:10]");
-    plot.AppendExtra("ErlangDist(x,k,l) = x**(k-1) * 1/l**k * exp(-x/l) / (k-1)!");
-
-    plot.AppendExtra("set label 1 'Erlang(x,k,{/Symbol l}) = x^{k-1} e^{-x {/Symbol l}^{-1}} ( {/Symbol l}^k (k-1)! )^{-1}' at 0.7, 0.9");
-
-    plot.AddDataset( Histogramm(ErlangVariable(1, 1.0), probes, precision,
-                                "ErlangVariable k=1 {/Symbol l}=1.0") );
-
-    plot.AddDataset( Gnuplot2dFunction("Erlang(x, 1, 1.0)",
-                                       "ErlangDist(x, 1, 1.0)") );
-
-    plot.AddDataset( Histogramm(ErlangVariable(2, 1.0), probes, precision,
-                                "ErlangVariable k=2 {/Symbol l}=1.0") );
-
-    plot.AddDataset( Gnuplot2dFunction("Erlang(x, 2, 1.0)",
-                                       "ErlangDist(x, 2, 1.0)") );
-
-    plot.AddDataset( Histogramm(ErlangVariable(3, 1.0), probes, precision,
-                                "ErlangVariable k=3 {/Symbol l}=1.0") );
-
-    plot.AddDataset( Gnuplot2dFunction("Erlang(x, 3, 1.0)",
-                                       "ErlangDist(x, 3, 1.0)") );
-
-    plot.AddDataset( Histogramm(ErlangVariable(5, 1.0), probes, precision,
-                                "ErlangVariable k=5 {/Symbol l}=1.0") );
-
-    plot.AddDataset( Gnuplot2dFunction("Erlang(x, 5, 1.0)",
-                                       "ErlangDist(x, 5, 1.0)") );
-
-    plot.AddDataset( Histogramm(ErlangVariable(2, 2.0), probes, precision,
-                                "ErlangVariable k=2 {/Symbol l}=2.0") );
-
-    plot.AddDataset( Gnuplot2dFunction("Erlang(x, 2, 2.0)",
-                                       "ErlangDist(x, 2, 2.0)") );
-
-    plot.AddDataset( Histogramm(ErlangVariable(2, 3.0), probes, precision,
-                                "ErlangVariable k=2 {/Symbol l}=3.0") );
-
-    plot.AddDataset( Gnuplot2dFunction("Erlang(x, 2, 3.0)",
-                                       "ErlangDist(x, 2, 3.0)") );
-
-    plot.AddDataset( Histogramm(ErlangVariable(2, 5.0), probes, precision,
-                                "ErlangVariable k=2 {/Symbol l}=5.0") );
-
-    plot.AddDataset( Gnuplot2dFunction("Erlang(x, 2, 5.0)",
-                                       "ErlangDist(x, 2, 5.0)") );
-
-    gnuplots.AddPlot(plot);
-  }
-
-  gnuplots.GenerateOutput(std::cout);
-
-  return 0;
-}
--- a/samples/main-random-walk.cc	Fri Apr 15 13:35:08 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-
-#include "ns3/core-module.h"
-#include "ns3/mobility-module.h"
-
-using namespace ns3;
-
-static void 
-CourseChange (std::string foo, Ptr<const MobilityModel> mobility)
-{
-  Vector pos = mobility->GetPosition ();
-  Vector vel = mobility->GetVelocity ();
-  std::cout << Simulator::Now () << ", model=" << mobility << ", POS: x=" << pos.x << ", y=" << pos.y
-            << ", z=" << pos.z << "; VEL:" << vel.x << ", y=" << vel.y
-            << ", z=" << vel.z << std::endl;
-}
-
-int main (int argc, char *argv[])
-{
-  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Mode", StringValue ("Time"));
-  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Time", StringValue ("2s"));
-  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Speed", StringValue ("Constant:1.0"));
-  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Bounds", StringValue ("0|200|0|200"));
-
-  CommandLine cmd;
-  cmd.Parse (argc, argv);
-
-  NodeContainer c;
-  c.Create (100);
-
-  MobilityHelper mobility;
-  mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator",
-                                 "X", StringValue ("100.0"),
-                                 "Y", StringValue ("100.0"),
-                                 "Rho", StringValue ("Uniform:0:30"));
-  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
-                             "Mode", StringValue ("Time"),
-                             "Time", StringValue ("2s"),
-                             "Speed", StringValue ("Constant:1.0"),
-                             "Bounds", StringValue ("0|200|0|200"));
-  mobility.InstallAll ();
-  Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
-                   MakeCallback (&CourseChange));
-
-  Simulator::Stop (Seconds (100.0));
-
-  Simulator::Run ();
-  
-  return 0;
-}
--- a/samples/main-simple.cc	Fri Apr 15 13:35:08 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-#include <iostream>
-
-#include "ns3/core-module.h"
-#include "ns3/network-module.h"
-#include "ns3/internet-module.h"
-
-using namespace ns3;
-
-static void
-GenerateTraffic (Ptr<Socket> socket, uint32_t size)
-{
-  std::cout << "at=" << Simulator::Now ().GetSeconds () << "s, tx bytes=" << size << std::endl;
-  socket->Send (Create<Packet> (size));
-  if (size > 0)
-    {
-      Simulator::Schedule (Seconds (0.5), &GenerateTraffic, socket, size - 50);
-    }
-  else
-    {
-      socket->Close ();
-    }
-}
-
-static void
-SocketPrinter (Ptr<Socket> socket)
-{
-  Ptr<Packet> packet;
-  while (packet = socket->Recv ())
-    { 
-      std::cout << "at=" << Simulator::Now ().GetSeconds () << "s, rx bytes=" << packet->GetSize () << std::endl;
-    }
-}
-
-static void
-PrintTraffic (Ptr<Socket> socket)
-{
-  socket->SetRecvCallback (MakeCallback (&SocketPrinter));
-}
-
-void
-RunSimulation (void)
-{
-  NodeContainer c;
-  c.Create (1);
-
-  InternetStackHelper internet;
-  internet.Install (c);
-
-
-  TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
-  Ptr<Socket> sink = Socket::CreateSocket (c.Get (0), tid);
-  InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 80);
-  sink->Bind (local);
-
-  Ptr<Socket> source = Socket::CreateSocket (c.Get (0), tid);
-  InetSocketAddress remote = InetSocketAddress (Ipv4Address::GetLoopback (), 80);
-  source->Connect (remote);
-
-  GenerateTraffic (source, 500);
-  PrintTraffic (sink);
-
-
-  Simulator::Run ();
-
-  Simulator::Destroy ();
-}
-
-int main (int argc, char *argv[])
-{
-  RunSimulation ();
-
-  return 0;
-}
--- a/samples/main-test-sync.cc	Fri Apr 15 13:35:08 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,133 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-
-#include "ns3/simulator.h"
-#include "ns3/realtime-simulator-impl.h"
-#include "ns3/nstime.h"
-#include "ns3/log.h"
-#include "ns3/system-thread.h"
-#include "ns3/string.h"
-#include "ns3/config.h"
-#include "ns3/global-value.h"
-#include "ns3/ptr.h"
-
-#include <unistd.h>
-#include <sys/time.h>
-
-using namespace ns3;
-
-NS_LOG_COMPONENT_DEFINE ("TestSync");
-
-bool gFirstRun = false;
-
-void 
-inserted_function (void)
-{
-  NS_ASSERT (gFirstRun);
-  NS_LOG_UNCOND ("inserted_function() called at " << 
-    Simulator::Now ().GetSeconds () << " s");
-}
-
-void 
-background_function (void)
-{
-  NS_ASSERT (gFirstRun);
-  NS_LOG_UNCOND ("background_function() called at " << 
-    Simulator::Now ().GetSeconds () << " s");
-}
-
-void 
-first_function (void)
-{
-  NS_LOG_UNCOND ("first_function() called at " << 
-    Simulator::Now ().GetSeconds () << " s");
-  gFirstRun = true;
-}
-
-class FakeNetDevice
-{
-public:
-  FakeNetDevice ();
-  void Doit3 (void);
-  void Doit4 (void);
-};
-
-FakeNetDevice::FakeNetDevice ()
-{
-  NS_LOG_FUNCTION_NOARGS ();
-}
-
-void
-FakeNetDevice::Doit3 (void)
-{
-  NS_LOG_FUNCTION_NOARGS ();
-  sleep (1);
-  for (uint32_t i = 0; i < 10000; ++i)
-    {
-      //
-      // Exercise the realtime relative now path
-      //
-      DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ())->ScheduleRealtimeNow (MakeEvent (&inserted_function));
-      usleep (1000);
-    }
-}
-
-void
-FakeNetDevice::Doit4 (void)
-{
-  NS_LOG_FUNCTION_NOARGS ();
-  sleep (1);
-  for (uint32_t i = 0; i < 10000; ++i)
-    {
-      //
-      // Exercise the realtime relative schedule path
-      //
-      DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ())->ScheduleRealtime (Seconds (0), MakeEvent (&inserted_function));
-      usleep (1000);
-    }
-}
-
-void 
-test (void)
-{
-  GlobalValue::Bind ("SimulatorImplementationType", 
-    StringValue ("ns3::RealtimeSimulatorImpl"));
-
-  FakeNetDevice fnd;
-
-  // 
-  // Make sure ScheduleNow works when the system isn't running
-  //
-  DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ())->ScheduleRealtimeNow(MakeEvent (&first_function));
-
-  // 
-  // drive the progression of m_currentTs at a ten millisecond rate from the main thread
-  //
-  for (double d = 0.; d < 14.999; d += 0.01)
-    {
-      Simulator::Schedule (Seconds (d), &background_function);
-    }
-
-  Ptr<SystemThread> st3 = Create<SystemThread> (
-    MakeCallback (&FakeNetDevice::Doit3, &fnd));
-  st3->Start ();
-
-  Ptr<SystemThread> st4 = Create<SystemThread> (
-    MakeCallback (&FakeNetDevice::Doit4, &fnd));
-  st4->Start ();
-
-  Simulator::Stop (Seconds (15.0));
-  Simulator::Run ();
-  st3->Join ();
-  st4->Join ();
-  Simulator::Destroy ();
-}
-
-int
-main (int argc, char *argv[])
-{
-  while (true)
-    {
-      test ();
-    }
-}
-
--- a/samples/sample-random-variable.cc	Fri Apr 15 13:35:08 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "ns3/simulator.h"
-#include "ns3/nstime.h"
-#include "ns3/command-line.h"
-#include "ns3/random-variable.h"
-#include <iostream>
-
-using namespace ns3;
-using namespace std;
-
-/*
- * This program can be run from waf such as "./waf --run sample-random-variable"
- * 
- * This program is about as simple as possible to display the use of ns-3 
- * to generate random numbers.  By default, the uniform random variate that
- * will be outputted is 0.816532.  Because ns-3 uses a fixed seed for the
- * pseudo-random number generator, this program should always output the
- * same number.  Likewise, ns-3 simulations using random variables will
- * behave deterministically unless the user changes the RunNumber or the
- * Seed.  
- * 
- * There are three primary mechanisms to change the seed or run numbers
- * from their default integer value of 1
- * 1) Through explicit call of SeedManager::SetSeed () and 
- *    SeedManager::SetRun () (commented out below) 
- * 2) Through the passing of command line arguments such as:
- *    "./waf --command-template="%s --RngRun=<value>" --run program-name"
- * 3) Through the use of the NS_GLOBAL_VALUE environment variable, such as:
- *    "NS_GLOBAL_VALUE="RngRun=<value>" ./waf --run program-name"
- * 
- * For instance, setting the run number to 3 will change the program output to
- * 0.775417
- * 
- * Consult the ns-3 manual for more information about the use of the 
- * random number generator
- */
-
-int main (int argc, char *argv[])
-{
-  CommandLine cmd;
-  cmd.Parse (argc, argv);
-
-  // SeedManager::SetRun (3);
-
-  UniformVariable uv;
-
-  cout << uv.GetValue () << endl;
-  
-}
--- a/samples/sample-rng-plot.py	Fri Apr 15 13:35:08 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-# -*- Mode:Python; -*-
-# /*
-#  * This program is free software; you can redistribute it and/or modify
-#  * it under the terms of the GNU General Public License version 2 as
-#  * published by the Free Software Foundation
-#  *
-#  * This program is distributed in the hope that it will be useful,
-#  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  * GNU General Public License for more details.
-#  *
-#  * You should have received a copy of the GNU General Public License
-#  * along with this program; if not, write to the Free Software
-#  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-#  */
-
-# Demonstrate use of ns-3 as a random number generator integrated with
-# plotting tools; adapted from Gustavo Carneiro's ns-3 tutorial
-
-import numpy as np
-import matplotlib.pyplot as plt
-import ns3
-
-# mu, var = 100, 225
-rng = ns3.NormalVariable(100.0, 225.0)
-x = [rng.GetValue() for t in range(10000)]
-
-# the histogram of the data
-n, bins, patches = plt.hist(x, 50, normed=1, facecolor='g', alpha=0.75)
-
-plt.title('ns-3 histogram')
-plt.text(60, .025, r'$\mu=100,\ \sigma=15$')
-plt.axis([40, 160, 0, 0.03])
-plt.grid(True)
-plt.show()
--- a/samples/sample-simulator.cc	Fri Apr 15 13:35:08 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2010 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-
-#include <iostream>
-#include "ns3/simulator.h"
-#include "ns3/nstime.h"
-#include "ns3/command-line.h"
-#include "ns3/random-variable.h"
-
-using namespace ns3;
-
-class MyModel
-{
-public:
-  void Start (void);
-private:
-  void HandleEvent (double eventValue);
-};
-
-void
-MyModel::Start (void)
-{
-  Simulator::Schedule (Seconds (10.0),
-                       &MyModel::HandleEvent,
-                       this, Simulator::Now ().GetSeconds ());
-}
-void
-MyModel::HandleEvent (double value)
-{
-  std::cout << "Member method received event at "
-            << Simulator::Now ().GetSeconds ()
-            << "s started at " << value << "s" << std::endl;
-}
-
-static void
-ExampleFunction (MyModel *model)
-{
-  std::cout << "ExampleFunction received event at "
-            << Simulator::Now ().GetSeconds () << "s" << std::endl;
-  model->Start ();
-}
-
-static void
-RandomFunction (void)
-{
-  std::cout << "RandomFunction received event at "
-            << Simulator::Now ().GetSeconds () << "s" << std::endl;
-}
-
-static void
-CancelledEvent (void)
-{
-  std::cout << "I should never be called... " << std::endl;
-}
-
-int main (int argc, char *argv[])
-{
-  CommandLine cmd;
-  cmd.Parse (argc, argv);
-
-  MyModel model;
-  UniformVariable v = UniformVariable (10, 20);
-
-  Simulator::Schedule (Seconds (10.0), &ExampleFunction, &model);
-
-  Simulator::Schedule (Seconds (v.GetValue ()), &RandomFunction);
-
-  EventId id = Simulator::Schedule (Seconds (30.0), &CancelledEvent);
-  Simulator::Cancel (id);
-  
-  Simulator::Run ();
-
-  Simulator::Destroy ();
-}
--- a/samples/sample-simulator.py	Fri Apr 15 13:35:08 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-# -*- Mode:Python; -*-
-# /*
-#  * Copyright (c) 2010 INRIA
-#  *
-#  * This program is free software; you can redistribute it and/or modify
-#  * it under the terms of the GNU General Public License version 2 as
-#  * published by the Free Software Foundation;
-#  *
-#  * This program is distributed in the hope that it will be useful,
-#  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  * GNU General Public License for more details.
-#  *
-#  * You should have received a copy of the GNU General Public License
-#  * along with this program; if not, write to the Free Software
-#  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-#  *
-#  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
-#  */
-# 
-# Python version of sample-simulator.cc
-
-import ns3 as ns
-
-class MyModel(object):
-
-    def Start(self):
-        ns.Simulator.Schedule(ns.Seconds(10.0), self.HandleEvent, ns.Simulator.Now().GetSeconds())
-
-    def HandleEvent(self, value):
-        print "Member method received event at", ns.Simulator.Now().GetSeconds(), \
-            "s started at", value, "s"
-
-def ExampleFunction(model):
-    print "ExampleFunction received event at", ns.Simulator.Now().GetSeconds(), "s"
-    model.Start()
-
-def RandomFunction(model):
-    print "RandomFunction received event at", ns.Simulator.Now().GetSeconds(), "s"
-
-def CancelledEvent():
-    print "I should never be called... "
-
-def main(dummy_argv):
-
-    model = MyModel()
-    v = ns.UniformVariable(10,20)
-
-    ns.Simulator.Schedule(ns.Seconds(10.0), ExampleFunction, model)
-
-    ns.Simulator.Schedule(ns.Seconds(v.GetValue()), RandomFunction, model)
-
-    id = ns.Simulator.Schedule(ns.Seconds(30.0), CancelledEvent)
-    ns.Simulator.Cancel(id)
-
-    ns.Simulator.Run()
-
-    ns.Simulator.Destroy()
-
-if __name__ == '__main__':
-    import sys
-    main(sys.argv)
--- a/samples/waf	Fri Apr 15 13:35:08 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-exec "`dirname "$0"`"/../waf "$@"
--- a/samples/wscript	Fri Apr 15 13:35:08 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-
-def build(bld):
-    env = bld.env_of_name('default')
-    if not env['ENABLE_EXAMPLES']:
-        return;
-
-    obj = bld.create_ns3_program('main-attribute-value', ['core', 'node', 'devices/point-to-point'])
-    obj.source = 'main-attribute-value.cc'
-
-    obj = bld.create_ns3_program('main-callback', ['core'])
-    obj.source = 'main-callback.cc'
-
-    obj = bld.create_ns3_program('sample-simulator', ['core'])
-    obj.source = 'sample-simulator.cc'
-
-    obj = bld.create_ns3_program('main-ptr', ['core'] )
-    obj.source = 'main-ptr.cc'
-
-    obj = bld.create_ns3_program('main-random-variable', ['core', 'config-store', 'tools'])
-    obj.source = 'main-random-variable.cc'
-
-    obj = bld.create_ns3_program('main-packet-header', ['common', 'core'])
-    obj.source = 'main-packet-header.cc'
-
-    obj = bld.create_ns3_program('main-packet-tag', ['common', 'core'])
-    obj.source = 'main-packet-tag.cc'
-
-    if bld.env['ENABLE_THREADING'] and bld.env["ENABLE_REAL_TIME"]:
-        obj = bld.create_ns3_program('main-test-sync')
-        obj.source = 'main-test-sync.cc'
-
-    obj = bld.create_ns3_program('main-simple',
-                                 ['node', 'internet', 'applications'])
-    obj.source = 'main-simple.cc'
-
-    obj = bld.create_ns3_program('main-grid-topology',
-                                 ['core', 'mobility', 'network'])
-    obj.source = 'main-grid-topology.cc'
-
-    obj = bld.create_ns3_program('main-random-topology',
-                                 ['core', 'mobility'])
-    obj.source = 'main-random-topology.cc'
-    
-    obj = bld.create_ns3_program('main-random-walk',
-                                 ['core', 'mobility'])
-    obj.source = 'main-random-walk.cc'
-
-    obj = bld.create_ns3_program('main-propagation-loss',
-                                 ['core', 'mobility', 'config-store', 'tools', 'propagation'])
-    obj.source = 'main-propagation-loss.cc'
-
-    obj = bld.create_ns3_program('sample-random-variable',
-                                 ['core'])
-    obj.source = 'sample-random-variable.cc'
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/examples/main-attribute-value.cc	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,142 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008 University of Washington
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Tom Henderson <tomh@tomh.org>
+ */
+
+#include "ns3/log.h"
+#include "ns3/command-line.h"
+#include "ns3/ptr.h"
+#include "ns3/config.h"
+#include "ns3/uinteger.h"
+#include "ns3/string.h"
+#include "ns3/pointer.h"
+#include "ns3/simulator.h"
+
+#include "ns3/node.h"
+#include "ns3/queue.h"
+#include "ns3/drop-tail-queue.h"
+#include "ns3/point-to-point-net-device.h"
+
+using namespace ns3;
+
+NS_LOG_COMPONENT_DEFINE ("AttributeValueSample");
+
+//
+// This is a basic example of how to use the attribute system to
+// set and get a value in the underlying system; namely, an unsigned
+// integer of the maximum number of packets in a queue
+//
+
+int 
+main (int argc, char *argv[])
+{
+  LogComponentEnable ("AttributeValueSample", LOG_LEVEL_INFO);
+
+  // By default, the MaxPackets attribute has a value of 100 packets
+  // (this default can be observed in the function DropTailQueue::GetTypeId)
+  // 
+  // Here, we set it to 80 packets.  We could use one of two value types:
+  // a string-based value or a UintegerValue value
+  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("80"));
+  // The below function call is redundant
+  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (80));
+
+  // Allow the user to override any of the defaults and the above
+  // SetDefaults() at run-time, via command-line arguments
+  CommandLine cmd;
+  cmd.Parse (argc, argv);
+
+  // Now, we will create a few objects using the low-level API
+  Ptr<Node> n0 = CreateObject<Node> ();
+
+  Ptr<PointToPointNetDevice> net0 = CreateObject<PointToPointNetDevice> ();
+  n0->AddDevice (net0);
+
+  Ptr<Queue> q = CreateObject<DropTailQueue> ();
+  net0->SetQueue(q);
+
+  // At this point, we have created a single node (Node 0) and a 
+  // single PointToPointNetDevice (NetDevice 0) and added a 
+  // DropTailQueue to it.
+
+  // Now, we can manipulate the MaxPackets value of the already 
+  // instantiated DropTailQueue.  Here are various ways to do that.
+
+  // We assume that a smart pointer (Ptr) to a relevant network device
+  // is in hand; here, it is the net0 pointer. 
+
+  // 1.  Pointer-based access
+  //
+  // One way to change the value is to access a pointer to the
+  // underlying queue and modify its attribute.
+  // 
+  // First, we observe that we can get a pointer to the (base class)
+  // queue via the PointToPointNetDevice attributes, where it is called
+  // TxQueue 
+  PointerValue ptr;
+  net0->GetAttribute ("TxQueue", ptr);
+  Ptr<Queue> txQueue = ptr.Get<Queue> ();
+
+  // Using the GetObject function, we can perform a safe downcast
+  // to a DropTailQueue, where MaxPackets is a member
+  Ptr<DropTailQueue> dtq = txQueue->GetObject <DropTailQueue> ();
+  NS_ASSERT (dtq);
+
+  // Next, we can get the value of an attribute on this queue
+  // We have introduced wrapper "Value" classes for the underlying
+  // data types, similar to Java wrappers around these types, since
+  // the attribute system stores values and not disparate types.
+  // Here, the attribute value is assigned to a Uinteger, and
+  // the Get() method on this value produces the (unwrapped) uint32_t.
+  UintegerValue limit;
+  dtq->GetAttribute ("MaxPackets", limit);
+  NS_LOG_INFO ("1.  dtq limit: " << limit.Get () << " packets");
+  
+  // Note that the above downcast is not really needed; we could have
+  // done the same using the Ptr<Queue> even though the attribute
+  // is a member of the subclass
+  txQueue->GetAttribute ("MaxPackets", limit);
+  NS_LOG_INFO ("2.  txQueue limit: " << limit.Get () << " packets");
+
+  // Now, let's set it to another value (60 packets)
+  txQueue->SetAttribute("MaxPackets", UintegerValue (60));
+  txQueue->GetAttribute ("MaxPackets", limit);
+  NS_LOG_INFO ("3.  txQueue limit changed: " << limit.Get () << " packets");
+
+  // 2.  Namespace-based access
+  //
+  // An alternative way to get at the attribute is to use the configuration
+  // namespace.  Here, this attribute resides on a known path in this
+  // namespace; this approach is useful if one doesn't have access to
+  // the underlying pointers and would like to configure a specific
+  // attribute with a single statement.  
+  Config::Set ("/NodeList/0/DeviceList/0/TxQueue/MaxPackets", UintegerValue (25));
+  txQueue->GetAttribute ("MaxPackets", limit); 
+  NS_LOG_INFO ("4.  txQueue limit changed through namespace: " << 
+               limit.Get () << " packets");
+
+  // we could have also used wildcards to set this value for all nodes
+  // and all net devices (which in this simple example has the same
+  // effect as the previous Set())
+  Config::Set ("/NodeList/*/DeviceList/*/TxQueue/MaxPackets", UintegerValue (15));
+  txQueue->GetAttribute ("MaxPackets", limit); 
+  NS_LOG_INFO ("5.  txQueue limit changed through wildcarded namespace: " << 
+               limit.Get () << " packets");
+
+  Simulator::Destroy ();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/examples/main-callback.cc	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,72 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+#include "ns3/callback.h"
+#include "ns3/assert.h"
+#include <iostream>
+
+using namespace ns3;
+
+static double 
+CbOne (double a, double b)
+{
+  std::cout << "invoke cbOne a=" << a << ", b=" << b << std::endl;
+  return a;
+}
+
+class MyCb {
+public:
+  int CbTwo (double a) {
+      std::cout << "invoke cbTwo a=" << a << std::endl;
+      return -5;
+  }
+};
+
+
+int main (int argc, char *argv[])
+{
+  // return type: double
+  // first arg type: double
+  // second arg type: double
+  Callback<double, double, double> one;
+  // build callback instance which points to cbOne function
+  one = MakeCallback (&CbOne);
+  // this is not a null callback
+  NS_ASSERT (!one.IsNull ());
+  // invoke cbOne function through callback instance
+  double retOne;
+  retOne = one (10.0, 20.0);
+
+  // return type: int
+  // first arg type: double
+  Callback<int, double> two;
+  MyCb cb;
+  // build callback instance which points to MyCb::cbTwo
+  two = MakeCallback (&MyCb::CbTwo, &cb);
+  // this is not a null callback
+  NS_ASSERT (!two.IsNull ());
+  // invoke MyCb::cbTwo through callback instance
+  int retTwo;
+  retTwo = two (10.0);    
+
+  two = MakeNullCallback<int, double> ();
+  // invoking a null callback is just like
+  // invoking a null function pointer:
+  // it will crash.
+  //int retTwoNull = two (20.0);
+  NS_ASSERT (two.IsNull ());
+
+#if 0
+  // The below type mismatch between CbOne() and callback two will fail to 
+  // compile if enabled in this program.
+  two = MakeCallback (&CbOne);
+#endif
+
+#if 0
+  // This is a slightly different example, in which the code will compile
+  // but because callbacks are type-safe, will cause a fatal error at runtime 
+  // (the difference here is that Assign() is called instead of operator=)
+  Callback<void, float> three;
+  three.Assign (MakeCallback (&CbOne));
+#endif
+
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/examples/main-ptr.cc	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,76 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+#include "ns3/ptr.h"
+#include "ns3/object.h"
+#include <iostream>
+
+using namespace ns3;
+
+class A : public Object
+{
+public:
+  A ();
+  ~A ();
+  void Method (void);
+};
+A::A ()
+{
+  std::cout << "A constructor" << std::endl;
+}
+A::~A()
+{
+  std::cout << "A destructor" << std::endl;
+}
+void
+A::Method (void)
+{
+  std::cout << "A method" << std::endl;
+}
+
+static Ptr<A> g_a = 0;
+
+static Ptr<A>
+StoreA (Ptr<A> a)
+{
+  Ptr<A> prev = g_a;
+  g_a = a;
+  return prev;
+}
+
+static void
+ClearA (void)
+{
+  g_a = 0;
+}
+
+
+
+int main (int argc, char *argv[])
+{
+  {
+    // Create a new object of type A, store it in global 
+    // variable g_a
+    Ptr<A> a = CreateObject<A> ();
+    a->Method ();
+    Ptr<A> prev = StoreA (a);
+    NS_ASSERT (prev == 0);
+  }
+
+  {
+    // Create a new object of type A, store it in global 
+    // variable g_a, get a hold on the previous A object.
+    Ptr<A> a = CreateObject<A> ();
+    Ptr<A> prev = StoreA (a);
+    // call method on object
+    prev->Method ();
+    // Clear the currently-stored object
+    ClearA ();
+    // get the raw pointer and release it.
+    A *raw = GetPointer (prev);
+    prev = 0;
+    raw->Method ();
+    raw->Unref ();
+  }
+
+
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/examples/main-random-variable.cc	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,377 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008 Timo Bingmann
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Timo Bingmann <timo.bingmann@student.kit.edu>
+ */
+#include "ns3/random-variable.h"
+#include "ns3/gnuplot.h"
+#include <map>
+#include <cmath>
+
+using namespace ns3;
+
+/// Round a double number to the given precision. e.g. dround(0.234, 0.1) = 0.2
+/// and dround(0.257, 0.1) = 0.3
+double dround(double number, double precision)
+{
+  number /= precision;
+  if (number >= 0)
+    number = std::floor(number + 0.5);
+  else
+    number = std::ceil(number - 0.5);
+  number *= precision;
+  return number;
+}
+
+static GnuplotDataset
+Histogramm (RandomVariable rndvar, unsigned int probes, double precision, const std::string& title, bool notcontinous = false)
+{
+  typedef std::map<double, unsigned int> histogramm_maptype;
+  histogramm_maptype histogramm;
+
+  for(unsigned int i = 0; i < probes; ++i)
+    {
+      double val = dround( rndvar.GetValue(), precision );
+
+      ++histogramm[val];
+    }
+
+  Gnuplot2dDataset data;
+  data.SetTitle(title);
+
+  if (notcontinous)
+    {
+      data.SetStyle(Gnuplot2dDataset::IMPULSES);
+    }
+
+  for(histogramm_maptype::const_iterator hi = histogramm.begin();
+      hi != histogramm.end(); ++hi)
+    {
+      data.Add(hi->first, (double)hi->second / (double)probes / precision);
+    }
+
+  return data;
+}
+
+int main (int argc, char *argv[])
+{
+  unsigned int probes = 1000000;
+  double precision = 0.01;
+
+  GnuplotCollection gnuplots("main-random-variables.pdf");
+  gnuplots.SetTerminal("pdf enhanced");
+
+  {
+    Gnuplot plot;
+    plot.SetTitle("UniformVariable");
+    plot.AppendExtra("set yrange [0:]");
+
+    plot.AddDataset( Histogramm(UniformVariable(0.0, 1.0), probes, precision,
+                                "UniformVariable [0.0 .. 1.0)") );
+
+    plot.AddDataset( Gnuplot2dFunction("0.1",
+                                       "0 <= x && x <= 1 ? 1.0 : 0") );
+
+    gnuplots.AddPlot(plot);
+  }
+
+  {
+    Gnuplot plot;
+    plot.SetTitle("ExponentialVariable");
+    plot.AppendExtra("set xrange [0:8]");
+    plot.AppendExtra("ExpDist(x,l) = 1/l * exp(-1/l * x)");
+
+    plot.AddDataset( Histogramm(ExponentialVariable(0.5), probes, precision,
+                                "ExponentialVariable m=0.5") );
+
+    plot.AddDataset( Gnuplot2dFunction("ExponentialDistribution mean 0.5",
+                                       "ExpDist(x, 0.5)") );
+
+    plot.AddDataset( Histogramm(ExponentialVariable(1.0), probes, precision,
+                                "ExponentialVariable m=1") );
+
+    plot.AddDataset( Gnuplot2dFunction("ExponentialDistribution mean 1.0",
+                                       "ExpDist(x, 1.0)") );
+
+    plot.AddDataset( Histogramm(ExponentialVariable(1.5), probes, precision,
+                                "ExponentialVariable m=1.5") );
+
+    plot.AddDataset( Gnuplot2dFunction("ExponentialDistribution mean 1.5",
+                                       "ExpDist(x, 1.5)") );
+
+    gnuplots.AddPlot(plot);
+  }
+
+  {
+    Gnuplot plot;
+    plot.SetTitle("ParetoVariable");
+    plot.AppendExtra("set xrange [0:2]");
+
+    plot.AddDataset( Histogramm(ParetoVariable(1.0, 1.5), probes, precision,
+                                "ParetoVariable m=1.0 s=1.5") );
+
+    plot.AddDataset( Histogramm(ParetoVariable(1.0, 2.0), probes, precision,
+                                "ParetoVariable m=1.0 s=2.0") );
+
+    plot.AddDataset( Histogramm(ParetoVariable(1.0, 2.5), probes, precision,
+                                "ParetoVariable m=1.0 s=2.5") );
+
+    gnuplots.AddPlot(plot);
+  }
+
+  {
+    Gnuplot plot;
+    plot.SetTitle("WeibullVariable");
+    plot.AppendExtra("set xrange [0:3]");
+
+    plot.AddDataset( Histogramm(WeibullVariable(1.0, 1.0), probes, precision,
+                                "WeibullVariable m=1.0 s=1.0") );
+
+    plot.AddDataset( Histogramm(WeibullVariable(1.0, 2.0), probes, precision,
+                                "WeibullVariable m=1.0 s=2.0") );
+
+    plot.AddDataset( Histogramm(WeibullVariable(1.0, 3.0), probes, precision,
+                                "WeibullVariable m=1.0 s=3.0") );
+
+    gnuplots.AddPlot(plot);
+  }
+
+  {
+    Gnuplot plot;
+    plot.SetTitle("NormalVariable");
+    plot.AppendExtra("set xrange [-3:3]");
+    plot.AppendExtra("NormalDist(x,m,s) = 1 / (s * sqrt(2*pi)) * exp(-1.0 / 2.0 * ((x-m) / s)**2)");
+
+    plot.AddDataset( Histogramm(NormalVariable(0.0, 1.0), probes, precision,
+                                "NormalVariable m=0.0 v=1.0") );
+
+    plot.AddDataset( Gnuplot2dFunction("NormalDist {/Symbol m}=0.0 {/Symbol s}=1.0",
+                                       "NormalDist(x,0.0,1.0)") );
+
+    plot.AddDataset( Histogramm(NormalVariable(0.0, 2.0), probes, precision,
+                                "NormalVariable m=0.0 v=2.0") );
+
+    plot.AddDataset( Gnuplot2dFunction("NormalDist {/Symbol m}=0.0 {/Symbol s}=sqrt(2.0)",
+                                       "NormalDist(x,0.0,sqrt(2.0))") );
+
+    plot.AddDataset( Histogramm(NormalVariable(0.0, 3.0), probes, precision,
+                                "NormalVariable m=0.0 v=3.0") );
+
+    plot.AddDataset( Gnuplot2dFunction("NormalDist {/Symbol m}=0.0 {/Symbol s}=sqrt(3.0)",
+                                       "NormalDist(x,0.0,sqrt(3.0))") );
+
+    gnuplots.AddPlot(plot);
+  }
+
+  {
+    Gnuplot plot;
+    plot.SetTitle("EmpiricalVariable");
+    plot.AppendExtra("set xrange [*:*]");
+
+    EmpiricalVariable emp1;
+    emp1.CDF(0.0,  0.0 / 15.0);
+    emp1.CDF(0.2,  1.0 / 15.0);
+    emp1.CDF(0.4,  3.0 / 15.0);
+    emp1.CDF(0.6,  6.0 / 15.0);
+    emp1.CDF(0.8, 10.0 / 15.0);
+    emp1.CDF(1.0, 15.0 / 15.0);
+
+    plot.AddDataset( Histogramm(emp1, probes, precision,
+                                "EmpiricalVariable (Stairs)") );
+
+    gnuplots.AddPlot(plot);
+  }
+
+  {
+    Gnuplot plot;
+    plot.SetTitle("DeterministicVariable");
+    plot.AppendExtra("set xrange [*:*]");
+
+    double values[] = { 0.0, 0.2, 0.2, 0.4, 0.2, 0.6, 0.8, 0.8, 1.0 };
+    DeterministicVariable det1 (values, sizeof(values) / sizeof(values[0]));
+
+    plot.AddDataset( Histogramm(det1, probes, precision,
+                                "DeterministicVariable", true) );
+
+    gnuplots.AddPlot(plot);
+  }
+
+  {
+    Gnuplot plot;
+    plot.SetTitle("LogNormalVariable");
+    plot.AppendExtra("set xrange [0:3]");
+
+    plot.AppendExtra("LogNormalDist(x,m,s) = 1.0/x * NormalDist(log(x), m, s)");
+
+    plot.AddDataset( Histogramm(LogNormalVariable(0.0, 1.0), probes, precision,
+                                "LogNormalVariable m=0.0 s=1.0") );
+
+    plot.AddDataset( Gnuplot2dFunction("LogNormalDist(x, 0.0, 1.0)",
+                                       "LogNormalDist(x, 0.0, 1.0)") );
+
+    plot.AddDataset( Histogramm(LogNormalVariable(0.0, 0.5), probes, precision,
+                                "LogNormalVariable m=0.0 s=0.5") );
+
+    plot.AddDataset( Histogramm(LogNormalVariable(0.0, 0.25), probes, precision,
+                                "LogNormalVariable m=0.0 s=0.25") );
+
+    plot.AddDataset( Gnuplot2dFunction("LogNormalDist(x, 0.0, 0.25)",
+                                       "LogNormalDist(x, 0.0, 0.25)") );
+
+    plot.AddDataset( Histogramm(LogNormalVariable(0.0, 0.125), probes, precision,
+                                "LogNormalVariable m=0.0 s=0.125") );
+
+    plot.AddDataset( Histogramm(LogNormalVariable(0.0, 2.0), probes, precision,
+                                "LogNormalVariable m=0.0 s=2.0") );
+
+    plot.AddDataset( Gnuplot2dFunction("LogNormalDist(x, 0.0, 2.0)",
+                                       "LogNormalDist(x, 0.0, 2.0)") );
+
+    plot.AddDataset( Histogramm(LogNormalVariable(0.0, 2.5), probes, precision,
+                                "LogNormalVariable m=0.0 s=2.5") );
+
+    gnuplots.AddPlot(plot);
+  }
+
+  {
+    Gnuplot plot;
+    plot.SetTitle("TriangularVariable");
+    plot.AppendExtra("set xrange [*:*]");
+
+    plot.AddDataset( Histogramm(TriangularVariable(0.0, 1.0, 0.5), probes, precision,
+                                "TriangularVariable [0.0 .. 1.0) m=0.5") );
+
+    plot.AddDataset( Histogramm(TriangularVariable(0.0, 1.0, 0.4), probes, precision,
+                                "TriangularVariable [0.0 .. 1.0) m=0.4") );
+
+    plot.AddDataset( Histogramm(TriangularVariable(0.0, 1.0, 0.65), probes, precision,
+                                "TriangularVariable [0.0 .. 1.0) m=0.65") );
+
+    gnuplots.AddPlot(plot);
+  }
+
+  {
+    Gnuplot plot;
+    plot.SetTitle("GammaVariable");
+    plot.AppendExtra("set xrange [0:10]");
+    plot.AppendExtra("set yrange [0:1]");
+    plot.AppendExtra("GammaDist(x,a,b) = x**(a-1) * 1/b**a * exp(-x/b) / gamma(a)");
+
+    plot.AppendExtra("set label 1 '{/Symbol g}(x,{/Symbol a},{/Symbol b}) = x^{/Symbol a-1} e^{-x {/Symbol b}^{-1}} ( {/Symbol b}^{/Symbol a} {/Symbol G}({/Symbol a}) )^{-1}' at 0.7, 0.9");
+
+    plot.AddDataset( Histogramm(GammaVariable(1.0, 1.0), probes, precision,
+                                "GammaVariable a=1.0 b=1.0") );
+
+    plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 1.0, 1.0)",
+                                       "GammaDist(x, 1.0, 1.0)") );
+
+    plot.AddDataset( Histogramm(GammaVariable(1.5, 1.0), probes, precision,
+                                "GammaVariable a=1.5 b=1.0") );
+
+    plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 1.5, 1.0)",
+                                       "GammaDist(x, 1.5, 1.0)") );
+
+    plot.AddDataset( Histogramm(GammaVariable(2.0, 1.0), probes, precision,
+                                "GammaVariable a=2.0 b=1.0") );
+
+    plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 2.0, 1.0)",
+                                       "GammaDist(x, 2.0, 1.0)") );
+
+    plot.AddDataset( Histogramm(GammaVariable(4.0, 1.0), probes, precision,
+                                "GammaVariable a=4.0 b=1.0") );
+
+    plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 4.0, 1.0)",
+                                       "GammaDist(x, 4.0, 1.0)") );
+
+    plot.AddDataset( Histogramm(GammaVariable(2.0, 2.0), probes, precision,
+                                "GammaVariable a=2.0 b=2.0") );
+
+    plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 2.0, 2.0)",
+                                       "GammaDist(x, 2.0, 2.0)") );
+
+    plot.AddDataset( Histogramm(GammaVariable(2.5, 3.0), probes, precision,
+                                "GammaVariable a=2.5 b=3.0") );
+
+    plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 2.5, 3.0)",
+                                       "GammaDist(x, 2.5, 3.0)") );
+
+    plot.AddDataset( Histogramm(GammaVariable(2.5, 4.5), probes, precision,
+                                "GammaVariable a=2.5 b=4.5") );
+
+    plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 2.5, 4.5)",
+                                       "GammaDist(x, 2.5, 4.5)") );
+
+    gnuplots.AddPlot(plot);
+  }
+
+  {
+    Gnuplot plot;
+    plot.SetTitle("ErlangVariable");
+    plot.AppendExtra("set xrange [0:10]");
+    plot.AppendExtra("ErlangDist(x,k,l) = x**(k-1) * 1/l**k * exp(-x/l) / (k-1)!");
+
+    plot.AppendExtra("set label 1 'Erlang(x,k,{/Symbol l}) = x^{k-1} e^{-x {/Symbol l}^{-1}} ( {/Symbol l}^k (k-1)! )^{-1}' at 0.7, 0.9");
+
+    plot.AddDataset( Histogramm(ErlangVariable(1, 1.0), probes, precision,
+                                "ErlangVariable k=1 {/Symbol l}=1.0") );
+
+    plot.AddDataset( Gnuplot2dFunction("Erlang(x, 1, 1.0)",
+                                       "ErlangDist(x, 1, 1.0)") );
+
+    plot.AddDataset( Histogramm(ErlangVariable(2, 1.0), probes, precision,
+                                "ErlangVariable k=2 {/Symbol l}=1.0") );
+
+    plot.AddDataset( Gnuplot2dFunction("Erlang(x, 2, 1.0)",
+                                       "ErlangDist(x, 2, 1.0)") );
+
+    plot.AddDataset( Histogramm(ErlangVariable(3, 1.0), probes, precision,
+                                "ErlangVariable k=3 {/Symbol l}=1.0") );
+
+    plot.AddDataset( Gnuplot2dFunction("Erlang(x, 3, 1.0)",
+                                       "ErlangDist(x, 3, 1.0)") );
+
+    plot.AddDataset( Histogramm(ErlangVariable(5, 1.0), probes, precision,
+                                "ErlangVariable k=5 {/Symbol l}=1.0") );
+
+    plot.AddDataset( Gnuplot2dFunction("Erlang(x, 5, 1.0)",
+                                       "ErlangDist(x, 5, 1.0)") );
+
+    plot.AddDataset( Histogramm(ErlangVariable(2, 2.0), probes, precision,
+                                "ErlangVariable k=2 {/Symbol l}=2.0") );
+
+    plot.AddDataset( Gnuplot2dFunction("Erlang(x, 2, 2.0)",
+                                       "ErlangDist(x, 2, 2.0)") );
+
+    plot.AddDataset( Histogramm(ErlangVariable(2, 3.0), probes, precision,
+                                "ErlangVariable k=2 {/Symbol l}=3.0") );
+
+    plot.AddDataset( Gnuplot2dFunction("Erlang(x, 2, 3.0)",
+                                       "ErlangDist(x, 2, 3.0)") );
+
+    plot.AddDataset( Histogramm(ErlangVariable(2, 5.0), probes, precision,
+                                "ErlangVariable k=2 {/Symbol l}=5.0") );
+
+    plot.AddDataset( Gnuplot2dFunction("Erlang(x, 2, 5.0)",
+                                       "ErlangDist(x, 2, 5.0)") );
+
+    gnuplots.AddPlot(plot);
+  }
+
+  gnuplots.GenerateOutput(std::cout);
+
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/examples/sample-random-variable.cc	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,63 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include "ns3/simulator.h"
+#include "ns3/nstime.h"
+#include "ns3/command-line.h"
+#include "ns3/random-variable.h"
+#include <iostream>
+
+using namespace ns3;
+using namespace std;
+
+/*
+ * This program can be run from waf such as "./waf --run sample-random-variable"
+ * 
+ * This program is about as simple as possible to display the use of ns-3 
+ * to generate random numbers.  By default, the uniform random variate that
+ * will be outputted is 0.816532.  Because ns-3 uses a fixed seed for the
+ * pseudo-random number generator, this program should always output the
+ * same number.  Likewise, ns-3 simulations using random variables will
+ * behave deterministically unless the user changes the RunNumber or the
+ * Seed.  
+ * 
+ * There are three primary mechanisms to change the seed or run numbers
+ * from their default integer value of 1
+ * 1) Through explicit call of SeedManager::SetSeed () and 
+ *    SeedManager::SetRun () (commented out below) 
+ * 2) Through the passing of command line arguments such as:
+ *    "./waf --command-template="%s --RngRun=<value>" --run program-name"
+ * 3) Through the use of the NS_GLOBAL_VALUE environment variable, such as:
+ *    "NS_GLOBAL_VALUE="RngRun=<value>" ./waf --run program-name"
+ * 
+ * For instance, setting the run number to 3 will change the program output to
+ * 0.775417
+ * 
+ * Consult the ns-3 manual for more information about the use of the 
+ * random number generator
+ */
+
+int main (int argc, char *argv[])
+{
+  CommandLine cmd;
+  cmd.Parse (argc, argv);
+
+  // SeedManager::SetRun (3);
+
+  UniformVariable uv;
+
+  cout << uv.GetValue () << endl;
+  
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/examples/sample-rng-plot.py	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,35 @@
+# -*- Mode:Python; -*-
+# /*
+#  * This program is free software; you can redistribute it and/or modify
+#  * it under the terms of the GNU General Public License version 2 as
+#  * published by the Free Software Foundation
+#  *
+#  * This program is distributed in the hope that it will be useful,
+#  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  * GNU General Public License for more details.
+#  *
+#  * You should have received a copy of the GNU General Public License
+#  * along with this program; if not, write to the Free Software
+#  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#  */
+
+# Demonstrate use of ns-3 as a random number generator integrated with
+# plotting tools; adapted from Gustavo Carneiro's ns-3 tutorial
+
+import numpy as np
+import matplotlib.pyplot as plt
+import ns3
+
+# mu, var = 100, 225
+rng = ns3.NormalVariable(100.0, 225.0)
+x = [rng.GetValue() for t in range(10000)]
+
+# the histogram of the data
+n, bins, patches = plt.hist(x, 50, normed=1, facecolor='g', alpha=0.75)
+
+plt.title('ns-3 histogram')
+plt.text(60, .025, r'$\mu=100,\ \sigma=15$')
+plt.axis([40, 160, 0, 0.03])
+plt.grid(True)
+plt.show()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/examples/sample-simulator.cc	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,91 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2010 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+
+#include <iostream>
+#include "ns3/simulator.h"
+#include "ns3/nstime.h"
+#include "ns3/command-line.h"
+#include "ns3/random-variable.h"
+
+using namespace ns3;
+
+class MyModel
+{
+public:
+  void Start (void);
+private:
+  void HandleEvent (double eventValue);
+};
+
+void
+MyModel::Start (void)
+{
+  Simulator::Schedule (Seconds (10.0),
+                       &MyModel::HandleEvent,
+                       this, Simulator::Now ().GetSeconds ());
+}
+void
+MyModel::HandleEvent (double value)
+{
+  std::cout << "Member method received event at "
+            << Simulator::Now ().GetSeconds ()
+            << "s started at " << value << "s" << std::endl;
+}
+
+static void
+ExampleFunction (MyModel *model)
+{
+  std::cout << "ExampleFunction received event at "
+            << Simulator::Now ().GetSeconds () << "s" << std::endl;
+  model->Start ();
+}
+
+static void
+RandomFunction (void)
+{
+  std::cout << "RandomFunction received event at "
+            << Simulator::Now ().GetSeconds () << "s" << std::endl;
+}
+
+static void
+CancelledEvent (void)
+{
+  std::cout << "I should never be called... " << std::endl;
+}
+
+int main (int argc, char *argv[])
+{
+  CommandLine cmd;
+  cmd.Parse (argc, argv);
+
+  MyModel model;
+  UniformVariable v = UniformVariable (10, 20);
+
+  Simulator::Schedule (Seconds (10.0), &ExampleFunction, &model);
+
+  Simulator::Schedule (Seconds (v.GetValue ()), &RandomFunction);
+
+  EventId id = Simulator::Schedule (Seconds (30.0), &CancelledEvent);
+  Simulator::Cancel (id);
+  
+  Simulator::Run ();
+
+  Simulator::Destroy ();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/examples/sample-simulator.py	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,62 @@
+# -*- Mode:Python; -*-
+# /*
+#  * Copyright (c) 2010 INRIA
+#  *
+#  * This program is free software; you can redistribute it and/or modify
+#  * it under the terms of the GNU General Public License version 2 as
+#  * published by the Free Software Foundation;
+#  *
+#  * This program is distributed in the hope that it will be useful,
+#  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  * GNU General Public License for more details.
+#  *
+#  * You should have received a copy of the GNU General Public License
+#  * along with this program; if not, write to the Free Software
+#  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#  *
+#  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+#  */
+# 
+# Python version of sample-simulator.cc
+
+import ns3 as ns
+
+class MyModel(object):
+
+    def Start(self):
+        ns.Simulator.Schedule(ns.Seconds(10.0), self.HandleEvent, ns.Simulator.Now().GetSeconds())
+
+    def HandleEvent(self, value):
+        print "Member method received event at", ns.Simulator.Now().GetSeconds(), \
+            "s started at", value, "s"
+
+def ExampleFunction(model):
+    print "ExampleFunction received event at", ns.Simulator.Now().GetSeconds(), "s"
+    model.Start()
+
+def RandomFunction(model):
+    print "RandomFunction received event at", ns.Simulator.Now().GetSeconds(), "s"
+
+def CancelledEvent():
+    print "I should never be called... "
+
+def main(dummy_argv):
+
+    model = MyModel()
+    v = ns.UniformVariable(10,20)
+
+    ns.Simulator.Schedule(ns.Seconds(10.0), ExampleFunction, model)
+
+    ns.Simulator.Schedule(ns.Seconds(v.GetValue()), RandomFunction, model)
+
+    id = ns.Simulator.Schedule(ns.Seconds(30.0), CancelledEvent)
+    ns.Simulator.Cancel(id)
+
+    ns.Simulator.Run()
+
+    ns.Simulator.Destroy()
+
+if __name__ == '__main__':
+    import sys
+    main(sys.argv)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/examples/wscript	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,25 @@
+## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+def build(bld):
+    if not bld.env['ENABLE_EXAMPLES']:
+        return;
+
+    obj = bld.create_ns3_program('main-attribute-value', ['core', 'node', 'devices/point-to-point'])
+    obj.source = 'main-attribute-value.cc'
+
+    obj = bld.create_ns3_program('main-callback', ['core'])
+    obj.source = 'main-callback.cc'
+
+    obj = bld.create_ns3_program('sample-simulator', ['core'])
+    obj.source = 'sample-simulator.cc'
+
+    obj = bld.create_ns3_program('main-ptr', ['core'] )
+    obj.source = 'main-ptr.cc'
+
+    obj = bld.create_ns3_program('main-random-variable', ['core', 'config-store', 'tools'])
+    obj.source = 'main-random-variable.cc'
+
+    obj = bld.create_ns3_program('sample-random-variable',
+                                 ['core'])
+    obj.source = 'sample-random-variable.cc'
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/test/examples-to-run.py	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,19 @@
+#! /usr/bin/env python
+## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+# A list of C++ examples to run in order to ensure that they remain
+# buildable and runnable over time.  Each tuple in the list contains
+#
+#     (example_name, do_run, do_valgrind_run).
+#
+# See test.py for more information.
+cpp_examples = [
+]
+
+# A list of Python examples to run in order to ensure that they remain
+# runnable over time.  Each tuple in the list contains
+#
+#     (example_name, do_run).
+#
+# See test.py for more information.
+python_examples = []
--- a/src/energy/examples/wscript	Fri Apr 15 13:35:08 2011 +0200
+++ b/src/energy/examples/wscript	Fri Apr 15 20:50:42 2011 +0200
@@ -1,5 +1,8 @@
 ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
 
 def build(bld):
+    if not bld.env['ENABLE_EXAMPLES']:
+        return;
+
     obj = bld.create_ns3_program('li-ion-energy-source', ['core', 'energy'])
     obj.source = 'li-ion-energy-source.cc'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/internet/examples/main-simple.cc	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,73 @@
+#include <iostream>
+
+#include "ns3/core-module.h"
+#include "ns3/network-module.h"
+#include "ns3/internet-module.h"
+
+using namespace ns3;
+
+static void
+GenerateTraffic (Ptr<Socket> socket, uint32_t size)
+{
+  std::cout << "at=" << Simulator::Now ().GetSeconds () << "s, tx bytes=" << size << std::endl;
+  socket->Send (Create<Packet> (size));
+  if (size > 0)
+    {
+      Simulator::Schedule (Seconds (0.5), &GenerateTraffic, socket, size - 50);
+    }
+  else
+    {
+      socket->Close ();
+    }
+}
+
+static void
+SocketPrinter (Ptr<Socket> socket)
+{
+  Ptr<Packet> packet;
+  while (packet = socket->Recv ())
+    { 
+      std::cout << "at=" << Simulator::Now ().GetSeconds () << "s, rx bytes=" << packet->GetSize () << std::endl;
+    }
+}
+
+static void
+PrintTraffic (Ptr<Socket> socket)
+{
+  socket->SetRecvCallback (MakeCallback (&SocketPrinter));
+}
+
+void
+RunSimulation (void)
+{
+  NodeContainer c;
+  c.Create (1);
+
+  InternetStackHelper internet;
+  internet.Install (c);
+
+
+  TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
+  Ptr<Socket> sink = Socket::CreateSocket (c.Get (0), tid);
+  InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 80);
+  sink->Bind (local);
+
+  Ptr<Socket> source = Socket::CreateSocket (c.Get (0), tid);
+  InetSocketAddress remote = InetSocketAddress (Ipv4Address::GetLoopback (), 80);
+  source->Connect (remote);
+
+  GenerateTraffic (source, 500);
+  PrintTraffic (sink);
+
+
+  Simulator::Run ();
+
+  Simulator::Destroy ();
+}
+
+int main (int argc, char *argv[])
+{
+  RunSimulation ();
+
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/internet/examples/wscript	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,9 @@
+## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+def build(bld):
+    if not bld.env['ENABLE_EXAMPLES']:
+        return;
+
+    obj = bld.create_ns3_program('main-simple',
+                                 ['node', 'internet', 'applications'])
+    obj.source = 'main-simple.cc'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/internet/test/examples-to-run.py	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,19 @@
+#! /usr/bin/env python
+## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+# A list of C++ examples to run in order to ensure that they remain
+# buildable and runnable over time.  Each tuple in the list contains
+#
+#     (example_name, do_run, do_valgrind_run).
+#
+# See test.py for more information.
+cpp_examples = [
+]
+
+# A list of Python examples to run in order to ensure that they remain
+# runnable over time.  Each tuple in the list contains
+#
+#     (example_name, do_run).
+#
+# See test.py for more information.
+python_examples = []
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/examples/main-grid-topology.cc	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,54 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+
+#include "ns3/core-module.h"
+#include "ns3/network-module.h"
+#include "ns3/mobility-module.h"
+
+
+using namespace ns3;
+
+int main (int argc, char *argv[])
+{
+  CommandLine cmd;
+  cmd.Parse (argc, argv);
+
+  NodeContainer nodes;
+
+  // create an array of empty nodes for testing purposes 
+  nodes.Create (120);
+
+  MobilityHelper mobility;
+  // setup the grid itself: objects are layed out
+  // started from (-100,-100) with 20 objects per row, 
+  // the x interval between each object is 5 meters
+  // and the y interval between each object is 20 meters
+  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
+                                 "MinX", DoubleValue (-100.0),
+                                 "MinY", DoubleValue (-100.0),
+                                 "DeltaX", DoubleValue (5.0),
+                                 "DeltaY", DoubleValue (20.0),
+                                 "GridWidth", UintegerValue (20),
+                                 "LayoutType", StringValue ("RowFirst"));
+  // each object will be attached a static position.
+  // i.e., once set by the "position allocator", the
+  // position will never change.
+  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
+
+  // finalize the setup by attaching to each object
+  // in the input array a position and initializing
+  // this position with the calculated coordinates.
+  mobility.Install (nodes);
+
+  // iterate our nodes and print their position.
+  for (NodeContainer::Iterator j = nodes.Begin ();
+       j != nodes.End (); ++j)
+    {
+      Ptr<Node> object = *j;
+      Ptr<MobilityModel> position = object->GetObject<MobilityModel> ();
+      NS_ASSERT (position != 0);
+      Vector pos = position->GetPosition ();
+      std::cout << "x=" << pos.x << ", y=" << pos.y << ", z=" << pos.z << std::endl;
+    }
+
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/examples/main-random-topology.cc	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,41 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+
+#include "ns3/core-module.h"
+#include "ns3/mobility-module.h"
+
+using namespace ns3;
+
+static void 
+CourseChange (std::string context, Ptr<const MobilityModel> position)
+{
+  Vector pos = position->GetPosition ();
+  std::cout << Simulator::Now () << ", pos=" << position << ", x=" << pos.x << ", y=" << pos.y
+            << ", z=" << pos.z << std::endl;
+}
+
+int main (int argc, char *argv[])
+{
+  CommandLine cmd;
+  cmd.Parse (argc, argv);
+
+
+  NodeContainer c;
+  c.Create (10000);
+
+  MobilityHelper mobility;
+  mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator",
+                                 "X", StringValue ("100.0"),
+                                 "Y", StringValue ("100.0"),
+                                 "Rho", StringValue ("Uniform:0:30"));
+  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
+  mobility.Install (c);
+
+  Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
+                              MakeCallback (&CourseChange));
+  
+  Simulator::Stop (Seconds (100.0));
+
+  Simulator::Run ();
+  
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/examples/main-random-walk.cc	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,50 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+
+#include "ns3/core-module.h"
+#include "ns3/mobility-module.h"
+
+using namespace ns3;
+
+static void 
+CourseChange (std::string foo, Ptr<const MobilityModel> mobility)
+{
+  Vector pos = mobility->GetPosition ();
+  Vector vel = mobility->GetVelocity ();
+  std::cout << Simulator::Now () << ", model=" << mobility << ", POS: x=" << pos.x << ", y=" << pos.y
+            << ", z=" << pos.z << "; VEL:" << vel.x << ", y=" << vel.y
+            << ", z=" << vel.z << std::endl;
+}
+
+int main (int argc, char *argv[])
+{
+  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Mode", StringValue ("Time"));
+  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Time", StringValue ("2s"));
+  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Speed", StringValue ("Constant:1.0"));
+  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Bounds", StringValue ("0|200|0|200"));
+
+  CommandLine cmd;
+  cmd.Parse (argc, argv);
+
+  NodeContainer c;
+  c.Create (100);
+
+  MobilityHelper mobility;
+  mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator",
+                                 "X", StringValue ("100.0"),
+                                 "Y", StringValue ("100.0"),
+                                 "Rho", StringValue ("Uniform:0:30"));
+  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
+                             "Mode", StringValue ("Time"),
+                             "Time", StringValue ("2s"),
+                             "Speed", StringValue ("Constant:1.0"),
+                             "Bounds", StringValue ("0|200|0|200"));
+  mobility.InstallAll ();
+  Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
+                   MakeCallback (&CourseChange));
+
+  Simulator::Stop (Seconds (100.0));
+
+  Simulator::Run ();
+  
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/examples/wscript	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,18 @@
+## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+def build(bld):
+    if not bld.env['ENABLE_EXAMPLES']:
+        return;
+
+    obj = bld.create_ns3_program('main-grid-topology',
+                                 ['core', 'mobility', 'network'])
+    obj.source = 'main-grid-topology.cc'
+
+    obj = bld.create_ns3_program('main-random-topology',
+                                 ['core', 'mobility'])
+    obj.source = 'main-random-topology.cc'
+    
+    obj = bld.create_ns3_program('main-random-walk',
+                                 ['core', 'mobility'])
+    obj.source = 'main-random-walk.cc'
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/test/examples-to-run.py	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,19 @@
+#! /usr/bin/env python
+## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+# A list of C++ examples to run in order to ensure that they remain
+# buildable and runnable over time.  Each tuple in the list contains
+#
+#     (example_name, do_run, do_valgrind_run).
+#
+# See test.py for more information.
+cpp_examples = [
+]
+
+# A list of Python examples to run in order to ensure that they remain
+# runnable over time.  Each tuple in the list contains
+#
+#     (example_name, do_run).
+#
+# See test.py for more information.
+python_examples = []
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/network/examples/main-packet-header.cc	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,125 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+#include "ns3/ptr.h"
+#include "ns3/packet.h"
+#include "ns3/header.h"
+#include <iostream>
+
+using namespace ns3;
+
+/* A sample Header implementation
+ */
+class MyHeader : public Header 
+{
+public:
+
+  MyHeader ();
+  virtual ~MyHeader ();
+
+  void SetData (uint16_t data);
+  uint16_t GetData (void) const;
+
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
+  virtual void Print (std::ostream &os) const;
+  virtual void Serialize (Buffer::Iterator start) const;
+  virtual uint32_t Deserialize (Buffer::Iterator start);
+  virtual uint32_t GetSerializedSize (void) const;
+private:
+  uint16_t m_data;
+};
+
+MyHeader::MyHeader ()
+{
+  // we must provide a public default constructor, 
+  // implicit or explicit, but never private.
+}
+MyHeader::~MyHeader ()
+{}
+
+TypeId 
+MyHeader::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::MyHeader")
+    .SetParent<Header> ()
+    .AddConstructor<MyHeader> ()
+    ;
+  return tid;
+}
+TypeId 
+MyHeader::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
+
+void 
+MyHeader::Print (std::ostream &os) const
+{
+  // This method is invoked by the packet printing
+  // routines to print the content of my header.
+  //os << "data=" << m_data << std::endl;
+  os << "data=" << m_data;
+}
+uint32_t
+MyHeader::GetSerializedSize (void) const
+{
+  // we reserve 2 bytes for our header.
+  return 2;
+}
+void
+MyHeader::Serialize (Buffer::Iterator start) const
+{
+  // we can serialize two bytes at the start of the buffer.
+  // we write them in network byte order.
+  start.WriteHtonU16 (m_data);
+}
+uint32_t
+MyHeader::Deserialize (Buffer::Iterator start)
+{
+  // we can deserialize two bytes from the start of the buffer.
+  // we read them in network byte order and store them
+  // in host byte order.
+  m_data = start.ReadNtohU16 ();
+
+  // we return the number of bytes effectively read.
+  return 2;
+}
+
+void 
+MyHeader::SetData (uint16_t data)
+{
+  m_data = data;
+}
+uint16_t 
+MyHeader::GetData (void) const
+{
+  return m_data;
+}
+
+
+
+int main (int argc, char *argv[])
+{
+  // instantiate a header.
+  MyHeader sourceHeader;
+  sourceHeader.SetData (2);
+
+  // instantiate a packet
+  Ptr<Packet> p = Create<Packet> ();
+
+  // and store my header into the packet.
+  p->AddHeader (sourceHeader);
+
+  // print the content of my packet on the standard output.
+  p->Print (std::cout);
+  std::cout << std::endl;  
+
+  // you can now remove the header from the packet:
+  MyHeader destinationHeader;
+  p->RemoveHeader (destinationHeader);
+
+  // and check that the destination and source
+  // headers contain the same values.
+  NS_ASSERT (sourceHeader.GetData () == destinationHeader.GetData ());
+
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/network/examples/main-packet-tag.cc	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,120 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2006,2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#include "ns3/tag.h"
+#include "ns3/packet.h"
+#include "ns3/uinteger.h"
+#include <iostream>
+
+using namespace ns3;
+
+// define this class in a public header
+class MyTag : public Tag
+{
+public:
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
+  virtual uint32_t GetSerializedSize (void) const;
+  virtual void Serialize (TagBuffer i) const;
+  virtual void Deserialize (TagBuffer i);
+  virtual void Print (std::ostream &os) const;
+  
+  // these are our accessors to our tag structure
+  void SetSimpleValue (uint8_t value);
+  uint8_t GetSimpleValue (void) const;
+private:
+  uint8_t m_simpleValue;
+};
+
+TypeId 
+MyTag::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::MyTag")
+    .SetParent<Tag> ()
+    .AddConstructor<MyTag> ()
+    .AddAttribute ("SimpleValue",
+                   "A simple value",
+                   EmptyAttributeValue (),
+                   MakeUintegerAccessor (&MyTag::GetSimpleValue),
+                   MakeUintegerChecker<uint8_t> ())
+    ;
+  return tid;
+}
+TypeId 
+MyTag::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
+uint32_t 
+MyTag::GetSerializedSize (void) const
+{
+  return 1;
+}
+void 
+MyTag::Serialize (TagBuffer i) const
+{
+  i.WriteU8 (m_simpleValue);
+}
+void 
+MyTag::Deserialize (TagBuffer i)
+{
+  m_simpleValue = i.ReadU8 ();
+}
+void 
+MyTag::Print (std::ostream &os) const
+{
+  os << "v=" << (uint32_t)m_simpleValue;
+}
+void 
+MyTag::SetSimpleValue (uint8_t value)
+{
+  m_simpleValue = value;
+}
+uint8_t 
+MyTag::GetSimpleValue (void) const
+{
+  return m_simpleValue;
+}
+
+
+int main (int argc, char *argv[])
+{
+  // create a tag.
+  MyTag tag;
+  tag.SetSimpleValue (0x56);
+
+  // store the tag in a packet.
+  Ptr<Packet> p = Create<Packet> (100);
+  p->AddPacketTag (tag);
+
+  // create a copy of the packet
+  Ptr<Packet> aCopy = p->Copy ();
+
+  // read the tag from the packet copy
+  MyTag tagCopy;
+  p->PeekPacketTag (tagCopy);
+
+  // the copy and the original are the same !
+  NS_ASSERT (tagCopy.GetSimpleValue () == tag.GetSimpleValue ());
+
+  aCopy->PrintPacketTags (std::cout);
+  std::cout << std::endl;
+
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/network/examples/main-test-sync.cc	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,133 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+
+#include "ns3/simulator.h"
+#include "ns3/realtime-simulator-impl.h"
+#include "ns3/nstime.h"
+#include "ns3/log.h"
+#include "ns3/system-thread.h"
+#include "ns3/string.h"
+#include "ns3/config.h"
+#include "ns3/global-value.h"
+#include "ns3/ptr.h"
+
+#include <unistd.h>
+#include <sys/time.h>
+
+using namespace ns3;
+
+NS_LOG_COMPONENT_DEFINE ("TestSync");
+
+bool gFirstRun = false;
+
+void 
+inserted_function (void)
+{
+  NS_ASSERT (gFirstRun);
+  NS_LOG_UNCOND ("inserted_function() called at " << 
+    Simulator::Now ().GetSeconds () << " s");
+}
+
+void 
+background_function (void)
+{
+  NS_ASSERT (gFirstRun);
+  NS_LOG_UNCOND ("background_function() called at " << 
+    Simulator::Now ().GetSeconds () << " s");
+}
+
+void 
+first_function (void)
+{
+  NS_LOG_UNCOND ("first_function() called at " << 
+    Simulator::Now ().GetSeconds () << " s");
+  gFirstRun = true;
+}
+
+class FakeNetDevice
+{
+public:
+  FakeNetDevice ();
+  void Doit3 (void);
+  void Doit4 (void);
+};
+
+FakeNetDevice::FakeNetDevice ()
+{
+  NS_LOG_FUNCTION_NOARGS ();
+}
+
+void
+FakeNetDevice::Doit3 (void)
+{
+  NS_LOG_FUNCTION_NOARGS ();
+  sleep (1);
+  for (uint32_t i = 0; i < 10000; ++i)
+    {
+      //
+      // Exercise the realtime relative now path
+      //
+      DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ())->ScheduleRealtimeNow (MakeEvent (&inserted_function));
+      usleep (1000);
+    }
+}
+
+void
+FakeNetDevice::Doit4 (void)
+{
+  NS_LOG_FUNCTION_NOARGS ();
+  sleep (1);
+  for (uint32_t i = 0; i < 10000; ++i)
+    {
+      //
+      // Exercise the realtime relative schedule path
+      //
+      DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ())->ScheduleRealtime (Seconds (0), MakeEvent (&inserted_function));
+      usleep (1000);
+    }
+}
+
+void 
+test (void)
+{
+  GlobalValue::Bind ("SimulatorImplementationType", 
+    StringValue ("ns3::RealtimeSimulatorImpl"));
+
+  FakeNetDevice fnd;
+
+  // 
+  // Make sure ScheduleNow works when the system isn't running
+  //
+  DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ())->ScheduleRealtimeNow(MakeEvent (&first_function));
+
+  // 
+  // drive the progression of m_currentTs at a ten millisecond rate from the main thread
+  //
+  for (double d = 0.; d < 14.999; d += 0.01)
+    {
+      Simulator::Schedule (Seconds (d), &background_function);
+    }
+
+  Ptr<SystemThread> st3 = Create<SystemThread> (
+    MakeCallback (&FakeNetDevice::Doit3, &fnd));
+  st3->Start ();
+
+  Ptr<SystemThread> st4 = Create<SystemThread> (
+    MakeCallback (&FakeNetDevice::Doit4, &fnd));
+  st4->Start ();
+
+  Simulator::Stop (Seconds (15.0));
+  Simulator::Run ();
+  st3->Join ();
+  st4->Join ();
+  Simulator::Destroy ();
+}
+
+int
+main (int argc, char *argv[])
+{
+  while (true)
+    {
+      test ();
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/network/examples/wscript	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,16 @@
+## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+def build(bld):
+    if not bld.env['ENABLE_EXAMPLES']:
+        return;
+
+    obj = bld.create_ns3_program('main-packet-header', ['common', 'core'])
+    obj.source = 'main-packet-header.cc'
+
+    obj = bld.create_ns3_program('main-packet-tag', ['common', 'core'])
+    obj.source = 'main-packet-tag.cc'
+
+    if bld.env['ENABLE_THREADING'] and bld.env["ENABLE_REAL_TIME"]:
+        obj = bld.create_ns3_program('main-test-sync')
+        obj.source = 'main-test-sync.cc'
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/network/test/examples-to-run.py	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,19 @@
+#! /usr/bin/env python
+## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+# A list of C++ examples to run in order to ensure that they remain
+# buildable and runnable over time.  Each tuple in the list contains
+#
+#     (example_name, do_run, do_valgrind_run).
+#
+# See test.py for more information.
+cpp_examples = [
+]
+
+# A list of Python examples to run in order to ensure that they remain
+# runnable over time.  Each tuple in the list contains
+#
+#     (example_name, do_run).
+#
+# See test.py for more information.
+python_examples = []
--- a/src/network/utils/radiotap-header.cc	Fri Apr 15 13:35:08 2011 +0200
+++ b/src/network/utils/radiotap-header.cc	Fri Apr 15 20:50:42 2011 +0200
@@ -324,37 +324,29 @@
 }
 
 void 
-RadiotapHeader::SetAntennaSignalPower (int8_t signal)
+RadiotapHeader::SetAntennaSignalPower (double signal)
 {
   NS_LOG_FUNCTION (this << signal);
-  m_antennaSignal = signal;
 
   if (!(m_present & RADIOTAP_DBM_ANTSIGNAL))
     {
       m_present |= RADIOTAP_DBM_ANTSIGNAL;
       m_length += 1;
     }
-
-  NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec);
-}
-
-void 
-RadiotapHeader::SetAntennaSignalPower (double signal)
-{
-  NS_LOG_FUNCTION (this << signal);
-
-  if (signal < -128)
+  if (signal > 127)
+    {
+      m_antennaSignal = 127;
+    }
+  else if (signal < -128)
     {
-      return SetAntennaSignalPower (static_cast<int8_t> (-128));
+      m_antennaSignal = -128;
+    }
+  else
+    {
+      m_antennaSignal = static_cast<int8_t> (floor(signal + 0.5));
     }
 
-  if (signal > 127)
-    {
-      return SetAntennaSignalPower (static_cast<int8_t> (127));
-    }
-  
-  SetAntennaSignalPower (static_cast<int8_t> (floor(signal + 0.5)));
-}
+  NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec);}
 
 uint8_t 
 RadiotapHeader::GetAntennaSignalPower (void) const
@@ -364,38 +356,31 @@
 }
 
 void 
-RadiotapHeader::SetAntennaNoisePower (int8_t noise)
+RadiotapHeader::SetAntennaNoisePower (double noise)
 {
   NS_LOG_FUNCTION (this << noise);
-  m_antennaNoise = noise;
 
   if (!(m_present & RADIOTAP_DBM_ANTNOISE))
     {
       m_present |= RADIOTAP_DBM_ANTNOISE;
       m_length += 1;
     }
+  if (noise > 127.0)
+    {
+      m_antennaNoise = 127;
+    }
+  else if (noise < -128.0)
+    {
+      m_antennaNoise = -128;
+    }
+  else
+    {
+      m_antennaNoise = static_cast<int8_t> (floor (noise + 0.5));
+    }
 
   NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec);
 }
 
-void 
-RadiotapHeader::SetAntennaNoisePower (double noise)
-{
-  NS_LOG_FUNCTION (this << noise);
-
-  if (noise < -128)
-    {
-      return SetAntennaNoisePower (static_cast<int8_t> (-128));
-    }
-
-  if (noise > 127)
-    {
-      return SetAntennaNoisePower (static_cast<int8_t> (127));
-    }
-  
-  SetAntennaNoisePower (static_cast<int8_t> (floor(noise + 0.5)));
-}
-
 uint8_t 
 RadiotapHeader::GetAntennaNoisePower (void) const
 {
--- a/src/network/utils/radiotap-header.h	Fri Apr 15 13:35:08 2011 +0200
+++ b/src/network/utils/radiotap-header.h	Fri Apr 15 20:50:42 2011 +0200
@@ -192,15 +192,6 @@
    * from an arbitrary, fixed reference. 
    *
    * @param signal The RF signal power at the antenna as a decibel difference
-   *               from an arbitrary, fixed reference. 
-   */
-  void SetAntennaSignalPower (int8_t signal);
-
-  /**
-   * @brief Set the RF signal power at the antenna as a decibel difference
-   * from an arbitrary, fixed reference. 
-   *
-   * @param signal The RF signal power at the antenna as a decibel difference
    *               from an arbitrary, fixed reference;
    */
   void SetAntennaSignalPower (double signal);
@@ -221,15 +212,6 @@
    * @param noise The RF noise power at the antenna as a decibel difference
    *              from an arbitrary, fixed reference. 
    */
-  void SetAntennaNoisePower (int8_t noise);
-
-  /**
-   * @brief Set the RF noise power at the antenna as a decibel difference
-   * from an arbitrary, fixed reference. 
-   *
-   * @param noise The RF noise power at the antenna as a decibel difference
-   *              from an arbitrary, fixed reference. 
-   */
   void SetAntennaNoisePower (double noise);
 
   /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/propagation/examples/main-propagation-loss.cc	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,312 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008 Timo Bingmann
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Timo Bingmann <timo.bingmann@student.kit.edu>
+ */
+
+#include "ns3/propagation-loss-model.h"
+#include "ns3/jakes-propagation-loss-model.h"
+#include "ns3/constant-position-mobility-model.h"
+
+#include "ns3/config.h"
+#include "ns3/string.h"
+#include "ns3/boolean.h"
+#include "ns3/double.h"
+#include "ns3/gnuplot.h"
+#include "ns3/simulator.h"
+
+#include <map>
+
+using namespace ns3;
+
+/// Round a double number to the given precision. e.g. dround(0.234, 0.1) = 0.2
+/// and dround(0.257, 0.1) = 0.3
+static double dround(double number, double precision)
+{
+  number /= precision;
+  if (number >= 0)
+    {
+      number = floor(number + 0.5);
+    }
+  else
+    {
+      number = ceil(number - 0.5);
+    }
+  number *= precision;
+  return number;
+}
+
+static Gnuplot
+TestDeterministic (Ptr<PropagationLossModel> model)
+{
+  Ptr<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
+  Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
+
+  Gnuplot plot;
+
+  plot.AppendExtra("set xlabel 'Distance'");
+  plot.AppendExtra("set ylabel 'rxPower (dBm)'");
+  plot.AppendExtra("set key top right");
+
+  double txPowerDbm = +20; // dBm
+
+  Gnuplot2dDataset dataset;
+
+  dataset.SetStyle(Gnuplot2dDataset::LINES);
+
+  {
+    a->SetPosition (Vector (0.0, 0.0, 0.0));
+
+    for (double distance = 0.0; distance < 2500.0; distance += 10.0)
+      {
+        b->SetPosition (Vector (distance, 0.0, 0.0));
+
+        // CalcRxPower() returns dBm.
+        double rxPowerDbm = model->CalcRxPower (txPowerDbm, a, b);
+
+        dataset.Add(distance, rxPowerDbm);
+
+        Simulator::Stop (Seconds (1.0));
+        Simulator::Run ();
+      }
+  }
+
+  std::ostringstream os;
+  os << "txPower " << txPowerDbm << "dBm";
+  dataset.SetTitle(os.str());
+
+  plot.AddDataset(dataset);
+
+  plot.AddDataset( Gnuplot2dFunction("-94 dBm CSThreshold", "-94.0") );
+
+  return plot;
+}
+
+static Gnuplot
+TestProbabilistic (Ptr<PropagationLossModel> model, unsigned int samples = 100000)
+{
+  Ptr<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
+  Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
+
+  Gnuplot plot;
+
+  plot.AppendExtra("set xlabel 'Distance'");
+  plot.AppendExtra("set ylabel 'rxPower (dBm)'");
+  plot.AppendExtra("set zlabel 'Probability' offset 0,+10");
+  plot.AppendExtra("set view 50, 120, 1.0, 1.0");
+  plot.AppendExtra("set key top right");
+
+  plot.AppendExtra("set ticslevel 0");
+  plot.AppendExtra("set xtics offset -0.5,0");
+  plot.AppendExtra("set ytics offset 0,-0.5");
+  plot.AppendExtra("set xrange [100:]");
+
+  double txPowerDbm = +20; // dBm
+
+  Gnuplot3dDataset dataset;
+
+  dataset.SetStyle("with linespoints");
+  dataset.SetExtra("pointtype 3 pointsize 0.5");
+  
+  typedef std::map<double, unsigned int> rxPowerMapType;
+
+  // Take given number of samples from CalcRxPower() and show probability
+  // density for discrete distances.
+  {
+    a->SetPosition (Vector (0.0, 0.0, 0.0));
+
+    for (double distance = 100.0; distance < 2500.0; distance += 100.0)
+      {
+        b->SetPosition (Vector (distance, 0.0, 0.0));
+
+        rxPowerMapType rxPowerMap;
+
+        for (unsigned int samp = 0; samp < samples; ++samp)
+          {
+            // CalcRxPower() returns dBm.
+            double rxPowerDbm = model->CalcRxPower (txPowerDbm, a, b);
+            rxPowerDbm = dround(rxPowerDbm, 1.0);
+
+            rxPowerMap[ rxPowerDbm ] ++;
+
+            Simulator::Stop (Seconds (0.01));
+            Simulator::Run ();
+          }
+
+        for (rxPowerMapType::const_iterator i = rxPowerMap.begin();
+             i != rxPowerMap.end(); ++i)
+          {
+            dataset.Add(distance, i->first, (double)i->second / (double)samples);
+          }
+        dataset.AddEmptyLine();
+      }
+  }
+
+  std::ostringstream os;
+  os << "txPower " << txPowerDbm << "dBm";
+  dataset.SetTitle(os.str());
+
+  plot.AddDataset(dataset);
+
+  return plot;
+}
+
+static Gnuplot
+TestDeterministicByTime (Ptr<PropagationLossModel> model,
+                         Time timeStep = Seconds(0.001),
+                         Time timeTotal = Seconds(1.0),
+                         double distance = 100.0)
+{
+  Ptr<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
+  Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
+
+  Gnuplot plot;
+
+  plot.AppendExtra("set xlabel 'Time (s)'");
+  plot.AppendExtra("set ylabel 'rxPower (dBm)'");
+  plot.AppendExtra("set key center right");
+
+  double txPowerDbm = +20; // dBm
+
+  Gnuplot2dDataset dataset;
+
+  dataset.SetStyle(Gnuplot2dDataset::LINES);
+
+  {
+    a->SetPosition (Vector (0.0, 0.0, 0.0));
+    b->SetPosition (Vector (distance, 0.0, 0.0));
+
+    Time start = Simulator::Now();
+    while( Simulator::Now() < start + timeTotal )
+      {
+        // CalcRxPower() returns dBm.
+        double rxPowerDbm = model->CalcRxPower (txPowerDbm, a, b);
+
+        Time elapsed = Simulator::Now() - start;
+        dataset.Add(elapsed.GetSeconds(), rxPowerDbm);
+
+        Simulator::Stop (timeStep);
+        Simulator::Run ();
+      }
+  }
+
+  std::ostringstream os;
+  os << "txPower " << txPowerDbm << "dBm";
+  dataset.SetTitle(os.str());
+
+  plot.AddDataset(dataset);
+
+  plot.AddDataset( Gnuplot2dFunction("-94 dBm CSThreshold", "-94.0") );
+
+  return plot;
+}
+
+int main (int argc, char *argv[])
+{
+  GnuplotCollection gnuplots("main-propagation-loss.pdf");
+
+  {
+    Ptr<FriisPropagationLossModel> friis = CreateObject<FriisPropagationLossModel> ();
+
+    Gnuplot plot = TestDeterministic(friis);
+    plot.SetTitle("ns3::FriisPropagationLossModel (Default Parameters)");
+    gnuplots.AddPlot(plot);
+  }
+
+  {
+    Ptr<LogDistancePropagationLossModel> log = CreateObject<LogDistancePropagationLossModel> ();
+    log->SetAttribute("Exponent", DoubleValue (2.5));
+
+    Gnuplot plot = TestDeterministic(log);
+    plot.SetTitle("ns3::LogDistancePropagationLossModel (Exponent = 2.5)");
+    gnuplots.AddPlot(plot);
+  }
+
+  {
+    Ptr<RandomPropagationLossModel> random = CreateObject<RandomPropagationLossModel> ();
+    random->SetAttribute("Variable", RandomVariableValue(ExponentialVariable(50.0)));
+
+    Gnuplot plot = TestDeterministic(random);
+    plot.SetTitle("ns3::RandomPropagationLossModel with Exponential Distribution");
+    gnuplots.AddPlot(plot);
+  }
+
+  {
+    Ptr<JakesPropagationLossModel> jakes = CreateObject<JakesPropagationLossModel> ();
+
+    // doppler frequency shift for 5.15 GHz at 100 km/h
+    jakes->SetAttribute("DopplerFreq", DoubleValue(477.9));
+
+    Gnuplot plot = TestDeterministicByTime (jakes, Seconds(0.001), Seconds(1.0));
+    plot.SetTitle("ns3::JakesPropagationLossModel (with 477.9 Hz shift and 1 millisec resolution)");
+    gnuplots.AddPlot(plot);
+  }
+
+  {
+    Ptr<JakesPropagationLossModel> jakes = CreateObject<JakesPropagationLossModel> ();
+
+    // doppler frequency shift for 5.15 GHz at 100 km/h
+    jakes->SetAttribute("DopplerFreq", DoubleValue(477.9));
+
+    Gnuplot plot = TestDeterministicByTime (jakes, Seconds(0.0001), Seconds(0.1));
+    plot.SetTitle("ns3::JakesPropagationLossModel (with 477.9 Hz shift and 0.1 millisec resolution)");
+    gnuplots.AddPlot(plot);
+  }
+
+  {
+    Ptr<ThreeLogDistancePropagationLossModel> log3 = CreateObject<ThreeLogDistancePropagationLossModel> ();
+
+    Gnuplot plot = TestDeterministic(log3);
+    plot.SetTitle("ns3::ThreeLogDistancePropagationLossModel (Defaults)");
+    gnuplots.AddPlot(plot);
+  }
+
+  {
+    Ptr<ThreeLogDistancePropagationLossModel> log3 = CreateObject<ThreeLogDistancePropagationLossModel> ();
+    // more prominent example values:
+    log3->SetAttribute("Exponent0", DoubleValue(1.0));
+    log3->SetAttribute("Exponent1", DoubleValue(3.0));
+    log3->SetAttribute("Exponent2", DoubleValue(10.0));
+
+    Gnuplot plot = TestDeterministic(log3);
+    plot.SetTitle("ns3::ThreeLogDistancePropagationLossModel (Exponents 1.0, 3.0 and 10.0)");
+    gnuplots.AddPlot(plot);
+  }
+
+  {
+    Ptr<NakagamiPropagationLossModel> nak = CreateObject<NakagamiPropagationLossModel> ();
+
+    Gnuplot plot = TestProbabilistic(nak);
+    plot.SetTitle("ns3::NakagamiPropagationLossModel (Default Parameters)");
+    gnuplots.AddPlot(plot);
+  }
+
+  {
+    Ptr<ThreeLogDistancePropagationLossModel> log3 = CreateObject<ThreeLogDistancePropagationLossModel> ();
+
+    Ptr<NakagamiPropagationLossModel> nak = CreateObject<NakagamiPropagationLossModel> ();
+    log3->SetNext(nak);
+
+    Gnuplot plot = TestProbabilistic(log3);
+    plot.SetTitle("ns3::ThreeLogDistancePropagationLossModel and ns3::NakagamiPropagationLossModel (Default Parameters)");
+    gnuplots.AddPlot(plot);
+  }
+
+  gnuplots.GenerateOutput(std::cout);
+
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/propagation/examples/wscript	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,11 @@
+## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+def build(bld):
+    if not bld.env['ENABLE_EXAMPLES']:
+        return;
+
+    obj = bld.create_ns3_program('main-propagation-loss',
+                                 ['core', 'mobility', 'config-store', 'tools', 'propagation'])
+    obj.source = 'main-propagation-loss.cc'
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/propagation/test/examples-to-run.py	Fri Apr 15 20:50:42 2011 +0200
@@ -0,0 +1,19 @@
+#! /usr/bin/env python
+## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+# A list of C++ examples to run in order to ensure that they remain
+# buildable and runnable over time.  Each tuple in the list contains
+#
+#     (example_name, do_run, do_valgrind_run).
+#
+# See test.py for more information.
+cpp_examples = [
+]
+
+# A list of Python examples to run in order to ensure that they remain
+# runnable over time.  Each tuple in the list contains
+#
+#     (example_name, do_run).
+#
+# See test.py for more information.
+python_examples = []
--- a/src/wscript	Fri Apr 15 13:35:08 2011 +0200
+++ b/src/wscript	Fri Apr 15 20:50:42 2011 +0200
@@ -105,6 +105,10 @@
         pcfile = bld.new_task_gen('ns3pcfile')
         pcfile.module = module
 
+    # Initially create an empty value for this because the pcfile
+    # writing task assumes every module has a uselib attribute.
+    module.uselib = ''
+
     module.is_ns3_module = True
     module.name = 'ns3-' + name
     # Add the proper path to the module's name.
--- a/utils.py	Fri Apr 15 13:35:08 2011 +0200
+++ b/utils.py	Fri Apr 15 20:50:42 2011 +0200
@@ -44,6 +44,38 @@
     return list
 
 
+def get_bool_from_file(file_path, bool_name, value_if_missing):
+    '''Looks for a Python boolean variable called bool_name in the
+    file specified by file_path and returns its value.
+
+    If the file or boolean variable aren't found, this function will
+    return value_if_missing.
+
+    '''
+
+    # Read in the file if it exists.
+    if os.path.exists(file_path):
+        file_in = open(file_path, "r")
+
+        # Look for the boolean variable.
+        bool_found = False
+        for line in file_in:
+            if bool_name in line:
+                # Evaluate the variable's line once it is found.  Make
+                # the split function only split it once.
+                bool = eval(line.split('=', 1)[1].strip())
+                bool_found = True
+                break
+
+        # Close the file
+        file_in.close()
+
+    if bool_found:
+        return bool
+    else:
+        return value_if_missing
+
+
 def read_config_file():
     '''Reads the NS-3 configuration file and returns a list of enabled modules.
 
@@ -53,20 +85,38 @@
 
     '''
 
+    # By default, all modules will be enabled, examples will be disabled,
+    # and tests will be disabled.
+    modules_enabled  = ['all_modules']
+    examples_enabled = False
+    tests_enabled    = False
+
     # See if the ns3 configuration file exists in the current working
     # directory and then look for it in the ~ directory.
+    config_file_exists = False
     dot_ns3rc_name = '.ns3rc'
     dot_ns3rc_path = dot_ns3rc_name
     if not os.path.exists(dot_ns3rc_path):
         dot_ns3rc_path = os.path.expanduser('~/') + dot_ns3rc_name
         if not os.path.exists(dot_ns3rc_path):
-            # Enable all modules if the .ns3rc file can't be found.
-            return ['all_modules']
+            # Return all of the default values if the .ns3rc file can't be found.
+            return (config_file_exists, modules_enabled, examples_enabled, tests_enabled)
 
-    # Read in the ns3 configuration file.
+    config_file_exists = True
+
+    # Read in the enabled modules.
     modules_enabled = get_list_from_file(dot_ns3rc_path, 'modules_enabled')
     if not modules_enabled:
         # Enable all modules if the modules_enabled line can't be found.
-        return ['all_modules']
+        modules_enabled = ['all_modules']
+
+    # Read in whether examples should be enabled or not.
+    value_if_missing = False
+    examples_enabled = get_bool_from_file(dot_ns3rc_path, 'examples_enabled', value_if_missing)
 
-    return modules_enabled
+    # Read in whether tests should be enabled or not.
+    value_if_missing = False
+    tests_enabled = get_bool_from_file(dot_ns3rc_path, 'tests_enabled', value_if_missing)
+
+    return (config_file_exists, modules_enabled, examples_enabled, tests_enabled)
+
--- a/utils/.ns3rc	Fri Apr 15 13:35:08 2011 +0200
+++ b/utils/.ns3rc	Fri Apr 15 20:50:42 2011 +0200
@@ -5,3 +5,9 @@
 #
 # All modules can be enabled by choosing 'all_modules'.
 modules_enabled = ['all_modules']
+
+# Set this equal to true if you want examples to be run.
+examples_enabled = False
+
+# Set this equal to true if you want tests to be run.
+tests_enabled = False
--- a/wscript	Fri Apr 15 13:35:08 2011 +0200
+++ b/wscript	Fri Apr 15 20:50:42 2011 +0200
@@ -30,11 +30,15 @@
 
 from utils import read_config_file
 
-# By default, all modules will be enabled.
-modules_enabled = ['all_modules']
+# By default, all modules will be enabled, examples will be disabled,
+# and tests will be disabled.
+modules_enabled  = ['all_modules']
+examples_enabled = False
+tests_enabled    = False
 
-# Get the list of enabled modules out of the NS-3 configuration file.
-modules_enabled = read_config_file()
+# Get the information out of the NS-3 configuration file.
+config_file_exists = False
+(config_file_exists, modules_enabled, examples_enabled, tests_enabled) = read_config_file()
 
 sys.path.insert(0, os.path.abspath('waf-tools'))
 try:
@@ -163,14 +167,16 @@
                    default=False)
     opt.add_option('--disable-tests',
                    help=('Do not build the ns-3 tests.'),
-                   dest='enable_tests', action='store_false')
+                   dest='disable_tests', action='store_true',
+                   default=False)
     opt.add_option('--enable-examples',
-                   help=('Build the ns-3 examples and samples.'),
+                   help=('Build the ns-3 examples.'),
                    dest='enable_examples', action='store_true',
-                   default=True)
+                   default=False)
     opt.add_option('--disable-examples',
-                   help=('Do not build the ns-3 examples and samples.'),
-                   dest='enable_examples', action='store_false')
+                   help=('Do not build the ns-3 examples.'),
+                   dest='disable_examples', action='store_true',
+                   default=False)
     opt.add_option('--check',
                    help=('DEPRECATED (run ./test.py)'),
                    default=False, dest='check', action="store_true")
@@ -321,21 +327,45 @@
 
     conf.report_optional_feature("ENABLE_SUDO", "Use sudo to set suid bit", env['ENABLE_SUDO'], why_not_sudo)
 
+    # Decide if tests will be built or not.
     if Options.options.enable_tests:
+        # Tests were explicitly enabled. 
         env['ENABLE_TESTS'] = True
         why_not_tests = "option --enable-tests selected"
-    else:
+    elif Options.options.disable_tests:
+        # Tests were explicitly disabled. 
         env['ENABLE_TESTS'] = False
-        why_not_tests = "defaults to disabled"
+        why_not_tests = "option --disable-tests selected"
+    else:
+        # Enable tests based on the ns3 configuration file.
+        env['ENABLE_TESTS'] = tests_enabled
+        if config_file_exists:
+            why_not_tests = "based on configuration file"
+        elif tests_enabled:
+            why_not_tests = "defaults to enabled"
+        else:
+            why_not_tests = "defaults to disabled"
 
     conf.report_optional_feature("ENABLE_TESTS", "Build tests", env['ENABLE_TESTS'], why_not_tests)
 
+    # Decide if examples will be built or not.
     if Options.options.enable_examples:
+        # Examples were explicitly enabled. 
         env['ENABLE_EXAMPLES'] = True
-        why_not_examples = "defaults to enabled"
-    else:
+        why_not_examples = "option --enable-examples selected"
+    elif Options.options.disable_examples:
+        # Examples were explicitly disabled. 
         env['ENABLE_EXAMPLES'] = False
         why_not_examples = "option --disable-examples selected"
+    else:
+        # Enable examples based on the ns3 configuration file.
+        env['ENABLE_EXAMPLES'] = examples_enabled
+        if config_file_exists:
+            why_not_examples = "based on configuration file"
+        elif examples_enabled:
+            why_not_examples = "defaults to enabled"
+        else:
+            why_not_examples = "defaults to disabled"
 
     env['EXAMPLE_DIRECTORIES'] = []
     for dir in os.listdir('examples'):
@@ -344,7 +374,7 @@
         if os.path.isdir(os.path.join('examples', dir)):
             env['EXAMPLE_DIRECTORIES'].append(dir)
 
-    conf.report_optional_feature("ENABLE_EXAMPLES", "Build examples and samples", env['ENABLE_EXAMPLES'], 
+    conf.report_optional_feature("ENABLE_EXAMPLES", "Build examples", env['ENABLE_EXAMPLES'], 
                                  why_not_examples)
 
     conf.find_program('valgrind', var='VALGRIND')
@@ -433,6 +463,10 @@
             status = 'not enabled (%s)' % reason_not_enabled
         print "%-30s: %s" % (caption, status)
 
+    # Print all of the enabled modules without the "ns3-" in their name.
+    print
+    print 'Enabled modules =', str([mod[len('ns3-'):] for mod in conf.env['NS3_ENABLED_MODULES']])
+    print
 
 class SuidBuildTask(Task.TaskBase):
     """task that makes a binary Suid
@@ -554,7 +588,6 @@
 
     # process subfolders from here
     bld.add_subdirs('src')
-    bld.add_subdirs('samples')
 
     env = bld.env
 
@@ -581,7 +614,6 @@
                         changed = True
 
         env['NS3_ENABLED_MODULES'] = modules
-        #print "Modules to build:", modules
 
         # If tests are being built, then set the list of the enabled
         # module test libraries.