A Discrete-Event Network Simulator
API
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 */
21#include "ns3/mobility-model.h"
22#include "ns3/double.h"
23#include "ns3/string.h"
24#include "ns3/pointer.h"
25
26namespace ns3 {
27
28NS_OBJECT_ENSURE_REGISTERED (PropagationDelayModel);
29
30TypeId
32{
33 static TypeId tid = TypeId ("ns3::PropagationDelayModel")
34 .SetParent<Object> ()
35 .SetGroupName ("Propagation")
36 ;
37 return tid;
38}
39
41{
42}
43
44int64_t
46{
47 return DoAssignStreams (stream);
48}
49
50// ------------------------------------------------------------------------- //
51
53
56{
57 static TypeId tid = 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 ;
67 return tid;
68}
69
71{
72}
74{
75}
76Time
78{
79 return Seconds (m_variable->GetValue ());
80}
81
82int64_t
84{
85 m_variable->SetStream (stream);
86 return 1;
87}
88
90
93{
94 static TypeId tid = TypeId ("ns3::ConstantSpeedPropagationDelayModel")
96 .SetGroupName ("Propagation")
97 .AddConstructor<ConstantSpeedPropagationDelayModel> ()
98 .AddAttribute ("Speed", "The propagation speed (m/s) in the propagation medium being considered. The default value is the propagation speed of light in the vacuum.",
99 DoubleValue (299792458),
101 MakeDoubleChecker<double> ())
102 ;
103 return tid;
104}
105
107{
108}
109Time
111{
112 double distance = a->GetDistanceFrom (b);
113 double seconds = distance / m_speed;
114 return Seconds (seconds);
115}
116void
118{
119 m_speed = speed;
120}
121double
123{
124 return m_speed;
125}
126
127int64_t
129{
130 return 0;
131}
132
133
134} // namespace ns3
Time GetDelay(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
static TypeId GetTypeId(void)
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.
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:41
double GetDistanceFrom(Ptr< const MobilityModel > position) const
A base class which provides memory management and object aggregation.
Definition: object.h:88
calculate a propagation delay.
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...
static TypeId GetTypeId(void)
Get the type ID.
the propagation delay is random
RandomPropagationDelayModel()
Use the default parameters from PropagationDelayRandomDistribution.
Ptr< RandomVariableStream > m_variable
random generator
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
static TypeId GetTypeId(void)
Get the type ID.
Time GetDelay(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
virtual double GetValue(void)=0
Get the next random value as a double drawn from the distribution.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Hold variables of type string.
Definition: string.h:41
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:42
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Definition: pointer.h:227
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1245
Every class exported by the ns3 library is enclosed in the ns3 namespace.