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);
diff --git a/bindings/modulegen__gcc_ILP32.py b/bindings/modulegen__gcc_ILP32.py
index b00bf37..b208b55 100644
--- a/bindings/modulegen__gcc_ILP32.py
+++ b/bindings/modulegen__gcc_ILP32.py
@@ -3866,6 +3866,8 @@
def register_Ns3TopologyReaderLink_methods(root_module, cls):
## topology-reader.h (module 'topology-read'): ns3::TopologyReader::Link::Link(ns3::TopologyReader::Link const & arg0) [copy constructor]
cls.add_constructor([param('ns3::TopologyReader::Link const &', 'arg0')])
+ ## topology-reader.h (module 'topology-read'): ns3::TopologyReader::Link::Link() [constructor]
+ cls.add_constructor([])
## topology-reader.h (module 'topology-read'): ns3::TopologyReader::Link::Link(ns3::Ptr<ns3::Node> fromPtr, std::string const & fromName, ns3::Ptr<ns3::Node> toPtr, std::string const & toName) [constructor]
cls.add_constructor([param('ns3::Ptr< ns3::Node >', 'fromPtr'), param('std::string const &', 'fromName'), param('ns3::Ptr< ns3::Node >', 'toPtr'), param('std::string const &', 'toName')])
## topology-reader.h (module 'topology-read'): std::_Rb_tree_const_iterator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > ns3::TopologyReader::Link::AttributesBegin() [member function]
@@ -4000,6 +4002,11 @@
'void',
[param('ns3::TagBuffer', 'i')],
is_virtual=True)
+ ## ccnx-path-stretch-tag.h (module 'NDNabstraction'): ns3::Ptr<ns3::Node> ns3::WeightsPathStretchTag::GetDestinationNode() const [member function]
+ cls.add_method('GetDestinationNode',
+ 'ns3::Ptr< ns3::Node >',
+ [],
+ is_const=True)
## ccnx-path-stretch-tag.h (module 'NDNabstraction'): std::list<ns3::WeightsPathStretchTag::NodeWeightPair, std::allocator<ns3::WeightsPathStretchTag::NodeWeightPair> > const & ns3::WeightsPathStretchTag::GetInfos() const [member function]
cls.add_method('GetInfos',
'std::list< ns3::WeightsPathStretchTag::NodeWeightPair > const &',
@@ -4015,9 +4022,9 @@
'ns3::Ptr< ns3::Node >',
[],
is_const=True)
- ## ccnx-path-stretch-tag.h (module 'NDNabstraction'): uint32_t ns3::WeightsPathStretchTag::GetTotalWeight() const [member function]
+ ## ccnx-path-stretch-tag.h (module 'NDNabstraction'): uint64_t ns3::WeightsPathStretchTag::GetTotalWeight() const [member function]
cls.add_method('GetTotalWeight',
- 'uint32_t',
+ 'uint64_t',
[],
is_const=True)
## ccnx-path-stretch-tag.h (module 'NDNabstraction'): static ns3::TypeId ns3::WeightsPathStretchTag::GetTypeId() [member function]
@@ -5085,10 +5092,10 @@
'void',
[param('std::ostream &', 'os')],
is_const=True, is_virtual=True)
- ## ccnx-path-weight-tracer.h (module 'NDNabstraction'): void ns3::CcnxPathWeightTracer::InLocalFace(std::string context, uint32_t weight, ns3::Ptr<ns3::Node> src, ns3::Ptr<ns3::Node> dst) [member function]
+ ## ccnx-path-weight-tracer.h (module 'NDNabstraction'): void ns3::CcnxPathWeightTracer::InLocalFace(std::string context, ns3::Ptr<ns3::Node> src, ns3::Ptr<ns3::Node> dst, uint32_t seqno, uint32_t weight) [member function]
cls.add_method('InLocalFace',
'void',
- [param('std::string', 'context'), param('uint32_t', 'weight'), param('ns3::Ptr< ns3::Node >', 'src'), param('ns3::Ptr< ns3::Node >', 'dst')],
+ [param('std::string', 'context'), param('ns3::Ptr< ns3::Node >', 'src'), param('ns3::Ptr< ns3::Node >', 'dst'), param('uint32_t', 'seqno'), param('uint32_t', 'weight')],
is_virtual=True)
return
diff --git a/bindings/modulegen__gcc_LP64.py b/bindings/modulegen__gcc_LP64.py
index b00bf37..b208b55 100644
--- a/bindings/modulegen__gcc_LP64.py
+++ b/bindings/modulegen__gcc_LP64.py
@@ -3866,6 +3866,8 @@
def register_Ns3TopologyReaderLink_methods(root_module, cls):
## topology-reader.h (module 'topology-read'): ns3::TopologyReader::Link::Link(ns3::TopologyReader::Link const & arg0) [copy constructor]
cls.add_constructor([param('ns3::TopologyReader::Link const &', 'arg0')])
+ ## topology-reader.h (module 'topology-read'): ns3::TopologyReader::Link::Link() [constructor]
+ cls.add_constructor([])
## topology-reader.h (module 'topology-read'): ns3::TopologyReader::Link::Link(ns3::Ptr<ns3::Node> fromPtr, std::string const & fromName, ns3::Ptr<ns3::Node> toPtr, std::string const & toName) [constructor]
cls.add_constructor([param('ns3::Ptr< ns3::Node >', 'fromPtr'), param('std::string const &', 'fromName'), param('ns3::Ptr< ns3::Node >', 'toPtr'), param('std::string const &', 'toName')])
## topology-reader.h (module 'topology-read'): std::_Rb_tree_const_iterator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > ns3::TopologyReader::Link::AttributesBegin() [member function]
@@ -4000,6 +4002,11 @@
'void',
[param('ns3::TagBuffer', 'i')],
is_virtual=True)
+ ## ccnx-path-stretch-tag.h (module 'NDNabstraction'): ns3::Ptr<ns3::Node> ns3::WeightsPathStretchTag::GetDestinationNode() const [member function]
+ cls.add_method('GetDestinationNode',
+ 'ns3::Ptr< ns3::Node >',
+ [],
+ is_const=True)
## ccnx-path-stretch-tag.h (module 'NDNabstraction'): std::list<ns3::WeightsPathStretchTag::NodeWeightPair, std::allocator<ns3::WeightsPathStretchTag::NodeWeightPair> > const & ns3::WeightsPathStretchTag::GetInfos() const [member function]
cls.add_method('GetInfos',
'std::list< ns3::WeightsPathStretchTag::NodeWeightPair > const &',
@@ -4015,9 +4022,9 @@
'ns3::Ptr< ns3::Node >',
[],
is_const=True)
- ## ccnx-path-stretch-tag.h (module 'NDNabstraction'): uint32_t ns3::WeightsPathStretchTag::GetTotalWeight() const [member function]
+ ## ccnx-path-stretch-tag.h (module 'NDNabstraction'): uint64_t ns3::WeightsPathStretchTag::GetTotalWeight() const [member function]
cls.add_method('GetTotalWeight',
- 'uint32_t',
+ 'uint64_t',
[],
is_const=True)
## ccnx-path-stretch-tag.h (module 'NDNabstraction'): static ns3::TypeId ns3::WeightsPathStretchTag::GetTypeId() [member function]
@@ -5085,10 +5092,10 @@
'void',
[param('std::ostream &', 'os')],
is_const=True, is_virtual=True)
- ## ccnx-path-weight-tracer.h (module 'NDNabstraction'): void ns3::CcnxPathWeightTracer::InLocalFace(std::string context, uint32_t weight, ns3::Ptr<ns3::Node> src, ns3::Ptr<ns3::Node> dst) [member function]
+ ## ccnx-path-weight-tracer.h (module 'NDNabstraction'): void ns3::CcnxPathWeightTracer::InLocalFace(std::string context, ns3::Ptr<ns3::Node> src, ns3::Ptr<ns3::Node> dst, uint32_t seqno, uint32_t weight) [member function]
cls.add_method('InLocalFace',
'void',
- [param('std::string', 'context'), param('uint32_t', 'weight'), param('ns3::Ptr< ns3::Node >', 'src'), param('ns3::Ptr< ns3::Node >', 'dst')],
+ [param('std::string', 'context'), param('ns3::Ptr< ns3::Node >', 'src'), param('ns3::Ptr< ns3::Node >', 'dst'), param('uint32_t', 'seqno'), param('uint32_t', 'weight')],
is_virtual=True)
return
diff --git a/examples/blackhole-sprint.cc b/examples/blackhole-sprint.cc
index 5f78b94..3901d70 100644
--- a/examples/blackhole-sprint.cc
+++ b/examples/blackhole-sprint.cc
@@ -299,10 +299,10 @@
CcnxAppHelper consumerHelper ("ns3::CcnxConsumerBatches");
consumerHelper.SetAttribute ("LifeTime", StringValue("100s"));
- consumerHelper.SetAttribute ("Batches", StringValue("0s 10 2s 1"));
+ consumerHelper.SetAttribute ("Batches", StringValue("0s 10 0.5s 1 2s 1"));
BOOST_FOREACH (const string &prefix, prefixes)
{
- consumerHelper.SetPrefix (prefix);
+ consumerHelper.SetPrefix (prefix + "/" + lexical_cast<string> (namedId)); // make sure we're requesting unique prefixes... this was a huge bug before
ApplicationContainer consumer = consumerHelper.Install (*node);
apps.Add (consumer);
@@ -364,7 +364,7 @@
std::cout << "Total " << apps.GetN () << " applications\n";
for (ApplicationContainer::Iterator i = apps.Begin (); i != apps.End (); i++)
{
- Simulator::Schedule (Seconds (1.999999), &CcnxTraceHelper::WeightsConnect, &traceHelper, (*i)->GetNode (), *i);
+ Simulator::Schedule (Seconds (0.45), &CcnxTraceHelper::WeightsConnect, &traceHelper, (*i)->GetNode (), *i);
}
experiment.Run (Seconds(40.0));
diff --git a/helper/ccnx-trace-helper.cc b/helper/ccnx-trace-helper.cc
index 303d1aa..f5df0cb 100644
--- a/helper/ccnx-trace-helper.cc
+++ b/helper/ccnx-trace-helper.cc
@@ -370,7 +370,7 @@
NS_LOG_FUNCTION (this);
m_pathWeightsTrace = new ofstream (pathWeights.c_str (), ios::trunc);
- WindowTracer::PrintHeader (*m_pathWeightsTrace);
+ CcnxPathWeightTracer::PrintHeader (*m_pathWeightsTrace);
*m_pathWeightsTrace << "\n";
}
diff --git a/helper/tracers/ccnx-path-weight-tracer.cc b/helper/tracers/ccnx-path-weight-tracer.cc
index d1cb709..4d6aa7d 100644
--- a/helper/tracers/ccnx-path-weight-tracer.cc
+++ b/helper/tracers/ccnx-path-weight-tracer.cc
@@ -27,6 +27,7 @@
#include "ns3/ccnx-app.h"
#include "ns3/ccnx-face.h"
#include "ns3/boolean.h"
+#include "ns3/simulator.h"
#include <boost/lexical_cast.hpp>
#include <boost/foreach.hpp>
@@ -57,25 +58,38 @@
Config::Set ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/ForwardingStrategy/MetricTagging",
BooleanValue (true));
- Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/FaceList/*/$ns3::CcnxLocalFace/PathWeightsTrace",
+ Config::Connect ("/NodeList/"+m_node+"/ApplicationList/"+m_appId+"/PathWeightsTrace",
MakeCallback (&CcnxPathWeightTracer::InLocalFace, this));
+ // Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/FaceList/*/$ns3::CcnxLocalFace/PathWeightsTrace",
+ // MakeCallback (&CcnxPathWeightTracer::InLocalFace, this));
}
void
-CcnxPathWeightTracer::PrintHeader (std::ostream &os) const
+CcnxPathWeightTracer::PrintHeader (std::ostream &os)
{
- os << "Node\t"
- << "AppId\t"
- << "PathWeight\t"
- << "PathWeights\n";
+ os << "Time\t"
+ << "Src\t"
+ << "Dst\t"
+ << "SeqNo\t"
+ << "Weight";
}
void
CcnxPathWeightTracer::InLocalFace (std::string context,
- uint32_t weight, Ptr<Node> src, Ptr<Node> dst)
+ Ptr<Node> src, Ptr<Node> dst, uint32_t seqno, uint32_t weight)
{
- std::cout << "Path weights from " << Names::FindName (src) << " to "<< Names::FindName (dst) <<" : " << weight << "\n";
+ std::string srcName = Names::FindName (src);
+ std::string dstName = Names::FindName (dst);
+ if (srcName == "") srcName = boost::lexical_cast<std::string> (src->GetId ());
+ if (dstName == "") srcName = boost::lexical_cast<std::string> (dst->GetId ());
+ // std::cout << "Path weights from " << Names::FindName (src) << " to "<< Names::FindName (dst) <<" : " << weight << "\n";
+
+ m_os << Simulator::Now ().ToDouble (Time::S) << "\t"
+ << srcName << "\t"
+ << dstName << "\t"
+ << seqno << "\t"
+ << weight << "\n";
}
} // namespace ns3
diff --git a/helper/tracers/ccnx-path-weight-tracer.h b/helper/tracers/ccnx-path-weight-tracer.h
index ca43a5d..868e61f 100644
--- a/helper/tracers/ccnx-path-weight-tracer.h
+++ b/helper/tracers/ccnx-path-weight-tracer.h
@@ -41,15 +41,15 @@
void
Connect ();
- virtual void
- PrintHeader (std::ostream &os) const;
+ static void
+ PrintHeader (std::ostream &os);
/**
* \brief Process packet weight upon reception of packet on a local face
*/
virtual void
InLocalFace (std::string context,
- uint32_t weight, Ptr<Node> src, Ptr<Node> dst);
+ Ptr<Node> src, Ptr<Node> dst, uint32_t seqno, uint32_t weight);
protected:
std::ostream &m_os;
diff --git a/model/ccnx-local-face.cc b/model/ccnx-local-face.cc
index 404e38f..f3abba9 100644
--- a/model/ccnx-local-face.cc
+++ b/model/ccnx-local-face.cc
@@ -46,8 +46,6 @@
static TypeId tid = TypeId ("ns3::CcnxLocalFace")
.SetParent<CcnxFace> ()
.SetGroupName ("Ccnx")
- .AddTraceSource ("PathWeightsTrace", "PathWeightsTrace",
- MakeTraceSourceAccessor (&CcnxLocalFace::m_pathWeightsTrace))
;
return tid;
}
@@ -96,15 +94,6 @@
CcnxLocalFace::SendImpl (Ptr<Packet> p)
{
NS_LOG_FUNCTION (this << p);
- std::cout << Simulator::Now () << ", " << m_app->GetInstanceTypeId ().GetName () << "\n";
-
- // Notify trace about path weights vector (e.g., for path-stretch calculation)
- Ptr<const WeightsPathStretchTag> tag = p->RemovePacketTag<WeightsPathStretchTag> ();
- if (tag != 0)
- {
- m_pathWeightsTrace (tag->GetTotalWeight (), tag->GetSourceNode (), m_app->GetNode ());
- std::cout << boost::cref(*tag) << "\n";
- }
try
{
diff --git a/model/ccnx-local-face.h b/model/ccnx-local-face.h
index 507f8b1..327199d 100644
--- a/model/ccnx-local-face.h
+++ b/model/ccnx-local-face.h
@@ -76,8 +76,6 @@
private:
Ptr<CcnxApp> m_app;
-
- TracedCallback<uint32_t, Ptr<Node>, Ptr<Node> > m_pathWeightsTrace;
};
std::ostream& operator<< (std::ostream& os, const CcnxLocalFace &localFace);
diff --git a/model/ccnx-path-stretch-tag.cc b/model/ccnx-path-stretch-tag.cc
index b4b29e1..c8fc6dd 100644
--- a/model/ccnx-path-stretch-tag.cc
+++ b/model/ccnx-path-stretch-tag.cc
@@ -50,10 +50,10 @@
// return GetTypeId ();
// }
-uint32_t
+uint64_t
WeightsPathStretchTag::GetTotalWeight () const
{
- uint32_t total = 0;
+ uint64_t total = 0;
for (std::list<NodeWeightPair>::const_iterator info = m_infos.begin (); info != m_infos.end (); info++)
{
total += info->weight;
@@ -68,6 +68,13 @@
return m_infos.front ().node;
}
+Ptr<Node>
+WeightsPathStretchTag::GetDestinationNode () const
+{
+ NS_ASSERT (m_infos.size () > 0);
+ return m_infos.back ().node;
+}
+
uint32_t WeightsPathStretchTag::GetSerializedSize (void) const
{
return 0;
diff --git a/model/ccnx-path-stretch-tag.h b/model/ccnx-path-stretch-tag.h
index 71a4582..644871f 100644
--- a/model/ccnx-path-stretch-tag.h
+++ b/model/ccnx-path-stretch-tag.h
@@ -52,12 +52,15 @@
void
AddPathInfo (Ptr<Node> node, uint32_t weight);
- uint32_t
+ uint64_t
GetTotalWeight () const;
Ptr<Node>
GetSourceNode () const;
+ Ptr<Node>
+ GetDestinationNode () const;
+
const std::list<NodeWeightPair> &
GetInfos () const
{ return m_infos; }