24 #include "ns3/olsr-routing-protocol.h"    25 #include "ns3/ipv4-header.h"    36 #define OLSR_WILL_NEVER         0    37 #define OLSR_WILL_LOW           1    39 #define OLSR_WILL_DEFAULT       3    41 #define OLSR_WILL_HIGH          6    43 #define OLSR_WILL_ALWAYS        7    61   virtual void DoRun (
void);
    66   : 
TestCase (
"Check OLSR MPR computing mechanism")
    77   OlsrState & state = protocol->m_state;
    86   NeighborTuple neigbor;
    87   neigbor.status = NeighborTuple::STATUS_SYM;
    89   neigbor.neighborMainAddr = 
Ipv4Address (
"10.0.0.2");
    90   protocol->m_state.InsertNeighborTuple (neigbor);
    91   neigbor.neighborMainAddr = 
Ipv4Address (
"10.0.0.3");
    92   protocol->m_state.InsertNeighborTuple (neigbor);
    93   TwoHopNeighborTuple tuple;
    94   tuple.expirationTime = 
Seconds (3600);
    96   tuple.twoHopNeighborAddr = 
Ipv4Address (
"10.0.0.4");
    97   protocol->m_state.InsertTwoHopNeighborTuple (tuple);
    99   tuple.twoHopNeighborAddr = 
Ipv4Address (
"10.0.0.4");
   100   protocol->m_state.InsertTwoHopNeighborTuple (tuple);
   102   protocol->MprComputation ();
   112   tuple.twoHopNeighborAddr = 
Ipv4Address (
"10.0.0.5");
   113   protocol->m_state.InsertTwoHopNeighborTuple (tuple);
   115   protocol->MprComputation ();
   116   MprSet mpr = state.GetMprSet ();
   118   NS_TEST_EXPECT_MSG_EQ ((mpr.find (
"10.0.0.2") != mpr.end ()), 
true, 
"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 ();
   135   NS_TEST_EXPECT_MSG_EQ ((mpr.find (
"10.0.0.2") != mpr.end ()), 
true, 
"Node 1 must select node 2 as MPR");
   136   NS_TEST_EXPECT_MSG_EQ ((mpr.find (
"10.0.0.3") != mpr.end ()), 
true, 
"Node 1 must select node 3 as MPR");
   149   neigbor.neighborMainAddr = 
Ipv4Address (
"10.0.0.7");
   150   protocol->m_state.InsertNeighborTuple (neigbor);
   152   protocol->MprComputation ();
   153   mpr = state.GetMprSet ();
   155   NS_TEST_EXPECT_MSG_EQ ((mpr.find (
"10.0.0.7") != mpr.end ()), 
true, 
"Node 1 must select node 7 as MPR");
   169   neigbor.neighborMainAddr = 
Ipv4Address (
"10.0.0.8");
   170   protocol->m_state.InsertNeighborTuple (neigbor);
   172   tuple.twoHopNeighborAddr = 
Ipv4Address (
"10.0.0.9");
   173   protocol->m_state.InsertTwoHopNeighborTuple (tuple);
   175   protocol->MprComputation ();
   176   mpr = state.GetMprSet ();
   178   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. 
OLSR protocol 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. 
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite. 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
static OlsrProtocolTestSuite g_olsrProtocolTestSuite
Static variable for test initialization. 
#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)
Implementation to actually run this TestCase. 
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.