22 #include "ns3/ipv4-header.h"
23 #include "ns3/olsr-repositories.h"
24 #include "ns3/olsr-routing-protocol.h"
46 void DoRun()
override;
50 :
TestCase(
"Check OLSR MPR computing mechanism")
63 OlsrState& state = protocol->m_state;
72 NeighborTuple neighbor;
73 neighbor.status = NeighborTuple::STATUS_SYM;
75 neighbor.neighborMainAddr =
Ipv4Address(
"10.0.0.2");
76 protocol->m_state.InsertNeighborTuple(neighbor);
77 neighbor.neighborMainAddr =
Ipv4Address(
"10.0.0.3");
78 protocol->m_state.InsertNeighborTuple(neighbor);
79 TwoHopNeighborTuple tuple;
80 tuple.expirationTime =
Seconds(3600);
83 protocol->m_state.InsertTwoHopNeighborTuple(tuple);
86 protocol->m_state.InsertTwoHopNeighborTuple(tuple);
88 protocol->MprComputation();
99 protocol->m_state.InsertTwoHopNeighborTuple(tuple);
101 protocol->MprComputation();
102 MprSet mpr = state.GetMprSet();
106 "Node 1 must select node 2 as MPR");
117 tuple.twoHopNeighborAddr =
Ipv4Address(
"10.0.0.6");
118 protocol->m_state.InsertTwoHopNeighborTuple(tuple);
120 protocol->MprComputation();
121 mpr = state.GetMprSet();
125 "Node 1 must select node 2 as MPR");
128 "Node 1 must select node 3 as MPR");
141 neighbor.neighborMainAddr =
Ipv4Address(
"10.0.0.7");
142 protocol->m_state.InsertNeighborTuple(neighbor);
144 protocol->MprComputation();
145 mpr = state.GetMprSet();
149 "Node 1 must select node 7 as MPR");
163 neighbor.neighborMainAddr =
Ipv4Address(
"10.0.0.8");
164 protocol->m_state.InsertNeighborTuple(neighbor);
166 tuple.twoHopNeighborAddr =
Ipv4Address(
"10.0.0.9");
167 protocol->m_state.InsertTwoHopNeighborTuple(tuple);
169 protocol->MprComputation();
170 mpr = state.GetMprSet();
174 "Node 1 must NOT select node 8 as MPR");
Testcase for MPR computation mechanism.
~OlsrMprTestCase() override
void DoRun() override
Implementation to actually run this TestCase.
OLSR protocol test suite.
Ipv4 addresses are stored in host order in this class.
Smart pointer class similar to boost::intrusive_ptr.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
std::set< Ipv4Address > MprSet
MPR Set type.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static OlsrProtocolTestSuite g_olsrProtocolTestSuite
Static variable for test initialization.