24 #include "ns3/olsr-routing-protocol.h"
25 #include "ns3/ipv4-header.h"
30 #define OLSR_WILL_NEVER 0
31 #define OLSR_WILL_LOW 1
33 #define OLSR_WILL_DEFAULT 3
35 #define OLSR_WILL_HIGH 6
37 #define OLSR_WILL_ALWAYS 7
49 virtual void DoRun (
void);
55 :
TestCase (
"Check OLSR MPR computing mechanism")
66 OlsrState & state = protocol->m_state;
75 NeighborTuple neigbor;
76 neigbor.status = NeighborTuple::STATUS_SYM;
78 neigbor.neighborMainAddr =
Ipv4Address (
"10.0.0.2");
79 protocol->m_state.InsertNeighborTuple (neigbor);
80 neigbor.neighborMainAddr =
Ipv4Address (
"10.0.0.3");
81 protocol->m_state.InsertNeighborTuple (neigbor);
82 TwoHopNeighborTuple tuple;
83 tuple.expirationTime =
Seconds (3600);
85 tuple.twoHopNeighborAddr =
Ipv4Address (
"10.0.0.4");
86 protocol->m_state.InsertTwoHopNeighborTuple (tuple);
88 tuple.twoHopNeighborAddr =
Ipv4Address (
"10.0.0.4");
89 protocol->m_state.InsertTwoHopNeighborTuple (tuple);
91 protocol->MprComputation ();
101 tuple.twoHopNeighborAddr =
Ipv4Address (
"10.0.0.5");
102 protocol->m_state.InsertTwoHopNeighborTuple (tuple);
104 protocol->MprComputation ();
105 MprSet mpr = state.GetMprSet ();
107 NS_TEST_EXPECT_MSG_EQ ((mpr.find (
"10.0.0.2") != mpr.end ()),
true,
"Node 1 must select node 2 as MPR");
118 tuple.twoHopNeighborAddr =
Ipv4Address (
"10.0.0.6");
119 protocol->m_state.InsertTwoHopNeighborTuple (tuple);
121 protocol->MprComputation ();
122 mpr = state.GetMprSet ();
124 NS_TEST_EXPECT_MSG_EQ ((mpr.find (
"10.0.0.2") != mpr.end ()),
true,
"Node 1 must select node 2 as MPR");
125 NS_TEST_EXPECT_MSG_EQ ((mpr.find (
"10.0.0.3") != mpr.end ()),
true,
"Node 1 must select node 3 as MPR");
138 neigbor.neighborMainAddr =
Ipv4Address (
"10.0.0.7");
139 protocol->m_state.InsertNeighborTuple (neigbor);
141 protocol->MprComputation ();
142 mpr = state.GetMprSet ();
144 NS_TEST_EXPECT_MSG_EQ ((mpr.find (
"10.0.0.7") != mpr.end ()),
true,
"Node 1 must select node 7 as MPR");
158 neigbor.neighborMainAddr =
Ipv4Address (
"10.0.0.8");
159 protocol->m_state.InsertNeighborTuple (neigbor);
161 tuple.twoHopNeighborAddr =
Ipv4Address (
"10.0.0.9");
162 protocol->m_state.InsertTwoHopNeighborTuple (tuple);
164 protocol->MprComputation ();
165 mpr = state.GetMprSet ();
167 NS_TEST_EXPECT_MSG_EQ ((mpr.find (
"10.0.0.9") == mpr.end ()),
true,
"Node 1 must NOT select node 8 as MPR");
#define OLSR_WILL_ALWAYS
Willingness for forwarding packets from other nodes: always.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
OlsrProtocolTestSuite g_olsrProtocolTestSuite
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
#define OLSR_WILL_NEVER
Willingness for forwarding packets from other nodes: never.
Ipv4 addresses are stored in host order in this class.
virtual void DoRun(void)
Run test case.
std::set< Ipv4Address > MprSet
MPR Set type.
Time Seconds(double value)
Construct a Time in the indicated unit.
#define OLSR_WILL_DEFAULT
Willingness for forwarding packets from other nodes: medium.
Testcase for MPR computation mechanism.