A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
delay-jitter-estimation.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8
10
11#include "ns3/simulator.h"
12#include "ns3/string.h"
13#include "ns3/timestamp-tag.h"
14
15namespace ns3
16{
17
21
22void
24{
26 packet->AddByteTag(tag);
27}
28
29void
31{
32 TimestampTag tag;
33
34 if (!packet->FindFirstMatchingByteTag(tag))
35 {
36 return;
37 }
38
39 // Variable names from
40 // RFC 1889 Appendix A.8 ,p. 71,
41 // RFC 3550 Appendix A.8, p. 94
42 Time r_ts = tag.GetTimestamp();
43 Time arrival = Simulator::Now();
44 Time transit = arrival - r_ts;
45 Time delta = transit - m_transit;
46 m_transit = transit;
47
48 // floating jitter version
49 // m_jitter += (Abs (delta) - m_jitter) / 16;
50
51 // int variant
52 m_jitter += Abs(delta) - ((m_jitter + TimeStep(8)) / 16);
53}
54
55Time
60
61uint64_t
63{
64 // floating jitter version
65 // return m_jitter.GetTimeStep();
66
67 // int variant
68 return (m_jitter / 16).GetTimeStep();
69}
70
71} // namespace ns3
Time GetLastDelay() const
Get the Last Delay object.
void RecordRx(Ptr< const Packet > packet)
Invoke this method to update the delay and jitter calculations After a call to this method,...
uint64_t GetLastJitter() const
The jitter is calculated using the RFC 1889 (RTP) jitter definition.
static void PrepareTx(Ptr< const Packet > packet)
This method should be invoked once on each packet to record within the packet the tx time which is us...
Time m_transit
Relative transit time for the previous packet.
Smart pointer class similar to boost::intrusive_ptr.
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Timestamp tag for associating a timestamp with a packet.
Time GetTimestamp() const
Get the Timestamp object.
int64x64_t Abs(const int64x64_t &value)
Absolute value.
Definition int64x64.h:203
Every class exported by the ns3 library is enclosed in the ns3 namespace.