apps+model+utils: Implementing Interest/Data hop counting using new PacketTag
diff --git a/apps/ndn-consumer-zipf-mandelbrot.cc b/apps/ndn-consumer-zipf-mandelbrot.cc
index c0e84d8..9982738 100644
--- a/apps/ndn-consumer-zipf-mandelbrot.cc
+++ b/apps/ndn-consumer-zipf-mandelbrot.cc
@@ -23,6 +23,9 @@
#include "ns3/ndn-app-face.h"
#include "ns3/ndn-interest.h"
#include "ns3/ndn-content-object.h"
+
+#include "ns3/ndnSIM/utils/ndn-fw-hop-count-tag.h"
+
#include <math.h>
@@ -176,6 +179,9 @@
m_rtt->SentSeq (SequenceNumber32 (seq), 1);
+ FwHopCountTag hopCountTag;
+ packet->AddPacketTag (hopCountTag);
+
m_protocolHandler (packet);
ConsumerZipfMandelbrot::ScheduleNextPacket ();
diff --git a/apps/ndn-consumer.cc b/apps/ndn-consumer.cc
index 08d4b2c..60ef55b 100644
--- a/apps/ndn-consumer.cc
+++ b/apps/ndn-consumer.cc
@@ -32,7 +32,7 @@
#include "ns3/ndn-app-face.h"
#include "ns3/ndn-interest.h"
#include "ns3/ndn-content-object.h"
-// #include "ns3/weights-path-stretch-tag.h"
+#include "ns3/ndnSIM/utils/ndn-fw-hop-count-tag.h"
#include <boost/ref.hpp>
#include <boost/lexical_cast.hpp>
@@ -76,9 +76,6 @@
MakeTimeAccessor (&Consumer::GetRetxTimer, &Consumer::SetRetxTimer),
MakeTimeChecker ())
- .AddTraceSource ("PathWeightsTrace", "PathWeightsTrace",
- MakeTraceSourceAccessor (&Consumer::m_pathWeightsTrace))
-
.AddTraceSource ("LastRetransmittedInterestDataDelay", "Delay between last retransmitted Interest and received Data",
MakeTraceSourceAccessor (&Consumer::m_lastRetransmittedInterestDataDelay))
@@ -228,6 +225,9 @@
m_rtt->SentSeq (SequenceNumber32 (seq), 1);
+ FwHopCountTag hopCountTag;
+ packet->AddPacketTag (hopCountTag);
+
m_protocolHandler (packet);
ScheduleNextPacket ();
@@ -253,16 +253,23 @@
uint32_t seq = boost::lexical_cast<uint32_t> (contentObject->GetName ().GetComponents ().back ());
NS_LOG_INFO ("< DATA for " << seq);
+ int hopCount = -1;
+ FwHopCountTag hopCountTag;
+ if (payload->RemovePacketTag (hopCountTag))
+ {
+ hopCount = hopCountTag.Get ();
+ }
+
SeqTimeoutsContainer::iterator entry = m_seqLastDelay.find (seq);
if (entry != m_seqLastDelay.end ())
{
- m_lastRetransmittedInterestDataDelay (this, seq, Simulator::Now () - entry->time);
+ m_lastRetransmittedInterestDataDelay (this, seq, Simulator::Now () - entry->time, hopCount);
}
entry = m_seqFullDelay.find (seq);
if (entry != m_seqFullDelay.end ())
{
- m_firstInterestDataDelay (this, seq, Simulator::Now () - entry->time, m_seqRetxCounts[seq]);
+ m_firstInterestDataDelay (this, seq, Simulator::Now () - entry->time, m_seqRetxCounts[seq], hopCount);
}
m_seqRetxCounts.erase (seq);
@@ -273,15 +280,6 @@
m_retxSeqs.erase (seq);
m_rtt->AckSeq (SequenceNumber32 (seq));
-
- // Ptr<const WeightsPathStretchTag> tag = payload->RemovePacketTag<WeightsPathStretchTag> ();
- // if (tag != 0)
- // {
- // // Notify trace about path weights vector (e.g., for path-stretch calculation)
- // m_pathWeightsTrace (GetNode (), tag->GetSourceNode (), seq, tag->GetTotalWeight ());
- // // if (Names::FindName (GetNode ()) == "36")// || Names::FindName (GetNode ()) == "40"|| Names::FindName (GetNode ()) == "5")
- // // std::cout << Simulator::Now () << "\t" << boost::cref(*tag) << " = " << tag->GetTotalWeight () << "\n";
- // }
}
void
diff --git a/apps/ndn-consumer.h b/apps/ndn-consumer.h
index 03c3dd9..5d09672 100644
--- a/apps/ndn-consumer.h
+++ b/apps/ndn-consumer.h
@@ -181,9 +181,11 @@
SeqTimeoutsContainer m_seqFullDelay;
std::map<uint32_t, uint32_t> m_seqRetxCounts;
- TracedCallback<Ptr<Node>, Ptr<Node>, uint32_t, uint32_t > m_pathWeightsTrace;
- TracedCallback<Ptr<App> /* app */, uint32_t /* seqno */, Time /* delay */> m_lastRetransmittedInterestDataDelay;
- TracedCallback<Ptr<App> /* app */, uint32_t /* seqno */, Time /* delay */, uint32_t /*retx count*/> m_firstInterestDataDelay;
+ TracedCallback<Ptr<App> /* app */, uint32_t /* seqno */,
+ Time /* delay */, int32_t /*hop count*/> m_lastRetransmittedInterestDataDelay;
+ TracedCallback<Ptr<App> /* app */, uint32_t /* seqno */,
+ Time /* delay */, uint32_t /*retx count*/,
+ int32_t /*hop count*/> m_firstInterestDataDelay;
/// @endcond
};
diff --git a/apps/ndn-producer.cc b/apps/ndn-producer.cc
index 4f7afc4..f0d464a 100644
--- a/apps/ndn-producer.cc
+++ b/apps/ndn-producer.cc
@@ -30,7 +30,8 @@
#include "ns3/ndn-app-face.h"
#include "ns3/ndn-fib.h"
-// #include "../model/ndn-fib-impl.h"
+
+#include "ns3/ndnSIM/utils/ndn-fw-hop-count-tag.h"
#include <boost/ref.hpp>
#include <boost/lambda/lambda.hpp>
@@ -123,22 +124,17 @@
NS_LOG_INFO ("node("<< GetNode()->GetId() <<") respodning with ContentObject:\n" << boost::cref(*header));
Ptr<Packet> packet = Create<Packet> (m_virtualPayloadSize);
- // Ptr<const WeightsPathStretchTag> tag = origPacket->RemovePacketTag<WeightsPathStretchTag> ();
- // if (tag != 0)
- // {
- // // std::cout << Simulator::Now () << ", " << m_app->GetInstanceTypeId ().GetName () << "\n";
-
- // // echo back WeightsPathStretchTag
- // packet->AddPacketTag (CreateObject<WeightsPathStretchTag> (*tag));
-
- // // \todo
- // // packet->AddPacketTag should actually accept Ptr<const WeightsPathStretchTag> instead of
- // // Ptr<WeightsPathStretchTag>. Echoing will be simplified after change is done
- // }
packet->AddHeader (*header);
packet->AddTrailer (tail);
+ // Echo back FwHopCountTag if exists
+ FwHopCountTag hopCountTag;
+ if (origPacket->RemovePacketTag (hopCountTag))
+ {
+ packet->AddPacketTag (hopCountTag);
+ }
+
m_protocolHandler (packet);
m_transmittedContentObjects (header, packet, this, m_face);