Moves mesh, flame and dot11s examples and helpers to respective module folders
authorLalith Suresh <suresh.lalith@gmail.com>
Fri, 04 Mar 2011 19:14:23 +0000
changeset 6856 298dbc966811
parent 6855 104f16f72979
child 6857 d7db3cee241f
Moves mesh, flame and dot11s examples and helpers to respective module folders
examples/mesh/mesh.cc
examples/mesh/waf
examples/mesh/wscript
src/dot11s/helper/dot11s-installer.cc
src/dot11s/helper/dot11s-installer.h
src/dot11s/wscript
src/flame/helper/flame-installer.cc
src/flame/helper/flame-installer.h
src/flame/wscript
src/helper/dot11s-installer.cc
src/helper/dot11s-installer.h
src/helper/flame-installer.cc
src/helper/flame-installer.h
src/helper/mesh-helper.cc
src/helper/mesh-helper.h
src/helper/mesh-stack-installer.h
src/helper/wscript
src/mesh/examples/mesh.cc
src/mesh/examples/waf
src/mesh/examples/wscript
src/mesh/helper/mesh-helper.cc
src/mesh/helper/mesh-helper.h
src/mesh/helper/mesh-stack-installer.h
src/mesh/wscript
test.py
--- a/examples/mesh/mesh.cc	Fri Mar 04 10:56:07 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,260 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2008,2009 IITP RAS
- *
- * 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: Kirill Andreev <andreev@iitp.ru>
- *
- *
- * By default this script creates m_xSize * m_ySize square grid topology with
- * IEEE802.11s stack installed at each node with peering management
- * and HWMP protocol.
- * The side of the square cell is defined by m_step parameter.
- * When topology is created, UDP ping is installed to opposite corners
- * by diagonals. packet size of the UDP ping and interval between two
- * successive packets is configurable.
- * 
- *  m_xSize * step
- *  |<--------->|
- *   step
- *  |<--->|
- *  * --- * --- * <---Ping sink  _
- *  | \   |   / |                ^
- *  |   \ | /   |                |
- *  * --- * --- * m_ySize * step |
- *  |   / | \   |                |
- *  | /   |   \ |                |
- *  * --- * --- *                _
- *  ^ Ping source
- *
- *  See also MeshTest::Configure to read more about configurable
- *  parameters.
- */
-
-
-#include "ns3/core-module.h"
-#include "ns3/internet-module.h"
-#include "ns3/network-module.h"
-#include "ns3/helper-module.h"
-#include "ns3/applications-module.h"
-#include "ns3/wifi-module.h"
-#include "ns3/mesh-module.h"
-#include "ns3/mobility-module.h"
-#include "ns3/mesh-helper.h"
-
-#include <iostream>
-#include <sstream>
-#include <fstream>
-
-using namespace ns3;
-
-NS_LOG_COMPONENT_DEFINE ("TestMeshScript");
-class MeshTest
-{
-  public:
-    /// Init test
-    MeshTest ();
-    /// Configure test from command line arguments
-    void Configure (int argc, char ** argv);
-    /// Run test
-    int Run ();
-  private:
-    int       m_xSize;
-    int       m_ySize;
-    double    m_step;
-    double    m_randomStart;
-    double    m_totalTime;
-    double    m_packetInterval;
-    uint16_t  m_packetSize;
-    uint32_t  m_nIfaces;
-    bool      m_chan;
-    bool      m_pcap;
-    std::string m_stack;
-    std::string m_root;
-    /// List of network nodes
-    NodeContainer nodes;
-    /// List of all mesh point devices
-    NetDeviceContainer meshDevices;
-    //Addresses of interfaces:
-    Ipv4InterfaceContainer interfaces;
-    // MeshHelper. Report is not static methods
-    MeshHelper mesh;
-  private:
-    /// Create nodes and setup their mobility
-    void CreateNodes ();
-    /// Install internet m_stack on nodes
-    void InstallInternetStack ();
-    /// Install applications
-    void InstallApplication ();
-    /// Print mesh devices diagnostics
-    void Report ();  
-};
-MeshTest::MeshTest () :
-  m_xSize (3),
-  m_ySize (3),
-  m_step (100.0),
-  m_randomStart (0.1),
-  m_totalTime (100.0),
-  m_packetInterval (0.1),
-  m_packetSize (1024),
-  m_nIfaces (1),
-  m_chan (true),
-  m_pcap (false),
-  m_stack ("ns3::Dot11sStack"),
-  m_root ("ff:ff:ff:ff:ff:ff")
-{
-}
-void
-MeshTest::Configure (int argc, char *argv[])
-{
-  CommandLine cmd;
-  cmd.AddValue ("x-size", "Number of nodes in a row grid. [6]", m_xSize);
-  cmd.AddValue ("y-size", "Number of rows in a grid. [6]", m_ySize);
-  cmd.AddValue ("step",   "Size of edge in our grid, meters. [100 m]", m_step);
-  /*
-   * As soon as starting node means that it sends a beacon,
-   * simultaneous start is not good.
-   */
-  cmd.AddValue ("start",  "Maximum random start delay, seconds. [0.1 s]", m_randomStart);
-  cmd.AddValue ("time",  "Simulation time, seconds [100 s]", m_totalTime);
-  cmd.AddValue ("packet-interval",  "Interval between packets in UDP ping, seconds [0.001 s]", m_packetInterval);
-  cmd.AddValue ("packet-size",  "Size of packets in UDP ping", m_packetSize);
-  cmd.AddValue ("interfaces", "Number of radio interfaces used by each mesh point. [1]", m_nIfaces);
-  cmd.AddValue ("channels",   "Use different frequency channels for different interfaces. [0]", m_chan);
-  cmd.AddValue ("pcap",   "Enable PCAP traces on interfaces. [0]", m_pcap);
-  cmd.AddValue ("stack",  "Type of protocol stack. ns3::Dot11sStack by default", m_stack);
-  cmd.AddValue ("root", "Mac address of root mesh point in HWMP", m_root);
-  
-  cmd.Parse (argc, argv);
-  NS_LOG_DEBUG ("Grid:" << m_xSize << "*" << m_ySize);
-  NS_LOG_DEBUG ("Simulation time: " << m_totalTime << " s");
-}
-void
-MeshTest::CreateNodes ()
-{ 
-  /*
-   * Create m_ySize*m_xSize stations to form a grid topology
-   */
-  nodes.Create (m_ySize*m_xSize);
-  // Configure YansWifiChannel
-  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
-  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
-  wifiPhy.SetChannel (wifiChannel.Create ());
-  /*
-   * Create mesh helper and set stack installer to it
-   * Stack installer creates all needed protocols and install them to
-   * mesh point device
-   */
-  mesh = MeshHelper::Default ();
-  if (!Mac48Address (m_root.c_str ()).IsBroadcast ())
-    {
-      mesh.SetStackInstaller (m_stack, "Root", Mac48AddressValue (Mac48Address (m_root.c_str ())));
-    }
-  else
-    {
-      //If root is not set, we do not use "Root" attribute, because it
-      //is specified only for 11s
-      mesh.SetStackInstaller (m_stack);
-    }
-  if (m_chan)
-    {
-      mesh.SetSpreadInterfaceChannels (MeshHelper::SPREAD_CHANNELS);
-    }
-  else
-    {
-      mesh.SetSpreadInterfaceChannels (MeshHelper::ZERO_CHANNEL);
-    }
-  mesh.SetMacType ("RandomStart", TimeValue (Seconds(m_randomStart)));
-  // Set number of interfaces - default is single-interface mesh point
-  mesh.SetNumberOfInterfaces (m_nIfaces);
-  // Install protocols and return container if MeshPointDevices
-  meshDevices = mesh.Install (wifiPhy, nodes);
-  // Setup mobility - static grid topology
-  MobilityHelper mobility;
-  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
-                                 "MinX", DoubleValue (0.0),
-                                 "MinY", DoubleValue (0.0),
-                                 "DeltaX", DoubleValue (m_step),
-                                 "DeltaY", DoubleValue (m_step),
-                                 "GridWidth", UintegerValue (m_xSize),
-                                 "LayoutType", StringValue ("RowFirst"));
-  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
-  mobility.Install (nodes);
-  if (m_pcap)
-    wifiPhy.EnablePcapAll (std::string ("mp-"));
-}
-void
-MeshTest::InstallInternetStack ()
-{
-  InternetStackHelper internetStack;
-  internetStack.Install (nodes);
-  Ipv4AddressHelper address;
-  address.SetBase ("10.1.1.0", "255.255.255.0");
-  interfaces = address.Assign (meshDevices);
-}
-void
-MeshTest::InstallApplication ()
-{
-  UdpEchoServerHelper echoServer (9);
-  ApplicationContainer serverApps = echoServer.Install (nodes.Get (0));
-  serverApps.Start (Seconds (0.0));
-  serverApps.Stop (Seconds (m_totalTime));
-  UdpEchoClientHelper echoClient (interfaces.GetAddress (0), 9);
-  echoClient.SetAttribute ("MaxPackets", UintegerValue ((uint32_t)(m_totalTime*(1/m_packetInterval))));
-  echoClient.SetAttribute ("Interval", TimeValue (Seconds (m_packetInterval)));
-  echoClient.SetAttribute ("PacketSize", UintegerValue (m_packetSize));
-  ApplicationContainer clientApps = echoClient.Install (nodes.Get (m_xSize*m_ySize-1));
-  clientApps.Start (Seconds (0.0));
-  clientApps.Stop (Seconds (m_totalTime));
-}
-int
-MeshTest::Run ()
-{
-  CreateNodes ();
-  InstallInternetStack ();
-  InstallApplication ();
-  Simulator::Schedule (Seconds(m_totalTime), & MeshTest::Report, this);
-  Simulator::Stop (Seconds (m_totalTime));
-  Simulator::Run ();
-  Simulator::Destroy ();
-  return 0;
-}
-void
-MeshTest::Report ()
-{
-  unsigned n (0);
-  for (NetDeviceContainer::Iterator i = meshDevices.Begin (); i != meshDevices.End (); ++i, ++n)
-  {
-    std::ostringstream os;
-    os << "mp-report-" << n << ".xml";
-    std::cerr << "Printing mesh point device #" << n << " diagnostics to " << os.str () << "\n";
-    std::ofstream of;
-    of.open (os.str().c_str());
-    if (! of.is_open ())
-    {
-      std::cerr << "Error: Can't open file " << os.str() << "\n";
-      return;
-    }
-    mesh.Report (*i, of);
-    of.close ();
-  }
-}
-int
-main (int argc, char *argv[])
-{
-  MeshTest t; 
-  t.Configure (argc, argv);
-  return t.Run();
-}
--- a/examples/mesh/waf	Fri Mar 04 10:56:07 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-exec "`dirname "$0"`"/../../waf "$@"
--- a/examples/mesh/wscript	Fri Mar 04 10:56:07 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-
-def build(bld):
-    obj = bld.create_ns3_program('mesh', ['core', 'mobility', 'wifi', 'mesh'])
-    obj.source = 'mesh.cc'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/dot11s/helper/dot11s-installer.cc	Fri Mar 04 19:14:23 2011 +0000
@@ -0,0 +1,125 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008,2009 IITP RAS
+ *
+ * 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: Kirill Andreev <andreev@iitp.ru>
+ */
+#include "ns3/dot11s-installer.h"
+#include "ns3/peer-management-protocol.h"
+#include "ns3/hwmp-protocol.h"
+#include "ns3/wifi-net-device.h"
+#include "ns3/mesh-wifi-interface-mac.h"
+
+namespace ns3 {
+using namespace dot11s;
+NS_OBJECT_ENSURE_REGISTERED (Dot11sStack);
+TypeId
+Dot11sStack::GetTypeId ()
+{
+  static TypeId tid = TypeId ("ns3::Dot11sStack")
+    .SetParent<Object> ()
+    .AddConstructor<Dot11sStack> ()
+    .AddAttribute ("Root", 
+                   "The MAC address of root mesh point.",
+                   Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
+                   MakeMac48AddressAccessor (&Dot11sStack::m_root),
+                   MakeMac48AddressChecker ());
+  return tid;
+}
+Dot11sStack::Dot11sStack () :
+  m_root (Mac48Address ("ff:ff:ff:ff:ff:ff"))
+{
+}
+Dot11sStack::~Dot11sStack ()
+{
+}
+void
+Dot11sStack::DoDispose ()
+{
+}
+bool
+Dot11sStack::InstallStack (Ptr<MeshPointDevice> mp)
+{
+  //Install Peer management protocol:
+  Ptr<PeerManagementProtocol> pmp = CreateObject<PeerManagementProtocol> ();
+  pmp->SetMeshId ("mesh");
+  bool install_ok = pmp->Install (mp);
+  if (!install_ok)
+    {
+      return false;
+    }
+  //Install HWMP:
+  Ptr<HwmpProtocol> hwmp = CreateObject<HwmpProtocol> ();
+  install_ok = hwmp->Install (mp);
+  if (!install_ok)
+    {
+      return false;
+    }
+  if (mp->GetAddress() == m_root)
+    {
+      hwmp->SetRoot ();
+    }
+  //Install interaction between HWMP and Peer management protocol:
+  //PeekPointer()'s to avoid circular Ptr references
+  pmp->SetPeerLinkStatusCallback (MakeCallback (&HwmpProtocol::PeerLinkStatus, PeekPointer (hwmp)));
+  hwmp->SetNeighboursCallback (MakeCallback (&PeerManagementProtocol::GetPeers, PeekPointer (pmp)));
+  return true;
+}
+void
+Dot11sStack::Report (const Ptr<MeshPointDevice> mp, std::ostream& os)
+{
+  mp->Report (os);
+
+  std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
+  for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != ifaces.end (); ++i)
+    {
+      Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
+      NS_ASSERT (device != 0);
+      Ptr<MeshWifiInterfaceMac> mac = device->GetMac ()->GetObject<MeshWifiInterfaceMac> ();
+      NS_ASSERT (mac != 0);
+      mac->Report (os);
+    }
+  Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
+  NS_ASSERT (hwmp != 0);
+  hwmp->Report (os);
+
+  Ptr<PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> ();
+  NS_ASSERT (pmp != 0);
+  pmp->Report (os);
+}
+void
+Dot11sStack::ResetStats (const Ptr<MeshPointDevice> mp)
+{
+  mp->ResetStats ();
+
+  std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
+  for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != ifaces.end (); ++i)
+    {
+      Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
+      NS_ASSERT (device != 0);
+      Ptr<MeshWifiInterfaceMac> mac = device->GetMac ()->GetObject<MeshWifiInterfaceMac> ();
+      NS_ASSERT (mac != 0);
+      mac->ResetStats ();
+    }
+  Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
+  NS_ASSERT (hwmp != 0);
+  hwmp->ResetStats ();
+
+  Ptr<PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> ();
+  NS_ASSERT (pmp != 0);
+  pmp->ResetStats ();
+}
+} //namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/dot11s/helper/dot11s-installer.h	Fri Mar 04 19:14:23 2011 +0000
@@ -0,0 +1,78 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008,2009 IITP RAS
+ *
+ * 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: Kirill Andreev <andreev@iitp.ru>
+ */
+
+#ifndef DOT11S_STACK_INSTALLER_H
+#define DOT11S_STACK_INSTALLER_H
+
+#include "ns3/mesh-stack-installer.h"
+
+namespace ns3 {
+
+/**
+ * \brief Helper class to allow easy installation of 802.11s stack.
+ */
+class Dot11sStack : public MeshStack
+{
+public:
+  /**
+   * \internal
+   */
+  static TypeId GetTypeId ();
+  
+  /**
+   * Create a Dot11sStack() installer helper.
+   */
+  Dot11sStack ();
+
+  /**
+   * Destroy a Dot11sStack() installer helper.
+   */
+  ~Dot11sStack ();
+
+  /**
+   * Break any reference cycles in the installer helper.  Required for ns-3
+   * Object support.
+   */
+  void DoDispose ();
+
+  /**
+   * \brief Install an 802.11s stack.
+   * \param mp The Ptr<MeshPointDevice> to use when setting up the PMP.
+   */
+  bool InstallStack (Ptr<MeshPointDevice> mp);
+ 
+  /**
+   * \brief Iterate through the referenced devices and protocols and print
+   * their statistics
+   */
+  void Report (const Ptr<MeshPointDevice> mp, std::ostream&);
+
+  /**
+   * \brief Reset the statistics on the referenced devices and protocols.
+   */
+  void ResetStats (const Ptr<MeshPointDevice> mp);
+private:
+  Mac48Address m_root;
+};
+
+} //namespace ns3
+
+#endif
+
--- a/src/dot11s/wscript	Fri Mar 04 10:56:07 2011 -0800
+++ b/src/dot11s/wscript	Fri Mar 04 19:14:23 2011 +0000
@@ -23,6 +23,7 @@
         'model/hwmp-protocol-mac.cc',
         'model/hwmp-protocol.cc',
         'model/airtime-metric.cc',
