author | Nicola Baldo <nbaldo@cttc.es> |
Tue, 04 Oct 2011 18:40:50 +0200 | |
changeset 7553 | 2b93d333dea6 |
parent 7385 | 10beb0e53130 |
child 7581 | 6ac3fa410583 |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents:
7241
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
6349 | 2 |
/* |
3 |
* Copyright (c) 2009 CTTC |
|
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: Nicola Baldo <nbaldo@cttc.es> |
|
19 |
*/ |
|
20 |
||
21 |
#ifndef HALF_DUPLEX_IDEAL_PHY_H |
|
22 |
#define HALF_DUPLEX_IDEAL_PHY_H |
|
23 |
||
24 |
||
25 |
#include <ns3/spectrum-value.h> |
|
26 |
#include <ns3/mobility-model.h> |
|
27 |
#include <ns3/packet.h> |
|
28 |
#include <ns3/nstime.h> |
|
29 |
#include <ns3/net-device.h> |
|
30 |
#include <ns3/spectrum-phy.h> |
|
31 |
#include <ns3/spectrum-channel.h> |
|
32 |
#include <ns3/spectrum-type.h> |
|
33 |
#include <ns3/spectrum-interference.h> |
|
34 |
#include <ns3/data-rate.h> |
|
6969 | 35 |
#include <ns3/generic-phy.h> |
6929
c9f51fcb766c
lte: add missing event-id.h includes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6801
diff
changeset
|
36 |
#include <ns3/event-id.h> |
6349 | 37 |
|
38 |
namespace ns3 { |
|
39 |
||
40 |
||
41 |
||
42 |
/** |
|
7241
0a7a16b599e8
Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents:
7142
diff
changeset
|
43 |
* \ingroup spectrum |
0a7a16b599e8
Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents:
7142
diff
changeset
|
44 |
* |
6349 | 45 |
* This PHY layer implementation realizes an ideal OFDM PHY which |
46 |
* transmits half-duplex (i.e., it can either receive or transmit at a |
|
47 |
* given time). The device is ideal in the sense that: |
|
48 |
* 1) it uses an error model based on the Shannon capacity, which |
|
49 |
* assumes ideal channel coding; |
|
50 |
* 2) it uses ideal signal acquisition, i.e., preamble detection and |
|
51 |
* synchronization are always successful |
|
52 |
* 3) it has no PHY layer overhead |
|
53 |
* |
|
54 |
* Being half duplex, if a RX is ongoing but a TX is requested, the RX |
|
55 |
* is aborted and the TX is started. Of course, no RX can be performed |
|
56 |
* while there is an ongoing TX. |
|
57 |
* |
|
58 |
* The use of OFDM is modeled by means of the Spectrum framework. By |
|
59 |
* calling the method SetTxPowerSpectralDensity(), the |
|
60 |
* user can specify how much of the spectrum is used, how many |
|
61 |
* subcarriers are used, and what power is allocated to each |
|
62 |
* subcarrier. |
|
63 |
* |
|
64 |
* The user can also specify the PHY rate |
|
65 |
* at which communications take place by using SetRate(). This is |
|
66 |
* equivalent to choosing a particular modulation and coding scheme. |
|
67 |
* |
|
68 |
* The use of the ShannonSpectrumErrorModel allows us to account for |
|
69 |
* the following aspects in determining whether a |
|
70 |
* transmission is successful or not: |
|
71 |
* - the PHY rate (trades off communication speed with reliability) |
|
72 |
* - the power spectral density (trade-off among total power consumed, |
|
73 |
* total bandwidth used (i.e., how much of the spectrum is occupied), |
|
74 |
* and communication reliability) |
|
75 |
* - the signal propagation |
|
76 |
*/ |
|
77 |
class HalfDuplexIdealPhy : public SpectrumPhy |
|
78 |
{ |
|
79 |
||
80 |
public: |
|
81 |
HalfDuplexIdealPhy (); |
|
82 |
virtual ~HalfDuplexIdealPhy (); |
|
83 |
||
84 |
/** |
|
85 |
* PHY states |
|
86 |
* |
|
87 |
*/ |
|
7142
89a701fec3a1
run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents:
6969
diff
changeset
|
88 |
enum State |
89a701fec3a1
run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents:
6969
diff
changeset
|
89 |
{ |
6349 | 90 |
IDLE, TX, RX |
91 |
}; |
|
92 |
||
93 |
static TypeId GetTypeId (void); |
|
94 |
||
95 |
// inherited from SpectrumPhy |
|
96 |
void SetChannel (Ptr<SpectrumChannel> c); |
|
7553
2b93d333dea6
Bug 1271 - stronger type checking in SpectrumPhy
Nicola Baldo <nbaldo@cttc.es>
parents:
7385
diff
changeset
|
97 |
void SetMobility (Ptr<MobilityModel> m); |
2b93d333dea6
Bug 1271 - stronger type checking in SpectrumPhy
Nicola Baldo <nbaldo@cttc.es>
parents:
7385
diff
changeset
|
98 |
void SetDevice (Ptr<NetDevice> d); |
2b93d333dea6
Bug 1271 - stronger type checking in SpectrumPhy
Nicola Baldo <nbaldo@cttc.es>
parents:
7385
diff
changeset
|
99 |
Ptr<MobilityModel> GetMobility (); |
2b93d333dea6
Bug 1271 - stronger type checking in SpectrumPhy
Nicola Baldo <nbaldo@cttc.es>
parents:
7385
diff
changeset
|
100 |
Ptr<NetDevice> GetDevice (); |
6349 | 101 |
Ptr<const SpectrumModel> GetRxSpectrumModel () const; |
102 |
void StartRx (Ptr<PacketBurst> p, Ptr <const SpectrumValue> rxPsd, SpectrumType st, Time duration); |
|
7142
89a701fec3a1
run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents:
6969
diff
changeset
|
103 |
|
6349 | 104 |
|
105 |
||
106 |
/** |
|
107 |
* Get the SpectrumType used by this PHY |
|
108 |
* |
|
109 |
* @return |
|
110 |
*/ |
|
111 |
SpectrumType GetSpectrumType (); |
|
112 |
||
113 |
||
114 |
/** |
|
115 |
* set the Power Spectral Density of outgoing signals in power units |
|
116 |
* (Watt, Pascal...) per Hz. |
|
117 |
* |
|
118 |
* @param txPsd |
|
119 |
*/ |
|
120 |
void SetTxPowerSpectralDensity (Ptr<SpectrumValue> txPsd); |
|
121 |
||
122 |
/** |
|
123 |
* |
|
124 |
* @param noisePsd the Noise Power Spectral Density in power units |
|
125 |
* (Watt, Pascal...) per Hz. |
|
126 |
*/ |
|
127 |
void SetNoisePowerSpectralDensity (Ptr<const SpectrumValue> noisePsd); |
|
128 |
||
129 |
||
130 |
/** |
|
131 |
* Start a transmission |
|
132 |
* |
|
133 |
* |
|
134 |
* @param p the packet to be transmitted |
|
135 |
* |
|
136 |
* @return true if an error occurred and the transmission was not |
|
137 |
* started, false otherwise. |
|
138 |
*/ |
|
139 |
bool StartTx (Ptr<Packet> p); |
|
140 |
||
141 |
/** |
|
142 |
* set the PHY rate to be used by this PHY. |
|
143 |
* |
|
144 |
* @param rate |
|
145 |
*/ |
|
146 |
void SetRate (DataRate rate); |
|
147 |
||
148 |
/** |
|
149 |
* |
|
150 |
* @return the PHY rate used by this PHY. |
|
151 |
*/ |
|
152 |
DataRate GetRate () const; |
|
153 |
||
154 |
/** |
|
155 |
* set the callback for the end of a TX, as part of the |
|
156 |
* interconnections betweenthe PHY and the MAC |
|
157 |
* |
|
158 |
* @param c the callback |
|
159 |
*/ |
|
6969 | 160 |
void SetGenericPhyTxEndCallback (GenericPhyTxEndCallback c); |
6349 | 161 |
|
162 |
/** |
|
163 |
* set the callback for the start of RX, as part of the |
|
164 |
* interconnections betweenthe PHY and the MAC |
|
165 |
* |
|
166 |
* @param c the callback |
|
167 |
*/ |
|
6969 | 168 |
void SetGenericPhyRxStartCallback (GenericPhyRxStartCallback c); |
6349 | 169 |
|
170 |
/** |
|
171 |
* set the callback for the end of a RX in error, as part of the |
|
172 |
* interconnections betweenthe PHY and the MAC |
|
173 |
* |
|
174 |
* @param c the callback |
|
175 |
*/ |
|
6969 | 176 |
void SetGenericPhyRxEndErrorCallback (GenericPhyRxEndErrorCallback c); |
6349 | 177 |
|
178 |
/** |
|
179 |
* set the callback for the successful end of a RX, as part of the |
|
180 |
* interconnections betweenthe PHY and the MAC |
|
181 |
* |
|
182 |
* @param c the callback |
|
183 |
*/ |
|
6969 | 184 |
void SetGenericPhyRxEndOkCallback (GenericPhyRxEndOkCallback c); |
6349 | 185 |
|
186 |
||
187 |
||
188 |
private: |
|
7142
89a701fec3a1
run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents:
6969
diff
changeset
|
189 |
virtual void DoDispose (void); |
6349 | 190 |
|
191 |
void ChangeState (State newState); |
|
192 |
void EndTx (); |
|
193 |
void AbortRx (); |
|
194 |
void EndRx (); |
|
195 |
||
196 |
EventId m_endRxEventId; |
|
197 |
||
7553
2b93d333dea6
Bug 1271 - stronger type checking in SpectrumPhy
Nicola Baldo <nbaldo@cttc.es>
parents:
7385
diff
changeset
|
198 |
Ptr<MobilityModel> m_mobility; |
2b93d333dea6
Bug 1271 - stronger type checking in SpectrumPhy
Nicola Baldo <nbaldo@cttc.es>
parents:
7385
diff
changeset
|
199 |
Ptr<NetDevice> m_netDevice; |
6349 | 200 |
Ptr<SpectrumChannel> m_channel; |
201 |
||
202 |
Ptr<SpectrumValue> m_txPsd; |
|
203 |
Ptr<const SpectrumValue> m_rxPsd; |
|
204 |
Ptr<Packet> m_txPacket; |
|
205 |
Ptr<Packet> m_rxPacket; |
|
206 |
||
207 |
DataRate m_rate; |
|
208 |
||
209 |
State m_state; |
|
210 |
||
211 |
TracedCallback<Ptr<const Packet> > m_phyTxStartTrace; |
|
212 |
TracedCallback<Ptr<const Packet> > m_phyTxEndTrace; |
|
213 |
TracedCallback<Ptr<const Packet> > m_phyRxStartTrace; |
|
214 |
TracedCallback<Ptr<const Packet> > m_phyRxAbortTrace; |
|
215 |
TracedCallback<Ptr<const Packet> > m_phyRxEndOkTrace; |
|
216 |
TracedCallback<Ptr<const Packet> > m_phyRxEndErrorTrace; |
|
217 |
||
6969 | 218 |
GenericPhyTxEndCallback m_phyMacTxEndCallback; |
219 |
GenericPhyRxStartCallback m_phyMacRxStartCallback; |
|
220 |
GenericPhyRxEndErrorCallback m_phyMacRxEndErrorCallback; |
|
221 |
GenericPhyRxEndOkCallback m_phyMacRxEndOkCallback; |
|
6349 | 222 |
|
223 |
SpectrumInterference m_interference; |
|
224 |
||
225 |
}; |
|
226 |
||
227 |
||
228 |
||
229 |
||
230 |
||
231 |
||
232 |
} |
|
233 |
||
234 |
||
235 |
||
236 |
||
237 |
||
238 |
#endif /* HALF_DUPLEX_IDEAL_PHY_H */ |