merge
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 21 Apr 2008 08:58:23 -0700
changeset 2988 8774a8c9526f
parent 2987 4fe951be604c (current diff)
parent 2925 7149e19cada4 (diff)
child 2989 b7eb3929096c
merge
--- a/src/core/object.h	Thu Apr 17 15:54:35 2008 -0700
+++ b/src/core/object.h	Mon Apr 21 08:58:23 2008 -0700
@@ -137,6 +137,8 @@
   friend Ptr<T> CreateObject (const AttributeList &attributes);
   template <typename T>
   friend Ptr<T> CopyObject (Ptr<T> object);
+  template <typename T>
+  friend Ptr<T> CopyObject (Ptr<const T> object);
 
   friend class ObjectFactory;
 
@@ -203,8 +205,11 @@
  * and returns the new instance.
  */
 template <typename T>
+Ptr<T> CopyObject (Ptr<const T> object);
+template <typename T>
 Ptr<T> CopyObject (Ptr<T> object);
 
+
 /**
  * \param attributes a list of attributes to set on the 
  *        object during construction.
@@ -314,6 +319,14 @@
   return p;
 }
 
+template <typename T>
+Ptr<T> CopyObject (Ptr<const T> object)
+{
+  Ptr<T> p = Ptr<T> (new T (*PeekPointer (object)), false);
+  NS_ASSERT (p->m_tid == object->m_tid);
+  return p;
+}
+
 
 template <typename T>
 Ptr<T> CreateObject (const AttributeList &attributes)
--- a/src/internet-node/rtt-estimator.cc	Thu Apr 17 15:54:35 2008 -0700
+++ b/src/internet-node/rtt-estimator.cc	Mon Apr 21 08:58:23 2008 -0700
@@ -74,12 +74,9 @@
   //note next=1 everywhere since first segment will have sequence 1
 }
 
-RttEstimator::RttEstimator (Time e) : next (1), history (), est (e),
-    nSamples (0), multiplier (1.0) 
-{ }
-
 RttEstimator::RttEstimator(const RttEstimator& c)
-  : next(c.next), history(c.history), est(c.est), nSamples(c.nSamples),
+  : Object (c), next(c.next), history(c.history), 
+    m_maxMultiplier (c.m_maxMultiplier), est(c.est), nSamples(c.nSamples),
     multiplier(c.multiplier)
 {}
 
@@ -144,6 +141,10 @@
 
 void RttEstimator::IncreaseMultiplier ()
 {
+  double a;
+  a = multiplier * 2.0;
+  double b;
+  b = m_maxMultiplier * 2.0;
   multiplier = std::min (multiplier * 2.0, m_maxMultiplier);
 }
 
@@ -223,7 +224,7 @@
 
 Ptr<RttEstimator> RttMeanDeviation::Copy () const
 {
-  return Create<RttMeanDeviation> (*this);
+  return CopyObject<RttMeanDeviation> (this);
 }
 
 void RttMeanDeviation::Reset ()
--- a/src/internet-node/rtt-estimator.h	Thu Apr 17 15:54:35 2008 -0700
+++ b/src/internet-node/rtt-estimator.h	Mon Apr 21 08:58:23 2008 -0700
@@ -51,7 +51,6 @@
   static TypeId GetTypeId (void);
 
   RttEstimator();
-  RttEstimator(Time e);
   RttEstimator(const RttEstimator&); // Copy constructor
   virtual ~RttEstimator();
 
@@ -71,7 +70,6 @@
   SequenceNumber        next;    // Next expected sequence to be sent
   RttHistory_t history; // List of sent packet
   double m_maxMultiplier;
-  Time m_initialEstimate;
 public:
   Time       est;     // Current estimate
   uint32_t      nSamples;// Number of samples
--- a/src/node/address.cc	Thu Apr 17 15:54:35 2008 -0700
+++ b/src/node/address.cc	Mon Apr 21 08:58:23 2008 -0700
@@ -109,13 +109,28 @@
 
 ATTRIBUTE_HELPER_CPP (Address);
 
+
 bool operator == (const Address &a, const Address &b)
 {
-  if (a.m_type != b.m_type)
+  /* Two addresses can be equal even if their types are 
+   * different if one of the two types is zero. a type of 
+   * zero identifies an Address which might contain meaningful 
+   * payload but for which the type field could not be set because
+   * we did not know it. This can typically happen in the ARP
+   * layer where we receive an address from an ArpHeader but
+   * we do not know its type: we really want to be able to
+   * compare addresses without knowing their real type.
+   */
+  if (a.m_type != b.m_type &&
+      a.m_type != 0 && 
+      b.m_type != 0)
     {
       return false;
     }
-  NS_ASSERT (a.GetLength() == b.GetLength());  
+  if (a.m_len != b.m_len)
+    {
+      return false;
+    }
   return memcmp (a.m_data, b.m_data, a.m_len) == 0;
 }
 bool operator != (const Address &a, const Address &b)
@@ -124,9 +139,16 @@
 }
 bool operator < (const Address &a, const Address &b)
 {
-  NS_ASSERT (a.m_type == b.m_type  || 
-	     a.m_type == 0 || 
-	     b.m_type == 0);
+  // XXX: it is not clear to me how to order based on type.
+  // so, we do not compare the types here but we should.
+  if (a.m_len < b.m_len)
+    {
+      return true;
+    }
+  else if (a.m_len > b.m_len)
+    {
+      return false;
+    }
   NS_ASSERT (a.GetLength() == b.GetLength());
   for (uint8_t i = 0; i < a.GetLength(); i++) 
     {