+        'helper/dot11s-installer.cc',
         'test/dot11s-test-suite.cc',
         'test/pmp-regression.cc',
         'test/hwmp-reactive-regression.cc',
@@ -51,4 +52,5 @@
         'model/ie-dot11s-prep.h',
         'model/ie-dot11s-preq.h',
         'model/ie-dot11s-rann.h',
+        'helper/dot11s-installer.h',
         ]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/flame/helper/flame-installer.cc	Fri Mar 04 19:14:23 2011 +0000
@@ -0,0 +1,73 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008,2009 IITP RAS
+ *
+ * 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: Kirill Andreev <andreev@iitp.ru>
+ */
+
+#include "ns3/flame-installer.h"
+#include "ns3/flame-protocol.h"
+#include "ns3/wifi-net-device.h"
+#include "ns3/mesh-wifi-interface-mac.h"
+
+namespace ns3
+{
+using namespace flame;
+NS_OBJECT_ENSURE_REGISTERED (FlameStack);
+TypeId
+FlameStack::GetTypeId ()
+{
+  static TypeId tid = TypeId ("ns3::FlameStack")
+    .SetParent<Object> ()
+    .AddConstructor<FlameStack> ();
+  return tid;
+}
+FlameStack::FlameStack ()
+{
+}
+FlameStack::~FlameStack ()
+{
+}
+void
+FlameStack::DoDispose ()
+{
+}
+bool
+FlameStack::InstallStack (Ptr<MeshPointDevice> mp)
+{
+  Ptr<FlameProtocol> flame = CreateObject<FlameProtocol> ();
+  return flame->Install (mp);
+}
+void
+FlameStack::Report (const Ptr<MeshPointDevice> mp, std::ostream& os)
+{
+  mp->Report (os);
+  // TODO report flame counters
+  Ptr<FlameProtocol> flame = mp->GetObject<FlameProtocol> ();
+  NS_ASSERT (flame != 0);
+  flame->Report (os);
+}
+void
+FlameStack::ResetStats (const Ptr<MeshPointDevice> mp)
+{
+  mp->ResetStats ();
+  // TODO reset flame counters
+  Ptr<FlameProtocol> flame = mp->GetObject<FlameProtocol> ();
+  NS_ASSERT (flame != 0);
+
+  flame->ResetStats ();
+}
+} //namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/flame/helper/flame-installer.h	Fri Mar 04 19:14:23 2011 +0000
@@ -0,0 +1,79 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008,2009 IITP RAS
+ *
+ * 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: Kirill Andreev <andreev@iitp.ru>
+ */
+
+#ifndef FLAME_STACK_INSTALLER_H
+#define FLAME_STACK_INSTALLER_H
+
+#include "ns3/mesh-stack-installer.h"
+
+namespace ns3 {
+
+/**
+ * \ingroup flame
+ *
+ * \brief Helper class used to install FLAME mesh stack (actually single
+ * protocol in this stack)
+ */
+class FlameStack : public MeshStack
+{
+public:
+  /*
+   * \internal
+   */
+  static TypeId GetTypeId ();
+
+  /**
+   * Construct a FlameStack helper class.
+   */
+  FlameStack ();
+
+  /**
+   * Destroy a FlameStack helper class.
+   */
+  ~FlameStack ();
+
+  /**
+   * \internal
+   * Break any reference cycles in the installer helper.  Required for ns-3
+   * Object support.
+   */
+  void DoDispose ();
+  
+  /**
+   * \brief Install a flame stack on the given MeshPointDevice
+   * \param mp The Ptr<MeshPointDevice> to use.
+   */
+  bool InstallStack (Ptr<MeshPointDevice> mp);
+
+  /**
+   * \brief Print flame protocol statistics.
+   */
+  void Report (const Ptr<MeshPointDevice> mp, std::ostream&);
+
+  /**
+   * \brief Reset the statistics.
+   */
+  void ResetStats (const Ptr<MeshPointDevice> mp);
+};
+
+} //namespace ns3
+
+#endif // FLAME_STACK_INSTALLER_H
+
--- a/src/flame/wscript	Fri Mar 04 10:56:07 2011 -0800
+++ b/src/flame/wscript	Fri Mar 04 19:14:23 2011 +0000
@@ -7,6 +7,7 @@
         'model/flame-rtable.cc',
         'model/flame-protocol-mac.cc',
         'model/flame-protocol.cc',
