Finalizing PathWeight tracing
Now tracing is moved to CcnxConsumer
diff --git a/apps/ccnx-consumer.cc b/apps/ccnx-consumer.cc
index c81e464..9fe2f64 100644
--- a/apps/ccnx-consumer.cc
+++ b/apps/ccnx-consumer.cc
@@ -33,6 +33,7 @@
#include "../model/ccnx-local-face.h"
#include "ns3/ccnx-interest-header.h"
#include "ns3/ccnx-content-object-header.h"
+#include "ns3/ccnx-path-stretch-tag.h"
#include <boost/ref.hpp>
#include <boost/lexical_cast.hpp>
@@ -91,6 +92,9 @@
.AddTraceSource ("TransmittedInterests", "TransmittedInterests",
MakeTraceSourceAccessor (&CcnxConsumer::m_transmittedInterests))
+
+ .AddTraceSource ("PathWeightsTrace", "PathWeightsTrace",
+ MakeTraceSourceAccessor (&CcnxConsumer::m_pathWeightsTrace))
;
return tid;
@@ -129,8 +133,6 @@
{
Time now = Simulator::Now ();
- boost::mutex::scoped_lock (m_seqTimeoutsGuard);
-
Time rto = m_rtt->RetransmitTimeout ();
while (!m_seqTimeouts.empty ())
@@ -181,8 +183,6 @@
NS_LOG_FUNCTION_NOARGS ();
- boost::mutex::scoped_lock (m_seqTimeoutsGuard);
-
uint32_t seq;
if (m_retxSeqs.size () != 0)
@@ -267,8 +267,6 @@
uint32_t seq = boost::lexical_cast<uint32_t> (contentObject->GetName ().GetComponents ().back ());
NS_LOG_INFO ("< DATA for " << seq);
- boost::mutex::scoped_lock (m_seqTimeoutsGuard);
-
// SeqTimeoutsContainer::iterator entry = m_seqTimeouts.find (seq);
// NS_ASSERT_MSG (entry != m_seqTimeouts.end (),
@@ -281,6 +279,14 @@
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->GetDestinationNode (), seq, tag->GetTotalWeight ());
+ // std::cout << boost::cref(*tag) << "\n";
+ }
}
void
@@ -291,7 +297,6 @@
CcnxApp::OnNack (interest, origPacket); // tracing inside
NS_LOG_DEBUG ("Nack type: " << interest->GetNack ());
- boost::mutex::scoped_lock (m_seqTimeoutsGuard);
NS_LOG_FUNCTION (this << interest);
diff --git a/apps/ccnx-consumer.h b/apps/ccnx-consumer.h
index 9f2ae53..0030a81 100644
--- a/apps/ccnx-consumer.h
+++ b/apps/ccnx-consumer.h
@@ -37,8 +37,6 @@
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/member.hpp>
-#include <boost/thread/mutex.hpp>
-
namespace ns3
{
@@ -169,13 +167,14 @@
> { } ;
SeqTimeoutsContainer m_seqTimeouts; ///< \brief multi-index for the set of SeqTimeout structs
- boost::mutex m_seqTimeoutsGuard; ///< \brief mutex for safe work with the m_seqTimeouts
/**
* \brief A trace that is called after each transmitted Interest packet
*/
TracedCallback<Ptr<const CcnxInterestHeader>,
Ptr<CcnxApp>, Ptr<CcnxFace> > m_transmittedInterests;
+
+ TracedCallback<Ptr<Node>, Ptr<Node>, uint32_t, uint32_t > m_pathWeightsTrace;
};
} // namespace ns3
diff --git a/apps/ccnx-producer.cc b/apps/ccnx-producer.cc
index cff6af4..291fb82 100644
--- a/apps/ccnx-producer.cc
+++ b/apps/ccnx-producer.cc
@@ -23,6 +23,7 @@
#include "ns3/log.h"
#include "ns3/ccnx-interest-header.h"
#include "ns3/ccnx-content-object-header.h"
+#include "ns3/ccnx-path-stretch-tag.h"
#include "ns3/string.h"
#include "ns3/uinteger.h"
#include "ns3/packet.h"
@@ -113,7 +114,19 @@
NS_LOG_INFO ("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
+ }
+
m_transmittedContentObjects (header, packet, this, m_face);
packet->AddHeader (*header);