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 
26 namespace ns3 {
27 
28 NS_OBJECT_ENSURE_REGISTERED (PropagationDelayModel);
29 
30 TypeId
32 {
33  static TypeId tid = TypeId ("ns3::PropagationDelayModel")
34  .SetParent<Object> ()
35  .SetGroupName ("Propagation")
36  ;
37  return tid;
38 }
39 
41 {
42 }
43 
44 int64_t
46 {
47  return DoAssignStreams (stream);
48 }
49 
50 // ------------------------------------------------------------------------- //
51 
53 
54 TypeId
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 }
76 Time
78 {
79  return Seconds (m_variable->GetValue ());
80 }
81 
82 int64_t
84 {
85  m_variable->SetStream (stream);
86  return 1;
87 }
88 
90 
91 TypeId
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 }
109 Time
111 {
112  double distance = a->GetDistanceFrom (b);
113  double seconds = distance / m_speed;
114  return Seconds (seconds);
115 }
116 void
118 {
119  m_speed = speed;
120 }
121 double
123 {
124  return m_speed;
125 }
126 
127 int64_t
129 {
130  return 0;
131 }
132 
133 
134 } // namespace ns3
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Hold variables of type string.
Definition: string.h:41
static TypeId GetTypeId(void)
Get the type ID.
RandomPropagationDelayModel()
Use the default parameters from PropagationDelayRandomDistribution.
Ptr< RandomVariableStream > m_variable
random generator
virtual double GetValue(void)=0
Get the next random value as a double drawn from the distribution.
static TypeId GetTypeId(void)
Get the type ID.
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:220
virtual int64_t DoAssignStreams(int64_t stream)=0
Subclasses must implement this; those not using random variables can return zero. ...
virtual Time GetDelay(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
virtual Time GetDelay(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
calculate a propagation delay.
double GetDistanceFrom(Ptr< const MobilityModel > position) const
the propagation speed is constant
int64_t AssignStreams(int64_t stream)
If this delay model uses objects of type RandomVariableStream, set the stream numbers to the integers...
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero. ...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: double.h:42
the propagation delay is random
ConstantSpeedPropagationDelayModel()
Use the default parameters from PropagationDelayConstantSpeed.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1014
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero. ...
static TypeId GetTypeId(void)
Get the type ID.
A base class which provides memory management and object aggregation.
Definition: object.h:87
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915