diff --git a/src/devices/mesh/dot11s/ie-dot11s-beacon-timing.cc b/src/devices/mesh/dot11s/ie-dot11s-beacon-timing.cc index 3524f966c..cdf6bd931 100644 --- a/src/devices/mesh/dot11s/ie-dot11s-beacon-timing.cc +++ b/src/devices/mesh/dot11s/ie-dot11s-beacon-timing.cc @@ -220,36 +220,6 @@ operator== (const IeBeaconTiming & a, const IeBeaconTiming& b) } return true; } - -#ifdef RUN_SELF_TESTS -struct IeBeaconTimingBist : public IeTest -{ - IeBeaconTimingBist () : - IeTest ("Mesh/802.11s/IE/BeaconTiming") - { - } - virtual bool - RunTests (); -}; - -/// Test instance -static IeBeaconTimingBist g_IePerrBist; - -bool -IeBeaconTimingBist::RunTests () -{ - bool result (true); - // create test information element - IeBeaconTiming a; - a.IeBeaconTiming::AddNeighboursTimingElementUnit (1, Seconds (1.0), Seconds (4.0)); - a.IeBeaconTiming::AddNeighboursTimingElementUnit (2, Seconds (2.0), Seconds (3.0)); - a.IeBeaconTiming::AddNeighboursTimingElementUnit (3, Seconds (3.0), Seconds (2.0)); - a.IeBeaconTiming::AddNeighboursTimingElementUnit (4, Seconds (4.0), Seconds (1.0)); - - result = TestRoundtripSerialization (a); - return result; -} -#endif } // namespace dot11s } //namespace ns3 diff --git a/src/devices/mesh/dot11s/ie-dot11s-configuration.cc b/src/devices/mesh/dot11s/ie-dot11s-configuration.cc index 72e07f514..ca97d210c 100644 --- a/src/devices/mesh/dot11s/ie-dot11s-configuration.cc +++ b/src/devices/mesh/dot11s/ie-dot11s-configuration.cc @@ -212,32 +212,7 @@ operator== (const IeConfiguration & a, const IeConfiguration & b) == b.m_SPId) && (a.m_APId == b.m_APId) && (a.m_neighbors == b.m_neighbors) && (a.m_meshCap == b.m_meshCap)); } -#ifdef RUN_SELF_TESTS -/// Built-in self test for IePreq -struct IeConfigurationBist : public IeTest -{ - IeConfigurationBist () : - IeTest ("Mesh/802.11s/IE/Configuration") - { - } - virtual bool - RunTests (); -}; - -/// Test instance -static IeConfigurationBist g_IeConfigurationBist; - -bool -IeConfigurationBist::RunTests () -{ - bool result (true); - IeConfiguration a; - - result = TestRoundtripSerialization (a); - return result; -} -#endif } // namespace dot11s } //namespace ns3 diff --git a/src/devices/mesh/dot11s/ie-dot11s-id.cc b/src/devices/mesh/dot11s/ie-dot11s-id.cc index 8bc8452ef..88d3d7dcc 100644 --- a/src/devices/mesh/dot11s/ie-dot11s-id.cc +++ b/src/devices/mesh/dot11s/ie-dot11s-id.cc @@ -139,32 +139,5 @@ operator << (std::ostream &os, const IeMeshId &meshId) os << meshId.PeekString (); return os; } -#ifdef RUN_SELF_TESTS - -/// Built-in self test for IeMeshId -struct IeMeshIdBist : public IeTest -{ - IeMeshIdBist () : - IeTest ("Mesh/802.11s/IE/MESH_ID") - { - } - virtual bool - RunTests (); -}; - -/// Test instance -static IeMeshIdBist g_IeMeshIdBist; - -bool -IeMeshIdBist::RunTests () -{ - bool result (true); - - // create test information element - IeMeshId a ("qwerty"); - result = result && TestRoundtripSerialization (a); - return result; -} -#endif // RUN_SELF_TESTS } //namespace dot11s } // namespace ns3 diff --git a/src/devices/mesh/dot11s/ie-dot11s-metric-report.cc b/src/devices/mesh/dot11s/ie-dot11s-metric-report.cc index b7168cb6a..2a682ca9f 100644 --- a/src/devices/mesh/dot11s/ie-dot11s-metric-report.cc +++ b/src/devices/mesh/dot11s/ie-dot11s-metric-report.cc @@ -73,32 +73,5 @@ operator== (const IeLinkMetricReport & a, const IeLinkMetricReport & b) { return (a.m_metric == b.m_metric); }; -#ifdef RUN_SELF_TESTS - -/// Built-in self test for IeLinkMetricReport -struct IeLinkMetricReportBist : public IeTest -{ - IeLinkMetricReportBist () : - IeTest ("Mesh/802.11s/IE/LINK_METRIC_REPORT") - { - } - virtual bool - RunTests (); -}; - -/// Test instance -static IeLinkMetricReportBist g_IeLinkMetricReportBist; - -bool -IeLinkMetricReportBist::RunTests () -{ - bool result (true); - - // create test information element - IeLinkMetricReport a (123456); - result = result && TestRoundtripSerialization (a); - return result; -} -#endif // RUN_SELF_TESTS } //namespace dot11s } // namespace ns3 diff --git a/src/devices/mesh/dot11s/ie-dot11s-peer-management.cc b/src/devices/mesh/dot11s/ie-dot11s-peer-management.cc index 0c0565b0c..9eb734278 100644 --- a/src/devices/mesh/dot11s/ie-dot11s-peer-management.cc +++ b/src/devices/mesh/dot11s/ie-dot11s-peer-management.cc @@ -165,42 +165,6 @@ operator== (const IePeerManagement & a, const IePeerManagement & b) return ((a.m_length == b.m_length) && (a.m_subtype == b.m_subtype) && (a.m_localLinkId == b.m_localLinkId) && (a.m_peerLinkId == b.m_peerLinkId) && (a.m_reasonCode == b.m_reasonCode)); } -#ifdef RUN_SELF_TESTS -struct IePeerManagementBist : public IeTest -{ - IePeerManagementBist () : - IeTest ("Mesh/802.11s/IE/PeerManagement") - { - } - virtual bool - RunTests (); -}; - -/// Test instance -static IePeerManagementBist g_IePerrBist; - -bool -IePeerManagementBist::RunTests () -{ - bool result (true); - { - IePeerManagement a; - a.SetPeerOpen (1); - result = result && TestRoundtripSerialization (a); - } - { - IePeerManagement a; - a.SetPeerConfirm (1, 2); - result = result && TestRoundtripSerialization (a); - } - { - IePeerManagement a; - a.SetPeerClose (1, 2, REASON11S_MESH_CAPABILITY_POLICY_VIOLATION); - result = result && TestRoundtripSerialization (a); - } - return result; -} -#endif } // namespace dot11s } //namespace ns3 diff --git a/src/devices/mesh/dot11s/ie-dot11s-perr.cc b/src/devices/mesh/dot11s/ie-dot11s-perr.cc index a14b5c66c..0baba8889 100644 --- a/src/devices/mesh/dot11s/ie-dot11s-perr.cc +++ b/src/devices/mesh/dot11s/ie-dot11s-perr.cc @@ -153,44 +153,6 @@ operator== (const IePerr & a, const IePerr & b) } return true; } -#ifdef RUN_SELF_TESTS - -/// Built-in self test for IePreq -struct IePerrBist : public IeTest -{ - IePerrBist () : - IeTest ("Mesh/802.11s/IE/PERR") - { - } - virtual bool - RunTests (); -}; - -/// Test instance -static IePerrBist g_IePerrBist; - -bool -IePerrBist::RunTests () -{ - bool result (true); - // create test information element - IePerr a; - IePerr::FailedDestination dest; - dest.destination = Mac48Address ("11:22:33:44:55:66"); - dest.seqnum = 1; - a.AddAddressUnit (dest); - dest.destination = Mac48Address ("10:20:30:40:50:60"); - dest.seqnum = 2; - a.AddAddressUnit (dest); - dest.destination = Mac48Address ("01:02:03:04:05:06"); - dest.seqnum = 3; - a.AddAddressUnit (dest); - - result = result && TestRoundtripSerialization (a); - return result; -} - -#endif // RUN_SELF_TESTS } // namespace dot11s } //namespace ns3 diff --git a/src/devices/mesh/dot11s/ie-dot11s-prep.cc b/src/devices/mesh/dot11s/ie-dot11s-prep.cc index 22a440ad8..6132ffd3e 100644 --- a/src/devices/mesh/dot11s/ie-dot11s-prep.cc +++ b/src/devices/mesh/dot11s/ie-dot11s-prep.cc @@ -203,45 +203,6 @@ operator== (const IePrep & a, const IePrep & b) && (a.m_lifetime == b.m_lifetime) && (a.m_metric == b.m_metric) && (a.m_originatorAddress == b.m_originatorAddress) && (a.m_originatorSeqNumber == b.m_originatorSeqNumber)); } - -#ifdef RUN_SELF_TESTS - -/// Built-in self test for IePrep -struct IePrepBist : public IeTest -{ - IePrepBist () : - IeTest ("Mesh/802.11s/IE/PREP") - { - }; - virtual bool - RunTests (); -}; - -/// Test instance -static IePrepBist g_IePrepBist; - -bool -IePrepBist::RunTests () -{ - bool result (true); - - // create test information element - IePrep a; - a.SetFlags (12); - a.SetHopcount (11); - a.SetTtl (10); - a.SetDestinationAddress (Mac48Address ("11:22:33:44:55:66")); - a.SetDestinationSeqNumber (123); - a.SetLifetime (5000); - a.SetMetric (4321); - a.SetOriginatorAddress (Mac48Address ("33:00:22:00:11:00")); - a.SetOriginatorSeqNumber (666); - - result = result && TestRoundtripSerialization (a); - return result; -} - -#endif // RUN_SELF_TESTS } // namespace dot11s } //namespace ns3 diff --git a/src/devices/mesh/dot11s/ie-dot11s-preq.cc b/src/devices/mesh/dot11s/ie-dot11s-preq.cc index 943a5e728..cbe791b3c 100644 --- a/src/devices/mesh/dot11s/ie-dot11s-preq.cc +++ b/src/devices/mesh/dot11s/ie-dot11s-preq.cc @@ -444,43 +444,6 @@ IePreq::IsFull () const { return ((GetInformationSize () + 11) > 255); } -#ifdef RUN_SELF_TESTS - -/// Built-in self test for IePreq -struct IePreqBist : public IeTest -{ - IePreqBist () : - IeTest ("Mesh/802.11s/IE/PREQ") - { - } - virtual bool - RunTests (); -}; - -/// Test instance -static IePreqBist g_IePreqBist; - -bool -IePreqBist::RunTests () -{ - bool result (true); - - // create test information element - IePreq a; - a.SetHopcount (0); - a.SetTTL (1); - a.SetPreqID (2); - a.SetOriginatorAddress (Mac48Address ("11:22:33:44:55:66")); - a.SetOriginatorSeqNumber (3); - a.SetLifetime (4); - a.AddDestinationAddressElement (false, false, Mac48Address ("11:11:11:11:11:11"), 5); - a.AddDestinationAddressElement (false, false, Mac48Address ("22:22:22:22:22:22"), 6); - - result = result && TestRoundtripSerialization (a); - return result; -} - -#endif // RUN_SELF_TESTS } // namespace dot11s } //namespace ns3 diff --git a/src/devices/mesh/dot11s/ie-dot11s-rann.cc b/src/devices/mesh/dot11s/ie-dot11s-rann.cc index 23595cdb7..ed01daca7 100644 --- a/src/devices/mesh/dot11s/ie-dot11s-rann.cc +++ b/src/devices/mesh/dot11s/ie-dot11s-rann.cc @@ -168,46 +168,6 @@ operator== (const IeRann & a, const IeRann & b) && a.m_originatorAddress == b.m_originatorAddress && a.m_destSeqNumber == b.m_destSeqNumber && a.m_metric == b.m_metric); } - -#ifdef RUN_SELF_TESTS - -/// Built-in self test for IeRann -struct IeRannBist : public IeTest -{ - IeRannBist () : - IeTest ("Mesh/802.11s/IE/RANN") - { - } - virtual bool - RunTests (); -}; - -/// Test instance -static IeRannBist g_IeRannBist; - -bool -IeRannBist::RunTests () -{ - bool result (true); - - // create test information element - IeRann a; - - a.SetFlags (1); - a.SetHopcount (2); - a.SetTTL (4); - a.DecrementTtl (); - NS_TEST_ASSERT_EQUAL (a.GetTtl (), 3); - a.SetOriginatorAddress (Mac48Address ("11:22:33:44:55:66")); - a.SetDestSeqNumber (5); - a.SetMetric (6); - a.IncrementMetric (2); - NS_TEST_ASSERT_EQUAL (a.GetMetric (), 8); - - result = result && TestRoundtripSerialization (a); - return result; -} -#endif // RUN_SELF_TESTS } } // namespace ns3::dot11s diff --git a/src/devices/mesh/dot11s/peer-link-frame.cc b/src/devices/mesh/dot11s/peer-link-frame.cc index 53c56bac5..f7915a994 100644 --- a/src/devices/mesh/dot11s/peer-link-frame.cc +++ b/src/devices/mesh/dot11s/peer-link-frame.cc @@ -242,7 +242,7 @@ operator== (const PeerLinkFrameStart & a, const PeerLinkFrameStart & b) struct PeerLinkFrameStartBist : public Test { PeerLinkFrameStartBist () : - Test ("Mesh/802.11s/IE/PeerLinkFrameStart") + Test ("Mesh/802.11s/PeerLinkFrameStart") { } virtual bool diff --git a/src/devices/mesh/flame/flame-header.cc b/src/devices/mesh/flame/flame-header.cc index 443590156..52cde33f5 100644 --- a/src/devices/mesh/flame/flame-header.cc +++ b/src/devices/mesh/flame/flame-header.cc @@ -149,7 +149,7 @@ operator== (const FlameHeader & a, const FlameHeader & b) struct FlameHeaderBist : public Test { FlameHeaderBist () : - Test ("mesh/flame/FlameHeader") + Test ("mesh/Flame/FlameHeader") { } virtual bool diff --git a/src/devices/mesh/flame/flame-rtable.cc b/src/devices/mesh/flame/flame-rtable.cc index ffb018953..c3825058d 100644 --- a/src/devices/mesh/flame/flame-rtable.cc +++ b/src/devices/mesh/flame/flame-rtable.cc @@ -146,7 +146,7 @@ private: static FlameRtableTest g_FlameRtableTest; FlameRtableTest::FlameRtableTest () : - Test ("Mesh/flame/FlameRtable"), result (true), dst ("01:00:00:01:00:01"), hop ("01:00:00:01:00:03"), + Test ("Mesh/Flame/FlameRtable"), result (true), dst ("01:00:00:01:00:01"), hop ("01:00:00:01:00:03"), iface (8010), cost (10), seqnum (1) { } diff --git a/src/devices/mesh/wifi-information-element-vector.cc b/src/devices/mesh/wifi-information-element-vector.cc index c696d3f30..39314254f 100644 --- a/src/devices/mesh/wifi-information-element-vector.cc +++ b/src/devices/mesh/wifi-information-element-vector.cc @@ -208,7 +208,7 @@ operator== (const WifiInformationElementVector & a, const WifiInformationElement WifiInformationElementVector::IE_VECTOR::const_iterator j = b.m_elements.begin (); for (WifiInformationElementVector::IE_VECTOR::const_iterator i = a.m_elements.begin (); i != a.m_elements.end (); i++, j++) - { + { if ((*i)->ElementId () != (*j)->ElementId ()) { return false; @@ -217,6 +217,143 @@ operator== (const WifiInformationElementVector & a, const WifiInformationElement { return false; } + uint8_t id = (*i)->ElementId (); + switch (id) + { + case IE11S_MESH_CONFIGURATION: + if (DynamicCast ((*i)) == 0) + { + return false; + } + if (DynamicCast ((*j)) == 0) + { + return false; + } + if (!(*DynamicCast ((*i)) == *DynamicCast ((*j)))) + { + return false; + } + break; + case IE11S_MESH_ID: + if (DynamicCast ((*i)) == 0) + { + return false; + } + if (DynamicCast ((*j)) == 0) + { + return false; + } + if (!(*DynamicCast ((*i)) == *DynamicCast ((*j)))) + { + return false; + } + break; + case IE11S_LINK_METRIC_REPORT: + if (DynamicCast ((*i)) == 0) + { + return false; + } + if (DynamicCast ((*j)) == 0) + { + return false; + } + if (!(*DynamicCast ((*i)) == *DynamicCast ( + (*j)))) + { + return false; + } + break; + case IE11S_PEERING_MANAGEMENT: + if (DynamicCast ((*i)) == 0) + { + return false; + } + if (DynamicCast ((*j)) == 0) + { + return false; + } + if (!(*DynamicCast ((*i)) == *DynamicCast ((*j)))) + { + return false; + } + break; + case IE11S_BEACON_TIMING: + if (DynamicCast ((*i)) == 0) + { + return false; + } + if (DynamicCast ((*j)) == 0) + { + return false; + } + if (!(*DynamicCast ((*i)) == *DynamicCast ((*j)))) + { + return false; + } + break; + case IE11S_RANN: + if (DynamicCast ((*i)) == 0) + { + return false; + } + if (DynamicCast ((*j)) == 0) + { + return false; + } + if (!(*DynamicCast ((*i)) == *DynamicCast ((*j)))) + { + return false; + } + break; + case IE11S_PREQ: + if (DynamicCast ((*i)) == 0) + { + return false; + } + if (DynamicCast ((*j)) == 0) + { + return false; + } + if (!(*DynamicCast ((*i)) == *DynamicCast ((*j)))) + { + return false; + } + break; + case IE11S_PREP: + if (DynamicCast ((*i)) == 0) + { + return false; + } + if (DynamicCast ((*j)) == 0) + { + return false; + } + if (!(*DynamicCast ((*i)) == *DynamicCast ((*j)))) + { + return false; + } + + break; + case IE11S_PERR: + if (DynamicCast ((*i)) == 0) + { + return false; + } + if (DynamicCast ((*j)) == 0) + { + return false; + } + if (!(*DynamicCast ((*i)) == *DynamicCast ((*j)))) + { + return false; + } + break; + case IE11S_MESH_PEERING_PROTOCOL_VERSION: + break; + default: + NS_FATAL_ERROR ("Information element " << (uint16_t) id << " is not implemented"); + return false; + } } return true; } @@ -241,15 +378,91 @@ WifiInformationElementVectorBist::RunTests () { bool result = true; WifiInformationElementVector vector; - vector.AddInformationElement (Create ()); - vector.AddInformationElement (Create ()); - vector.AddInformationElement (Create ()); - vector.AddInformationElement (Create ()); - vector.AddInformationElement (Create ()); - vector.AddInformationElement (Create ()); - vector.AddInformationElement (Create ()); - vector.AddInformationElement (Create ()); - vector.AddInformationElement (Create ()); + { + //Mesh ID test + Ptr meshId = Create ("qwerty"); + vector.AddInformationElement (meshId); + } + { + Ptr config = Create (); + vector.AddInformationElement (config); + } + { + Ptr report = Create (123456); + vector.AddInformationElement (report); + } + { + Ptr peerMan1 = Create (); + peerMan1->SetPeerOpen (1); + Ptr peerMan2 = Create (); + peerMan2->SetPeerConfirm (1, 2); + Ptr peerMan3 = Create (); + peerMan3->SetPeerClose (1, 2, dot11s::REASON11S_MESH_CAPABILITY_POLICY_VIOLATION); + vector.AddInformationElement (peerMan1); + vector.AddInformationElement (peerMan2); + vector.AddInformationElement (peerMan3); + } + { + Ptr beaconTiming = Create (); + beaconTiming->AddNeighboursTimingElementUnit (1, Seconds (1.0), Seconds (4.0)); + beaconTiming->AddNeighboursTimingElementUnit (2, Seconds (2.0), Seconds (3.0)); + beaconTiming->AddNeighboursTimingElementUnit (3, Seconds (3.0), Seconds (2.0)); + beaconTiming->AddNeighboursTimingElementUnit (4, Seconds (4.0), Seconds (1.0)); + vector.AddInformationElement (beaconTiming); + } + { + Ptr rann = Create (); + rann->SetFlags (1); + rann->SetHopcount (2); + rann->SetTTL (4); + rann->DecrementTtl (); + NS_TEST_ASSERT_EQUAL (rann->GetTtl (), 3); + rann->SetOriginatorAddress (Mac48Address ("11:22:33:44:55:66")); + rann->SetDestSeqNumber (5); + rann->SetMetric (6); + rann->IncrementMetric (2); + NS_TEST_ASSERT_EQUAL (rann->GetMetric (), 8); + vector.AddInformationElement (rann); + } + { + Ptr preq = Create (); + preq->SetHopcount (0); + preq->SetTTL (1); + preq->SetPreqID (2); + preq->SetOriginatorAddress (Mac48Address ("11:22:33:44:55:66")); + preq->SetOriginatorSeqNumber (3); + preq->SetLifetime (4); + preq->AddDestinationAddressElement (false, false, Mac48Address ("11:11:11:11:11:11"), 5); + preq->AddDestinationAddressElement (false, false, Mac48Address ("22:22:22:22:22:22"), 6); + vector.AddInformationElement (preq); + } + { + Ptr prep = Create (); + prep->SetFlags (12); + prep->SetHopcount (11); + prep->SetTtl (10); + prep->SetDestinationAddress (Mac48Address ("11:22:33:44:55:66")); + prep->SetDestinationSeqNumber (123); + prep->SetLifetime (5000); + prep->SetMetric (4321); + prep->SetOriginatorAddress (Mac48Address ("33:00:22:00:11:00")); + prep->SetOriginatorSeqNumber (666); + vector.AddInformationElement (prep); + } + { + Ptr perr = Create (); + dot11s::IePerr::FailedDestination dest; + dest.destination = Mac48Address ("11:22:33:44:55:66"); + dest.seqnum = 1; + perr->AddAddressUnit (dest); + dest.destination = Mac48Address ("10:20:30:40:50:60"); + dest.seqnum = 2; + perr->AddAddressUnit (dest); + dest.destination = Mac48Address ("01:02:03:04:05:06"); + dest.seqnum = 3; + perr->AddAddressUnit (dest); + vector.AddInformationElement (perr); + } Ptr packet = Create (); packet->AddHeader (vector); WifiInformationElementVector resultVector;