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 TypeId
32 {
33  static TypeId tid = TypeId ("ns3::PropagationDelayModel")
34  .SetParent<Object> ()
35  ;
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 = TypeId ("ns3::RandomPropagationDelayModel")
58  .AddConstructor<RandomPropagationDelayModel> ()
59  .AddAttribute ("Variable",
60  "The random variable which generates random delays (s).",
61  StringValue ("ns3::UniformRandomVariable"),
62  MakePointerAccessor (&RandomPropagationDelayModel::m_variable),
63  MakePointerChecker<RandomVariableStream> ())
64  ;
65  return tid;
66 }
67 
69 {
70 }
72 {
73 }
74 Time
76 {
77  return Seconds (m_variable->GetValue ());
78 }
79 
80 int64_t
82 {
83  m_variable->SetStream (stream);
84  return 1;
85 }
86 
88 
89 TypeId
91 {
92  static TypeId tid = TypeId ("ns3::ConstantSpeedPropagationDelayModel")
94  .AddConstructor<ConstantSpeedPropagationDelayModel> ()
95  .AddAttribute ("Speed", "The speed (m/s)",
96  DoubleValue (300000000.0),
97  MakeDoubleAccessor (&ConstantSpeedPropagationDelayModel::m_speed),
98  MakeDoubleChecker<double> ())
99  ;
100  return tid;
101 }
102 
104 {
105 }
106 Time
108 {
109  double distance = a->GetDistanceFrom (b);
110  double seconds = distance / m_speed;
111  return Seconds (seconds);
112 }
113 void
115 {
116  m_speed = speed;
117 }
118 double
120 {
121  return m_speed;
122 }
123 
124 int64_t
126 {
127  return 0;
128 }
129 
130 
131 } // namespace ns3
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
double GetDistanceFrom(Ptr< const MobilityModel > position) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
hold variables of type string
Definition: string.h:18
virtual Time GetDelay(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
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:64
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:610