diff --git a/src/devices/mesh/dot11s/hwmp-protocol.cc b/src/devices/mesh/dot11s/hwmp-protocol.cc index 5b4d6954f..ae9b39765 100644 --- a/src/devices/mesh/dot11s/hwmp-protocol.cc +++ b/src/devices/mesh/dot11s/hwmp-protocol.cc @@ -985,8 +985,7 @@ HwmpProtocol::RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry) 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 @@ HwmpProtocol::RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry) 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 ++) diff --git a/src/devices/mesh/dot11s/dot11s-test-suite.cc b/src/devices/mesh/dot11s/test/dot11s-test-suite.cc similarity index 98% rename from src/devices/mesh/dot11s/dot11s-test-suite.cc rename to src/devices/mesh/dot11s/test/dot11s-test-suite.cc index 5499d866a..fcca8a33f 100644 --- a/src/devices/mesh/dot11s/dot11s-test-suite.cc +++ b/src/devices/mesh/dot11s/test/dot11s-test-suite.cc @@ -20,10 +20,10 @@ #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" +#include "../dot11s-mac-header.h" +#include "../hwmp-rtable.h" +#include "../peer-link-frame.h" +#include "../ie-dot11s-peer-management.h" namespace ns3 { namespace dot11s { diff --git a/src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-0-1.pcap b/src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-0-1.pcap new file mode 100644 index 000000000..eaa0c63cf Binary files /dev/null and b/src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-0-1.pcap differ diff --git a/src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-1-1.pcap b/src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-1-1.pcap new file mode 100644 index 000000000..1747c6bc3 Binary files /dev/null and b/src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-1-1.pcap differ diff --git a/src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-2-1.pcap b/src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-2-1.pcap new file mode 100644 index 000000000..dd04cebe7 Binary files /dev/null and b/src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-2-1.pcap differ diff --git a/src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-3-1.pcap b/src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-3-1.pcap new file mode 100644 index 000000000..af181764a Binary files /dev/null and b/src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-3-1.pcap differ diff --git a/src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-4-1.pcap b/src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-4-1.pcap new file mode 100644 index 000000000..e44c60329 Binary files /dev/null and b/src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-4-1.pcap differ diff --git a/src/devices/mesh/dot11s/test/hwmp-proactive-regression.cc b/src/devices/mesh/dot11s/test/hwmp-proactive-regression.cc new file mode 100644 index 000000000..d5f8dd462 --- /dev/null +++ b/src/devices/mesh/dot11s/test/hwmp-proactive-regression.cc @@ -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 + */ + +#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 +#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"); + } +} + diff --git a/src/devices/mesh/dot11s/test/hwmp-proactive-regression.h b/src/devices/mesh/dot11s/test/hwmp-proactive-regression.h new file mode 100644 index 000000000..cd38ce09e --- /dev/null +++ b/src/devices/mesh/dot11s/test/hwmp-proactive-regression.h @@ -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 + */ + +#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 (); +}; + diff --git a/src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-0-1.pcap b/src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-0-1.pcap new file mode 100644 index 000000000..845996368 Binary files /dev/null and b/src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-0-1.pcap differ diff --git a/src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-1-1.pcap b/src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-1-1.pcap new file mode 100644 index 000000000..6a66fb7a8 Binary files /dev/null and b/src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-1-1.pcap differ diff --git a/src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-2-1.pcap b/src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-2-1.pcap new file mode 100644 index 000000000..19de55c72 Binary files /dev/null and b/src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-2-1.pcap differ diff --git a/src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-3-1.pcap b/src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-3-1.pcap new file mode 100644 index 000000000..07dfd5dee Binary files /dev/null and b/src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-3-1.pcap differ diff --git a/src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-4-1.pcap b/src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-4-1.pcap new file mode 100644 index 000000000..c0d4880a4 Binary files /dev/null and b/src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-4-1.pcap differ diff --git a/src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-5-1.pcap b/src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-5-1.pcap new file mode 100644 index 000000000..083265185 Binary files /dev/null and b/src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-5-1.pcap differ diff --git a/src/devices/mesh/dot11s/test/hwmp-reactive-regression.cc b/src/devices/mesh/dot11s/test/hwmp-reactive-regression.cc new file mode 100644 index 000000000..c52be5cf1 --- /dev/null +++ b/src/devices/mesh/dot11s/test/hwmp-reactive-regression.cc @@ -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 + */ + +#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 + +#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 positionAlloc = CreateObject(); + 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 = m_nodes->Get(3); + Ptr model = object->GetObject (); + if (model == 0) + { + return; + } + model->SetPosition (Vector(9000, 0, 0)); + +} diff --git a/src/devices/mesh/dot11s/test/hwmp-reactive-regression.h b/src/devices/mesh/dot11s/test/hwmp-reactive-regression.h new file mode 100644 index 000000000..a7e3a904c --- /dev/null +++ b/src/devices/mesh/dot11s/test/hwmp-reactive-regression.h @@ -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 + */ +#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 (); +}; + diff --git a/src/devices/mesh/dot11s/test/hwmp-simplest-regression-test-0-1.pcap b/src/devices/mesh/dot11s/test/hwmp-simplest-regression-test-0-1.pcap new file mode 100644 index 000000000..2c72d0caa Binary files /dev/null and b/src/devices/mesh/dot11s/test/hwmp-simplest-regression-test-0-1.pcap differ diff --git a/src/devices/mesh/dot11s/test/hwmp-simplest-regression-test-1-1.pcap b/src/devices/mesh/dot11s/test/hwmp-simplest-regression-test-1-1.pcap new file mode 100644 index 000000000..e4ccc9865 Binary files /dev/null and b/src/devices/mesh/dot11s/test/hwmp-simplest-regression-test-1-1.pcap differ diff --git a/src/devices/mesh/dot11s/test/hwmp-simplest-regression.cc b/src/devices/mesh/dot11s/test/hwmp-simplest-regression.cc new file mode 100644 index 000000000..fe9998e31 --- /dev/null +++ b/src/devices/mesh/dot11s/test/hwmp-simplest-regression.cc @@ -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 + */ + +#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 +#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 = m_nodes->Get(1); + Ptr model = object->GetObject (); + 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"); + } +} + diff --git a/src/devices/mesh/dot11s/test/hwmp-simplest-regression.h b/src/devices/mesh/dot11s/test/hwmp-simplest-regression.h new file mode 100644 index 000000000..cdbed35b2 --- /dev/null +++ b/src/devices/mesh/dot11s/test/hwmp-simplest-regression.h @@ -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 + */ + +#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 (); +}; + diff --git a/src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-0-1.pcap b/src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-0-1.pcap new file mode 100644 index 000000000..3b6768ae5 Binary files /dev/null and b/src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-0-1.pcap differ diff --git a/src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-1-1.pcap b/src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-1-1.pcap new file mode 100644 index 000000000..bee8105d8 Binary files /dev/null and b/src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-1-1.pcap differ diff --git a/src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-2-1.pcap b/src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-2-1.pcap new file mode 100644 index 000000000..51140c842 Binary files /dev/null and b/src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-2-1.pcap differ diff --git a/src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-3-1.pcap b/src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-3-1.pcap new file mode 100644 index 000000000..53683489c Binary files /dev/null and b/src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-3-1.pcap differ diff --git a/src/devices/mesh/dot11s/test/hwmp-target-flags-regression.cc b/src/devices/mesh/dot11s/test/hwmp-target-flags-regression.cc new file mode 100644 index 000000000..1f267ce77 --- /dev/null +++ b/src/devices/mesh/dot11s/test/hwmp-target-flags-regression.cc @@ -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 + */ + +#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 +#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"); + } +} + diff --git a/src/devices/mesh/dot11s/test/hwmp-target-flags-regression.h b/src/devices/mesh/dot11s/test/hwmp-target-flags-regression.h new file mode 100644 index 000000000..123844d87 --- /dev/null +++ b/src/devices/mesh/dot11s/test/hwmp-target-flags-regression.h @@ -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 + */ + +#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 (); +}; + diff --git a/src/devices/mesh/dot11s/test/pmp-regression-test-0-1.pcap b/src/devices/mesh/dot11s/test/pmp-regression-test-0-1.pcap new file mode 100644 index 000000000..f8fbb750f Binary files /dev/null and b/src/devices/mesh/dot11s/test/pmp-regression-test-0-1.pcap differ diff --git a/src/devices/mesh/dot11s/test/pmp-regression-test-1-1.pcap b/src/devices/mesh/dot11s/test/pmp-regression-test-1-1.pcap new file mode 100644 index 000000000..4422a2736 Binary files /dev/null and b/src/devices/mesh/dot11s/test/pmp-regression-test-1-1.pcap differ diff --git a/src/devices/mesh/dot11s/test/pmp-regression.cc b/src/devices/mesh/dot11s/test/pmp-regression.cc new file mode 100644 index 000000000..9bb40c367 --- /dev/null +++ b/src/devices/mesh/dot11s/test/pmp-regression.cc @@ -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 + */ +#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 + +#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"); + } +} + diff --git a/src/devices/mesh/dot11s/test/pmp-regression.h b/src/devices/mesh/dot11s/test/pmp-regression.h new file mode 100644 index 000000000..f98d7655a --- /dev/null +++ b/src/devices/mesh/dot11s/test/pmp-regression.h @@ -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 + */ +#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 + diff --git a/src/devices/mesh/dot11s/test/regression.cc b/src/devices/mesh/dot11s/test/regression.cc new file mode 100644 index 000000000..789e84703 --- /dev/null +++ b/src/devices/mesh/dot11s/test/regression.cc @@ -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 + */ + +#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; diff --git a/src/devices/mesh/dot11s/wscript b/src/devices/mesh/dot11s/wscript index a79453bb6..b40c2f038 100644 --- a/src/devices/mesh/dot11s/wscript +++ b/src/devices/mesh/dot11s/wscript @@ -23,7 +23,14 @@ def build(bld): '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'