model+NFD: Re-enable tracing for sentInterests/Data/Nacks
Change-Id: If7329004b82afd66a09fcf35d1e938006183b34b
diff --git a/NFD b/NFD
index 85d60eb..bc600d7 160000
--- a/NFD
+++ b/NFD
@@ -1 +1 @@
-Subproject commit 85d60ebaa89fb0a28cad336ff8576fb067847291
+Subproject commit bc600d7ccc3d2bf27e8305cc1d2a5780e10c81d4
diff --git a/model/ndn-l3-protocol.cpp b/model/ndn-l3-protocol.cpp
index 8556db7..33e0113 100644
--- a/model/ndn-l3-protocol.cpp
+++ b/model/ndn-l3-protocol.cpp
@@ -424,13 +424,25 @@
this->m_inData(data, *face);
}
});
+ // TODO Add nack signals
- // TODO: Discover why these signal were removed and fix it
+ auto tracingLink = face->getLinkService();
+ NS_LOG_LOGIC("Adding trace sources for afterSendInterest and afterSendData");
+ tracingLink->afterSendInterest.connect([this, weakFace](const Interest& interest) {
+ shared_ptr<Face> face = weakFace.lock();
+ if (face != nullptr) {
+ this->m_outInterests(interest, *face);
+ }
+ });
- // face->afterSendInterest.connect
- // ([this, weakFace](const Interest& interest) { this->m_outInterests(interest, *face); });
+ tracingLink->afterSendData.connect([this, weakFace](const Data& data) {
+ shared_ptr<Face> face = weakFace.lock();
+ if (face != nullptr) {
+ this->m_outData(data, *face);
+ }
+ });
- // face->afterSendData.connect([this, weakFace](const Data& data) { this->m_outData(data, *face); });
+ // TODO Add nack signals
return face->getId();
}
diff --git a/tests/unit-tests/model/ndn-net-device-face.t.cpp b/tests/unit-tests/model/ndn-net-device-face.t.cpp
index 5269ed9..c33afdb 100644
--- a/tests/unit-tests/model/ndn-net-device-face.t.cpp
+++ b/tests/unit-tests/model/ndn-net-device-face.t.cpp
@@ -27,7 +27,43 @@
BOOST_FIXTURE_TEST_SUITE(ModelNdnNetDeviceFace, ScenarioHelperWithCleanupFixture)
-BOOST_AUTO_TEST_CASE(Basic)
+class FixtureWithTracers : public ScenarioHelperWithCleanupFixture
+{
+public:
+ void
+ InInterests(const Interest&, const Face& face)
+ {
+ nInInterests[boost::lexical_cast<std::string>(face)] += 1;
+ }
+
+ void
+ OutInterests(const Interest&, const Face& face)
+ {
+ nOutInterests[boost::lexical_cast<std::string>(face)] += 1;
+ }
+
+ void
+ InData(const Data&, const Face& face)
+ {
+ nInData[boost::lexical_cast<std::string>(face)] += 1;
+ }
+
+ void
+ OutData(const Data&, const Face& face)
+ {
+ nOutData[boost::lexical_cast<std::string>(face)] += 1;
+ }
+
+public:
+ std::map<std::string, uint32_t> nInInterests;
+ std::map<std::string, uint32_t> nOutInterests;
+ std::map<std::string, uint32_t> nInData;
+ std::map<std::string, uint32_t> nOutData;
+
+ // TODO add NACKs
+};
+
+BOOST_FIXTURE_TEST_CASE(Basic, FixtureWithTracers)
{
Config::SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue("10Mbps"));
Config::SetDefault("ns3::PointToPointChannel::Delay", StringValue("10ms"));
@@ -55,14 +91,44 @@
"0s", "100s"}
});
+ Config::ConnectWithoutContext("/NodeList/*/$ns3::ndn::L3Protocol/InInterests", MakeCallback(&FixtureWithTracers::InInterests, this));
+ Config::ConnectWithoutContext("/NodeList/*/$ns3::ndn::L3Protocol/OutInterests", MakeCallback(&FixtureWithTracers::OutInterests, this));
+
+ Config::ConnectWithoutContext("/NodeList/*/$ns3::ndn::L3Protocol/InData", MakeCallback(&FixtureWithTracers::InData, this));
+ Config::ConnectWithoutContext("/NodeList/*/$ns3::ndn::L3Protocol/OutData", MakeCallback(&FixtureWithTracers::OutData, this));
+
+ // TODO: implement Nack testing
+ // Config::Connect("/NodeList/*/InNacks", ...);
+ // Config::Connect("/NodeList/*/OutNacks", ...);
+
Simulator::Stop(Seconds(20.001));
Simulator::Run();
+ BOOST_CHECK_EQUAL(getFace("1", "2")->getCounters().nInInterests, 0);
BOOST_CHECK_EQUAL(getFace("1", "2")->getCounters().nOutInterests, 100);
BOOST_CHECK_EQUAL(getFace("1", "2")->getCounters().nInData, 100);
+ BOOST_CHECK_EQUAL(getFace("1", "2")->getCounters().nOutData, 0);
+ BOOST_CHECK_EQUAL(getFace("1", "2")->getCounters().nInNacks, 0);
+ BOOST_CHECK_EQUAL(getFace("1", "2")->getCounters().nOutNacks, 0);
+
+ BOOST_CHECK_EQUAL(nInInterests [boost::lexical_cast<std::string>(*getFace("1", "2"))], 0);
+ BOOST_CHECK_EQUAL(nOutInterests[boost::lexical_cast<std::string>(*getFace("1", "2"))], 100);
+ BOOST_CHECK_EQUAL(nInData [boost::lexical_cast<std::string>(*getFace("1", "2"))], 100);
+ BOOST_CHECK_EQUAL(nOutData [boost::lexical_cast<std::string>(*getFace("1", "2"))], 0);
+ // TODO add nacks
BOOST_CHECK_EQUAL(getFace("2", "1")->getCounters().nInInterests, 100);
+ BOOST_CHECK_EQUAL(getFace("2", "1")->getCounters().nOutInterests, 0);
+ BOOST_CHECK_EQUAL(getFace("2", "1")->getCounters().nInData, 0);
BOOST_CHECK_EQUAL(getFace("2", "1")->getCounters().nOutData, 100);
+ BOOST_CHECK_EQUAL(getFace("2", "1")->getCounters().nInNacks, 0);
+ BOOST_CHECK_EQUAL(getFace("2", "1")->getCounters().nOutNacks, 0);
+
+ BOOST_CHECK_EQUAL(nInInterests [boost::lexical_cast<std::string>(*getFace("2", "1"))], 100);
+ BOOST_CHECK_EQUAL(nOutInterests[boost::lexical_cast<std::string>(*getFace("2", "1"))], 0);
+ BOOST_CHECK_EQUAL(nInData [boost::lexical_cast<std::string>(*getFace("2", "1"))], 0);
+ BOOST_CHECK_EQUAL(nOutData [boost::lexical_cast<std::string>(*getFace("2", "1"))], 100);
+ // TODO add nacks
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(*getFace("1", "2")), "netdev://[00:00:00:ff:ff:01]");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(*getFace("2", "1")), "netdev://[00:00:00:ff:ff:02]");