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);
54 OlsrMprTestCase::OlsrMprTestCase ()
55 :
TestCase (
"Check OLSR MPR computing mechanism")
58 OlsrMprTestCase::~OlsrMprTestCase ()
76 neigbor.status = NeighborTuple::STATUS_SYM;
79 protocol->m_state.InsertNeighborTuple (neigbor);
81 protocol->m_state.InsertNeighborTuple (neigbor);
86 protocol->m_state.InsertTwoHopNeighborTuple (tuple);
89 protocol->m_state.InsertTwoHopNeighborTuple (tuple);
91 protocol->MprComputation ();
92 NS_TEST_EXPECT_MSG_EQ (state.
GetMprSet ().size (), 1,
"An only address must be chosen.");
102 protocol->m_state.InsertTwoHopNeighborTuple (tuple);
104 protocol->MprComputation ();
106 NS_TEST_EXPECT_MSG_EQ (mpr.size (), 1,
"An only address must be chosen.");
107 NS_TEST_EXPECT_MSG_EQ ((mpr.find (
"10.0.0.2") != mpr.end ()),
true,
"Node 1 must select node 2 as MPR");
119 protocol->m_state.InsertTwoHopNeighborTuple (tuple);
121 protocol->MprComputation ();
123 NS_TEST_EXPECT_MSG_EQ (mpr.size (), 2,
"An only address must be chosen.");
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");
139 protocol->m_state.InsertNeighborTuple (neigbor);
141 protocol->MprComputation ();
143 NS_TEST_EXPECT_MSG_EQ (mpr.size (), 3,
"An only address must be chosen.");
144 NS_TEST_EXPECT_MSG_EQ ((mpr.find (
"10.0.0.7") != mpr.end ()),
true,
"Node 1 must select node 7 as MPR");
159 protocol->m_state.InsertNeighborTuple (neigbor);
162 protocol->m_state.InsertTwoHopNeighborTuple (tuple);
164 protocol->MprComputation ();
166 NS_TEST_EXPECT_MSG_EQ (mpr.size (), 3,
"An only address must be chosen.");
167 NS_TEST_EXPECT_MSG_EQ ((mpr.find (
"10.0.0.9") == mpr.end ()),
true,
"Node 1 must NOT select node 8 as MPR");
174 } g_olsrProtocolTestSuite;
176 OlsrProtocolTestSuite::OlsrProtocolTestSuite()
This class encapsulates all data structures needed for maintaining internal state of an OLSR node...
smart pointer class similar to boost::intrusive_ptr
Testcase for MPR computation mechanism.
virtual void DoRun(void)
Run test case.
uint8_t willingness
A value between 0 and 7 specifying the node's willingness to carry traffic on behalf of other nodes...
Time expirationTime
Time at which this tuple expires and must be removed.
Ipv4Address neighborMainAddr
Main address of a neighbor node.
Ipv4Address twoHopNeighborAddr
Main address of a 2-hop neighbor with a symmetric link to nb_main_addr.
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
Ipv4 addresses are stored in host order in this class.
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
MprSet GetMprSet() const
Gets an MPR Set needed by tests.
Ipv4Address neighborMainAddr
Main address of a neighbor.