+        'helper/flame-installer.cc',
         'test/flame-test-suite.cc',
         'test/flame-regression.cc',
         'test/regression.cc',
@@ -18,4 +19,5 @@
         'model/flame-header.h',
         'model/flame-rtable.h',
         'model/flame-protocol-mac.h',
+        'helper/flame-installer.h',
         ]
--- a/src/helper/dot11s-installer.cc	Fri Mar 04 10:56:07 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,125 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2008,2009 IITP RAS
- *
- * 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: Kirill Andreev <andreev@iitp.ru>
- */
-#include "ns3/dot11s-installer.h"
-#include "ns3/peer-management-protocol.h"
-#include "ns3/hwmp-protocol.h"
-#include "ns3/wifi-net-device.h"
-#include "ns3/mesh-wifi-interface-mac.h"
-
-namespace ns3 {
-using namespace dot11s;
-NS_OBJECT_ENSURE_REGISTERED (Dot11sStack);
-TypeId
-Dot11sStack::GetTypeId ()
-{
-  static TypeId tid = TypeId ("ns3::Dot11sStack")
-    .SetParent<Object> ()
-    .AddConstructor<Dot11sStack> ()
-    .AddAttribute ("Root", 
-                   "The MAC address of root mesh point.",
-                   Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
-                   MakeMac48AddressAccessor (&Dot11sStack::m_root),
-                   MakeMac48AddressChecker ());
-  return tid;
-}
-Dot11sStack::Dot11sStack () :
-  m_root (Mac48Address ("ff:ff:ff:ff:ff:ff"))
-{
-}
-Dot11sStack::~Dot11sStack ()
-{
-}
-void
-Dot11sStack::DoDispose ()
-{
-}
-bool
-Dot11sStack::InstallStack (Ptr<MeshPointDevice> mp)
-{
-  //Install Peer management protocol:
-  Ptr<PeerManagementProtocol> pmp = CreateObject<PeerManagementProtocol> ();
-  pmp->SetMeshId ("mesh");
-  bool install_ok = pmp->Install (mp);
-  if (!install_ok)
-    {
-      return false;
-    }
-  //Install HWMP:
-  Ptr<HwmpProtocol> hwmp = CreateObject<HwmpProtocol> ();
-  install_ok = hwmp->Install (mp);
-  if (!install_ok)
-    {
-      return false;
-    }
-  if (mp->GetAddress() == m_root)
-    {
-      hwmp->SetRoot ();
-    }
-  //Install interaction between HWMP and Peer management protocol:
-  //PeekPointer()'s to avoid circular Ptr references
-  pmp->SetPeerLinkStatusCallback (MakeCallback (&HwmpProtocol::PeerLinkStatus, PeekPointer (hwmp)));
-  hwmp->SetNeighboursCallback (MakeCallback (&PeerManagementProtocol::GetPeers, PeekPointer (pmp)));
-  return true;
-}
-void
-Dot11sStack::Report (const Ptr<MeshPointDevice> mp, std::ostream& os)
-{
-  mp->Report (os);
-
-  std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
-  for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != ifaces.end (); ++i)
-    {
-      Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
-      NS_ASSERT (device != 0);
-      Ptr<MeshWifiInterfaceMac> mac = device->GetMac ()->GetObject<MeshWifiInterfaceMac> ();
-      NS_ASSERT (mac != 0);
-      mac->Report (os);
-    }
-  Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
-  NS_ASSERT (hwmp != 0);
-  hwmp->Report (os);
-
-  Ptr<PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> ();
-  NS_ASSERT (pmp != 0);
-  pmp->Report (os);
-}
-void
-Dot11sStack::ResetStats (const Ptr<MeshPointDevice> mp)
-{
-  mp->ResetStats ();
-
-  std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
-  for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != ifaces.end (); ++i)
-    {
-      Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
-      NS_ASSERT (device != 0);
-      Ptr<MeshWifiInterfaceMac> mac = device->GetMac ()->GetObject<MeshWifiInterfaceMac> ();
-      NS_ASSERT (mac != 0);
-      mac->ResetStats ();
-    }
-  Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
-  NS_ASSERT (hwmp != 0);
-  hwmp->ResetStats ();
-
-  Ptr<PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> ();
-  NS_ASSERT (pmp != 0);
-  pmp->ResetStats ();
-}
-} //namespace ns3
--- a/src/helper/dot11s-installer.h	Fri Mar 04 10:56:07 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2008,2009 IITP RAS
- *
- * 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: Kirill Andreev <andreev@iitp.ru>
- */
-
-#ifndef DOT11S_STACK_INSTALLER_H
-#define DOT11S_STACK_INSTALLER_H
-
-#include "ns3/mesh-stack-installer.h"
-
-namespace ns3 {
-
-/**
- * \brief Helper class to allow easy installation of 802.11s stack.
- */
-class Dot11sStack : public MeshStack
-{
-public:
-  /**
-   * \internal
-   */
-  static TypeId GetTypeId ();
-  
-  /**
-   * Create a Dot11sStack() installer helper.
-   */
-  Dot11sStack ();
-
-  /**
-   * Destroy a Dot11sStack() installer helper.
-   */
-  ~Dot11sStack ();
-
-  /**
-   * Break any reference cycles in the installer helper.  Required for ns-3
-   * Object support.
-   */
-  void DoDispose ();
-
-  /**
-   * \brief Install an 802.11s stack.
-   * \param mp The Ptr<MeshPointDevice> to use when setting up the PMP.
-   */
-  bool InstallStack (Ptr<MeshPointDevice> mp);
- 
-  /**
-   * \brief Iterate through the referenced devices and protocols and print
-   * their statistics
-   */
-  void Report (const Ptr<MeshPointDevice> mp, std::ostream&);
-
-  /**
-   * \brief Reset the statistics on the referenced devices and protocols.
-   */
-  void ResetStats (const Ptr<MeshPointDevice> mp);
-private:
-  Mac48Address m_root;
-};
-
-} //namespace ns3
-
-#endif
-
--- a/src/helper/flame-installer.cc	Fri Mar 04 10:56:07 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2008,2009 IITP RAS
- *
- * 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: Kirill Andreev <andreev@iitp.ru>
- */
-
-#include "ns3/flame-installer.h"
-#include "ns3/flame-protocol.h"
-#include "ns3/wifi-net-device.h"
-#include "ns3/mesh-wifi-interface-mac.h"
-
-namespace ns3
-{
-using namespace flame;
-NS_OBJECT_ENSURE_REGISTERED (FlameStack);
-TypeId
-FlameStack::GetTypeId ()
-{
-  static TypeId tid = TypeId ("ns3::FlameStack")
-    .SetParent<Object> ()
-    .AddConstructor<FlameStack> ();
-  return tid;
-}
-FlameStack::FlameStack ()
-{
-}
-FlameStack::~FlameStack ()
-{
-}
-void
-FlameStack::DoDispose ()
-{
-}
-bool
-FlameStack::InstallStack (Ptr<MeshPointDevice> mp)
-{
-  Ptr<FlameProtocol> flame = CreateObject<FlameProtocol> ();
-  return flame->Install (mp);
-}
-void
-FlameStack::Report (const Ptr<MeshPointDevice> mp, std::ostream& os)
-{
-  mp->Report (os);
-  // TODO report flame counters
-  Ptr<FlameProtocol> flame = mp->GetObject<FlameProtocol> ();
-  NS_ASSERT (flame != 0);
-  flame->Report (os);
-}
-void
-FlameStack::ResetStats (const Ptr<MeshPointDevice> mp)
-{
-  mp->ResetStats ();
-  // TODO reset flame counters
-  Ptr<FlameProtocol> flame = mp->GetObject<FlameProtocol> ();
-  NS_ASSERT (flame != 0);
-
-  flame->ResetStats ();
-}
-} //namespace ns3
--- a/src/helper/flame-installer.h	Fri Mar 04 10:56:07 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2008,2009 IITP RAS
- *
- * 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: Kirill Andreev <andreev@iitp.ru>
- */
-
-#ifndef FLAME_STACK_INSTALLER_H
-#define FLAME_STACK_INSTALLER_H
-
-#include "ns3/mesh-stack-installer.h"
-
-namespace ns3 {
-
-/**
- * \ingroup flame
- *
- * \brief Helper class used to install FLAME mesh stack (actually single
- * protocol in this stack)
- */
-class FlameStack : public MeshStack
-{
-public:
-  /*
-   * \internal
-   */
-  static TypeId GetTypeId ();
-
-  /**
-   * Construct a FlameStack helper class.
-   */
-  FlameStack ();
-
-  /**
-   * Destroy a FlameStack helper class.
-   */
-  ~FlameStack ();
-
-  /**
-   * \internal
-   * Break any reference cycles in the installer helper.  Required for ns-3
-   * Object support.
-   */
-  void DoDispose ();
-  
-  /**
-   * \brief Install a flame stack on the given MeshPointDevice
-   * \param mp The Ptr<MeshPointDevice> to use.
-   */
-  bool InstallStack (Ptr<MeshPointDevice> mp);
-
-  /**
-   * \brief Print flame protocol statistics.
-   */
-  void Report (const Ptr<MeshPointDevice> mp, std::ostream&);
-
-  /**
-   * \brief Reset the statistics.
-   */
-  void ResetStats (const Ptr<MeshPointDevice> mp);
-};
-
-} //namespace ns3
-
-#endif // FLAME_STACK_INSTALLER_H
-
--- a/src/helper/mesh-helper.cc	Fri Mar 04 10:56:07 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,211 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2008,2009 IITP RAS
- *
- * 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: Kirill Andreev <andreev@iitp.ru>
- *         Pavel Boyko <boyko@iitp.ru>
- */
-#include "mesh-helper.h"
-#include "ns3/simulator.h"
-#include "ns3/mesh-point-device.h"
-#include "ns3/wifi-net-device.h"
-#include "ns3/mesh-wifi-interface-mac.h"
-namespace ns3
-{
-MeshHelper::MeshHelper () :
-  m_nInterfaces (1),
-  m_spreadChannelPolicy (ZERO_CHANNEL),
-  m_stack (0),
-  m_standard (WIFI_PHY_STANDARD_80211a)
-{
-}
-MeshHelper::~MeshHelper ()
-{
-  m_stack = 0;
-}
-void
-MeshHelper::SetSpreadInterfaceChannels (enum ChannelPolicy policy)
-{
-  m_spreadChannelPolicy = policy;
-}
-void
-MeshHelper::SetStackInstaller (std::string type,
-                std::string n0, const AttributeValue &v0,
-                std::string n1, const AttributeValue &v1,
-                std::string n2, const AttributeValue &v2,
-                std::string n3, const AttributeValue &v3,
-                std::string n4, const AttributeValue &v4,
-                std::string n5, const AttributeValue &v5,
-                std::string n6, const AttributeValue &v6,
-                std::string n7, const AttributeValue &v7)
-{
-  m_stackFactory.SetTypeId (type);
-  m_stackFactory.Set (n0, v0);
-  m_stackFactory.Set (n1, v1);
-  m_stackFactory.Set (n2, v2);
-  m_stackFactory.Set (n3, v3);
-  m_stackFactory.Set (n4, v4);
-  m_stackFactory.Set (n5, v5);
-  m_stackFactory.Set (n6, v6);
-  m_stackFactory.Set (n7, v7);
-
-  m_stack = m_stackFactory.Create<MeshStack> ();
-  if (m_stack == 0)
-    {
-      NS_FATAL_ERROR ("Stack has not been created: " << type);
-    }
-}
-
-void
-MeshHelper::SetNumberOfInterfaces (uint32_t nInterfaces)
-{
-  m_nInterfaces = nInterfaces;
-}
-NetDeviceContainer
-MeshHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c) const
-{
-  NetDeviceContainer devices;
-  NS_ASSERT (m_stack != 0);
-  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
-    {
-      Ptr<Node> node = *i;
-      // Create a mesh point device
-      Ptr<MeshPointDevice> mp = CreateObject<MeshPointDevice> ();
-      node->AddDevice (mp);
-      // Create wifi interfaces (single interface by default)
-      for (uint32_t i = 0; i < m_nInterfaces; ++i)
-        {
-          uint32_t channel = 0;
-          if (m_spreadChannelPolicy == ZERO_CHANNEL)
-            {
-              channel = 0;
-            }
-          if (m_spreadChannelPolicy == SPREAD_CHANNELS)
-            {
-              channel = i * 5;
-            }
-          Ptr<WifiNetDevice> iface = CreateInterface (phyHelper, node, channel);
-          mp->AddInterface (iface);
-        }
-      if (!m_stack->InstallStack (mp))
-        {
-          NS_FATAL_ERROR ("Stack is not installed!");
-        }
-      devices.Add (mp);
-    }
-  return devices;
-}
-MeshHelper
-MeshHelper::Default (void)
-{
-  MeshHelper helper;
-  helper.SetMacType ();
-  helper.SetRemoteStationManager ("ns3::ArfWifiManager");
-  helper.SetSpreadInterfaceChannels (SPREAD_CHANNELS);
-  return helper;
-}
-
-void
-MeshHelper::SetMacType (std::string n0, const AttributeValue &v0,
-                              std::string n1, const AttributeValue &v1,
-                              std::string n2, const AttributeValue &v2,
-                              std::string n3, const AttributeValue &v3,
-                              std::string n4, const AttributeValue &v4,
-                              std::string n5, const AttributeValue &v5,
-                              std::string n6, const AttributeValue &v6,
-                              std::string n7, const AttributeValue &v7)
-{
-  m_mac.SetTypeId ("ns3::MeshWifiInterfaceMac");
-  m_mac.Set (n0, v0);
-  m_mac.Set (n1, v1);
-  m_mac.Set (n2, v2);
-  m_mac.Set (n3, v3);
-  m_mac.Set (n4, v4);
-  m_mac.Set (n5, v5);
-  m_mac.Set (n6, v6);
-  m_mac.Set (n7, v7);
-}
-void
-MeshHelper::SetRemoteStationManager (std::string type,
-                                     std::string n0, const AttributeValue &v0,
-                                     std::string n1, const AttributeValue &v1,
-                                     std::string n2, const AttributeValue &v2,
-                                     std::string n3, const AttributeValue &v3,
-                                     std::string n4, const AttributeValue &v4,
-                                     std::string n5, const AttributeValue &v5,
-                                     std::string n6, const AttributeValue &v6,
-                                     std::string n7, const AttributeValue &v7)
-{
-  m_stationManager = ObjectFactory ();
-  m_stationManager.SetTypeId (type);
-  m_stationManager.Set (n0, v0);
-  m_stationManager.Set (n1, v1);
-  m_stationManager.Set (n2, v2);
-  m_stationManager.Set (n3, v3);
-  m_stationManager.Set (n4, v4);
-  m_stationManager.Set (n5, v5);
-  m_stationManager.Set (n6, v6);
-  m_stationManager.Set (n7, v7);
-}
-void 
-MeshHelper::SetStandard (enum WifiPhyStandard standard)
-{
-  m_standard = standard;
-}
-
-Ptr<WifiNetDevice>
-MeshHelper::CreateInterface (const WifiPhyHelper &phyHelper, Ptr<Node> node, uint16_t channelId) const
-{
-  Ptr<WifiNetDevice> device = CreateObject<WifiNetDevice> ();
-
-  Ptr<MeshWifiInterfaceMac> mac = m_mac.Create<MeshWifiInterfaceMac> ();
-  NS_ASSERT (mac != 0);
-  mac->SetSsid (Ssid ());
-  Ptr<WifiRemoteStationManager> manager = m_stationManager.Create<WifiRemoteStationManager> ();
-  NS_ASSERT (manager != 0);
-  Ptr<WifiPhy> phy = phyHelper.Create (node, device);
-  mac->SetAddress (Mac48Address::Allocate ());
-  mac->ConfigureStandard (m_standard);
-  phy->ConfigureStandard (m_standard);
-  device->SetMac (mac);
-  device->SetPhy (phy);
-  device->SetRemoteStationManager (manager);
-  node->AddDevice (device);
-  mac->SwitchFrequencyChannel (channelId);
-  return device;
-}
-void
-MeshHelper::Report (const ns3::Ptr<ns3::NetDevice>& device, std::ostream& os)
-{
-  NS_ASSERT (m_stack != 0);
-  Ptr<MeshPointDevice> mp = device->GetObject<MeshPointDevice> ();
-  NS_ASSERT (mp != 0);
-  std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
-  os << "<MeshPointDevice time=\"" << Simulator::Now ().GetSeconds () << "\" address=\""
-      << Mac48Address::ConvertFrom (mp->GetAddress ()) << "\">\n";
-  m_stack->Report (mp, os);
-  os << "</MeshPointDevice>\n";
-}
-void
-MeshHelper::ResetStats (const ns3::Ptr<ns3::NetDevice>& device)
-{
-  NS_ASSERT (m_stack != 0);
-  Ptr<MeshPointDevice> mp = device->GetObject<MeshPointDevice> ();
-  NS_ASSERT (mp != 0);
-  m_stack->ResetStats (mp);
-}
-} //namespace ns3
-
--- a/src/helper/mesh-helper.h	Fri Mar 04 10:56:07 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,213 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2008,2009 IITP RAS
- *
- * 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: Kirill Andreev <andreev@iitp.ru>
- *         Pavel Boyko <boyko@iitp.ru>
- */
-
-
-#ifndef MESH_HELPER_H
-#define MESH_HELPER_H
-
-#include "ns3/wifi-helper.h"
-#include "ns3/mesh-stack-installer.h"
-
-namespace ns3 {
-
-class WifiChannel;
-
-/** 
- * \ingroup dot11s
- * 
- * \brief Helper to create IEEE 802.11s mesh networks
- */
-class MeshHelper
-{
-public:
-  /**
-   * Construct a MeshHelper used to make life easier when creating 802.11s networks.
-   */
-  MeshHelper ();
-
-  /**
-   * Destroy a MeshHelper.
-   */
-  ~MeshHelper ();
-
-  /**
-   * \brief Set the helper to the default values for the MAC type,  remote
-   * station manager and channel policy.
-   */
-   static MeshHelper Default ();
-
-  /**
-   * \param n0 the name of the attribute to set
-   * \param v0 the value of the attribute to set
-   * \param n1 the name of the attribute to set
-   * \param v1 the value of the attribute to set
-   * \param n2 the name of the attribute to set
-   * \param v2 the value of the attribute to set
-   * \param n3 the name of the attribute to set
-   * \param v3 the value of the attribute to set
-   * \param n4 the name of the attribute to set
-   * \param v4 the value of the attribute to set
-   * \param n5 the name of the attribute to set
-   * \param v5 the value of the attribute to set
-   * \param n6 the name of the attribute to set
-   * \param v6 the value of the attribute to set
-   * \param n7 the name of the attribute to set
-   * \param v7 the value of the attribute to set
-   *
-   * All the attributes specified in this method should exist
-   * in the requested mac.
-   */
-  void SetMacType (std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
-        std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
-        std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
-        std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
-        std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
-        std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
-        std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
-        std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ());
-  /**
-   * \param type the type of ns3::WifiRemoteStationManager to create.
-   * \param n0 the name of the attribute to set
-   * \param v0 the value of the attribute to set
-   * \param n1 the name of the attribute to set
-   * \param v1 the value of the attribute to set
-   * \param n2 the name of the attribute to set
-   * \param v2 the value of the attribute to set
-   * \param n3 the name of the attribute to set
-   * \param v3 the value of the attribute to set
-   * \param n4 the name of the attribute to set
-   * \param v4 the value of the attribute to set
-   * \param n5 the name of the attribute to set
-   * \param v5 the value of the attribute to set
-   * \param n6 the name of the attribute to set
-   * \param v6 the value of the attribute to set
-   * \param n7 the name of the attribute to set
-   * \param v7 the value of the attribute to set
-   *
-   * All the attributes specified in this method should exist
-   * in the requested station manager.
-   */
-  void
-  SetRemoteStationManager (std::string type,
-      std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),    
-      std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
-      std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
-      std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
-      std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
-      std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
-      std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
-      std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ());
-  /**
-   * Set PHY standard
-   */
-  void SetStandard (enum WifiPhyStandard standard);
-  //void SetMeshId (std::string s); // XXX
-  /** 
-   *  \brief Spread/not spread frequency channels of MP interfaces. 
-   * 
-   *  If set to true different non-overlapping 20MHz frequency 
-   *  channels will be assigned to different mesh point interfaces.
-   */
-  enum ChannelPolicy
-  {
-    SPREAD_CHANNELS,
-    ZERO_CHANNEL
-  };
-
-  /**
-   * \brief set the channel policy
-   */
-  void SetSpreadInterfaceChannels (ChannelPolicy);
-  /**
-   * \brief Set a number of interfaces in a mesh network
-   * \param nInterfaces is the number of interfaces
-   */
-  void SetNumberOfInterfaces (uint32_t nInterfaces);
-  
-  /** 
-   * \brief Install 802.11s mesh device & protocols on given node list
-   * 
-   * \param phyHelper           Wifi PHY helper
-   * \param c               List of nodes to install
-   * 
-   * \return list of created mesh point devices, see MeshPointDevice
-   */
-  NetDeviceContainer
-  Install (const WifiPhyHelper &phyHelper, NodeContainer c) const;
-  /**
-   * \param type the type of ns3::MeshStack.
-   * \param n0 the name of the attribute to set
-   * \param v0 the value of the attribute to set
-   * \param n1 the name of the attribute to set
-   * \param v1 the value of the attribute to set
-   * \param n2 the name of the attribute to set
-   * \param v2 the value of the attribute to set
-   * \param n3 the name of the attribute to set
-   * \param v3 the value of the attribute to set
-   * \param n4 the name of the attribute to set
-   * \param v4 the value of the attribute to set
-   * \param n5 the name of the attribute to set
-   * \param v5 the value of the attribute to set
-   * \param n6 the name of the attribute to set
-   * \param v6 the value of the attribute to set
-   * \param n7 the name of the attribute to set
-   * \param v7 the value of the attribute to set
-   */
-  void SetStackInstaller (std::string type,
-                std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
-                std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
-                std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
-                std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
-                std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
-                std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
-                std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
-                std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ());
-
-  /**
-   * \brief Print statistics.
-   */
-  void Report (const ns3::Ptr<ns3::NetDevice>&, std::ostream&);
-
-  /**
-   * \brief Reset statistics.
-   */
-  void ResetStats (const ns3::Ptr<ns3::NetDevice>&);
-private:
-  /**
-   * \internal
-   * \returns a WifiNetDevice with ready-to-use interface
-   */
-  Ptr<WifiNetDevice> CreateInterface (const WifiPhyHelper &phyHelper, Ptr<Node> node, uint16_t channelId) const;
-  uint32_t m_nInterfaces;
-  ChannelPolicy m_spreadChannelPolicy;
-  Ptr<MeshStack> m_stack;
-  ObjectFactory m_stackFactory;
-  ///\name Interface factory
-  ///\{
-  ObjectFactory m_mac;
-  ObjectFactory m_stationManager;
-  enum WifiPhyStandard m_standard;
-    ///\}
-};
-} //namespace ns3
-
-#endif /* MESH_HELPER_H */
-
--- a/src/helper/mesh-stack-installer.h	Fri Mar 04 10:56:07 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2008,2009 IITP RAS
- *
- * 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: Kirill Andreev <andreev@iitp.ru>
- */
-
-
-#ifndef MESH_STACK_INSTALLER_H
-#define MESH_STACK_INSTALLER_H
-#include "ns3/mesh-point-device.h"
-namespace ns3 {
-/**
- * \ingroup mesh
- *
- * \brief Prototype for class, which helps to install MAC-layer
- * routing stack to ns3::MeshPointDevice
- * \details You need to create a  MeshPointDevice and attach all
- * interfaces to it, than call Install method
- */
-class MeshStack : public Object
-{
-  public:
-    ///\brief Installs mesh stack. needed by helper only
-    virtual bool InstallStack (Ptr<MeshPointDevice> mp) = 0;
-    /// Report statistics of a given mesh point
-    virtual void Report (const Ptr<MeshPointDevice> mp, std::ostream&) = 0;
-    /// Reset statistics of a given mesh point
-    virtual void ResetStats (const Ptr<MeshPointDevice> mp) = 0;
-};
-}
-#endif
-
--- a/src/helper/wscript	Fri Mar 04 10:56:07 2011 -0800
+++ b/src/helper/wscript	Fri Mar 04 19:14:23 2011 +0000
@@ -3,9 +3,6 @@
 def build(bld):
     helper = bld.create_ns3_module('helper', ['mobility', 'network', 'internet', 'wifi', 'point-to-point', 'spectrum'])
     helper.source = [
-        'mesh-helper.cc',
-        'dot11s-installer.cc',
-        'flame-installer.cc',
         'athstats-helper.cc',
         'animation-interface.cc',
         'canvas-location.cc',
@@ -15,10 +12,6 @@
     headers = bld.new_task_gen('ns3header')
     headers.module = 'helper'
     headers.source = [
-        'mesh-helper.h',
-        'mesh-stack-installer.h',
-        'dot11s-installer.h',
-        'flame-installer.h',
         'athstats-helper.h',
         'animation-interface.h',
         'canvas-location.h',
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mesh/examples/mesh.cc	Fri Mar 04 19:14:23 2011 +0000
@@ -0,0 +1,260 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008,2009 IITP RAS
+ *
+ * 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: Kirill Andreev <andreev@iitp.ru>
+ *
+ *
+ * By default this script creates m_xSize * m_ySize square grid topology with
+ * IEEE802.11s stack installed at each node with peering management
+ * and HWMP protocol.
+ * The side of the square cell is defined by m_step parameter.
+ * When topology is created, UDP ping is installed to opposite corners
+ * by diagonals. packet size of the UDP ping and interval between two
+ * successive packets is configurable.
+ * 
+ *  m_xSize * step
+ *  |<--------->|
+ *   step
+ *  |<--->|
+ *  * --- * --- * <---Ping sink  _
+ *  | \   |   / |                ^
+ *  |   \ | /   |                |
+ *  * --- * --- * m_ySize * step |
+ *  |   / | \   |                |
+ *  | /   |   \ |                |
+ *  * --- * --- *                _
+ *  ^ Ping source
+ *
+ *  See also MeshTest::Configure to read more about configurable
+ *  parameters.
+ */
+
+
+#include "ns3/core-module.h"
+#include "ns3/internet-module.h"
+#include "ns3/network-module.h"
+#include "ns3/helper-module.h"
+#include "ns3/applications-module.h"
+#include "ns3/wifi-module.h"
+#include "ns3/mesh-module.h"
+#include "ns3/mobility-module.h"
+#include "ns3/mesh-helper.h"
+
+#include <iostream>
+#include <sstream>
+#include <fstream>
+
+using namespace ns3;
+
+NS_LOG_COMPONENT_DEFINE ("TestMeshScript");
+class MeshTest
+{
+  public:
+    /// Init test
+    MeshTest ();
+    /// Configure test from command line arguments
+    void Configure (int argc, char ** argv);
+    /// Run test
+    int Run ();
+  private:
+    int       m_xSize;
+    int       m_ySize;
+    double    m_step;
+    double    m_randomStart;
+    double    m_totalTime;
+    double    m_packetInterval;
+    uint16_t  m_packetSize;
+    uint32_t  m_nIfaces;
+    bool      m_chan;
+    bool      m_pcap;
+    std::string m_stack;
+    std::string m_root;
+    /// List of network nodes
+    NodeContainer nodes;
+    /// List of all mesh point devices
+    NetDeviceContainer meshDevices;
+    //Addresses of interfaces:
+    Ipv4InterfaceContainer interfaces;
+    // MeshHelper. Report is not static methods
+    MeshHelper mesh;
+  private:
+    /// Create nodes and setup their mobility
+    void CreateNodes ();
+    /// Install internet m_stack on nodes
+    void InstallInternetStack ();
+    /// Install applications
+    void InstallApplication ();
+    /// Print mesh devices diagnostics
+    void Report ();  
+};
+MeshTest::MeshTest () :
+  m_xSize (3),
+  m_ySize (3),
+  m_step (100.0),
+  m_randomStart (0.1),
+  m_totalTime (100.0),
+  m_packetInterval (0.1),
+  m_packetSize (1024),
+  m_nIfaces (1),
+  m_chan (true),
+  m_pcap (false),
+  m_stack ("ns3::Dot11sStack"),
+  m_root ("ff:ff:ff:ff:ff:ff")
+{
+}
+void
+MeshTest::Configure (int argc, char *argv[])
+{
+  CommandLine cmd;
+  cmd.AddValue ("x-size", "Number of nodes in a row grid. [6]", m_xSize);
+  cmd.AddValue ("y-size", "Number of rows in a grid. [6]", m_ySize);
+  cmd.AddValue ("step",   "Size of edge in our grid, meters. [100 m]", m_step);
+  /*
+   * As soon as starting node means that it sends a beacon,
+   * simultaneous start is not good.
+   */
+  cmd.AddValue ("start",  "Maximum random start delay, seconds. [0.1 s]", m_randomStart);
+  cmd.AddValue ("time",  "Simulation time, seconds [100 s]", m_totalTime);
+  cmd.AddValue ("packet-interval",  "Interval between packets in UDP ping, seconds [0.001 s]", m_packetInterval);
+  cmd.AddValue ("packet-size",  "Size of packets in UDP ping", m_packetSize);
+  cmd.AddValue ("interfaces", "Number of radio interfaces used by each mesh point. [1]", m_nIfaces);
+  cmd.AddValue ("channels",   "Use different frequency channels for different interfaces. [0]", m_chan);
+  cmd.AddValue ("pcap",   "Enable PCAP traces on interfaces. [0]", m_pcap);
+  cmd.AddValue ("stack",  "Type of protocol stack. ns3::Dot11sStack by default", m_stack);
+  cmd.AddValue ("root", "Mac address of root mesh point in HWMP", m_root);
+  
+  cmd.Parse (argc, argv);
+  NS_LOG_DEBUG ("Grid:" << m_xSize << "*" << m_ySize);
+  NS_LOG_DEBUG ("Simulation time: " << m_totalTime << " s");
+}
+void
+MeshTest::CreateNodes ()
+{ 
+  /*
+   * Create m_ySize*m_xSize stations to form a grid topology
+   */
+  nodes.Create (m_ySize*m_xSize);
+  // Configure YansWifiChannel
+  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
+  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
+  wifiPhy.SetChannel (wifiChannel.Create ());
+  /*
+   * Create mesh helper and set stack installer to it
+   * Stack installer creates all needed protocols and install them to
+   * mesh point device
+   */
+  mesh = MeshHelper::Default ();
+  if (!Mac48Address (m_root.c_str ()).IsBroadcast ())
+    {
+      mesh.SetStackInstaller (m_stack, "Root", Mac48AddressValue (Mac48Address (m_root.c_str ())));
+    }
+  else
+    {
+      //If root is not set, we do not use "Root" attribute, because it
+      //is specified only for 11s
+      mesh.SetStackInstaller (m_stack);
+    }
+  if (m_chan)
+    {
+      mesh.SetSpreadInterfaceChannels (MeshHelper::SPREAD_CHANNELS);
+    }
+  else
+    {
+      mesh.SetSpreadInterfaceChannels (MeshHelper::ZERO_CHANNEL);
+    }
+  mesh.SetMacType ("RandomStart", TimeValue (Seconds(m_randomStart)));
+  // Set number of interfaces - default is single-interface mesh point
+  mesh.SetNumberOfInterfaces (m_nIfaces);
+  // Install protocols and return container if MeshPointDevices
+  meshDevices = mesh.Install (wifiPhy, nodes);
+  // Setup mobility - static grid topology
+  MobilityHelper mobility;
+  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
+                                 "MinX", DoubleValue (0.0),
+                                 "MinY", DoubleValue (0.0),
+                                 "DeltaX", DoubleValue (m_step),
+                                 "DeltaY", DoubleValue (m_step),
+                                 "GridWidth", UintegerValue (m_xSize),
+                                 "LayoutType", StringValue ("RowFirst"));
+  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
+  mobility.Install (nodes);
+  if (m_pcap)
+    wifiPhy.EnablePcapAll (std::string ("mp-"));
+}
+void
+MeshTest::InstallInternetStack ()
+{
+  InternetStackHelper internetStack;
+  internetStack.Install (nodes);
+  Ipv4AddressHelper address;
+  address.SetBase ("10.1.1.0", "255.255.255.0");
+  interfaces = address.Assign (meshDevices);
+}
+void
+MeshTest::InstallApplication ()
+{
+  UdpEchoServerHelper echoServer (9);
+  ApplicationContainer serverApps = echoServer.Install (nodes.Get (0));
+  serverApps.Start (Seconds (0.0));
+  serverApps.Stop (Seconds (m_totalTime));
+  UdpEchoClientHelper echoClient (interfaces.GetAddress (0), 9);
+  echoClient.SetAttribute ("MaxPackets", UintegerValue ((uint32_t)(m_totalTime*(1/m_packetInterval))));
+  echoClient.SetAttribute ("Interval", TimeValue (Seconds (m_packetInterval)));
+  echoClient.SetAttribute ("PacketSize", UintegerValue (m_packetSize));
+  ApplicationContainer clientApps = echoClient.Install (nodes.Get (m_xSize*m_ySize-1));
+  clientApps.Start (Seconds (0.0));
+  clientApps.Stop (Seconds (m_totalTime));
+}
+int
+MeshTest::Run ()
+{
+  CreateNodes ();
+  InstallInternetStack ();
+  InstallApplication ();
+  Simulator::Schedule (Seconds(m_totalTime), & MeshTest::Report, this);
+  Simulator::Stop (Seconds (m_totalTime));
+  Simulator::Run ();
+  Simulator::Destroy ();
+  return 0;
+}
+void
+MeshTest::Report ()
+{
+  unsigned n (0);
+  for (NetDeviceContainer::Iterator i = meshDevices.Begin (); i != meshDevices.End (); ++i, ++n)
+  {
+    std::ostringstream os;
+    os << "mp-report-" << n << ".xml";
+    std::cerr << "Printing mesh point device #" << n << " diagnostics to " << os.str () << "\n";
+    std::ofstream of;
+    of.open (os.str().c_str());
+    if (! of.is_open ())
+    {
+      std::cerr << "Error: Can't open file " << os.str() << "\n";
+      return;
+    }
+    mesh.Report (*i, of);
+    of.close ();
+  }
+}
+int
+main (int argc, char *argv[])
+{
+  MeshTest t; 
+  t.Configure (argc, argv);
+  return t.Run();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mesh/examples/waf	Fri Mar 04 19:14:23 2011 +0000
@@ -0,0 +1,1 @@
+exec "`dirname "$0"`"/../../waf "$@"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mesh/examples/wscript	Fri Mar 04 19:14:23 2011 +0000
@@ -0,0 +1,5 @@
+## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+def build(bld):
+    obj = bld.create_ns3_program('mesh', ['core', 'mobility', 'wifi', 'mesh'])
+    obj.source = 'mesh.cc'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mesh/helper/mesh-helper.cc	Fri Mar 04 19:14:23 2011 +0000
@@ -0,0 +1,211 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008,2009 IITP RAS
+ *
+ * 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: Kirill Andreev <andreev@iitp.ru>
+ *         Pavel Boyko <boyko@iitp.ru>
+ */
+#include "mesh-helper.h"
+#include "ns3/simulator.h"
+#include "ns3/mesh-point-device.h"
+#include "ns3/wifi-net-device.h"
+#include "ns3/mesh-wifi-interface-mac.h"
+namespace ns3
+{
+MeshHelper::MeshHelper () :
+  m_nInterfaces (1),
+  m_spreadChannelPolicy (ZERO_CHANNEL),
+  m_stack (0),
+  m_standard (WIFI_PHY_STANDARD_80211a)
+{
+}
+MeshHelper::~MeshHelper ()
+{
+  m_stack = 0;
+}
+void
+MeshHelper::SetSpreadInterfaceChannels (enum ChannelPolicy policy)
+{
+  m_spreadChannelPolicy = policy;
+}
+void
+MeshHelper::SetStackInstaller (std::string type,
+                std::string n0, const AttributeValue &v0,
+                std::string n1, const AttributeValue &v1,
+                std::string n2, const AttributeValue &v2,
+                std::string n3, const AttributeValue &v3,
+                std::string n4, const AttributeValue &v4,
+                std::string n5, const AttributeValue &v5,
+                std::string n6, const AttributeValue &v6,
+                std::string n7, const AttributeValue &v7)
+{
+  m_stackFactory.SetTypeId (type);
+  m_stackFactory.Set (n0, v0);
+  m_stackFactory.Set (n1, v1);
+  m_stackFactory.Set (n2, v2);
+  m_stackFactory.Set (n3, v3);
+  m_stackFactory.Set (n4, v4);
+  m_stackFactory.Set (n5, v5);
+  m_stackFactory.Set (n6, v6);
+  m_stackFactory.Set (n7, v7);
+
+  m_stack = m_stackFactory.Create<MeshStack> ();
+  if (m_stack == 0)
+    {
+      NS_FATAL_ERROR ("Stack has not been created: " << type);
+    }
+}
+
+void
+MeshHelper::SetNumberOfInterfaces (uint32_t nInterfaces)
+{
+  m_nInterfaces = nInterfaces;
+}
+NetDeviceContainer
+MeshHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c) const
+{
+  NetDeviceContainer devices;
+  NS_ASSERT (m_stack != 0);
+  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
+    {
+      Ptr<Node> node = *i;
+      // Create a mesh point device
+      Ptr<MeshPointDevice> mp = CreateObject<MeshPointDevice> ();
+      node->AddDevice (mp);
+      // Create wifi interfaces (single interface by default)
+      for (uint32_t i = 0; i < m_nInterfaces; ++i)
+        {
+          uint32_t channel = 0;
+          if (m_spreadChannelPolicy == ZERO_CHANNEL)
+            {
+              channel = 0;
+            }
+          if (m_spreadChannelPolicy == SPREAD_CHANNELS)
+            {
+              channel = i * 5;
+            }
+          Ptr<WifiNetDevice> iface = CreateInterface (phyHelper, node, channel);
+          mp->AddInterface (iface);
+        }
+      if (!m_stack->InstallStack (mp))
+        {
+          NS_FATAL_ERROR ("Stack is not installed!");
+        }
+      devices.Add (mp);
+    }
+  return devices;
+}
+MeshHelper
+MeshHelper::Default (void)
+{
+  MeshHelper helper;
+  helper.SetMacType ();
+  helper.SetRemoteStationManager ("ns3::ArfWifiManager");
+  helper.SetSpreadInterfaceChannels (SPREAD_CHANNELS);
+  return helper;
+}
+
+void
+MeshHelper::SetMacType (std::string n0, const AttributeValue &v0,
+                              std::string n1, const AttributeValue &v1,
+                              std::string n2, const AttributeValue &v2,
+                              std::string n3, const AttributeValue &v3,
+                              std::string n4, const AttributeValue &v4,
+                              std::string n5, const AttributeValue &v5,
+                              std::string n6, const AttributeValue &v6,
+                              std::string n7, const AttributeValue &v7)
+{
+  m_mac.SetTypeId ("ns3::MeshWifiInterfaceMac");
+  m_mac.Set (n0, v0);
+  m_mac.Set (n1, v1);
+  m_mac.Set (n2, v2);
+  m_mac.Set (n3, v3);
+  m_mac.Set (n4, v4);
+  m_mac.Set (n5, v5);
+  m_mac.Set (n6, v6);
+  m_mac.Set (n7, v7);
+}
+void
+MeshHelper::SetRemoteStationManager (std::string type,
+                                     std::string n0, const AttributeValue &v0,
+                                     std::string n1, const AttributeValue &v1,
+                                     std::string n2, const AttributeValue &v2,
+                                     std::string n3, const AttributeValue &v3,
+                                     std::string n4, const AttributeValue &v4,
+                                     std::string n5, const AttributeValue &v5,
+                                     std::string n6, const AttributeValue &v6,
+                                     std::string n7, const AttributeValue &v7)
+{
+  m_stationManager = ObjectFactory ();
+  m_stationManager.SetTypeId (type);
+  m_stationManager.Set (n0, v0);
+  m_stationManager.Set (n1, v1);
+  m_stationManager.Set (n2, v2);
+  m_stationManager.Set (n3, v3);
+  m_stationManager.Set (n4, v4);
+  m_stationManager.Set (n5, v5);
+  m_stationManager.Set (n6, v6);
+  m_stationManager.Set (n7, v7);
+}
+void 
+MeshHelper::SetStandard (enum WifiPhyStandard standard)
+{
+  m_standard = standard;
+}
+
+Ptr<WifiNetDevice>
+MeshHelper::CreateInterface (const WifiPhyHelper &phyHelper, Ptr<Node> node, uint16_t channelId) const
+{
+  Ptr<WifiNetDevice> device = CreateObject<WifiNetDevice> ();
+
+  Ptr<MeshWifiInterfaceMac> mac = m_mac.Create<MeshWifiInterfaceMac> ();
+  NS_ASSERT (mac != 0);
+  mac->SetSsid (Ssid ());
+  Ptr<WifiRemoteStationManager> manager = m_stationManager.Create<WifiRemoteStationManager> ();
+  NS_ASSERT (manager != 0);
+  Ptr<WifiPhy> phy = phyHelper.Create (node, device);
+  mac->SetAddress (Mac48Address::Allocate ());
+  mac->ConfigureStandard (m_standard);
+  phy->ConfigureStandard (m_standard);
+  device->SetMac (mac);
+  device->SetPhy (phy);
+  device->SetRemoteStationManager (manager);
+  node->AddDevice (device);
+  mac->SwitchFrequencyChannel (channelId);
+  return device;
+}
+void
+MeshHelper::Report (const ns3::Ptr<ns3::NetDevice>& device, std::ostream& os)
+{
+  NS_ASSERT (m_stack != 0);
+  Ptr<MeshPointDevice> mp = device->GetObject<MeshPointDevice> ();
+  NS_ASSERT (mp != 0);
+  std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
+  os << "<MeshPointDevice time=\"" << Simulator::Now ().GetSeconds () << "\" address=\""
+      << Mac48Address::ConvertFrom (mp->GetAddress ()) << "\">\n";
+  m_stack->Report (mp, os);
+  os << "</MeshPointDevice>\n";
+}
+void
+MeshHelper::ResetStats (const ns3::Ptr<ns3::NetDevice>& device)
+{
+  NS_ASSERT (m_stack != 0);
+  Ptr<MeshPointDevice> mp = device->GetObject<MeshPointDevice> ();
+  NS_ASSERT (mp != 0);
+  m_stack->ResetStats (mp);
+}
+} //namespace ns3
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mesh/helper/mesh-helper.h	Fri Mar 04 19:14:23 2011 +0000
@@ -0,0 +1,213 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008,2009 IITP RAS
+ *
+ * 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: Kirill Andreev <andreev@iitp.ru>
+ *         Pavel Boyko <boyko@iitp.ru>
+ */
+
+
+#ifndef MESH_HELPER_H
+#define MESH_HELPER_H
+
+#include "ns3/wifi-helper.h"
+#include "ns3/mesh-stack-installer.h"
+
+namespace ns3 {
+
+class WifiChannel;
+
+/** 
+ * \ingroup dot11s
+ * 
+ * \brief Helper to create IEEE 802.11s mesh networks
+ */
+class MeshHelper
+{
+public:
+  /**
+   * Construct a MeshHelper used to make life easier when creating 802.11s networks.
+   */
+  MeshHelper ();
+
+  /**
+   * Destroy a MeshHelper.
+   */
+  ~MeshHelper ();
+
+  /**
+   * \brief Set the helper to the default values for the MAC type,  remote
+   * station manager and channel policy.
+   */
+   static MeshHelper Default ();
+
+  /**
+   * \param n0 the name of the attribute to set
+   * \param v0 the value of the attribute to set
+   * \param n1 the name of the attribute to set
+   * \param v1 the value of the attribute to set
+   * \param n2 the name of the attribute to set
+   * \param v2 the value of the attribute to set
+   * \param n3 the name of the attribute to set
+   * \param v3 the value of the attribute to set
+   * \param n4 the name of the attribute to set
+   * \param v4 the value of the attribute to set
+   * \param n5 the name of the attribute to set
+   * \param v5 the value of the attribute to set
+   * \param n6 the name of the attribute to set
+   * \param v6 the value of the attribute to set
+   * \param n7 the name of the attribute to set
+   * \param v7 the value of the attribute to set
+   *
+   * All the attributes specified in this method should exist
+   * in the requested mac.
+   */
+  void SetMacType (std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
+        std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
+        std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
+        std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
+        std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
+        std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
+        std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
+        std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ());
+  /**
+   * \param type the type of ns3::WifiRemoteStationManager to create.
+   * \param n0 the name of the attribute to set
+   * \param v0 the value of the attribute to set
+   * \param n1 the name of the attribute to set
+   * \param v1 the value of the attribute to set
+   * \param n2 the name of the attribute to set
+   * \param v2 the value of the attribute to set
+   * \param n3 the name of the attribute to set
+   * \param v3 the value of the attribute to set
+   * \param n4 the name of the attribute to set
+   * \param v4 the value of the attribute to set
+   * \param n5 the name of the attribute to set
+   * \param v5 the value of the attribute to set
+   * \param n6 the name of the attribute to set
+   * \param v6 the value of the attribute to set
+   * \param n7 the name of the attribute to set
+   * \param v7 the value of the attribute to set
+   *
+   * All the attributes specified in this method should exist
+   * in the requested station manager.
+   */
+  void
+  SetRemoteStationManager (std::string type,
+      std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),    
+      std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
+      std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
+      std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
+      std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
+      std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
+      std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
+      std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ());
+  /**
+   * Set PHY standard
+   */
+  void SetStandard (enum WifiPhyStandard standard);
+  //void SetMeshId (std::string s); // XXX
+  /** 
+   *  \brief Spread/not spread frequency channels of MP interfaces. 
+   * 
+   *  If set to true different non-overlapping 20MHz frequency 
+   *  channels will be assigned to different mesh point interfaces.
+   */
+  enum ChannelPolicy
+  {
+    SPREAD_CHANNELS,
+    ZERO_CHANNEL
+  };
+
+  /**
+   * \brief set the channel policy
+   */
+  void SetSpreadInterfaceChannels (ChannelPolicy);
+  /**
+   * \brief Set a number of interfaces in a mesh network
+   * \param nInterfaces is the number of interfaces
+   */
+  void SetNumberOfInterfaces (uint32_t nInterfaces);
+  
+  /** 
+   * \brief Install 802.11s mesh device & protocols on given node list
+   * 
+   * \param phyHelper           Wifi PHY helper
+   * \param c               List of nodes to install
+   * 
+   * \return list of created mesh point devices, see MeshPointDevice
+   */
+  NetDeviceContainer
+  Install (const WifiPhyHelper &phyHelper, NodeContainer c) const;
+  /**
+   * \param type the type of ns3::MeshStack.
+   * \param n0 the name of the attribute to set
+   * \param v0 the value of the attribute to set
+   * \param n1 the name of the attribute to set
+   * \param v1 the value of the attribute to set
+   * \param n2 the name of the attribute to set
+   * \param v2 the value of the attribute to set
+   * \param n3 the name of the attribute to set
+   * \param v3 the value of the attribute to set
+   * \param n4 the name of the attribute to set
+   * \param v4 the value of the attribute to set
+   * \param n5 the name of the attribute to set
+   * \param v5 the value of the attribute to set
+   * \param n6 the name of the attribute to set
+   * \param v6 the value of the attribute to set
+   * \param n7 the name of the attribute to set
+   * \param v7 the value of the attribute to set
+   */
+  void SetStackInstaller (std::string type,
+                std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
+                std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
+                std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
+                std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
+                std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
+                std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
+                std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
+                std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ());
+
+  /**
+   * \brief Print statistics.
+   */
+  void Report (const ns3::Ptr<ns3::NetDevice>&, std::ostream&);
+
+  /**
+   * \brief Reset statistics.
+   */
+  void ResetStats (const ns3::Ptr<ns3::NetDevice>&);
+private:
+  /**
+   * \internal
+   * \returns a WifiNetDevice with ready-to-use interface
+   */
+  Ptr<WifiNetDevice> CreateInterface (const WifiPhyHelper &phyHelper, Ptr<Node> node, uint16_t channelId) const;
+  uint32_t m_nInterfaces;
+  ChannelPolicy m_spreadChannelPolicy;
+  Ptr<MeshStack> m_stack;
+  ObjectFactory m_stackFactory;
+  ///\name Interface factory
+  ///\{
+  ObjectFactory m_mac;
+  ObjectFactory m_stationManager;
+  enum WifiPhyStandard m_standard;
+    ///\}
+};
+} //namespace ns3
+
+#endif /* MESH_HELPER_H */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mesh/helper/mesh-stack-installer.h	Fri Mar 04 19:14:23 2011 +0000
@@ -0,0 +1,46 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008,2009 IITP RAS
+ *
+ * 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: Kirill Andreev <andreev@iitp.ru>
+ */
+
+
+#ifndef MESH_STACK_INSTALLER_H
+#define MESH_STACK_INSTALLER_H
+#include "ns3/mesh-point-device.h"
+namespace ns3 {
+/**
+ * \ingroup mesh
+ *
+ * \brief Prototype for class, which helps to install MAC-layer
+ * routing stack to ns3::MeshPointDevice
+ * \details You need to create a  MeshPointDevice and attach all
+ * interfaces to it, than call Install method
+ */
+class MeshStack : public Object
+{
+  public:
+    ///\brief Installs mesh stack. needed by helper only
+    virtual bool InstallStack (Ptr<MeshPointDevice> mp) = 0;
+    /// Report statistics of a given mesh point
+    virtual void Report (const Ptr<MeshPointDevice> mp, std::ostream&) = 0;
+    /// Reset statistics of a given mesh point
+    virtual void ResetStats (const Ptr<MeshPointDevice> mp) = 0;
+};
+}
+#endif
+
--- a/src/mesh/wscript	Fri Mar 04 10:56:07 2011 -0800
+++ b/src/mesh/wscript	Fri Mar 04 19:14:23 2011 +0000
@@ -9,6 +9,7 @@
         'model/mesh-l2-routing-protocol.cc',
         'model/mesh-wifi-beacon.cc',
         'model/mesh-wifi-interface-mac.cc',
+        'helper/mesh-helper.cc',
         ]
     headers = bld.new_task_gen('ns3header')
     headers.module = 'mesh'
@@ -20,4 +21,9 @@
         'model/mesh-wifi-beacon.h',
         'model/mesh-wifi-interface-mac.h',
         'model/mesh-wifi-interface-mac-plugin.h',
+        'helper/mesh-helper.h',
+        'helper/mesh-stack-installer.h',
         ]
+
+    if bld.env['ENABLE_EXAMPLES']:
+        bld.add_subdirs('examples')
--- a/test.py	Fri Mar 04 10:56:07 2011 -0800
+++ b/test.py	Fri Mar 04 19:14:23 2011 +0000
@@ -114,7 +114,7 @@
     ("examples/ipv6/radvd-two-prefix", "True", "True"),    
     ("examples/ipv6/test-ipv6", "True", "True"),
 
-    ("examples/mesh/mesh", "True", "True"),
+    ("src/mesh/examples/mesh", "True", "True"),
 
     ("examples/naming/object-names", "True", "True"),