apps+model+utils: Implementing Interest/Data hop counting using new PacketTag
diff --git a/utils/ndn-fw-hop-count-tag.cc b/utils/ndn-fw-hop-count-tag.cc
new file mode 100644
index 0000000..8e4ba4c
--- /dev/null
+++ b/utils/ndn-fw-hop-count-tag.cc
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2013 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ndn-fw-hop-count-tag.h"
+
+namespace ns3 {
+namespace ndn {
+
+TypeId
+FwHopCountTag::GetTypeId ()
+{
+ static TypeId tid = TypeId("ns3::ndn::FwHopCountTag")
+ .SetParent<Tag>()
+ .AddConstructor<FwHopCountTag>()
+ ;
+ return tid;
+}
+
+TypeId
+FwHopCountTag::GetInstanceTypeId () const
+{
+ return FwHopCountTag::GetTypeId ();
+}
+
+uint32_t
+FwHopCountTag::GetSerializedSize () const
+{
+ return sizeof(uint32_t);
+}
+
+void
+FwHopCountTag::Serialize (TagBuffer i) const
+{
+ i.WriteU32 (m_hopCount);
+}
+
+void
+FwHopCountTag::Deserialize (TagBuffer i)
+{
+ m_hopCount = i.ReadU32 ();
+}
+
+void
+FwHopCountTag::Print (std::ostream &os) const
+{
+ os << m_hopCount;
+}
+
+} // namespace ndn
+} // namespace ns3
diff --git a/utils/ndn-fw-hop-count-tag.h b/utils/ndn-fw-hop-count-tag.h
new file mode 100644
index 0000000..0ed62f0
--- /dev/null
+++ b/utils/ndn-fw-hop-count-tag.h
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2013 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef NDN_FW_HOP_COUNT_TAG_H
+#define NDN_FW_HOP_COUNT_TAG_H
+
+#include "ns3/tag.h"
+
+namespace ns3 {
+namespace ndn {
+
+/**
+ * @brief Packet tag that is used to track hop count for Interest-Data pairs
+ */
+class FwHopCountTag : public Tag
+{
+public:
+ static TypeId
+ GetTypeId (void);
+
+ /**
+ * @brief Default constructor
+ */
+ FwHopCountTag () : m_hopCount (0) { };
+
+ /**
+ * @brief Destructor
+ */
+ ~FwHopCountTag () { }
+
+ /**
+ * @brief Increment hop count
+ */
+ void
+ Increment () { m_hopCount ++; }
+
+ /**
+ * @brief Get value of hop count
+ */
+ uint32_t
+ Get () const { return m_hopCount; }
+
+ ////////////////////////////////////////////////////////
+ // from ObjectBase
+ ////////////////////////////////////////////////////////
+ virtual TypeId
+ GetInstanceTypeId () const;
+
+ ////////////////////////////////////////////////////////
+ // from Tag
+ ////////////////////////////////////////////////////////
+
+ virtual uint32_t
+ GetSerializedSize () const;
+
+ virtual void
+ Serialize (TagBuffer i) const;
+
+ virtual void
+ Deserialize (TagBuffer i);
+
+ virtual void
+ Print (std::ostream &os) const;
+
+private:
+ uint32_t m_hopCount;
+};
+
+} // namespace ndn
+} // namespace ns3
+
+#endif // NDN_FW_HOP_COUNT_TAG_H
diff --git a/utils/tracers/ndn-app-delay-tracer.cc b/utils/tracers/ndn-app-delay-tracer.cc
index b02b3ac..3893d33 100644
--- a/utils/tracers/ndn-app-delay-tracer.cc
+++ b/utils/tracers/ndn-app-delay-tracer.cc
@@ -129,11 +129,12 @@
<< "Type" << "\t"
<< "DelayS" << "\t"
<< "DelayUS" << "\t"
- << "RetxCount" << "";
+ << "RetxCount" << "\t"
+ << "HopCount" << "";
}
void
-AppDelayTracer::LastRetransmittedInterestDataDelay (Ptr<App> app, uint32_t seqno, Time delay)
+AppDelayTracer::LastRetransmittedInterestDataDelay (Ptr<App> app, uint32_t seqno, Time delay, int32_t hopCount)
{
*m_os << m_node << "\t"
<< app->GetId () << "\t"
@@ -141,11 +142,12 @@
<< "LastDelay" << "\t"
<< delay.ToDouble (Time::S) << "\t"
<< delay.ToDouble (Time::US) << "\t"
- << 1 << "\n";
+ << 1 << "\t"
+ << hopCount << "\n";
}
void
-AppDelayTracer::FirstInterestDataDelay (Ptr<App> app, uint32_t seqno, Time delay, uint32_t retxCount)
+AppDelayTracer::FirstInterestDataDelay (Ptr<App> app, uint32_t seqno, Time delay, uint32_t retxCount, int32_t hopCount)
{
*m_os << m_node << "\t"
<< app->GetId () << "\t"
@@ -153,7 +155,8 @@
<< "FullDelay" << "\t"
<< delay.ToDouble (Time::S) << "\t"
<< delay.ToDouble (Time::US) << "\t"
- << retxCount << "\n";
+ << retxCount << "\t"
+ << hopCount << "\n";
}
diff --git a/utils/tracers/ndn-app-delay-tracer.h b/utils/tracers/ndn-app-delay-tracer.h
index ac586b2..c7a433c 100644
--- a/utils/tracers/ndn-app-delay-tracer.h
+++ b/utils/tracers/ndn-app-delay-tracer.h
@@ -91,10 +91,10 @@
Connect ();
void
- LastRetransmittedInterestDataDelay (Ptr<App> app, uint32_t seqno, Time delay);
+ LastRetransmittedInterestDataDelay (Ptr<App> app, uint32_t seqno, Time delay, int32_t hopCount);
void
- FirstInterestDataDelay (Ptr<App> app, uint32_t seqno, Time delay, uint32_t rextCount);
+ FirstInterestDataDelay (Ptr<App> app, uint32_t seqno, Time delay, uint32_t rextCount, int32_t hopCount);
private:
std::string m_node;