--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/network/helper/delay-jitter-estimation.cc Fri Aug 09 06:35:28 2013 -0700
@@ -0,0 +1,139 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * 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
+ *
+ * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+
+#include "delay-jitter-estimation.h"
+#include "ns3/tag.h"
+#include "ns3/simulator.h"
+#include "ns3/string.h"
+
+namespace ns3 {
+
+class DelayJitterEstimationTimestampTag : public Tag
+{
+public:
+ DelayJitterEstimationTimestampTag ();
+ static TypeId GetTypeId (void);
+ virtual TypeId GetInstanceTypeId (void) const;
+
+ virtual uint32_t GetSerializedSize (void) const;
+ virtual void Serialize (TagBuffer i) const;
+ virtual void Deserialize (TagBuffer i);
+ virtual void Print (std::ostream &os) const;
+
+ Time GetTxTime (void) const;
+private:
+ uint64_t m_creationTime;
+};
+
+DelayJitterEstimationTimestampTag::DelayJitterEstimationTimestampTag ()
+ : m_creationTime (Simulator::Now ().GetTimeStep ())
+{
+}
+
+TypeId
+DelayJitterEstimationTimestampTag::GetTypeId (void)
+{
+ static TypeId tid = TypeId ("anon::DelayJitterEstimationTimestampTag")
+ .SetParent<Tag> ()
+ .AddConstructor<DelayJitterEstimationTimestampTag> ()
+ .AddAttribute ("CreationTime",
+ "The time at which the timestamp was created",
+ StringValue ("0.0s"),
+ MakeTimeAccessor (&DelayJitterEstimationTimestampTag::GetTxTime),
+ MakeTimeChecker ())
+ ;
+ return tid;
+}
+TypeId
+DelayJitterEstimationTimestampTag::GetInstanceTypeId (void) const
+{
+ return GetTypeId ();
+}
+
+uint32_t
+DelayJitterEstimationTimestampTag::GetSerializedSize (void) const
+{
+ return 8;
+}
+void
+DelayJitterEstimationTimestampTag::Serialize (TagBuffer i) const
+{
+ i.WriteU64 (m_creationTime);
+}
+void
+DelayJitterEstimationTimestampTag::Deserialize (TagBuffer i)
+{
+ m_creationTime = i.ReadU64 ();
+}
+void
+DelayJitterEstimationTimestampTag::Print (std::ostream &os) const
+{
+ os << "CreationTime=" << m_creationTime;
+}
+Time
+DelayJitterEstimationTimestampTag::GetTxTime (void) const
+{
+ return TimeStep (m_creationTime);
+}
+
+DelayJitterEstimation::DelayJitterEstimation ()
+ : m_previousRx (Simulator::Now ()),
+ m_previousRxTx (Simulator::Now ()),
+ m_jitter (0),
+ m_delay (Seconds (0.0))
+{
+}
+void
+DelayJitterEstimation::PrepareTx (Ptr<const Packet> packet)
+{
+ DelayJitterEstimationTimestampTag tag;
+ packet->AddByteTag (tag);
+}
+void
+DelayJitterEstimation::RecordRx (Ptr<const Packet> packet)
+{
+ DelayJitterEstimationTimestampTag tag;
+ bool found;
+ found = packet->FindFirstMatchingByteTag (tag);
+ if (!found)
+ {
+ return;
+ }
+ tag.GetTxTime ();
+
+ Time delta = (Simulator::Now () - m_previousRx) - (tag.GetTxTime () - m_previousRxTx);
+ m_jitter += (Abs (delta) - m_jitter) / 16;
+ m_previousRx = Simulator::Now ();
+ m_previousRxTx = tag.GetTxTime ();
+ m_delay = Simulator::Now () - tag.GetTxTime ();
+}
+
+Time
+DelayJitterEstimation::GetLastDelay (void) const
+{
+ return m_delay;
+}
+uint64_t
+DelayJitterEstimation::GetLastJitter (void) const
+{
+ return m_jitter.GetHigh ();
+}
+
+} // namespace ns3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/network/helper/delay-jitter-estimation.h Fri Aug 09 06:35:28 2013 -0700
@@ -0,0 +1,80 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * 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
+ *
+ * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#ifndef DELAY_JITTER_ESTIMATION_H
+#define DELAY_JITTER_ESTIMATION_H
+
+#include "ns3/nstime.h"
+#include "ns3/packet.h"
+
+namespace ns3 {
+
+/**
+ * \ingroup stats
+ *
+ * \brief quick and dirty delay and jitter estimation
+ *
+ */
+class DelayJitterEstimation
+{
+public:
+ DelayJitterEstimation ();
+
+ /**
+ * \param packet the packet to send over a wire
+ *
+ * This method should be invoked once on each packet to
+ * record within the packet the tx time which is used upon
+ * packet reception to calculate the delay and jitter. The
+ * tx time is stored in the packet as an ns3::Tag which means
+ * that it does not use any network resources and is not
+ * taken into account in transmission delay calculations.
+ */
+ static void PrepareTx (Ptr<const Packet> packet);
+ /**
+ * \param packet the packet received
+ *
+ * Invoke this method to update the delay and jitter calculations
+ * After a call to this method, \ref GetLastDelay and \ref GetLastJitter
+ * will return an updated delay and jitter.
+ */
+ void RecordRx (Ptr<const Packet> packet);
+
+ /**
+ * \returns the updated delay.
+ */
+ Time GetLastDelay (void) const;
+ /**
+ * The jitter is calculated using the RFC 1889 (RTP) jitter
+ * definition.
+ *
+ * \returns the updated jitter.
+ */
+ uint64_t GetLastJitter (void) const;
+
+private:
+ Time m_previousRx;
+ Time m_previousRxTx;
+ int64x64_t m_jitter;
+ Time m_delay;
+};
+
+} // namespace ns3
+
+#endif /* DELAY_JITTER_ESTIMATION_H */
--- a/src/network/wscript Fri Aug 09 06:15:11 2013 -0700
+++ b/src/network/wscript Fri Aug 09 06:35:28 2013 -0700
@@ -59,6 +59,7 @@
'helper/node-container.cc',
'helper/packet-socket-helper.cc',
'helper/trace-helper.cc',
+ 'helper/delay-jitter-estimation.cc',
]
network_test = bld.create_ns3_module_test_library('network')
@@ -139,6 +140,7 @@
'helper/node-container.h',
'helper/packet-socket-helper.h',
'helper/trace-helper.h',
+ 'helper/delay-jitter-estimation.h',
]
if (bld.env['ENABLE_EXAMPLES']):
--- a/src/stats/helper/delay-jitter-estimation.cc Fri Aug 09 06:15:11 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *
- * 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
- *
- * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-
-#include "delay-jitter-estimation.h"
-#include "ns3/tag.h"
-#include "ns3/simulator.h"
-#include "ns3/string.h"
-
-namespace ns3 {
-
-class DelayJitterEstimationTimestampTag : public Tag
-{
-public:
- DelayJitterEstimationTimestampTag ();
- static TypeId GetTypeId (void);
- virtual TypeId GetInstanceTypeId (void) const;
-
- virtual uint32_t GetSerializedSize (void) const;
- virtual void Serialize (TagBuffer i) const;
- virtual void Deserialize (TagBuffer i);
- virtual void Print (std::ostream &os) const;
-
- Time GetTxTime (void) const;
-private:
- uint64_t m_creationTime;
-};
-
-DelayJitterEstimationTimestampTag::DelayJitterEstimationTimestampTag ()
- : m_creationTime (Simulator::Now ().GetTimeStep ())
-{
-}
-
-TypeId
-DelayJitterEstimationTimestampTag::GetTypeId (void)
-{
- static TypeId tid = TypeId ("anon::DelayJitterEstimationTimestampTag")
- .SetParent<Tag> ()
- .AddConstructor<DelayJitterEstimationTimestampTag> ()
- .AddAttribute ("CreationTime",
- "The time at which the timestamp was created",
- StringValue ("0.0s"),
- MakeTimeAccessor (&DelayJitterEstimationTimestampTag::GetTxTime),
- MakeTimeChecker ())
- ;
- return tid;
-}
-TypeId
-DelayJitterEstimationTimestampTag::GetInstanceTypeId (void) const
-{
- return GetTypeId ();
-}
-
-uint32_t
-DelayJitterEstimationTimestampTag::GetSerializedSize (void) const
-{
- return 8;
-}
-void
-DelayJitterEstimationTimestampTag::Serialize (TagBuffer i) const
-{
- i.WriteU64 (m_creationTime);
-}
-void
-DelayJitterEstimationTimestampTag::Deserialize (TagBuffer i)
-{
- m_creationTime = i.ReadU64 ();
-}
-void
-DelayJitterEstimationTimestampTag::Print (std::ostream &os) const
-{
- os << "CreationTime=" << m_creationTime;
-}
-Time
-DelayJitterEstimationTimestampTag::GetTxTime (void) const
-{
- return TimeStep (m_creationTime);
-}
-
-DelayJitterEstimation::DelayJitterEstimation ()
- : m_previousRx (Simulator::Now ()),
- m_previousRxTx (Simulator::Now ()),
- m_jitter (0),
- m_delay (Seconds (0.0))
-{
-}
-void
-DelayJitterEstimation::PrepareTx (Ptr<const Packet> packet)
-{
- DelayJitterEstimationTimestampTag tag;
- packet->AddByteTag (tag);
-}
-void
-DelayJitterEstimation::RecordRx (Ptr<const Packet> packet)
-{
- DelayJitterEstimationTimestampTag tag;
- bool found;
- found = packet->FindFirstMatchingByteTag (tag);
- if (!found)
- {
- return;
- }
- tag.GetTxTime ();
-
- Time delta = (Simulator::Now () - m_previousRx) - (tag.GetTxTime () - m_previousRxTx);
- m_jitter += (Abs (delta) - m_jitter) / 16;
- m_previousRx = Simulator::Now ();
- m_previousRxTx = tag.GetTxTime ();
- m_delay = Simulator::Now () - tag.GetTxTime ();
-}
-
-Time
-DelayJitterEstimation::GetLastDelay (void) const
-{
- return m_delay;
-}
-uint64_t
-DelayJitterEstimation::GetLastJitter (void) const
-{
- return m_jitter.GetHigh ();
-}
-
-} // namespace ns3
--- a/src/stats/helper/delay-jitter-estimation.h Fri Aug 09 06:15:11 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *
- * 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
- *
- * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#ifndef DELAY_JITTER_ESTIMATION_H
-#define DELAY_JITTER_ESTIMATION_H
-
-#include "ns3/nstime.h"
-#include "ns3/packet.h"
-
-namespace ns3 {
-
-/**
- * \ingroup stats
- *
- * \brief quick and dirty delay and jitter estimation
- *
- */
-class DelayJitterEstimation
-{
-public:
- DelayJitterEstimation ();
-
- /**
- * \param packet the packet to send over a wire
- *
- * This method should be invoked once on each packet to
- * record within the packet the tx time which is used upon
- * packet reception to calculate the delay and jitter. The
- * tx time is stored in the packet as an ns3::Tag which means
- * that it does not use any network resources and is not
- * taken into account in transmission delay calculations.
- */
- static void PrepareTx (Ptr<const Packet> packet);
- /**
- * \param packet the packet received
- *
- * Invoke this method to update the delay and jitter calculations
- * After a call to this method, \ref GetLastDelay and \ref GetLastJitter
- * will return an updated delay and jitter.
- */
- void RecordRx (Ptr<const Packet> packet);
-
- /**
- * \returns the updated delay.
- */
- Time GetLastDelay (void) const;
- /**
- * The jitter is calculated using the RFC 1889 (RTP) jitter
- * definition.
- *
- * \returns the updated jitter.
- */
- uint64_t GetLastJitter (void) const;
-
-private:
- Time m_previousRx;
- Time m_previousRxTx;
- int64x64_t m_jitter;
- Time m_delay;
-};
-
-} // namespace ns3
-
-#endif /* DELAY_JITTER_ESTIMATION_H */
--- a/src/stats/wscript Fri Aug 09 06:15:11 2013 -0700
+++ b/src/stats/wscript Fri Aug 09 06:35:28 2013 -0700
@@ -13,7 +13,6 @@
def build(bld):
obj = bld.create_ns3_module('stats', ['core'])
obj.source = [
- 'helper/delay-jitter-estimation.cc',
'helper/file-helper.cc',
'helper/gnuplot-helper.cc',
'model/data-calculator.cc',
@@ -45,7 +44,6 @@
headers = bld(features='ns3header')
headers.module = 'stats'
headers.source = [
- 'helper/delay-jitter-estimation.h',
'helper/file-helper.h',
'helper/gnuplot-helper.h',
'model/data-calculator.h',