Mesh: added regression tests: peer management, reactive and proactive HWMP
authorKirill Andreev <andreev@iitp.ru>
Mon, 30 Nov 2009 19:25:04 +0300
changeset 5818 57d0c9adbf8f
parent 5817 87aaf687f869
child 5819 514ec98954ab
Mesh: added regression tests: peer management, reactive and proactive HWMP
src/devices/mesh/dot11s/dot11s-test-suite.cc
src/devices/mesh/dot11s/hwmp-protocol.cc
src/devices/mesh/dot11s/test/dot11s-test-suite.cc
src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-0-1.pcap
src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-1-1.pcap
src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-2-1.pcap
src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-3-1.pcap
src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-4-1.pcap
src/devices/mesh/dot11s/test/hwmp-proactive-regression.cc
src/devices/mesh/dot11s/test/hwmp-proactive-regression.h
src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-0-1.pcap
src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-1-1.pcap
src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-2-1.pcap
src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-3-1.pcap
src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-4-1.pcap
src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-5-1.pcap
src/devices/mesh/dot11s/test/hwmp-reactive-regression.cc
src/devices/mesh/dot11s/test/hwmp-reactive-regression.h
src/devices/mesh/dot11s/test/hwmp-simplest-regression-test-0-1.pcap
src/devices/mesh/dot11s/test/hwmp-simplest-regression-test-1-1.pcap
src/devices/mesh/dot11s/test/hwmp-simplest-regression.cc
src/devices/mesh/dot11s/test/hwmp-simplest-regression.h
src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-0-1.pcap
src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-1-1.pcap
src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-2-1.pcap
src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-3-1.pcap
src/devices/mesh/dot11s/test/hwmp-target-flags-regression.cc
src/devices/mesh/dot11s/test/hwmp-target-flags-regression.h
src/devices/mesh/dot11s/test/pmp-regression-test-0-1.pcap
src/devices/mesh/dot11s/test/pmp-regression-test-1-1.pcap
src/devices/mesh/dot11s/test/pmp-regression.cc
src/devices/mesh/dot11s/test/pmp-regression.h
src/devices/mesh/dot11s/test/regression.cc
src/devices/mesh/dot11s/wscript
--- a/src/devices/mesh/dot11s/dot11s-test-suite.cc	Mon Nov 30 17:37:32 2009 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,292 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 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: Pavel Boyko <boyko@iitp.ru>
- */
-#include "ns3/test.h"
-#include "ns3/packet.h"
-#include "ns3/simulator.h"
-#include "dot11s-mac-header.h"
-#include "hwmp-rtable.h"
-#include "peer-link-frame.h"
-#include "ie-dot11s-peer-management.h"
-
-namespace ns3 {
-namespace dot11s {
-
-/// Built-in self test for FlameHeader
-struct MeshHeaderTest : public TestCase
-{
-  MeshHeaderTest () :
-    TestCase ("Dot11sMeshHeader roundtrip serialization")
-  {
-  }
-  bool DoRun ();
-};
-
-bool
-MeshHeaderTest::DoRun ()
-{
-  {
-    MeshHeader a;
-    a.SetAddressExt (3);
-    a.SetAddr4 (Mac48Address ("11:22:33:44:55:66"));
-    a.SetAddr5 (Mac48Address ("11:00:33:00:55:00"));
-    a.SetAddr6 (Mac48Address ("00:22:00:44:00:66"));
-    a.SetMeshTtl (122);
-    a.SetMeshSeqno (321);
-    Ptr<Packet> packet = Create<Packet> ();
-    packet->AddHeader (a);
-    MeshHeader b;
-    packet->RemoveHeader (b);
-    NS_TEST_ASSERT_MSG_EQ (a, b, "Mesh header roundtrip serialization works, 3 addresses");
-  }
-  {
-    MeshHeader a;
-    a.SetAddressExt (2);
-    a.SetAddr5 (Mac48Address ("11:00:33:00:55:00"));
-    a.SetAddr6 (Mac48Address ("00:22:00:44:00:66"));
-    a.SetMeshTtl (122);
-    a.SetMeshSeqno (321);
-    Ptr<Packet> packet = Create<Packet> ();
-    packet->AddHeader (a);
-    MeshHeader b;
-    packet->RemoveHeader (b);
-    NS_TEST_ASSERT_MSG_EQ (a, b, "Mesh header roundtrip serialization works, 2 addresses");
-  }
-  {
-    MeshHeader a;
-    a.SetAddressExt (1);
-    a.SetAddr4 (Mac48Address ("11:22:33:44:55:66"));
-    a.SetMeshTtl (122);
-    a.SetMeshSeqno (321);
-    Ptr<Packet> packet = Create<Packet> ();
-    packet->AddHeader (a);
-    MeshHeader b;
-    packet->RemoveHeader (b);
-    NS_TEST_ASSERT_MSG_EQ (a, b, "Mesh header roundtrip serialization works, 1 address");
-  }
-  return false;
-}
-//-----------------------------------------------------------------------------
-/// Unit test for HwmpRtable
-class HwmpRtableTest : public TestCase
-{
-public:
-  HwmpRtableTest ();
-  virtual bool DoRun ();
-
-private:
-  /// Test Add apth and lookup path;
-  void TestLookup ();
-  /**
-   * \name Test add path and try to lookup after entry has expired
-   * \{
-   */
-  void TestAddPath ();
-  void TestExpire ();
-  ///\}
-  /**
-   * \name Test add precursors and find precursor list in rtable
-   * \{
-   */
-  void TestPrecursorAdd ();
-  void TestPrecursorFind ();
-  ///\}
-private:
-  Mac48Address dst;
-  Mac48Address hop;
-  uint32_t iface;
-  uint32_t metric;
-  uint32_t seqnum;
-  Time expire;
-  Ptr<HwmpRtable> table;
-  std::vector<Mac48Address> precursors;
-};
-
-HwmpRtableTest::HwmpRtableTest () :
-  TestCase ("HWMP routing table"), 
-  dst ("01:00:00:01:00:01"), 
-  hop ("01:00:00:01:00:03"),
-  iface (8010), 
-  metric (10), 
-  seqnum (1), 
-  expire (Seconds (10))
-{
-  precursors.push_back (Mac48Address ("00:10:20:30:40:50"));
-  precursors.push_back (Mac48Address ("00:11:22:33:44:55"));
-  precursors.push_back (Mac48Address ("00:01:02:03:04:05"));
-}
-
-void
-HwmpRtableTest::TestLookup ()
-{
-  HwmpRtable::LookupResult correct (hop, iface, metric, seqnum);
-
-  // Reactive path
-  table->AddReactivePath (dst, hop, iface, metric, expire, seqnum);
-  NS_TEST_EXPECT_MSG_EQ ((table->LookupReactive (dst) == correct), true, "Reactive lookup works");
-  table->DeleteReactivePath (dst);
-  NS_TEST_EXPECT_MSG_EQ (table->LookupReactive (dst).IsValid (), false, "Reactive lookup works");
-
-  // Proactive
-  table->AddProactivePath (metric, dst, hop, iface, expire, seqnum);
-  NS_TEST_EXPECT_MSG_EQ ((table->LookupProactive () == correct), true, "Proactive lookup works");
-  table->DeleteProactivePath (dst);
-  NS_TEST_EXPECT_MSG_EQ (table->LookupProactive ().IsValid (), false, "Proactive lookup works");
-}
-
-void
-HwmpRtableTest::TestAddPath ()
-{
-  table->AddReactivePath (dst, hop, iface, metric, expire, seqnum);
-  table->AddProactivePath (metric, dst, hop, iface, expire, seqnum);
-}
-
-void
-HwmpRtableTest::TestExpire ()
-{
-  // this is assumed to be called when path records are already expired
-  HwmpRtable::LookupResult correct (hop, iface, metric, seqnum);
-  NS_TEST_EXPECT_MSG_EQ ((table->LookupReactiveExpired (dst) == correct), true, "Reactive expiration works");
-  NS_TEST_EXPECT_MSG_EQ ((table->LookupProactiveExpired () == correct), true, "Proactive expiration works");
-
-  NS_TEST_EXPECT_MSG_EQ (table->LookupReactive (dst).IsValid (), false, "Reactive expiration works");
-  NS_TEST_EXPECT_MSG_EQ (table->LookupProactive ().IsValid (), false, "Proactive expiration works");
-}
-
-void
-HwmpRtableTest::TestPrecursorAdd ()
-{
-  for (std::vector<Mac48Address>::const_iterator i = precursors.begin (); i != precursors.end (); i++)
-    {
-      table->AddPrecursor (dst, iface, *i, Seconds (100));
-      // Check that duplicates are filtered
-      table->AddPrecursor (dst, iface, *i, Seconds (100));
-    }
-}
-
-void
-HwmpRtableTest::TestPrecursorFind ()
-{
-  HwmpRtable::PrecursorList precursorList = table->GetPrecursors (dst);
-  NS_TEST_EXPECT_MSG_EQ (precursors.size (), precursorList.size (), "Precursors size works");
-  for (unsigned i = 0; i < precursors.size (); i++)
-    {
-      NS_TEST_EXPECT_MSG_EQ (precursorList[i].first, iface, "Precursors lookup works");
-      NS_TEST_EXPECT_MSG_EQ (precursorList[i].second, precursors[i], "Precursors lookup works");
-    }
-}
-
-bool
-HwmpRtableTest::DoRun ()
-{
-  table = CreateObject<HwmpRtable> ();
-
-  Simulator::Schedule (Seconds (0), &HwmpRtableTest::TestLookup, this);
-  Simulator::Schedule (Seconds (1), &HwmpRtableTest::TestAddPath, this);
-  Simulator::Schedule (Seconds (2), &HwmpRtableTest::TestPrecursorAdd, this);
-  Simulator::Schedule (expire + Seconds (2), &HwmpRtableTest::TestExpire, this);
-  Simulator::Schedule (expire + Seconds (3), &HwmpRtableTest::TestPrecursorFind, this);
-
-  Simulator::Run ();
-  Simulator::Destroy ();
-
-  return GetErrorStatus ();
-}
-//-----------------------------------------------------------------------------
-/// Built-in self test for PeerLinkFrameStart
-struct PeerLinkFrameStartTest : public TestCase
-{
-  PeerLinkFrameStartTest () :
-    TestCase ("PeerLinkFrames (open, confirm, close) unit tests")
-  {
-  }
-  virtual bool DoRun ();
-};
-
-bool
-PeerLinkFrameStartTest::DoRun ()
-{
-  {
-    PeerLinkFrameStart a;
-    PeerLinkFrameStart::PlinkFrameStartFields fields;
-    fields.subtype = (uint8_t) (WifiMeshActionHeader::PEER_LINK_OPEN);
-    fields.capability = 0;
-    fields.aid = 101;
-    fields.reasonCode = 12;
-    fields.meshId = IeMeshId ("qwertyuiop");
-    a.SetPlinkFrameStart (fields);
-    Ptr<Packet> packet = Create<Packet> ();
-    packet->AddHeader (a);
-    PeerLinkFrameStart b;
-    b.SetPlinkFrameSubtype ((uint8_t) (WifiMeshActionHeader::PEER_LINK_OPEN));
-    packet->RemoveHeader (b);
-    NS_TEST_EXPECT_MSG_EQ (a, b, "PEER_LINK_OPEN works");
-  }
-  {
-    PeerLinkFrameStart a;
-    PeerLinkFrameStart::PlinkFrameStartFields fields;
-    fields.subtype = (uint8_t) (WifiMeshActionHeader::PEER_LINK_CONFIRM);
-    fields.capability = 0;
-    fields.aid = 1234;
-    fields.reasonCode = 12;
-    fields.meshId = IeMeshId ("qwerty");
-    a.SetPlinkFrameStart (fields);
-    Ptr<Packet> packet = Create<Packet> ();
-    packet->AddHeader (a);
-    PeerLinkFrameStart b;
-    b.SetPlinkFrameSubtype ((uint8_t) (WifiMeshActionHeader::PEER_LINK_CONFIRM));
-    packet->RemoveHeader (b);
-    NS_TEST_EXPECT_MSG_EQ (a, b, "PEER_LINK_CONFIRM works");
-  }
-  {
-    PeerLinkFrameStart a;
-    PeerLinkFrameStart::PlinkFrameStartFields fields;
-    fields.subtype = (uint8_t) (WifiMeshActionHeader::PEER_LINK_CLOSE);
-    fields.capability = 0;
-    fields.aid = 10;
-    fields.meshId = IeMeshId ("qqq");
-    fields.reasonCode = 12;
-    a.SetPlinkFrameStart (fields);
-    Ptr<Packet> packet = Create<Packet> ();
-    packet->AddHeader (a);
-    PeerLinkFrameStart b;
-    b.SetPlinkFrameSubtype ((uint8_t) (WifiMeshActionHeader::PEER_LINK_CLOSE));
-    packet->RemoveHeader (b);
-    NS_TEST_EXPECT_MSG_EQ (a, b, "PEER_LINK_CLOSE works");
-  }
-  return GetErrorStatus ();
-}
-//-----------------------------------------------------------------------------
-class Dot11sTestSuite : public TestSuite
-{
-public:
-  Dot11sTestSuite ();
-};
-
-Dot11sTestSuite::Dot11sTestSuite ()
-  : TestSuite ("devices-mesh-dot11s", UNIT)
-{
-  AddTestCase (new MeshHeaderTest);
-  AddTestCase (new HwmpRtableTest);
-  AddTestCase (new PeerLinkFrameStartTest);
-}
-
-Dot11sTestSuite g_dot11sTestSuite;
-}
-}
--- a/src/devices/mesh/dot11s/hwmp-protocol.cc	Mon Nov 30 17:37:32 2009 +0300
+++ b/src/devices/mesh/dot11s/hwmp-protocol.cc	Mon Nov 30 19:25:04 2009 +0300
@@ -985,8 +985,7 @@
       m_preqTimeouts.erase (i);
       return;
     }
