A Discrete-Event Network Simulator
API
propagation-delay-model.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2005,2006,2007 INRIA
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18  */
20 
21 #include "ns3/double.h"
22 #include "ns3/mobility-model.h"
23 #include "ns3/pointer.h"
24 #include "ns3/string.h"
25 
26 namespace ns3
27 {
28 
29 NS_OBJECT_ENSURE_REGISTERED(PropagationDelayModel);
30 
31 TypeId
33 {
34  static TypeId tid =
35  TypeId("ns3::PropagationDelayModel").SetParent<Object>().SetGroupName("Propagation");
36  return tid;
37 }
38 
40 {
41 }
42 
43 int64_t
45 {
46  return DoAssignStreams(stream);
47 }
48 
49 // ------------------------------------------------------------------------- //
50 
52 
53 TypeId
55 {
56  static TypeId tid =
57  TypeId("ns3::RandomPropagationDelayModel")
59  .SetGroupName("Propagation")
60  .AddConstructor<RandomPropagationDelayModel>()
61  .AddAttribute("Variable",
62  "The random variable which generates random delays (s).",
63  StringValue("ns3::UniformRandomVariable"),
65  MakePointerChecker<RandomVariableStream>());
66  return tid;
67 }
68 
70 {
71 }
72 
74 {
75 }
76 
77 Time
79 {
80  return Seconds(m_variable->GetValue());
81 }
82 
83 int64_t
85 {
86  m_variable->SetStream(stream);
87  return 1;
88 }
89 
91 
92 TypeId
94 {
95  static TypeId tid =
96  TypeId("ns3::ConstantSpeedPropagationDelayModel")
98  .SetGroupName("Propagation")
99  .AddConstructor<ConstantSpeedPropagationDelayModel>()
100  .AddAttribute("Speed",
101  "The propagation speed (m/s) in the propagation medium being considered. "
102  "The default value is the propagation speed of light in the vacuum.",
103  DoubleValue(299792458),
105  MakeDoubleChecker<double>());
106  return tid;
107 }
108 
110 {
111 }
112 
113 Time
115 {
116  double distance = a->GetDistanceFrom(b);
117  double seconds = distance / m_speed;
118  return Seconds(seconds);
119 }
120 
121 void
123 {
124  m_speed = speed;
125 }
126 
127 double
129 {
130  return m_speed;
131 }
132 
133 int64_t
135 {
136  return 0;
137 }
138 
139 } // namespace ns3
Time GetDelay(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
ConstantSpeedPropagationDelayModel()
Use the default parameters from PropagationDelayConstantSpeed.
static TypeId GetTypeId()
Get the type ID.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
double GetDistanceFrom(Ptr< const MobilityModel > position) const
A base class which provides memory management and object aggregation.
Definition: object.h:89
calculate a propagation delay.
static TypeId GetTypeId()
Get the type ID.
virtual int64_t DoAssignStreams(int64_t stream)=0
Assign a fixed random variable stream number to the random variables used by this model.
int64_t AssignStreams(int64_t stream)
If this delay model uses objects of type RandomVariableStream, set the stream numbers to the integers...
the propagation delay is random
RandomPropagationDelayModel()
Use the default parameters from PropagationDelayRandomDistribution.
Ptr< RandomVariableStream > m_variable
random generator
static TypeId GetTypeId()
Get the type ID.
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
Time GetDelay(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
virtual double GetValue()=0
Get the next random value drawn from the distribution.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Hold variables of type string.
Definition: string.h:56
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Definition: pointer.h:227
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43