22 #include "ns3/ipv4-header.h"
23 #include "ns3/olsr-routing-protocol.h"
34 #define OLSR_WILL_NEVER 0
36 #define OLSR_WILL_LOW 1
38 #define OLSR_WILL_DEFAULT 3
40 #define OLSR_WILL_HIGH 6
42 #define OLSR_WILL_ALWAYS 7
58 void DoRun()
override;
62 :
TestCase(
"Check OLSR MPR computing mechanism")
75 OlsrState& state = protocol->m_state;
84 NeighborTuple neighbor;
85 neighbor.status = NeighborTuple::STATUS_SYM;
87 neighbor.neighborMainAddr =
Ipv4Address(
"10.0.0.2");
88 protocol->m_state.InsertNeighborTuple(neighbor);
89 neighbor.neighborMainAddr =
Ipv4Address(
"10.0.0.3");
90 protocol->m_state.InsertNeighborTuple(neighbor);
91 TwoHopNeighborTuple tuple;
92 tuple.expirationTime =
Seconds(3600);
95 protocol->m_state.InsertTwoHopNeighborTuple(tuple);
98 protocol->m_state.InsertTwoHopNeighborTuple(tuple);
100 protocol->MprComputation();
110 tuple.twoHopNeighborAddr =
Ipv4Address(
"10.0.0.5");
111 protocol->m_state.InsertTwoHopNeighborTuple(tuple);
113 protocol->MprComputation();
114 MprSet mpr = state.GetMprSet();
118 "Node 1 must select node 2 as MPR");
129 tuple.twoHopNeighborAddr =
Ipv4Address(
"10.0.0.6");
130 protocol->m_state.InsertTwoHopNeighborTuple(tuple);
132 protocol->MprComputation();
133 mpr = state.GetMprSet();
137 "Node 1 must select node 2 as MPR");
140 "Node 1 must select node 3 as MPR");
153 neighbor.neighborMainAddr =
Ipv4Address(
"10.0.0.7");
154 protocol->m_state.InsertNeighborTuple(neighbor);
156 protocol->MprComputation();
157 mpr = state.GetMprSet();
161 "Node 1 must select node 7 as MPR");
175 neighbor.neighborMainAddr =
Ipv4Address(
"10.0.0.8");
176 protocol->m_state.InsertNeighborTuple(neighbor);
178 tuple.twoHopNeighborAddr =
Ipv4Address(
"10.0.0.9");
179 protocol->m_state.InsertTwoHopNeighborTuple(tuple);
181 protocol->MprComputation();
182 mpr = state.GetMprSet();
186 "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.
#define OLSR_WILL_DEFAULT
Willingness for forwarding packets from other nodes: medium.
#define OLSR_WILL_NEVER
Willingness for forwarding packets from other nodes: never.
#define OLSR_WILL_ALWAYS
Willingness for forwarding packets from other nodes: always.
static OlsrProtocolTestSuite g_olsrProtocolTestSuite
Static variable for test initialization.