-  numOfRetry++;
-  if (numOfRetry >= m_dot11MeshHWMPmaxPREQretries)
+  if (numOfRetry > m_dot11MeshHWMPmaxPREQretries)
     {
       QueuedPacket packet = DequeueFirstPacketByDst (dst);
       //purge queue and delete entry from retryDatabase
@@ -1002,6 +1001,7 @@
       m_preqTimeouts.erase (i);
       return;
     }
+  numOfRetry++;
   uint32_t originator_seqno = GetNextHwmpSeqno ();
   uint32_t dst_seqno = m_rtable->LookupReactiveExpired (dst).seqnum;
   for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/mesh/dot11s/test/dot11s-test-suite.cc	Mon Nov 30 19:25:04 2009 +0300
@@ -0,0 +1,292 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 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: Pavel Boyko <boyko@iitp.ru>
+ */
+#include "ns3/test.h"
+#include "ns3/packet.h"
+#include "ns3/simulator.h"
+#include "../dot11s-mac-header.h"
+#include "../hwmp-rtable.h"
+#include "../peer-link-frame.h"
+#include "../ie-dot11s-peer-management.h"
+
+namespace ns3 {
+namespace dot11s {
+
+/// Built-in self test for FlameHeader
+struct MeshHeaderTest : public TestCase
+{
+  MeshHeaderTest () :
+    TestCase ("Dot11sMeshHeader roundtrip serialization")
+  {
+  }
+  bool DoRun ();
+};
+
+bool
+MeshHeaderTest::DoRun ()
+{
+  {
+    MeshHeader a;
+    a.SetAddressExt (3);
+    a.SetAddr4 (Mac48Address ("11:22:33:44:55:66"));
+    a.SetAddr5 (Mac48Address ("11:00:33:00:55:00"));
+    a.SetAddr6 (Mac48Address ("00:22:00:44:00:66"));
+    a.SetMeshTtl (122);
+    a.SetMeshSeqno (321);
+    Ptr<Packet> packet = Create<Packet> ();
+    packet->AddHeader (a);
+    MeshHeader b;
+    packet->RemoveHeader (b);
+    NS_TEST_ASSERT_MSG_EQ (a, b, "Mesh header roundtrip serialization works, 3 addresses");
+  }
+  {
+    MeshHeader a;
+    a.SetAddressExt (2);
+    a.SetAddr5 (Mac48Address ("11:00:33:00:55:00"));
+    a.SetAddr6 (Mac48Address ("00:22:00:44:00:66"));
+    a.SetMeshTtl (122);
+    a.SetMeshSeqno (321);
+    Ptr<Packet> packet = Create<Packet> ();
+    packet->AddHeader (a);
+    MeshHeader b;
+    packet->RemoveHeader (b);
+    NS_TEST_ASSERT_MSG_EQ (a, b, "Mesh header roundtrip serialization works, 2 addresses");
+  }
+  {
+    MeshHeader a;
+    a.SetAddressExt (1);
+    a.SetAddr4 (Mac48Address ("11:22:33:44:55:66"));
+    a.SetMeshTtl (122);
+    a.SetMeshSeqno (321);
+    Ptr<Packet> packet = Create<Packet> ();
+    packet->AddHeader (a);
+    MeshHeader b;
+    packet->RemoveHeader (b);
+    NS_TEST_ASSERT_MSG_EQ (a, b, "Mesh header roundtrip serialization works, 1 address");
+  }
+  return false;
+}
+//-----------------------------------------------------------------------------
+/// Unit test for HwmpRtable
+class HwmpRtableTest : public TestCase
+{
+public:
+  HwmpRtableTest ();
+  virtual bool DoRun ();
+
+private:
+  /// Test Add apth and lookup path;
+  void TestLookup ();
+  /**
+   * \name Test add path and try to lookup after entry has expired
+   * \{
+   */
+  void TestAddPath ();
+  void TestExpire ();
+  ///\}
+  /**
+   * \name Test add precursors and find precursor list in rtable
+   * \{
+   */
+  void TestPrecursorAdd ();
+  void TestPrecursorFind ();
+  ///\}
+private:
+  Mac48Address dst;
+  Mac48Address hop;
+  uint32_t iface;
+  uint32_t metric;
+  uint32_t seqnum;
+  Time expire;
+  Ptr<HwmpRtable> table;
+  std::vector<Mac48Address> precursors;
+};
+
+HwmpRtableTest::HwmpRtableTest () :
+  TestCase ("HWMP routing table"), 
+  dst ("01:00:00:01:00:01"), 
+  hop ("01:00:00:01:00:03"),
+  iface (8010), 
+  metric (10), 
+  seqnum (1), 
+  expire (Seconds (10))
+{
+  precursors.push_back (Mac48Address ("00:10:20:30:40:50"));
+  precursors.push_back (Mac48Address ("00:11:22:33:44:55"));
+  precursors.push_back (Mac48Address ("00:01:02:03:04:05"));
+}
+
+void
+HwmpRtableTest::TestLookup ()
+{
+  HwmpRtable::LookupResult correct (hop, iface, metric, seqnum);
+
+  // Reactive path
+  table->AddReactivePath (dst, hop, iface, metric, expire, seqnum);
+  NS_TEST_EXPECT_MSG_EQ ((table->LookupReactive (dst) == correct), true, "Reactive lookup works");
+  table->DeleteReactivePath (dst);
+  NS_TEST_EXPECT_MSG_EQ (table->LookupReactive (dst).IsValid (), false, "Reactive lookup works");
+
+  // Proactive
+  table->AddProactivePath (metric, dst, hop, iface, expire, seqnum);
+  NS_TEST_EXPECT_MSG_EQ ((table->LookupProactive () == correct), true, "Proactive lookup works");
+  table->DeleteProactivePath (dst);
+  NS_TEST_EXPECT_MSG_EQ (table->LookupProactive ().IsValid (), false, "Proactive lookup works");
+}
+
+void
+HwmpRtableTest::TestAddPath ()
+{
+  table->AddReactivePath (dst, hop, iface, metric, expire, seqnum);
+  table->AddProactivePath (metric, dst, hop, iface, expire, seqnum);
+}
+
+void
+HwmpRtableTest::TestExpire ()
+{
+  // this is assumed to be called when path records are already expired
+  HwmpRtable::LookupResult correct (hop, iface, metric, seqnum);
+  NS_TEST_EXPECT_MSG_EQ ((table->LookupReactiveExpired (dst) == correct), true, "Reactive expiration works");
+  NS_TEST_EXPECT_MSG_EQ ((table->LookupProactiveExpired () == correct), true, "Proactive expiration works");
+
+  NS_TEST_EXPECT_MSG_EQ (table->LookupReactive (dst).IsValid (), false, "Reactive expiration works");
+  NS_TEST_EXPECT_MSG_EQ (table->LookupProactive ().IsValid (), false, "Proactive expiration works");
+}
+
+void
+HwmpRtableTest::TestPrecursorAdd ()
+{
+  for (std::vector<Mac48Address>::const_iterator i = precursors.begin (); i != precursors.end (); i++)
+    {
+      table->AddPrecursor (dst, iface, *i, Seconds (100));
+      // Check that duplicates are filtered
+      table->AddPrecursor (dst, iface, *i, Seconds (100));
+    }
+}
+
+void
+HwmpRtableTest::TestPrecursorFind ()
+{
+  HwmpRtable::PrecursorList precursorList = table->GetPrecursors (dst);
+  NS_TEST_EXPECT_MSG_EQ (precursors.size (), precursorList.size (), "Precursors size works");
+  for (unsigned i = 0; i < precursors.size (); i++)
+    {
+      NS_TEST_EXPECT_MSG_EQ (precursorList[i].first, iface, "Precursors lookup works");
+      NS_TEST_EXPECT_MSG_EQ (precursorList[i].second, precursors[i], "Precursors lookup works");
+    }
+}
+
+bool
+HwmpRtableTest::DoRun ()
+{
+  table = CreateObject<HwmpRtable> ();
+
+  Simulator::Schedule (Seconds (0), &HwmpRtableTest::TestLookup, this);
+  Simulator::Schedule (Seconds (1), &HwmpRtableTest::TestAddPath, this);
+  Simulator::Schedule (Seconds (2), &HwmpRtableTest::TestPrecursorAdd, this);
+  Simulator::Schedule (expire + Seconds (2), &HwmpRtableTest::TestExpire, this);
+  Simulator::Schedule (expire + Seconds (3), &HwmpRtableTest::TestPrecursorFind, this);
+
+  Simulator::Run ();
+  Simulator::Destroy ();
+
+  return GetErrorStatus ();
+}
+//-----------------------------------------------------------------------------
+/// Built-in self test for PeerLinkFrameStart
+struct PeerLinkFrameStartTest : public TestCase
+{
+  PeerLinkFrameStartTest () :
+    TestCase ("PeerLinkFrames (open, confirm, close) unit tests")
+  {
+  }
+  virtual bool DoRun ();
+};
+
+bool
+PeerLinkFrameStartTest::DoRun ()
+{
+  {
+    PeerLinkFrameStart a;
+    PeerLinkFrameStart::PlinkFrameStartFields fields;
+    fields.subtype = (uint8_t) (WifiMeshActionHeader::PEER_LINK_OPEN);
+    fields.capability = 0;
+    fields.aid = 101;
+    fields.reasonCode = 12;
+    fields.meshId = IeMeshId ("qwertyuiop");
+    a.SetPlinkFrameStart (fields);
+    Ptr<Packet> packet = Create<Packet> ();
+    packet->AddHeader (a);
+    PeerLinkFrameStart b;
+    b.SetPlinkFrameSubtype ((uint8_t) (WifiMeshActionHeader::PEER_LINK_OPEN));
+    packet->RemoveHeader (b);
+    NS_TEST_EXPECT_MSG_EQ (a, b, "PEER_LINK_OPEN works");
+  }
+  {
+    PeerLinkFrameStart a;
+    PeerLinkFrameStart::PlinkFrameStartFields fields;
+    fields.subtype = (uint8_t) (WifiMeshActionHeader::PEER_LINK_CONFIRM);
+    fields.capability = 0;
+    fields.aid = 1234;
+    fields.reasonCode = 12;
+    fields.meshId = IeMeshId ("qwerty");
+    a.SetPlinkFrameStart (fields);
+    Ptr<Packet> packet = Create<Packet> ();
+    packet->AddHeader (a);
+    PeerLinkFrameStart b;
+    b.SetPlinkFrameSubtype ((uint8_t) (WifiMeshActionHeader::PEER_LINK_CONFIRM));
+    packet->RemoveHeader (b);
+    NS_TEST_EXPECT_MSG_EQ (a, b, "PEER_LINK_CONFIRM works");
+  }
+  {
+    PeerLinkFrameStart a;
+    PeerLinkFrameStart::PlinkFrameStartFields fields;
+    fields.subtype = (uint8_t) (WifiMeshActionHeader::PEER_LINK_CLOSE);
+    fields.capability = 0;
+    fields.aid = 10;
+    fields.meshId = IeMeshId ("qqq");
+    fields.reasonCode = 12;
+    a.SetPlinkFrameStart (fields);
+    Ptr<Packet> packet = Create<Packet> ();
+    packet->AddHeader (a);
+    PeerLinkFrameStart b;
+    b.SetPlinkFrameSubtype ((uint8_t) (WifiMeshActionHeader::PEER_LINK_CLOSE));
+    packet->RemoveHeader (b);
+    NS_TEST_EXPECT_MSG_EQ (a, b, "PEER_LINK_CLOSE works");
+  }
+  return GetErrorStatus ();
+}
+//-----------------------------------------------------------------------------
+class Dot11sTestSuite : public TestSuite
+{
+public:
+  Dot11sTestSuite ();
+};
+
+Dot11sTestSuite::Dot11sTestSuite ()
+  : TestSuite ("devices-mesh-dot11s", UNIT)
+{
+  AddTestCase (new MeshHeaderTest);
+  AddTestCase (new HwmpRtableTest);
+  AddTestCase (new PeerLinkFrameStartTest);
+}
+
+Dot11sTestSuite g_dot11sTestSuite;
+}
+}
Binary file src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-0-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-1-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-2-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-3-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-4-1.pcap has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/mesh/dot11s/test/hwmp-proactive-regression.cc	Mon Nov 30 19:25:04 2009 +0300
@@ -0,0 +1,144 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 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/mesh-helper.h"
+#include "ns3/simulator.h"
+#include "ns3/random-variable.h"
+#include "ns3/mobility-helper.h"
+#include "ns3/double.h"
+#include "ns3/uinteger.h"
+#include "ns3/string.h"
+#include "ns3/yans-wifi-helper.h"
+#include "ns3/internet-stack-helper.h"
+#include "ns3/ipv4-interface-container.h"
+#include "ns3/ipv4-address-helper.h"
+#include "ns3/abort.h"
+#include "ns3/udp-echo-helper.h"
+#include "ns3/mobility-model.h"
+#include <sstream>
+#include "hwmp-proactive-regression.h"
+
+using namespace ns3;
+
+/// Set to true to rewrite reference traces, leave false to run regression test
+const bool WRITE_VECTORS = false;
+/// Unique PCAP file name prefix
+const char * const PREFIX = "hwmp-proactive-regression-test";
+
+
+HwmpProactiveRegressionTest::HwmpProactiveRegressionTest () : TestCase ("HWMP proactive regression test"),
+  m_nodes (0),
+  m_time (Seconds (5))
+{
+}
+
+HwmpProactiveRegressionTest::~HwmpProactiveRegressionTest ()
+{
+  delete m_nodes;
+}
+bool
+HwmpProactiveRegressionTest::DoRun ()
+{
+  SeedManager::SetSeed(12345);
+  CreateNodes ();
+  CreateDevices ();
+  InstallApplications ();
+
+  Simulator::Stop (m_time);
+  Simulator::Run ();
+  Simulator::Destroy ();
+  
+  if (!WRITE_VECTORS) CheckResults ();
+
+  delete m_nodes, m_nodes = 0;
+  return false;
+}
+void
+HwmpProactiveRegressionTest::CreateNodes ()
+{
+  m_nodes = new NodeContainer;
+  m_nodes->Create (5);
+  MobilityHelper mobility;
+  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
+                                "MinX", DoubleValue (0.0),
+                                "MinY", DoubleValue (0.0),
+                                "DeltaX", DoubleValue (100),
+                                "DeltaY", DoubleValue (0),
+                                "GridWidth", UintegerValue (5),
+                                "LayoutType", StringValue ("RowFirst"));
+  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
+  mobility.Install (*m_nodes);
+}
+void
+HwmpProactiveRegressionTest::InstallApplications ()
+{
+  UdpEchoServerHelper echoServer (9);
+  ApplicationContainer serverApps = echoServer.Install (m_nodes->Get (0));
+  serverApps.Start (Seconds (0.0));
+  serverApps.Stop (m_time);
+  UdpEchoClientHelper echoClient (m_interfaces.GetAddress (0), 9);
+  echoClient.SetAttribute ("MaxPackets", UintegerValue (300));
+  echoClient.SetAttribute ("Interval", TimeValue (Seconds(0.5)));
+  echoClient.SetAttribute ("PacketSize", UintegerValue (100));
+  ApplicationContainer clientApps = echoClient.Install (m_nodes->Get (4));
+  clientApps.Start (Seconds (2.5));
+  clientApps.Stop (m_time);
+}
+void
+HwmpProactiveRegressionTest::CreateDevices ()
+{
+  // 1. setup WiFi
+  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
+  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
+  wifiPhy.SetChannel (wifiChannel.Create ());
+  // 2. setup mesh
+  MeshHelper mesh = MeshHelper::Default ();
+  mesh.SetStackInstaller ("ns3::Dot11sStack", "Root", Mac48AddressValue (Mac48Address ("00:00:00:00:00:0d")));
+  mesh.SetMacType ("RandomStart", TimeValue (Seconds(0.1)));
+  mesh.SetNumberOfInterfaces (1);
+  NetDeviceContainer meshDevices = mesh.Install (wifiPhy, *m_nodes);  
+  // 3. setup TCP/IP
+  InternetStackHelper internetStack;
+  internetStack.Install (*m_nodes);
+  Ipv4AddressHelper address;
+  address.SetBase ("10.1.1.0", "255.255.255.0");
+  m_interfaces = address.Assign (meshDevices);
+  // 4. write PCAP if needed
+  std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : std::string(GetTempDir ())) + PREFIX;
+  wifiPhy.EnablePcapAll (prefix);
+}
+  
+void
+HwmpProactiveRegressionTest::CheckResults ()
+{
+  for (int i = 0; i < 5; ++i)
+    {
+      std::ostringstream os1, os2;
+      // File naming conventions are hard-coded here.
+      os1 << NS_TEST_SOURCEDIR << PREFIX << "-" << i << "-1.pcap";
+      os2 << GetTempDir () << PREFIX << "-" << i << "-1.pcap";
+      
+      uint32_t sec(0), usec(0);
+      bool diff = PcapFile::Diff (os1.str(), os2.str(), sec, usec); // TODO support default PcapWriter snap length here
+      NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str() << " and " << os2.str() 
+                                       << " differ starting from " << sec << " s " << usec << " us");
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/mesh/dot11s/test/hwmp-proactive-regression.h	Mon Nov 30 19:25:04 2009 +0300
@@ -0,0 +1,78 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 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/test.h"
+#include "ns3/node-container.h"
+#include "ns3/nstime.h"
+#include "ns3/ipv4-interface-container.h"
+#include "ns3/pcap-file.h"
+
+using namespace ns3;
+
+/**
+ * \ingroup dot11s
+ * \brief There are 5 stations set into a column, the center station is root.
+ * Regression test indicates, that traffic goes from the first to the
+ * last stations without reactive route discovery procedure
+ * \verbatim
+ * Src                Root                 Dst
+ *           |         |<--------|-------->|         |          Proactive PREQ
+ *           |         |-------->|         |         |          PREP
+ *           |         |         |<--------|         |          PREP
+ *           |<--------|-------->|<--------|-------->|          Proactive PREQ
+ *           |-------->|         |         |<--------|          PREP
+ *           |         |-------->|         |         |          PREP
+ *           |         |         |<--------|         |          PREP
+ *  <--------|-------->|         |         |<--------|--------> Proactive PREQ
+ *  Note, that at this moment all routes are known, and no reactive
+ *  path discovery procedure shall be initiated
+ *  <--------|-------->|         |         |         |          ARP request
+ *           |.........|.........|.........|.........|
+ *           |         |         |<--------|-------->|          ARP request
+ *           |         |         |         |<--------|          ARP reply
+ *           |.........|.........|.........|.........|
+ *           |<--------|         |         |         |          ARP reply
+ *           |-------->|         |         |         |          DATA
+ *             ^ Further data is forwarded by proactive path
+ * \endverbatim
+ *
+ */
+class HwmpProactiveRegressionTest : public TestCase
+{
+public:
+  HwmpProactiveRegressionTest ();
+  virtual ~HwmpProactiveRegressionTest();
+
+  virtual bool DoRun ();
+  void CheckResults ();
+
+private:
+  /// XXX It is important to have pointers here
+  NodeContainer * m_nodes;
+  /// Simulation time
+  Time m_time;
+  Ipv4InterfaceContainer m_interfaces;
+  
+  void CreateNodes ();
+  void CreateDevices ();
+  void InstallApplications ();
+  void ResetPosition ();
+};
+
Binary file src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-0-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-1-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-2-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-3-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-4-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-5-1.pcap has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/mesh/dot11s/test/hwmp-reactive-regression.cc	Mon Nov 30 19:25:04 2009 +0300
@@ -0,0 +1,154 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 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/mesh-helper.h"
+#include "ns3/simulator.h"
+#include "ns3/random-variable.h"
+#include "ns3/mobility-helper.h"
+#include "ns3/double.h"
+#include "ns3/uinteger.h"
+#include "ns3/string.h"
+#include "ns3/yans-wifi-helper.h"
+#include "ns3/internet-stack-helper.h"
+#include "ns3/ipv4-address-helper.h"
+#include "ns3/abort.h"
+#include "ns3/udp-echo-helper.h"
+#include "ns3/mobility-model.h"
+#include <sstream>
+
+#include "hwmp-reactive-regression.h"
+
+/// Set to true to rewrite reference traces, leave false to run regression test
+const bool WRITE_VECTORS = false;
+/// Unique PCAP file name prefix
+const char * const PREFIX = "hwmp-reactive-regression-test";
+
+HwmpReactiveRegressionTest::HwmpReactiveRegressionTest () : TestCase ("HWMP on-demand regression test"),
+  m_nodes (0),
+  m_time (Seconds (10))
+{
+}
+HwmpReactiveRegressionTest::~HwmpReactiveRegressionTest ()
+{
+  delete m_nodes;
+}
+bool
+HwmpReactiveRegressionTest::DoRun ()
+{
+  SeedManager::SetSeed(12345);
+  CreateNodes ();
+  CreateDevices ();
+  InstallApplications ();
+
+  Simulator::Stop (m_time);
+  Simulator::Run ();
+  Simulator::Destroy ();
+  
+  if (!WRITE_VECTORS) CheckResults ();
+  delete m_nodes, m_nodes = 0;
+  return false;
+}
+void
+HwmpReactiveRegressionTest::CreateNodes ()
+{
+  m_nodes = new NodeContainer;
+  m_nodes->Create (6);
+  MobilityHelper mobility;
+  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
+  positionAlloc->Add(Vector(  0,   0, 0));
+  positionAlloc->Add(Vector(  0, 150, 0));
+  positionAlloc->Add(Vector(  0, 300, 0));
+  positionAlloc->Add(Vector(  0, 450, 0));
+  positionAlloc->Add(Vector(  0, 600, 0));
+  positionAlloc->Add(Vector(  0, 750, 0));
+  mobility.SetPositionAllocator(positionAlloc);
+  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
+  mobility.Install (*m_nodes);
+  Simulator::Schedule (Seconds(5.0), &HwmpReactiveRegressionTest::ResetPosition, this);
+}
+void
+HwmpReactiveRegressionTest::InstallApplications ()
+{
+  UdpEchoServerHelper echoServer (9);
+  ApplicationContainer serverApps = echoServer.Install (m_nodes->Get (0));
+  serverApps.Start (Seconds (0.0));
+  serverApps.Stop (m_time);
+  UdpEchoClientHelper echoClient (m_interfaces.GetAddress (0), 9);
+  echoClient.SetAttribute ("MaxPackets", UintegerValue (300));
+  echoClient.SetAttribute ("Interval", TimeValue (Seconds(0.5)));
+  echoClient.SetAttribute ("PacketSize", UintegerValue (20));
+  ApplicationContainer clientApps = echoClient.Install (m_nodes->Get (5));
+  clientApps.Start (Seconds (2.0));
+  clientApps.Stop (m_time);
+}
+void
+HwmpReactiveRegressionTest::CreateDevices ()
+{
+  // 1. setup WiFi
+  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
+  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
+  wifiPhy.SetChannel (wifiChannel.Create ());
+  // 2. setup mesh
+  MeshHelper mesh = MeshHelper::Default ();
+  mesh.SetStackInstaller ("ns3::Dot11sStack");
+  mesh.SetMacType ("RandomStart", TimeValue (Seconds(0.1)));
+  mesh.SetNumberOfInterfaces (1);
+  NetDeviceContainer meshDevices = mesh.Install (wifiPhy, *m_nodes);  
+  // 3. setup TCP/IP
+  InternetStackHelper internetStack;
+  internetStack.Install (*m_nodes);
+  Ipv4AddressHelper address;
+  address.SetBase ("10.1.1.0", "255.255.255.0");
+  m_interfaces = address.Assign (meshDevices);
+  // 4. write PCAP if needed
+  std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : std::string(GetTempDir ())) + PREFIX;
+  wifiPhy.EnablePcapAll (prefix);
+
+}
+  
+void
+HwmpReactiveRegressionTest::CheckResults ()
+{
+  for (int i = 0; i < 6; ++i)
+    {
+      std::ostringstream os1, os2;
+      // File naming conventions are hard-coded here.
+      os1 << NS_TEST_SOURCEDIR << PREFIX << "-" << i << "-1.pcap";
+      os2 << GetTempDir () << PREFIX << "-" << i << "-1.pcap";
+      
+      uint32_t sec(0), usec(0);
+      bool diff = PcapFile::Diff (os1.str(), os2.str(), sec, usec); // TODO support default PcapWriter snap length here
+      NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str() << " and " << os2.str() 
+                                       << " differ starting from " << sec << " s " << usec << " us");
+    }
+}
+
+void
+HwmpReactiveRegressionTest::ResetPosition ()
+{
+  Ptr<Object> object = m_nodes->Get(3);
+  Ptr<MobilityModel> model = object->GetObject<MobilityModel> ();
+  if (model == 0)
+    {
+      return;
+    }
+  model->SetPosition (Vector(9000, 0, 0));
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/mesh/dot11s/test/hwmp-reactive-regression.h	Mon Nov 30 19:25:04 2009 +0300
@@ -0,0 +1,91 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 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/test.h"
+#include "ns3/node-container.h"
+#include "ns3/nstime.h"
+#include "ns3/ipv4-interface-container.h"
+#include "ns3/pcap-file.h"
+
+using namespace ns3;
+
+/**
+ * \ingroup dot11s
+ * \brief test for multihop path establishing and path error
+ * procedures
+ * Initiate scenario with 6 stations. Procedure of opening peer link
+ * is the following: (PMP routines are not shown)
+ * \verbatim
+ *      1    2    3    4    5    6
+ *      |    |    |    |    |<---|--->  ARP request (first attempt has failed!)
+ *      |....|....|....|....|....|      ARP reauest
+ *      |<---|--->|    |    |    |      ARP request
+ *  <---|--->|    |    |    |    |      PREQ       } This order is broken
+ *  <---|--->|    |    |    |    |      ARP request} due to BroadcastDca 
+ *      |<---|--->|    |    |    |      PREQ
+ *      |....|....|....|....|....|      ARP request
+ *      |    |    |    |<---|--->|      PREQ
+ *      |    |    |    |    |<---|      PREP
+ *      |....|....|....|....|....|      PREP 
+ *      |<---|    |    |    |    |      PREP
+ *      |--->|    |    |    |    |      ARP response
+ *      |....|....|....|....|....|      ARP response
+ *      |    |    |    |    |--->|      ARP response
+ *      |    |    |    |    |<---|      Data
+ *      |....|....|....|....|....|      Data
+ *      |<---|    |    |    |    |      Data
+ *  <---|--->|    |    |    |    |      ARP request
+ *      |....|....|....|....|....|      ARP reauest
+ *      |    |    |    |    |<---|--->  ARP request
+ *      |    |    |    |    |<---|      ARP response
+ *      |....|....|....|....|....|      ARP response
+ *      |<---|    |    |    |    |      ARP response
+ *      |--->|    |    |    |    |      Data
+ * At 5 station number 4 dissapears, and PERR is forwarded from 3 to 1
+ * and from 5 to 6, and station 6 starts path discovery procedure
+ * again:
+ *      |    |<---|         |--->|      PERR (one due to beacon loss and one due to TX error)
+ *      |<---|    |         |    |      PERR
+ *      |    |    |         |<---|--->  PREQ
+ *      |    |    |     <---|--->|      PREQ
+ *      |....|....|.........|....|      Repeated attempts of PREQ
+ * \endverbatim
+ */
+
+class HwmpReactiveRegressionTest : public TestCase
+{
+public:
+  HwmpReactiveRegressionTest ();
+  virtual ~HwmpReactiveRegressionTest();
+
+  virtual bool DoRun ();
+  void CheckResults ();
+private:
+  /// XXX It is important to have pointers here
+  NodeContainer * m_nodes;
+  /// Simulation time
+  Time m_time;
+  Ipv4InterfaceContainer m_interfaces;
+  
+  void CreateNodes ();
+  void CreateDevices ();
+  void InstallApplications ();
+  void ResetPosition ();
+};
+
Binary file src/devices/mesh/dot11s/test/hwmp-simplest-regression-test-0-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-simplest-regression-test-1-1.pcap has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/mesh/dot11s/test/hwmp-simplest-regression.cc	Mon Nov 30 19:25:04 2009 +0300
@@ -0,0 +1,155 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 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/mesh-helper.h"
+#include "ns3/simulator.h"
+#include "ns3/random-variable.h"
+#include "ns3/mobility-helper.h"
+#include "ns3/double.h"
+#include "ns3/uinteger.h"
+#include "ns3/string.h"
+#include "ns3/yans-wifi-helper.h"
+#include "ns3/internet-stack-helper.h"
+#include "ns3/ipv4-address-helper.h"
+#include "ns3/abort.h"
+#include "ns3/udp-echo-helper.h"
+#include "ns3/mobility-model.h"
+#include <sstream>
+#include "hwmp-simplest-regression.h"
+
+using namespace ns3;
+
+/// Set to true to rewrite reference traces, leave false to run regression test
+const bool WRITE_VECTORS = false;
+/// Unique PCAP file name prefix
+const char * const PREFIX = "hwmp-simplest-regression-test";
+
+
+HwmpSimplestRegressionTest::HwmpSimplestRegressionTest () : TestCase ("Simplest HWMP regression test"),
+  m_nodes (0),
+  m_time (Seconds (15))
+{
+}
+
+HwmpSimplestRegressionTest::~HwmpSimplestRegressionTest ()
+{
+  delete m_nodes;
+}
+bool
+HwmpSimplestRegressionTest::DoRun ()
+{
+  SeedManager::SetSeed(12345);
+  CreateNodes ();
+  CreateDevices ();
+  InstallApplications ();
+
+  Simulator::Stop (m_time);
+  Simulator::Run ();
+  Simulator::Destroy ();
+  
+  if (!WRITE_VECTORS) CheckResults ();
+
+  delete m_nodes, m_nodes = 0;
+  return false;
+}
+void
+HwmpSimplestRegressionTest::CreateNodes ()
+{
+  m_nodes = new NodeContainer;
+  m_nodes->Create (2);
+  MobilityHelper mobility;
+  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
+                                "MinX", DoubleValue (0.0),
+                                "MinY", DoubleValue (0.0),
+                                "DeltaX", DoubleValue (1 /*meter*/),
+                                "DeltaY", DoubleValue (0),
+                                "GridWidth", UintegerValue (2),
+                                "LayoutType", StringValue ("RowFirst"));
+  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
+  mobility.Install (*m_nodes);
+  Simulator::Schedule (Seconds(10.0), &HwmpSimplestRegressionTest::ResetPosition, this);
+}
+void
+HwmpSimplestRegressionTest::ResetPosition ()
+{
+  Ptr<Object> object = m_nodes->Get(1);
+  Ptr<MobilityModel> model = object->GetObject<MobilityModel> ();
+  if (model == 0)
+    {
+      return;
+    }
+  model->SetPosition (Vector(9000, 0, 0));
+}
+void
+HwmpSimplestRegressionTest::InstallApplications ()
+{
+  UdpEchoServerHelper echoServer (9);
+  ApplicationContainer serverApps = echoServer.Install (m_nodes->Get (0));
+  serverApps.Start (Seconds (0.0));
+  serverApps.Stop (m_time);
+  UdpEchoClientHelper echoClient (m_interfaces.GetAddress (0), 9);
+  echoClient.SetAttribute ("MaxPackets", UintegerValue (300));
+  echoClient.SetAttribute ("Interval", TimeValue (Seconds(0.05)));
+  echoClient.SetAttribute ("PacketSize", UintegerValue (100));
+  ApplicationContainer clientApps = echoClient.Install (m_nodes->Get (1));
+  clientApps.Start (Seconds (2.0));
+  clientApps.Stop (m_time);
+}
+void
+HwmpSimplestRegressionTest::CreateDevices ()
+{
+  // 1. setup WiFi
+  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
+  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
+  wifiPhy.SetChannel (wifiChannel.Create ());
+  // 2. setup mesh
+  MeshHelper mesh = MeshHelper::Default ();
+  mesh.SetStackInstaller ("ns3::Dot11sStack");
+  mesh.SetMacType ("RandomStart", TimeValue (Seconds(0.1)));
+  mesh.SetNumberOfInterfaces (1);
+  NetDeviceContainer meshDevices = mesh.Install (wifiPhy, *m_nodes);  
+  // 3. setup TCP/IP
+  InternetStackHelper internetStack;
+  internetStack.Install (*m_nodes);
+  Ipv4AddressHelper address;
+  address.SetBase ("10.1.1.0", "255.255.255.0");
+  m_interfaces = address.Assign (meshDevices);
+  // 4. write PCAP if needed
+  std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : std::string(GetTempDir ())) + PREFIX;
+  wifiPhy.EnablePcapAll (prefix);
+}
+  
+void
+HwmpSimplestRegressionTest::CheckResults ()
+{
+  for (int i = 0; i < 2; ++i)
+    {
+      std::ostringstream os1, os2;
+      // File naming conventions are hard-coded here.
+      os1 << NS_TEST_SOURCEDIR << PREFIX << "-" << i << "-1.pcap";
+      os2 << GetTempDir () << PREFIX << "-" << i << "-1.pcap";
+      
+      uint32_t sec(0), usec(0);
+      bool diff = PcapFile::Diff (os1.str(), os2.str(), sec, usec); // TODO support default PcapWriter snap length here
+      NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str() << " and " << os2.str() 
+                                       << " differ starting from " << sec << " s " << usec << " us");
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/mesh/dot11s/test/hwmp-simplest-regression.h	Mon Nov 30 19:25:04 2009 +0300
@@ -0,0 +1,89 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 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/test.h"
+#include "ns3/node-container.h"
+#include "ns3/nstime.h"
+#include "ns3/ipv4-interface-container.h"
+#include "ns3/pcap-file.h"
+
+using namespace ns3;
+
+/**
+ * \ingroup dot11s
+ * \brief Peering Management & HWM Protocol regression test
+ * Initiate scenario with 2 stations. Procedure of opening peer link
+ * is the following:
+ * \verbatim
+ * <-----------|----------->   Broadcast frame
+ *             |----------->|  Unicast frame
+ *
+ *                                        !!! PMP routines:
+ * <-----------|----------->|             Beacon
+ *             |<-----------|             Peer Link Open frame 
+ *             |----------->|             Peer Link Open frame
+ *             |----------->|             Peer Link Confirm frame
+ *             |<-----------|             Peer Link Confirm frame
+ *             |............|             !!! Data started:
+ *             |<-----------|-----------> Arp Request
+ * <-----------|----------->|             Arp Request (fwd)
+ * <-----------|----------->|             PREQ
+ *             |<-----------|             PREP
+ *             |----------->|             ARP reply
+ *             |<-----------|             Data
+ *             |----------->|             Data
+ *             |............|             Some other beacons
+ *             |<-----------|             Data
+ *             |----------->|             Data
+ *             |............|             !!! Route expiration routines:
+ *             |<-----------|-----------> PREQ (route expired)
+ *             |----------->|             PREP
+ *             |<-----------|             Data
+ *             |----------->|             Data
+ *             |............|
+ * \endverbatim
+ * At 10 seconds stations become unreachable, so UDP client tries to
+ * close peer link due to TX-fail, and UDP-srver tries to close link
+ * due to beacon loss
+
+
+ */
+class HwmpSimplestRegressionTest : public TestCase
+{
+public:
+  HwmpSimplestRegressionTest ();
+  virtual ~HwmpSimplestRegressionTest();
+
+  virtual bool DoRun ();
+  void CheckResults ();
+
+private:
+  /// XXX It is important to have pointers here
+  NodeContainer * m_nodes;
+  /// Simulation time
+  Time m_time;
+  Ipv4InterfaceContainer m_interfaces;
+  
+  void CreateNodes ();
+  void CreateDevices ();
+  void InstallApplications ();
+  void ResetPosition ();
+};
+
Binary file src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-0-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-1-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-2-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-3-1.pcap has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/mesh/dot11s/test/hwmp-target-flags-regression.cc	Mon Nov 30 19:25:04 2009 +0300
@@ -0,0 +1,160 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 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/mesh-helper.h"
+#include "ns3/simulator.h"
+#include "ns3/random-variable.h"
+#include "ns3/mobility-helper.h"
+#include "ns3/double.h"
+#include "ns3/uinteger.h"
+#include "ns3/string.h"
+#include "ns3/yans-wifi-helper.h"
+#include "ns3/internet-stack-helper.h"
+#include "ns3/ipv4-address-helper.h"
+#include "ns3/abort.h"
+#include "ns3/udp-echo-helper.h"
+#include "ns3/mobility-model.h"
+#include <sstream>
+#include "hwmp-target-flags-regression.h"
+
+using namespace ns3;
+
+/// Set to true to rewrite reference traces, leave false to run regression test
+const bool WRITE_VECTORS = false;
+/// Unique PCAP file name prefix
+const char * const PREFIX = "hwmp-target-flags-regression-test";
+
+
+HwmpDoRfRegressionTest::HwmpDoRfRegressionTest () : TestCase ("HWMP proactive regression test"),
+  m_nodes (0),
+  m_time (Seconds (5))
+{
+}
+
+HwmpDoRfRegressionTest::~HwmpDoRfRegressionTest ()
+{
+  delete m_nodes;
+}
+bool
+HwmpDoRfRegressionTest::DoRun ()
+{
+  SeedManager::SetSeed(12345);
+  CreateNodes ();
+  CreateDevices ();
+  InstallApplications ();
+
+  Simulator::Stop (m_time);
+  Simulator::Run ();
+  Simulator::Destroy ();
+  
+  if (!WRITE_VECTORS) CheckResults ();
+
+  delete m_nodes, m_nodes = 0;
+  return false;
+}
+void
+HwmpDoRfRegressionTest::CreateNodes ()
+{
+  m_nodes = new NodeContainer;
+  m_nodes->Create (4);
+  MobilityHelper mobility;
+  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
+                                "MinX", DoubleValue (0.0),
+                                "MinY", DoubleValue (0.0),
+                                "DeltaX", DoubleValue (100),
+                                "DeltaY", DoubleValue (0),
+                                "GridWidth", UintegerValue (4),
+                                "LayoutType", StringValue ("RowFirst"));
+  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
+  mobility.Install (*m_nodes);
+}
+void
+HwmpDoRfRegressionTest::InstallApplications ()
+{
+  UdpEchoServerHelper echoServer (9);
+  ApplicationContainer serverApps = echoServer.Install (m_nodes->Get (0));
+  serverApps.Start (Seconds (0.0));
+  serverApps.Stop (m_time);
+  UdpEchoClientHelper echoClient (m_interfaces.GetAddress (0), 9);
+  echoClient.SetAttribute ("MaxPackets", UintegerValue (300));
+  echoClient.SetAttribute ("Interval", TimeValue (Seconds(1.0)));
+  echoClient.SetAttribute ("PacketSize", UintegerValue (100));
+  //Install first client
+  ApplicationContainer clientApps = echoClient.Install (m_nodes->Get (1));
+  clientApps.Start (Seconds (2.2));
+  clientApps.Stop (m_time);
+  //Install second client
+  clientApps = echoClient.Install (m_nodes->Get (2));
+  clientApps.Start (Seconds (2.0));
+  clientApps.Stop (m_time);
+  //Install second server and attach client to it:
+  UdpEchoServerHelper echoServer1 (10);
+  serverApps = echoServer1.Install (m_nodes->Get (3));
+  serverApps.Start (Seconds (0.0));
+  serverApps.Stop (m_time);
+  UdpEchoClientHelper echoClient1 (m_interfaces.GetAddress (3), 10);
+  echoClient1.SetAttribute ("MaxPackets", UintegerValue (300));
+  echoClient1.SetAttribute ("Interval", TimeValue (Seconds(1.0)));
+  echoClient1.SetAttribute ("PacketSize", UintegerValue (100));
+  clientApps = echoClient1.Install (m_nodes->Get (0));
+  clientApps.Start (Seconds (2.4));
+  clientApps.Stop (m_time);
+}
+void
+HwmpDoRfRegressionTest::CreateDevices ()
+{
+  // 1. setup WiFi
+  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
+  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
+  wifiPhy.SetChannel (wifiChannel.Create ());
+  // 2. setup mesh
+  MeshHelper mesh = MeshHelper::Default ();
+  mesh.SetStackInstaller ("ns3::Dot11sStack");
+  mesh.SetMacType ("RandomStart", TimeValue (Seconds(0.1)));
+  mesh.SetNumberOfInterfaces (1);
+  NetDeviceContainer meshDevices = mesh.Install (wifiPhy, *m_nodes);  
+  // 3. setup TCP/IP
+  InternetStackHelper internetStack;
+  internetStack.Install (*m_nodes);
+  Ipv4AddressHelper address;
+  address.SetBase ("10.1.1.0", "255.255.255.0");
+  m_interfaces = address.Assign (meshDevices);
+  // 4. write PCAP if needed
+  std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : std::string(GetTempDir ())) + PREFIX;
+  wifiPhy.EnablePcapAll (prefix);
+}
+  
+void
+HwmpDoRfRegressionTest::CheckResults ()
+{
+  for (int i = 0; i < 4; ++i)
+    {
+      std::ostringstream os1, os2;
+      // File naming conventions are hard-coded here.
+      os1 << NS_TEST_SOURCEDIR << PREFIX << "-" << i << "-1.pcap";
+      os2 << GetTempDir () << PREFIX << "-" << i << "-1.pcap";
+      
+      uint32_t sec(0), usec(0);
+      bool diff = PcapFile::Diff (os1.str(), os2.str(), sec, usec); // TODO support default PcapWriter snap length here
+      NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str() << " and " << os2.str() 
+                                       << " differ starting from " << sec << " s " << usec << " us");
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/mesh/dot11s/test/hwmp-target-flags-regression.h	Mon Nov 30 19:25:04 2009 +0300
@@ -0,0 +1,88 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 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/test.h"
+#include "ns3/node-container.h"
+#include "ns3/nstime.h"
+#include "ns3/ipv4-interface-container.h"
+#include "ns3/pcap-file.h"
+
+using namespace ns3;
+
+/**
+ * \ingroup dot11s
+ * \brief This is a test for intermediate reply and saving routing
+ * information about neighbour. 4 stations and 3 UDP ping streams are initiated.
+ * \verbatim
+ *  <-----------|----------->   Broadcast frame
+ *              |----------->|  Unicast frame
+ *            10          11            12           13
+ *             |            |<-----------|----------->|             ARP request (12 asks who has 10)
+ *             |            |            |<-----------|-----------> ARP request
+ *             |<-----------|----------->|            |             ARP request
+ * <-----------|----------->|            |            |             PREQ
+ *             |<-----------|----------->|            |             PREQ
+ *             |            |<-----------|            |             PREP
+ *             |<-----------|            |            |             PREP
+ *             |----------->|            |            |             ARP reply
+ *             |            |----------->|            |             ARP REPLY
+ *             |            |<-----------|            |             Data
+ *             |............|............|............|
+ *             |<-----------|----------->|            |             ARP request (11 asks who has 10)
+ *             |............|............|............|
+ *             |----------->|            |            |             ARP reply
+ *                  ^ Note, that this arp reply goes without route
+ *                  discovery procedure, because route is known from
+ *                  previous PREQ/PREP exchange
+ *             |<-----------|            |            |             DATA
+ *             |............|............|............|
+ * <-----------|----------->|            |            |             ARP request (10 asks who has 13)
+ *             |............|............|............|
+ *             |            |            |<-----------|-----------> PREQ (13 asks about 10) DO=0 RF=1
+ *             |            |            |----------->|             PREP (intermediate reply - 12 knows about 10)
+ *             |            |<-----------|----------->|             PREQ DO=1 RF=0
+ *             |............|............|............|
+ *             |----------->|            |            |             PREP
+ *             |            |----------->|            |             PREP
+ *             |            |            |----------->|             PREP
+ * \endverbatim
+ */
+class HwmpDoRfRegressionTest : public TestCase
+{
+public:
+  HwmpDoRfRegressionTest ();
+  virtual ~HwmpDoRfRegressionTest();
+
+  virtual bool DoRun ();
+  void CheckResults ();
+
+private:
+  /// XXX It is important to have pointers here
+  NodeContainer * m_nodes;
+  /// Simulation time
+  Time m_time;
+  Ipv4InterfaceContainer m_interfaces;
+  
+  void CreateNodes ();
+  void CreateDevices ();
+  void InstallApplications ();
+  void ResetPosition ();
+};
+
Binary file src/devices/mesh/dot11s/test/pmp-regression-test-0-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/pmp-regression-test-1-1.pcap has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/mesh/dot11s/test/pmp-regression.cc	Mon Nov 30 19:25:04 2009 +0300
@@ -0,0 +1,121 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 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: Pavel Boyko <boyko@iitp.ru>
+ */
+#include "ns3/mesh-helper.h"
+#include "ns3/simulator.h"
+#include "ns3/random-variable.h"
+#include "ns3/mobility-helper.h"
+#include "ns3/double.h"
+#include "ns3/uinteger.h"
+#include "ns3/string.h"
+#include "ns3/yans-wifi-helper.h"
+#include "ns3/internet-stack-helper.h"
+#include "ns3/mobility-model.h"
+#include "ns3/pcap-file.h"
+#include <sstream>
+
+#include "pmp-regression.h"
+
+using namespace ns3;
+
+/// Set to true to rewrite reference traces, leave false to run regression test
+const bool WRITE_VECTORS = false;
+/// Unique PCAP file name prefix
+const char * const PREFIX = "pmp-regression-test";
+
+PeerManagementProtocolRegressionTest::PeerManagementProtocolRegressionTest () : TestCase ("PMP regression test"),
+  m_nodes (0),
+  m_time (Seconds (1))
+{
+}
+
+PeerManagementProtocolRegressionTest::~PeerManagementProtocolRegressionTest ()
+{
+  delete m_nodes;
+}
+
+bool
+PeerManagementProtocolRegressionTest::DoRun ()
+{
+  SeedManager::SetSeed(12345);
+  CreateNodes ();
+  CreateDevices ();
+
+  Simulator::Stop (m_time);
+  Simulator::Run ();
+  Simulator::Destroy ();
+  
+  if (!WRITE_VECTORS) CheckResults ();
+  
+  delete m_nodes, m_nodes = 0;
+  return GetErrorStatus ();
+}
+
+void
+PeerManagementProtocolRegressionTest::CreateNodes ()
+{
+  m_nodes = new NodeContainer;
+  m_nodes->Create (2);
+  MobilityHelper mobility;
+  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
+                                "MinX", DoubleValue (0.0),
+                                "MinY", DoubleValue (0.0),
+                                "DeltaX", DoubleValue (1 /*meter*/),
+                                "DeltaY", DoubleValue (0),
+                                "GridWidth", UintegerValue (2),
+                                "LayoutType", StringValue ("RowFirst"));
+  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
+  mobility.Install (*m_nodes);
+}
+
+void
+PeerManagementProtocolRegressionTest::CreateDevices ()
+{
+  // 1. setup WiFi
+  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
+  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
+  wifiPhy.SetChannel (wifiChannel.Create ());
+  // 2. setup mesh
+  MeshHelper mesh = MeshHelper::Default ();
+  mesh.SetStackInstaller ("ns3::Dot11sStack");
+  mesh.SetMacType ("RandomStart", TimeValue (Seconds(0.1)));
+  mesh.SetNumberOfInterfaces (1);
+  NetDeviceContainer meshDevices = mesh.Install (wifiPhy, *m_nodes);
+  // 3. write PCAP if needed
+  std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : std::string(GetTempDir ())) + PREFIX;
+  wifiPhy.EnablePcapAll (prefix);
+}
+
+void
+PeerManagementProtocolRegressionTest::CheckResults ()
+{
+  for (int i = 0; i < 2; ++i)
+    {
+      std::ostringstream os1, os2;
+      // File naming conventions are hard-coded here.
+      os1 << NS_TEST_SOURCEDIR << PREFIX << "-" << i << "-1.pcap";
+      os2 << GetTempDir () << PREFIX << "-" << i << "-1.pcap";
+      
+      uint32_t sec(0), usec(0);
+      bool diff = PcapFile::Diff (os1.str(), os2.str(), sec, usec); // TODO support default PcapWriter snap length here
+      NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str() << " and " << os2.str() 
+                                       << " differ starting from " << sec << " s " << usec << " us");
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/mesh/dot11s/test/pmp-regression.h	Mon Nov 30 19:25:04 2009 +0300
@@ -0,0 +1,62 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 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: Pavel Boyko <boyko@iitp.ru>
+ */
+#ifndef PMP_REGRESSION_H
+#define PMP_REGRESSION_H
+#include "ns3/test.h"
+#include "ns3/node-container.h"
+#include "ns3/nstime.h"
+
+using namespace ns3;
+/**
+ * \ingroup dot11s
+ * 
+ * \brief Peering Management Protocol regression test
+ * 
+ * Initiate scenario with 2 stations. Procedure of opening peer link
+ * is the following:
+ * \verbatim
+ * |----------->|  Beacon
+ * |<-----------|  Peer Link Open frame 
+ * |----------->|  Peer Link Open frame
+ * |----------->|  Peer Link Confirm frame
+ * |<-----------|  Peer Link Confirm frame
+ * |............|
+ * |<---------->|  Other beacons
+ * \endverbatim
+ */
+class PeerManagementProtocolRegressionTest : public TestCase
+{
+public:
+  PeerManagementProtocolRegressionTest ();
+  ~PeerManagementProtocolRegressionTest ();
+  
+private:
+  /// XXX It is important to have pointers here
+  NodeContainer * m_nodes;
+  /// Simulation time
+  Time m_time;
+  
+  void CreateNodes ();
+  void CreateDevices ();
+  void CheckResults ();
+  bool DoRun ();
+};
+#endif // PMP_REGRESSION_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/mesh/dot11s/test/regression.cc	Mon Nov 30 19:25:04 2009 +0300
@@ -0,0 +1,40 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 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/test.h"
+#include "pmp-regression.h"
+#include "hwmp-reactive-regression.h"
+#include "hwmp-proactive-regression.h"
+#include "hwmp-simplest-regression.h"
+#include "hwmp-target-flags-regression.h"
+
+using namespace ns3;
+class Dot11sRegressionSuite : public TestSuite
+{
+public:
+  Dot11sRegressionSuite () : TestSuite ("devices-mesh-dot11s-regression", SYSTEM) 
+  {
+    AddTestCase (new PeerManagementProtocolRegressionTest);
+    AddTestCase (new HwmpSimplestRegressionTest);
+    AddTestCase (new HwmpReactiveRegressionTest);
+    AddTestCase (new HwmpProactiveRegressionTest);
+    AddTestCase (new HwmpDoRfRegressionTest);
+  }
+} g_dot11sRegressionSuite;
--- a/src/devices/mesh/dot11s/wscript	Mon Nov 30 17:37:32 2009 +0300
+++ b/src/devices/mesh/dot11s/wscript	Mon Nov 30 19:25:04 2009 +0300
@@ -23,7 +23,14 @@
         'hwmp-protocol-mac.cc',
         'hwmp-protocol.cc',
         'airtime-metric.cc',
-        'dot11s-test-suite.cc',
+        'test/dot11s-test-suite.cc',
+        'test/pmp-regression.cc',
+        'test/hwmp-reactive-regression.cc',
+        'test/hwmp-proactive-regression.cc',
+        'test/hwmp-simplest-regression.cc',
+        'test/hwmp-target-flags-regression.cc',
+        'test/regression.cc',
+
         ]
     headers = bld.new_task_gen('ns3header')
     headers.module = 'dot11s'