A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
propagation-delay-model.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005,2006,2007 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
9
10#include "ns3/double.h"
11#include "ns3/mobility-model.h"
12#include "ns3/pointer.h"
13#include "ns3/string.h"
14
15namespace ns3
16{
17
18NS_OBJECT_ENSURE_REGISTERED(PropagationDelayModel);
19
20TypeId
22{
23 static TypeId tid =
24 TypeId("ns3::PropagationDelayModel").SetParent<Object>().SetGroupName("Propagation");
25 return tid;
26}
27
31
32int64_t
34{
35 return DoAssignStreams(stream);
36}
37
38// ------------------------------------------------------------------------- //
39
41
44{
45 static TypeId tid =
46 TypeId("ns3::RandomPropagationDelayModel")
48 .SetGroupName("Propagation")
49 .AddConstructor<RandomPropagationDelayModel>()
50 .AddAttribute("Variable",
51 "The random variable which generates random delays (s).",
52 StringValue("ns3::UniformRandomVariable"),
55 return tid;
56}
57
61
65
66Time
71
72int64_t
74{
75 m_variable->SetStream(stream);
76 return 1;
77}
78
80
83{
84 static TypeId tid =
85 TypeId("ns3::ConstantSpeedPropagationDelayModel")
87 .SetGroupName("Propagation")
88 .AddConstructor<ConstantSpeedPropagationDelayModel>()
89 .AddAttribute("Speed",
90 "The propagation speed (m/s) in the propagation medium being considered. "
91 "The default value is the propagation speed of light in the vacuum.",
92 DoubleValue(299792458),
95 return tid;
96}
97
101
102Time
104{
105 double distance = a->GetDistanceFrom(b);
106 double seconds = distance / m_speed;
107 return Seconds(seconds);
108}
109
110void
112{
113 m_speed = speed;
114}
115
116double
121
122int64_t
124{
125 return 0;
126}
127
128} // 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.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
A base class which provides memory management and object aggregation.
Definition object.h:78
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...
Smart pointer class similar to boost::intrusive_ptr.
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:45
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition pointer.h:248
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Definition pointer.h:269
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32