author | Kirill Andreev <andreev@iitp.ru> |
Tue, 08 Sep 2009 11:27:50 +0400 | |
changeset 5179 | 5791fa40e7b1 |
parent 2965 | 4b28e9740e3b |
permissions | -rw-r--r-- |
2034
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
2 |
/* |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
3 |
* Copyright (c) 2005,2006,2007 INRIA |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
4 |
* |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
7 |
* published by the Free Software Foundation; |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
8 |
* |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
12 |
* GNU General Public License for more details. |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
13 |
* |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
17 |
* |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
19 |
*/ |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
#include "propagation-delay-model.h" |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
#include "ns3/random-variable.h" |
2031
567dbc2475fc
replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1958
diff
changeset
|
22 |
#include "ns3/mobility-model.h" |
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
23 |
#include "ns3/double.h" |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
|
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
namespace ns3 { |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
|
2940
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2625
diff
changeset
|
27 |
NS_OBJECT_ENSURE_REGISTERED (PropagationDelayModel); |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2625
diff
changeset
|
28 |
|
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2625
diff
changeset
|
29 |
TypeId |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2625
diff
changeset
|
30 |
PropagationDelayModel::GetTypeId (void) |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2625
diff
changeset
|
31 |
{ |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2625
diff
changeset
|
32 |
static TypeId tid = TypeId ("ns3::PropagationDelayModel") |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2625
diff
changeset
|
33 |
.SetParent<Object> () |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2625
diff
changeset
|
34 |
; |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2625
diff
changeset
|
35 |
return tid; |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2625
diff
changeset
|
36 |
} |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2625
diff
changeset
|
37 |
|
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
38 |
PropagationDelayModel::~PropagationDelayModel () |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
39 |
{} |
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
40 |
|
2625
90ba95050923
fix typename
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2561
diff
changeset
|
41 |
NS_OBJECT_ENSURE_REGISTERED (RandomPropagationDelayModel); |
90ba95050923
fix typename
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2561
diff
changeset
|
42 |
|
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
43 |
TypeId |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
44 |
RandomPropagationDelayModel::GetTypeId (void) |
1957
9ce0828c6a19
add default value support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
45 |
{ |
2625
90ba95050923
fix typename
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2561
diff
changeset
|
46 |
static TypeId tid = TypeId ("ns3::RandomPropagationDelayModel") |
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
47 |
.SetParent<PropagationDelayModel> () |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
48 |
.AddConstructor<RandomPropagationDelayModel> () |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
49 |
.AddAttribute ("Variable", |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
50 |
"The random variable which generates random delays (s).", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2940
diff
changeset
|
51 |
RandomVariableValue (UniformVariable (0.0, 1.0)), |
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
52 |
MakeRandomVariableAccessor (&RandomPropagationDelayModel::m_variable), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
53 |
MakeRandomVariableChecker ()) |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
54 |
; |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
55 |
return tid; |
1957
9ce0828c6a19
add default value support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
56 |
} |
9ce0828c6a19
add default value support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
57 |
|
9ce0828c6a19
add default value support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
58 |
RandomPropagationDelayModel::RandomPropagationDelayModel () |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
59 |
{} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
60 |
RandomPropagationDelayModel::~RandomPropagationDelayModel () |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
61 |
{} |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
62 |
Time |
2031
567dbc2475fc
replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1958
diff
changeset
|
63 |
RandomPropagationDelayModel::GetDelay (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
64 |
{ |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
65 |
return Seconds (m_variable.GetValue ()); |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
66 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
67 |
|
2625
90ba95050923
fix typename
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2561
diff
changeset
|
68 |
NS_OBJECT_ENSURE_REGISTERED (ConstantSpeedPropagationDelayModel); |
90ba95050923
fix typename
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2561
diff
changeset
|
69 |
|
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
70 |
TypeId |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
71 |
ConstantSpeedPropagationDelayModel::GetTypeId (void) |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
72 |
{ |
2625
90ba95050923
fix typename
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2561
diff
changeset
|
73 |
static TypeId tid = TypeId ("ns3::ConstantSpeedPropagationDelayModel") |
2561
fb49fd82cbfd
avoid infinite loop.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2549
diff
changeset
|
74 |
.SetParent<PropagationDelayModel> () |
fb49fd82cbfd
avoid infinite loop.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2549
diff
changeset
|
75 |
.AddConstructor<ConstantSpeedPropagationDelayModel> () |
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
76 |
.AddAttribute ("Speed", "The speed (m/s)", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2940
diff
changeset
|
77 |
DoubleValue (300000000.0), |
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
78 |
MakeDoubleAccessor (&ConstantSpeedPropagationDelayModel::m_speed), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
79 |
MakeDoubleChecker<double> ()) |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
80 |
; |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
81 |
return tid; |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
82 |
} |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
83 |
|
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
84 |
ConstantSpeedPropagationDelayModel::ConstantSpeedPropagationDelayModel () |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
85 |
{} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
86 |
Time |
2031
567dbc2475fc
replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1958
diff
changeset
|
87 |
ConstantSpeedPropagationDelayModel::GetDelay (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
88 |
{ |
2031
567dbc2475fc
replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1958
diff
changeset
|
89 |
double distance = a->GetDistanceFrom (b); |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
90 |
double seconds = distance / m_speed; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
91 |
return Seconds (seconds); |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
92 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
93 |
void |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
94 |
ConstantSpeedPropagationDelayModel::SetSpeed (double speed) |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
95 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
96 |
m_speed = speed; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
97 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
98 |
double |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
99 |
ConstantSpeedPropagationDelayModel::GetSpeed (void) const |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
100 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
101 |
return m_speed; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
102 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
103 |
|
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
104 |
} // namespace ns3 |