Tracing
diff --git a/examples/abilene-topology.cc b/examples/abilene-topology.cc
index a96daf7..c0c1f16 100644
--- a/examples/abilene-topology.cc
+++ b/examples/abilene-topology.cc
@@ -26,6 +26,7 @@
#include "ns3/point-to-point-grid.h"
#include "ns3/ipv4-global-routing-helper.h"
#include "ns3/animation-interface.h"
+#include "ns3/ccnx-l3-protocol.h"
#include <iostream>
#include <sstream>
@@ -37,6 +38,14 @@
NS_LOG_COMPONENT_DEFINE ("CcnxAbileneTopology");
+int transmittedInterests = 0;
+int receivedInterests = 0;
+int droppedInterests = 0;
+
+int transmittedData = 0;
+int receivedData = 0;
+int droppedData = 0;
+
void PrintTime ()
{
NS_LOG_INFO (Simulator::Now ());
@@ -60,11 +69,47 @@
}
}
+static void OnTransmittedInterest (std::string context, Ptr<const CcnxInterestHeader> header,
+ Ptr<Ccnx> ccnx, Ptr<const CcnxFace> face)
+{
+ transmittedInterests++;
+}
+
+static void OnReceivedInterest (std::string context, Ptr<const CcnxInterestHeader> header,
+ Ptr<Ccnx> ccnx, Ptr<const CcnxFace> face)
+{
+ receivedInterests++;
+}
+
+static void OnDroppedInterest (std::string context, Ptr<const CcnxInterestHeader> header, CcnxL3Protocol::DropReason reason,
+ Ptr<Ccnx> ccnx, Ptr<const CcnxFace> face)
+{
+ droppedInterests++;
+}
+
+static void OnTransmittedData (std::string context, Ptr<const CcnxContentObjectHeader> header, Ptr<const Packet> packet,
+ CcnxL3Protocol::ContentObjectSource source, Ptr<Ccnx> ccnx, Ptr<const CcnxFace> face)
+{
+ transmittedData++;
+}
+
+static void OnReceivedData (std::string context, Ptr<const CcnxContentObjectHeader> header, Ptr<const Packet> packet,
+ Ptr<Ccnx> ccnx, Ptr<const CcnxFace> face)
+{
+ receivedData++;
+}
+
+static void OnDroppedData (std::string context, Ptr<const CcnxContentObjectHeader> header, Ptr<const Packet> packet,
+ CcnxL3Protocol::DropReason reason, Ptr<Ccnx> ccnx, Ptr<const CcnxFace> face )
+{
+ droppedData++;
+}
+
int
main (int argc, char *argv[])
{
- // Packet::EnableChecking();
- // Packet::EnablePrinting();
+ Packet::EnableChecking();
+ Packet::EnablePrinting();
string input ("./src/NDNabstraction/examples/abilene-topology.txt");
Time finishTime = Seconds (20.0);
@@ -92,6 +137,13 @@
return -1;
}
+ int droppedInterests[nodes.GetN()];
+ int congestedInterests[nodes.GetN()];
+ int sentInterests[nodes.GetN()];
+ (void)droppedInterests;
+ (void)sentInterests;
+ (void)congestedInterests;
+
SpringMobilityHelper::InstallSprings (reader.LinksBegin (), reader.LinksEnd ());
// InternetStackHelper stack;
@@ -137,9 +189,38 @@
anim->SetMobilityPollInterval (Seconds (1));
}
+ NS_LOG_INFO ("Configure Tracing.");
+ // first, pcap tracing in non-promiscuous mode
+ //ccnxHelper.EnablePcapAll ("csma-ping", false);
+ // then, print what the packet sink receives.
+ //Config::ConnectWithoutContext ("/NodeList/3/ApplicationList/0/$ns3::PacketSink/Rx",
+ // MakeCallback (&SinkRx));
+ // finally, print the ping rtts.
+ //Packet::EnablePrinting ();
+ Config::Connect("/NodeList/*/ns3::CcnxL3Protocol/TransmittedInterestTrace",
+ MakeCallback (&OnTransmittedInterest));
+ Config::Connect ("/NodeList/*/ns3::CcnxL3Protocol/ReceivedInterestTrace",
+ MakeCallback (&OnReceivedInterest));
+ Config::Connect ("/NodeList/*/ns3::CcnxL3Protocol/DroppedInterestTrace",
+ MakeCallback (&OnDroppedInterest));
+
+ Config::Connect ("/NodeList/*/ns3::CcnxL3Protocol/ReceivedDataTrace",
+ MakeCallback (&OnReceivedData));
+ Config::Connect ("/NodeList/*/ns3::CcnxL3Protocol/TransmittedDataTrace",
+ MakeCallback (&OnTransmittedData));
+ Config::Connect ("/NodeList/*/ns3::CcnxL3Protocol/DroppedDataTrace",
+ MakeCallback (&OnDroppedData));
+
NS_LOG_INFO ("Run Simulation.");
Simulator::Run ();
Simulator::Destroy ();
NS_LOG_INFO ("Done.");
+
+ NS_LOG_INFO("Total received interests = " << receivedInterests);
+ NS_LOG_INFO("Total transmitted interests = " << transmittedInterests);
+ NS_LOG_INFO("Total dropped interests = " << droppedInterests);
+ NS_LOG_INFO("Total received data = " << receivedData);
+ NS_LOG_INFO("Total transmitted data = " << transmittedData);
+ NS_LOG_INFO("Total dropped data = " << droppedData);
return 0;
}