21 #include "ns3/packet.h"
22 #include "ns3/simulator.h"
23 #include "ns3/mgt-headers.h"
24 #include "ns3/dot11s-mac-header.h"
25 #include "ns3/hwmp-rtable.h"
26 #include "ns3/peer-link-frame.h"
27 #include "ns3/ie-dot11s-peer-management.h"
36 TestCase (
"Dot11sMeshHeader roundtrip serialization")
57 NS_TEST_ASSERT_MSG_EQ (a, b,
"Mesh header roundtrip serialization works, 3 addresses");
70 NS_TEST_ASSERT_MSG_EQ (a, b,
"Mesh header roundtrip serialization works, 2 addresses");
82 NS_TEST_ASSERT_MSG_EQ (a, b,
"Mesh header roundtrip serialization works, 1 address");
91 virtual void DoRun ();
107 void TestPrecursorAdd ();
108 void TestPrecursorFind ();
118 std::vector<Mac48Address> precursors;
121 HwmpRtableTest::HwmpRtableTest () :
123 dst (
"01:00:00:01:00:01"),
124 hop (
"01:00:00:01:00:03"),
130 precursors.push_back (
Mac48Address (
"00:10:20:30:40:50"));
131 precursors.push_back (
Mac48Address (
"00:11:22:33:44:55"));
132 precursors.push_back (
Mac48Address (
"00:01:02:03:04:05"));
141 table->AddReactivePath (dst, hop, iface, metric, expire, seqnum);
142 NS_TEST_EXPECT_MSG_EQ ((table->LookupReactive (dst) == correct),
true,
"Reactive lookup works");
143 table->DeleteReactivePath (dst);
144 NS_TEST_EXPECT_MSG_EQ (table->LookupReactive (dst).IsValid (),
false,
"Reactive lookup works");
147 table->AddProactivePath (metric, dst, hop, iface, expire, seqnum);
148 NS_TEST_EXPECT_MSG_EQ ((table->LookupProactive () == correct),
true,
"Proactive lookup works");
149 table->DeleteProactivePath (dst);
150 NS_TEST_EXPECT_MSG_EQ (table->LookupProactive ().IsValid (),
false,
"Proactive lookup works");
154 HwmpRtableTest::TestAddPath ()
156 table->AddReactivePath (dst, hop, iface, metric, expire, seqnum);
157 table->AddProactivePath (metric, dst, hop, iface, expire, seqnum);
161 HwmpRtableTest::TestExpire ()
165 NS_TEST_EXPECT_MSG_EQ ((table->LookupReactiveExpired (dst) == correct),
true,
"Reactive expiration works");
166 NS_TEST_EXPECT_MSG_EQ ((table->LookupProactiveExpired () == correct),
true,
"Proactive expiration works");
168 NS_TEST_EXPECT_MSG_EQ (table->LookupReactive (dst).IsValid (),
false,
"Reactive expiration works");
169 NS_TEST_EXPECT_MSG_EQ (table->LookupProactive ().IsValid (),
false,
"Proactive expiration works");
173 HwmpRtableTest::TestPrecursorAdd ()
175 for (std::vector<Mac48Address>::const_iterator i = precursors.begin (); i != precursors.end (); i++)
177 table->AddPrecursor (dst, iface, *i,
Seconds (100));
179 table->AddPrecursor (dst, iface, *i,
Seconds (100));
184 HwmpRtableTest::TestPrecursorFind ()
187 NS_TEST_EXPECT_MSG_EQ (precursors.size (), precursorList.size (),
"Precursors size works");
188 for (
unsigned i = 0; i < precursors.size (); i++)
190 NS_TEST_EXPECT_MSG_EQ (precursorList[i].first, iface,
"Precursors lookup works");
191 NS_TEST_EXPECT_MSG_EQ (precursorList[i].second, precursors[i],
"Precursors lookup works");
198 table = CreateObject<HwmpRtable> ();
214 TestCase (
"PeerLinkFrames (open, confirm, close) unit tests")
217 virtual void DoRun ();
226 fields.subtype = (uint8_t)(WifiActionHeader::PEER_LINK_OPEN);
227 fields.capability = 0;
229 fields.reasonCode = 12;
230 fields.meshId =
IeMeshId (
"qwertyuiop");
231 a.SetPlinkFrameStart (fields);
237 NS_TEST_EXPECT_MSG_EQ (a, b,
"PEER_LINK_OPEN works");
242 fields.subtype = (uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM);
243 fields.capability = 0;
245 fields.reasonCode = 12;
246 fields.meshId =
IeMeshId (
"qwerty");
247 a.SetPlinkFrameStart (fields);
253 NS_TEST_EXPECT_MSG_EQ (a, b,
"PEER_LINK_CONFIRM works");
258 fields.subtype = (uint8_t)(WifiActionHeader::PEER_LINK_CLOSE);
259 fields.capability = 0;
262 fields.reasonCode = 12;
263 a.SetPlinkFrameStart (fields);
269 NS_TEST_EXPECT_MSG_EQ (a, b,
"PEER_LINK_CLOSE works");
279 Dot11sTestSuite::Dot11sTestSuite ()
280 :
TestSuite (
"devices-mesh-dot11s", UNIT)
uint32_t RemoveHeader(Header &header)
Unit test for HwmpRtable.
802.11s Peer link management frame
void SetPlinkFrameSubtype(uint8_t subtype)
Route lookup result, return type of LookupXXX methods.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
void TestLookup()
Test Add apth and lookup path;.
a IEEE 802.11s Mesh ID 7.3.287 of 802.11s draft 3.0
virtual void DoRun()
Implementation to actually run this test case.
std::vector< std::pair< uint32_t, Mac48Address > > PrecursorList
Path precursor = {MAC, interface ID}.
TestCase(std::string name)
static void Destroy(void)
virtual void DoRun()
Implementation to actually run this test case.
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Built-in self test for PeerLinkFrameStart.
void AddHeader(const Header &header)