utils+apps: Fix a bug in ndn::RttEstimator
In the constructor of ndn::RttEstimator, the code tries to set
m_currentEstimatedRtt to m_initialEstimatedRtt using the ConstructSelf()
technique. However, it doesn't take effect at this point since
ndn::RttEstimator hasn't defined GetInstanceTypeId().
According to the manual
(http://www.nsnam.org/docs/manual/html/attributes.html#initialization-order),
"the object and all its derived classes must also implement a virtual
TypeId GetInstanceTypeId (void) const; method. Otherwise the
ObjectBase::ConstructSelf () will not be able to read the attributes".
GetInstanceTypeId() was defined in the original RttEstimator but was
somehow lost during the port to ndnSIM.
closes #40
diff --git a/utils/ndn-rtt-estimator.cc b/utils/ndn-rtt-estimator.cc
index 93193d2..b0d2b83 100644
--- a/utils/ndn-rtt-estimator.cc
+++ b/utils/ndn-rtt-estimator.cc
@@ -158,6 +158,12 @@
NS_LOG_FUNCTION (this);
}
+TypeId
+RttEstimator::GetInstanceTypeId (void) const
+{
+ return GetTypeId ();
+}
+
void RttEstimator::SentSeq (SequenceNumber32 seq, uint32_t size)
{
NS_LOG_FUNCTION (this << seq << size);
diff --git a/utils/ndn-rtt-estimator.h b/utils/ndn-rtt-estimator.h
index 6bf6aa8..287452e 100644
--- a/utils/ndn-rtt-estimator.h
+++ b/utils/ndn-rtt-estimator.h
@@ -67,6 +67,8 @@
virtual ~RttEstimator();
+ virtual TypeId GetInstanceTypeId (void) const;
+
/**
* \brief Note that a particular sequence has been sent
* \param seq the packet sequence number.
diff --git a/utils/ndn-rtt-mean-deviation.cc b/utils/ndn-rtt-mean-deviation.cc
index c05ad75..88cebaa 100644
--- a/utils/ndn-rtt-mean-deviation.cc
+++ b/utils/ndn-rtt-mean-deviation.cc
@@ -74,6 +74,12 @@
NS_LOG_FUNCTION (this);
}
+TypeId
+RttMeanDeviation::GetInstanceTypeId (void) const
+{
+ return GetTypeId ();
+}
+
void RttMeanDeviation::Measurement (Time m)
{
NS_LOG_FUNCTION (this << m);
diff --git a/utils/ndn-rtt-mean-deviation.h b/utils/ndn-rtt-mean-deviation.h
index e8b419c..02d8fac 100644
--- a/utils/ndn-rtt-mean-deviation.h
+++ b/utils/ndn-rtt-mean-deviation.h
@@ -51,6 +51,8 @@
RttMeanDeviation ();
RttMeanDeviation (const RttMeanDeviation&);
+ virtual TypeId GetInstanceTypeId (void) const;
+
void SentSeq (SequenceNumber32 seq, uint32_t size);
Time AckSeq (SequenceNumber32 ackSeq);
void Measurement (Time measure);