A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
delay-jitter-estimation.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2007 INRIA
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
21
#include "
delay-jitter-estimation.h
"
22
#include "ns3/tag.h"
23
#include "ns3/simulator.h"
24
#include "ns3/string.h"
25
26
namespace
ns3 {
27
28
class
DelayJitterEstimationTimestampTag
:
public
Tag
29
{
30
public
:
31
DelayJitterEstimationTimestampTag
();
32
static
TypeId
GetTypeId
(
void
);
33
virtual
TypeId
GetInstanceTypeId
(
void
)
const
;
34
35
virtual
uint32_t
GetSerializedSize
(
void
)
const
;
36
virtual
void
Serialize
(
TagBuffer
i)
const
;
37
virtual
void
Deserialize
(
TagBuffer
i);
38
virtual
void
Print
(std::ostream &os)
const
;
39
40
Time
GetTxTime
(
void
)
const
;
41
private
:
42
uint64_t
m_creationTime
;
43
};
44
45
DelayJitterEstimationTimestampTag::DelayJitterEstimationTimestampTag
()
46
: m_creationTime (
Simulator
::
Now
().GetTimeStep ())
47
{
48
}
49
50
TypeId
51
DelayJitterEstimationTimestampTag::GetTypeId
(
void
)
52
{
53
static
TypeId
tid =
TypeId
(
"anon::DelayJitterEstimationTimestampTag"
)
54
.
SetParent
<
Tag
> ()
55
.AddConstructor<DelayJitterEstimationTimestampTag> ()
56
.AddAttribute (
"CreationTime"
,
57
"The time at which the timestamp was created"
,
58
StringValue
(
"0.0s"
),
59
MakeTimeAccessor (&
DelayJitterEstimationTimestampTag::GetTxTime
),
60
MakeTimeChecker
())
61
;
62
return
tid;
63
}
64
TypeId
65
DelayJitterEstimationTimestampTag::GetInstanceTypeId
(
void
)
const
66
{
67
return
GetTypeId
();
68
}
69
70
uint32_t
71
DelayJitterEstimationTimestampTag::GetSerializedSize
(
void
)
const
72
{
73
return
8;
74
}
75
void
76
DelayJitterEstimationTimestampTag::Serialize
(
TagBuffer
i)
const
77
{
78
i.
WriteU64
(
m_creationTime
);
79
}
80
void
81
DelayJitterEstimationTimestampTag::Deserialize
(
TagBuffer
i)
82
{
83
m_creationTime
= i.
ReadU64
();
84
}
85
void
86
DelayJitterEstimationTimestampTag::Print
(std::ostream &os)
const
87
{
88
os <<
"CreationTime="
<<
m_creationTime
;
89
}
90
Time
91
DelayJitterEstimationTimestampTag::GetTxTime
(
void
)
const
92
{
93
return
TimeStep
(
m_creationTime
);
94
}
95
96
DelayJitterEstimation::DelayJitterEstimation
()
97
: m_previousRx (
Simulator
::
Now
()),
98
m_previousRxTx (
Simulator
::
Now
()),
99
m_jitter (0),
100
m_delay (Seconds (0.0))
101
{
102
}
103
void
104
DelayJitterEstimation::PrepareTx
(
Ptr<const Packet>
packet)
105
{
106
DelayJitterEstimationTimestampTag
tag;
107
packet->
AddByteTag
(tag);
108
}
109
void
110
DelayJitterEstimation::RecordRx
(
Ptr<const Packet>
packet)
111
{
112
DelayJitterEstimationTimestampTag
tag;
113
bool
found;
114
found = packet->
FindFirstMatchingByteTag
(tag);
115
if
(!found)
116
{
117
return
;
118
}
119
tag.
GetTxTime
();
120
121
Time
delta = (
Simulator::Now
() -
m_previousRx
) - (tag.
GetTxTime
() -
m_previousRxTx
);
122
m_jitter
+= (
Abs
(delta) -
m_jitter
) / 16;
123
m_previousRx
=
Simulator::Now
();
124
m_previousRxTx
= tag.
GetTxTime
();
125
m_delay
=
Simulator::Now
() - tag.
GetTxTime
();
126
}
127
128
Time
129
DelayJitterEstimation::GetLastDelay
(
void
)
const
130
{
131
return
m_delay
;
132
}
133
uint64_t
134
DelayJitterEstimation::GetLastJitter
(
void
)
const
135
{
136
return
m_jitter
.GetHigh ();
137
}
138
139
}
// namespace ns3
ns3::DelayJitterEstimationTimestampTag::DelayJitterEstimationTimestampTag
DelayJitterEstimationTimestampTag()
Definition:
delay-jitter-estimation.cc:45
ns3::Packet::FindFirstMatchingByteTag
bool FindFirstMatchingByteTag(Tag &tag) const
Definition:
packet.cc:824
ns3::Time
keep track of time values and allow control of global simulation resolution
Definition:
nstime.h:81
ns3::Ptr< const Packet >
ns3::Abs
int64x64_t Abs(const int64x64_t &value)
Definition:
int64x64.h:85
ns3::Simulator
Control the scheduling of simulation events.
Definition:
simulator.h:62
ns3::StringValue
hold variables of type string
Definition:
string.h:19
ns3::TagBuffer::WriteU64
void WriteU64(uint64_t v)
Definition:
tag-buffer.cc:102
ns3::TimeStep
Time TimeStep(uint64_t ts)
Definition:
nstime.h:950
ns3::DelayJitterEstimation::RecordRx
void RecordRx(Ptr< const Packet > packet)
Definition:
delay-jitter-estimation.cc:110
ns3::DelayJitterEstimationTimestampTag::Print
virtual void Print(std::ostream &os) const
Definition:
delay-jitter-estimation.cc:86
ns3::DelayJitterEstimationTimestampTag::GetTypeId
static TypeId GetTypeId(void)
Definition:
delay-jitter-estimation.cc:51
ns3::DelayJitterEstimation::DelayJitterEstimation
DelayJitterEstimation()
Definition:
delay-jitter-estimation.cc:96
ns3::DelayJitterEstimation::GetLastJitter
uint64_t GetLastJitter(void) const
The jitter is calculated using the RFC 1889 (RTP) jitter definition.
Definition:
delay-jitter-estimation.cc:134
ns3::DelayJitterEstimation::PrepareTx
static void PrepareTx(Ptr< const Packet > packet)
Definition:
delay-jitter-estimation.cc:104
ns3::DelayJitterEstimationTimestampTag::Serialize
virtual void Serialize(TagBuffer i) const
Definition:
delay-jitter-estimation.cc:76
delay-jitter-estimation.h
ns3::Tag
tag a set of bytes in a packet
Definition:
tag.h:36
ns3::TagBuffer::ReadU64
uint64_t ReadU64(void)
Definition:
tag-buffer.cc:134
ns3::DelayJitterEstimation::m_previousRxTx
Time m_previousRxTx
Definition:
delay-jitter-estimation.h:73
ns3::DelayJitterEstimationTimestampTag
Definition:
delay-jitter-estimation.cc:28
ns3::DelayJitterEstimation::GetLastDelay
Time GetLastDelay(void) const
Definition:
delay-jitter-estimation.cc:129
ns3::Simulator::Now
static Time Now(void)
Return the "current simulation time".
Definition:
simulator.cc:180
ns3::DelayJitterEstimationTimestampTag::Deserialize
virtual void Deserialize(TagBuffer i)
Definition:
delay-jitter-estimation.cc:81
ns3::DelayJitterEstimation::m_delay
Time m_delay
Definition:
delay-jitter-estimation.h:75
ns3::DelayJitterEstimation::m_previousRx
Time m_previousRx
Definition:
delay-jitter-estimation.h:72
ns3::TagBuffer
read and write tag data
Definition:
tag-buffer.h:51
ns3::Now
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition:
simulator.cc:287
ns3::DelayJitterEstimationTimestampTag::GetTxTime
Time GetTxTime(void) const
Definition:
delay-jitter-estimation.cc:91
ns3::DelayJitterEstimationTimestampTag::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Definition:
delay-jitter-estimation.cc:65
ns3::DelayJitterEstimationTimestampTag::m_creationTime
uint64_t m_creationTime
Definition:
delay-jitter-estimation.cc:42
ns3::MakeTimeChecker
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition:
time.cc:452
ns3::DelayJitterEstimation::m_jitter
int64x64_t m_jitter
Definition:
delay-jitter-estimation.h:74
ns3::DelayJitterEstimationTimestampTag::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition:
delay-jitter-estimation.cc:71
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:611
ns3::Packet::AddByteTag
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
Definition:
packet.cc:808
src
network
helper
delay-jitter-estimation.cc
Generated on Sat Apr 19 2014 14:07:05 for ns-3 by
1.8.6