A Discrete-Event Network Simulator
API
 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  */
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 
31 TypeId
33 {
34  static TypeId tid = TypeId ("ns3::PropagationDelayModel")
35  .SetParent<Object> ()
36  ;
37  return tid;
38 }
39 
41 {
42 }
43 
44 int64_t
46 {
47  return DoAssignStreams (stream);
48 }
49 
50 // ------------------------------------------------------------------------- //
51 
53  ;
54 
55 TypeId
57 {
58  static TypeId tid = TypeId ("ns3::RandomPropagationDelayModel")
60  .AddConstructor<RandomPropagationDelayModel> ()
61  .AddAttribute ("Variable",
62  "The random variable which generates random delays (s).",
63  StringValue ("ns3::UniformRandomVariable"),
64  MakePointerAccessor (&RandomPropagationDelayModel::m_variable),
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 
92 TypeId
94 {
95  static TypeId tid = TypeId ("ns3::ConstantSpeedPropagationDelayModel")
97  .AddConstructor<ConstantSpeedPropagationDelayModel> ()
98  .AddAttribute ("Speed", "The speed (m/s)",
99  DoubleValue (300000000.0),
100  MakeDoubleAccessor (&ConstantSpeedPropagationDelayModel::m_speed),
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
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
double GetDistanceFrom(Ptr< const MobilityModel > position) const
hold variables of type string
Definition: string.h:19
virtual Time GetDelay(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
virtual Time GetDelay(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
RandomPropagationDelayModel()
Use the default parameters from PropagationDelayRandomDistribution.
Ptr< RandomVariableStream > m_variable
virtual double GetValue(void)=0
Returns a random double from the underlying distribution.
virtual int64_t DoAssignStreams(int64_t stream)=0
Subclasses must implement this; those not using random variables can return zero. ...
calculate a propagation delay.
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. ...
the propagation delay is random
ConstantSpeedPropagationDelayModel()
Use the default parameters from PropagationDelayConstantSpeed.
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero. ...
a base class which provides memory management and object aggregation
Definition: object.h:63
Hold a floating point type.
Definition: double.h:41
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611