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
propagation-delay-model.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2005,2006,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
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
#include "
propagation-delay-model.h
"
21
#include "ns3/mobility-model.h"
22
#include "ns3/double.h"
23
#include "ns3/string.h"
24
#include "ns3/pointer.h"
25
26
namespace
ns3 {
27
28
NS_OBJECT_ENSURE_REGISTERED
(PropagationDelayModel);
29
30
TypeId
31
PropagationDelayModel::GetTypeId
(
void
)
32
{
33
static
TypeId
tid =
TypeId
(
"ns3::PropagationDelayModel"
)
34
.
SetParent
<
Object
> ()
35
;
36
return
tid;
37
}
38
39
PropagationDelayModel::~PropagationDelayModel
()
40
{
41
}
42
43
int64_t
44
PropagationDelayModel::AssignStreams
(int64_t stream)
45
{
46
return
DoAssignStreams
(stream);
47
}
48
49
// ------------------------------------------------------------------------- //
50
51
NS_OBJECT_ENSURE_REGISTERED
(
RandomPropagationDelayModel
);
52
53
TypeId
54
RandomPropagationDelayModel::GetTypeId
(
void
)
55
{
56
static
TypeId
tid =
TypeId
(
"ns3::RandomPropagationDelayModel"
)
57
.
SetParent
<
PropagationDelayModel
> ()
58
.AddConstructor<RandomPropagationDelayModel> ()
59
.AddAttribute (
"Variable"
,
60
"The random variable which generates random delays (s)."
,
61
StringValue
(
"ns3::UniformRandomVariable"
),
62
MakePointerAccessor (&
RandomPropagationDelayModel::m_variable
),
63
MakePointerChecker<RandomVariableStream> ())
64
;
65
return
tid;
66
}
67
68
RandomPropagationDelayModel::RandomPropagationDelayModel
()
69
{
70
}
71
RandomPropagationDelayModel::~RandomPropagationDelayModel
()
72
{
73
}
74
Time
75
RandomPropagationDelayModel::GetDelay
(
Ptr<MobilityModel>
a,
Ptr<MobilityModel>
b)
const
76
{
77
return
Seconds
(
m_variable
->
GetValue
());
78
}
79
80
int64_t
81
RandomPropagationDelayModel::DoAssignStreams
(int64_t stream)
82
{
83
m_variable
->
SetStream
(stream);
84
return
1;
85
}
86
87
NS_OBJECT_ENSURE_REGISTERED
(
ConstantSpeedPropagationDelayModel
);
88
89
TypeId
90
ConstantSpeedPropagationDelayModel::GetTypeId
(
void
)
91
{
92
static
TypeId
tid =
TypeId
(
"ns3::ConstantSpeedPropagationDelayModel"
)
93
.
SetParent
<
PropagationDelayModel
> ()
94
.AddConstructor<ConstantSpeedPropagationDelayModel> ()
95
.AddAttribute (
"Speed"
,
"The speed (m/s)"
,
96
DoubleValue
(300000000.0),
97
MakeDoubleAccessor (&
ConstantSpeedPropagationDelayModel::m_speed
),
98
MakeDoubleChecker<double> ())
99
;
100
return
tid;
101
}
102
103
ConstantSpeedPropagationDelayModel::ConstantSpeedPropagationDelayModel
()
104
{
105
}
106
Time
107
ConstantSpeedPropagationDelayModel::GetDelay
(
Ptr<MobilityModel>
a,
Ptr<MobilityModel>
b)
const
108
{
109
double
distance = a->
GetDistanceFrom
(b);
110
double
seconds = distance /
m_speed
;
111
return
Seconds
(seconds);
112
}
113
void
114
ConstantSpeedPropagationDelayModel::SetSpeed
(
double
speed)
115
{
116
m_speed
= speed;
117
}
118
double
119
ConstantSpeedPropagationDelayModel::GetSpeed
(
void
)
const
120
{
121
return
m_speed
;
122
}
123
124
int64_t
125
ConstantSpeedPropagationDelayModel::DoAssignStreams
(int64_t stream)
126
{
127
return
0;
128
}
129
130
131
}
// namespace ns3
src
propagation
model
propagation-delay-model.cc
Generated on Tue Nov 13 2012 10:32:21 for ns-3 by
1.8.1.2