Index: src/dsr/test/dsr-test-suite.cc |
=================================================================== |
--- a/src/dsr/test/dsr-test-suite.cc |
+++ b/src/dsr/test/dsr-test-suite.cc |
@@ -27,6 +27,8 @@ |
* under grant CNS-0626918 (Postmodern Internet Architecture), |
* NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI), |
* US Department of Defense (DoD), and ITTC at The University of Kansas. |
+ * |
+ * Author of LEAR modification: Tomasz Seweryn <tomasz.seweryn7@gmail.com> |
*/ |
#include <vector> |
@@ -331,6 +333,180 @@ |
NS_TEST_EXPECT_MSG_EQ (bytes, 12, "Total RREP is 12 bytes long"); |
} |
// ----------------------------------------------------------------------------- |
+// / Unit test for DROP_RREQ |
+class DsrDropRreqHeaderTest : public TestCase |
+{ |
+public: |
+ DsrDropRreqHeaderTest (); |
+ ~DsrDropRreqHeaderTest (); |
+ virtual void |
+ DoRun (void); |
+}; |
+DsrDropRreqHeaderTest::DsrDropRreqHeaderTest () |
+ : TestCase ("DSR DROP_RREQ") |
+{ |
+} |
+DsrDropRreqHeaderTest::~DsrDropRreqHeaderTest () |
+{ |
+} |
+void |
+DsrDropRreqHeaderTest::DoRun () |
+{ |
+ dsr::DsrOptionDropRReqHeader h; |
+ std::vector<Ipv4Address> nodeList; |
+ nodeList.push_back (Ipv4Address ("1.1.1.0")); |
+ nodeList.push_back (Ipv4Address ("1.1.1.1")); |
+ nodeList.push_back (Ipv4Address ("1.1.1.2")); |
+ |
+ h.SetTarget (Ipv4Address ("1.1.1.3")); |
+ NS_TEST_EXPECT_MSG_EQ (h.GetTarget (), Ipv4Address ("1.1.1.3"), "trivial"); |
+ h.SetNodesAddresses (nodeList); |
+ NS_TEST_EXPECT_MSG_EQ (h.GetNodeAddress (0), Ipv4Address ("1.1.1.0"), "trivial"); |
+ NS_TEST_EXPECT_MSG_EQ (h.GetNodeAddress (1), Ipv4Address ("1.1.1.1"), "trivial"); |
+ NS_TEST_EXPECT_MSG_EQ (h.GetNodeAddress (2), Ipv4Address ("1.1.1.2"), "trivial"); |
+ h.SetId (1); |
+ NS_TEST_EXPECT_MSG_EQ (h.GetId (), 1, "trivial"); |
+ |
+ Ptr<Packet> p = Create<Packet> (); |
+ dsr::DsrRoutingHeader header; |
+ header.AddDsrOption (h); |
+ p->AddHeader (header); |
+ p->RemoveAtStart (8); |
+ dsr::DsrOptionDropRReqHeader h2; |
+ h2.SetNumberOfAddresses (3); |
+ uint32_t bytes = p->RemoveHeader (h2); |
+ NS_TEST_EXPECT_MSG_EQ (bytes, 20, "Total RREP is 20 bytes long"); |
+} |
+// ----------------------------------------------------------------------------- |
+// / Unit test for ROUTE_CACHE |
+class DsrRouteCacheHeaderTest : public TestCase |
+{ |
+public: |
+ DsrRouteCacheHeaderTest (); |
+ ~DsrRouteCacheHeaderTest (); |
+ virtual void |
+ DoRun (void); |
+}; |
+DsrRouteCacheHeaderTest::DsrRouteCacheHeaderTest () |
+ : TestCase ("DSR ROUTE_CACHE") |
+{ |
+} |
+DsrRouteCacheHeaderTest::~DsrRouteCacheHeaderTest () |
+{ |
+} |
+void |
+DsrRouteCacheHeaderTest::DoRun () |
+{ |
+ dsr::DsrOptionRCacheHeader h; |
+ std::vector<Ipv4Address> nodeList; |
+ nodeList.push_back (Ipv4Address ("1.1.1.0")); |
+ nodeList.push_back (Ipv4Address ("1.1.1.1")); |
+ nodeList.push_back (Ipv4Address ("1.1.1.2")); |
+ |
+ h.SetMiddle (Ipv4Address ("1.1.1.3")); |
+ NS_TEST_EXPECT_MSG_EQ (h.GetMiddle (), Ipv4Address ("1.1.1.3"), "trivial"); |
+ h.SetNodesAddresses (nodeList); |
+ NS_TEST_EXPECT_MSG_EQ (h.GetNodeAddress (0), Ipv4Address ("1.1.1.0"), "trivial"); |
+ NS_TEST_EXPECT_MSG_EQ (h.GetNodeAddress (1), Ipv4Address ("1.1.1.1"), "trivial"); |
+ NS_TEST_EXPECT_MSG_EQ (h.GetNodeAddress (2), Ipv4Address ("1.1.1.2"), "trivial"); |
+ h.SetId (1); |
+ NS_TEST_EXPECT_MSG_EQ (h.GetId (), 1, "trivial"); |
+ |
+ Ptr<Packet> p = Create<Packet> (); |
+ dsr::DsrRoutingHeader header; |
+ header.AddDsrOption (h); |
+ p->AddHeader (header); |
+ p->RemoveAtStart (8); |
+ dsr::DsrOptionRCacheHeader h2; |
+ h2.SetNumberOfAddresses (3); |
+ uint32_t bytes = p->RemoveHeader (h2); |
+ NS_TEST_EXPECT_MSG_EQ (bytes, 20, "Total RREP is 20 bytes long"); |
+} |
+// ----------------------------------------------------------------------------- |
+// / Unit test for DROP_ROUTE_CACHE |
+class DsrDropRouteCacheHeaderTest : public TestCase |
+{ |
+public: |
+ DsrDropRouteCacheHeaderTest (); |
+ ~DsrDropRouteCacheHeaderTest (); |
+ virtual void |
+ DoRun (void); |
+}; |
+DsrDropRouteCacheHeaderTest::DsrDropRouteCacheHeaderTest () |
+ : TestCase ("DSR DROP_ROUTE_CACHE") |
+{ |
+} |
+DsrDropRouteCacheHeaderTest::~DsrDropRouteCacheHeaderTest () |
+{ |
+} |
+void |
+DsrDropRouteCacheHeaderTest::DoRun () |
+{ |
+ dsr::DsrOptionDropRCacheHeader h; |
+ std::vector<Ipv4Address> nodeList; |
+ nodeList.push_back (Ipv4Address ("1.1.1.0")); |
+ nodeList.push_back (Ipv4Address ("1.1.1.1")); |
+ nodeList.push_back (Ipv4Address ("1.1.1.2")); |
+ |
+ h.SetNodesAddresses (nodeList); |
+ NS_TEST_EXPECT_MSG_EQ (h.GetNodeAddress (0), Ipv4Address ("1.1.1.0"), "trivial"); |
+ NS_TEST_EXPECT_MSG_EQ (h.GetNodeAddress (1), Ipv4Address ("1.1.1.1"), "trivial"); |
+ NS_TEST_EXPECT_MSG_EQ (h.GetNodeAddress (2), Ipv4Address ("1.1.1.2"), "trivial"); |
+ h.SetId (1); |
+ NS_TEST_EXPECT_MSG_EQ (h.GetId (), 1, "trivial"); |
+ |
+ Ptr<Packet> p = Create<Packet> (); |
+ dsr::DsrRoutingHeader header; |
+ header.AddDsrOption (h); |
+ p->AddHeader (header); |
+ p->RemoveAtStart (8); |
+ dsr::DsrOptionDropRCacheHeader h2; |
+ h2.SetNumberOfAddresses (3); |
+ uint32_t bytes = p->RemoveHeader (h2); |
+ NS_TEST_EXPECT_MSG_EQ (bytes, 16, "Total RREP is 16 bytes long"); |
+} |
+// ----------------------------------------------------------------------------- |
+// / Unit test for CANCEL_ROUTE_CACHE |
+class DsrCancelRouteCacheHeaderTest : public TestCase |
+{ |
+public: |
+ DsrCancelRouteCacheHeaderTest (); |
+ ~DsrCancelRouteCacheHeaderTest (); |
+ virtual void |
+ DoRun (void); |
+}; |
+DsrCancelRouteCacheHeaderTest::DsrCancelRouteCacheHeaderTest () |
+ : TestCase ("DSR DROP_ROUTE_CACHE") |
+{ |
+} |
+DsrCancelRouteCacheHeaderTest::~DsrCancelRouteCacheHeaderTest () |
+{ |
+} |
+void |
+DsrCancelRouteCacheHeaderTest::DoRun () |
+{ |
+ dsr::DsrOptionCancelRCacheHeader h; |
+ std::vector<Ipv4Address> nodeList; |
+ nodeList.push_back (Ipv4Address ("1.1.1.0")); |
+ nodeList.push_back (Ipv4Address ("1.1.1.1")); |
+ nodeList.push_back (Ipv4Address ("1.1.1.2")); |
+ |
+ h.SetNodesAddresses (nodeList); |
+ NS_TEST_EXPECT_MSG_EQ (h.GetNodeAddress (0), Ipv4Address ("1.1.1.0"), "trivial"); |
+ NS_TEST_EXPECT_MSG_EQ (h.GetNodeAddress (1), Ipv4Address ("1.1.1.1"), "trivial"); |
+ NS_TEST_EXPECT_MSG_EQ (h.GetNodeAddress (2), Ipv4Address ("1.1.1.2"), "trivial"); |
+ |
+ Ptr<Packet> p = Create<Packet> (); |
+ dsr::DsrRoutingHeader header; |
+ header.AddDsrOption (h); |
+ p->AddHeader (header); |
+ p->RemoveAtStart (8); |
+ dsr::DsrOptionCancelRCacheHeader h2; |
+ h2.SetNumberOfAddresses (3); |
+ uint32_t bytes = p->RemoveHeader (h2); |
+ NS_TEST_EXPECT_MSG_EQ (bytes, 20, "Total RREP is 20 bytes long"); |
+} |
+// ----------------------------------------------------------------------------- |
// / Unit test for DSR route cache entry |
class DsrCacheEntryTest : public TestCase |
{ |
@@ -515,6 +691,10 @@ |
AddTestCase (new DsrRerrHeaderTest, TestCase::QUICK); |
AddTestCase (new DsrAckReqHeaderTest, TestCase::QUICK); |
AddTestCase (new DsrAckHeaderTest, TestCase::QUICK); |
+ AddTestCase (new DsrDropRreqHeaderTest, TestCase::QUICK); |
+ AddTestCase (new DsrRouteCacheHeaderTest, TestCase::QUICK); |
+ AddTestCase (new DsrDropRouteCacheHeaderTest, TestCase::QUICK); |
+ AddTestCase (new DsrCancelRouteCacheHeaderTest, TestCase::QUICK); |
AddTestCase (new DsrCacheEntryTest, TestCase::QUICK); |
AddTestCase (new DsrSendBuffTest, TestCase::QUICK); |
} |