A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
uan-transducer.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 University of Washington
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Leonard Tracy <lentracy@gmail.com>
18 */
19
20#ifndef UAN_TRANSDUCER_H
21#define UAN_TRANSDUCER_H
22
23#include "uan-prop-model.h"
24#include "uan-tx-mode.h"
25
26#include "ns3/object.h"
27#include "ns3/packet.h"
28
29#include <list>
30
31namespace ns3
32{
33
34class UanPhy;
35class UanChannel;
36
37/**
38 * \ingroup uan
39 *
40 * Class consisting of packet arrival information (Time, RxPower, mode, PDP).
41 */
43{
44 public:
45 /** Default constructor. */
47 {
48 }
49
50 /**
51 * Constructor.
52 *
53 * \param packet Packet arriving.
54 * \param rxPowerDb RX signal power in dB of arriving packet.
55 * \param txMode TX mode of arriving packet.
56 * \param pdp Power delay profile of arriving packet.
57 * \param arrTime Arrival time of packet.
58 */
60 double rxPowerDb,
61 UanTxMode txMode,
62 UanPdp pdp,
63 Time arrTime)
64 : m_packet(packet),
65 m_rxPowerDb(rxPowerDb),
66 m_txMode(txMode),
67 m_pdp(pdp),
68 m_arrTime(arrTime)
69 {
70 }
71
72 /** Destructor */
74 {
75 m_packet = nullptr;
76 }
77
78 /**
79 * Get the arriving packet.
80 *
81 * \return Pointer to packet.
82 */
83 inline Ptr<Packet> GetPacket() const
84 {
85 return m_packet;
86 }
87
88 /**
89 * Get the received signal strength.
90 *
91 * \return Received signal strength in dB re 1uPa
92 */
93 inline double GetRxPowerDb() const
94 {
95 return m_rxPowerDb;
96 }
97
98 /**
99 * Get the transmission mode of the packet.
100 *
101 * \return UanTxMode.
102 */
103 inline const UanTxMode& GetTxMode() const
104 {
105 return m_txMode;
106 }
107
108 /**
109 * Get the packet arrival time.
110 *
111 * \return Arrival time.
112 */
113 inline Time GetArrivalTime() const
114 {
115 return m_arrTime;
116 }
117
118 /**
119 * Get the propagation delay profile.
120 *
121 * \return PDP of arriving signal.
122 */
123 inline UanPdp GetPdp() const
124 {
125 return m_pdp;
126 }
127
128 private:
129 Ptr<Packet> m_packet; //!< The arrived packet.
130 double m_rxPowerDb; //!< The received power, in dB.
131 UanTxMode m_txMode; //!< The transmission mode.
132 UanPdp m_pdp; //!< The propagation delay profile.
133 Time m_arrTime; //!< The arrival time.
134
135}; // class UanPacketArrival
136
137/**
138 * \ingroup uan
139 *
140 * Virtual base for Transducer objects.
141 *
142 * The Transducer was added to support classes such as UanPhyDual.
143 * In a generic Phy setting, this class functions to hold information about all
144 * possibly interfering packets.
145 */
146class UanTransducer : public Object
147{
148 public:
149 /**
150 * Register this type.
151 * \return The object TypeId.
152 */
153 static TypeId GetTypeId();
154
155 /** Transducer state. */
156 enum State
157 {
158 TX, //!< Transmitting.
159 RX //!< Receiving.
160 };
161
162 /** List of arriving packets overlapping in time. */
163 typedef std::list<UanPacketArrival> ArrivalList;
164 /** List of UanPhy objects. */
165 typedef std::list<Ptr<UanPhy>> UanPhyList;
166
167 /**
168 * Get the transducer state.
169 *
170 * \return State (TX or RX) of this transducer.
171 */
172 virtual State GetState() const = 0;
173
174 /**
175 * Is the state receiving (or available for reception)?
176 *
177 * \return True if this transducer is available for receiving
178 * an incoming packet.
179 */
180 virtual bool IsRx() const = 0;
181 /**
182 * Is the state transmitting?
183 *
184 * \return True if there is a packet being transmitted from this transducer.
185 */
186 virtual bool IsTx() const = 0;
187 /**
188 * Get the list of overlapped (in time) packets at this transducer.
189 *
190 * \return List of all packets currently crossing this node in the water.
191 */
192 virtual const ArrivalList& GetArrivalList() const = 0;
193 /**
194 * Set the receiver gain.
195 *
196 * \param gainDb Gain added at receiver, in dB.
197 */
198 virtual void SetRxGainDb(double gainDb) = 0;
199 /**
200 * Get the receiver gain added to signal at receiver in dB.
201 *
202 * \return The gain (in dB).
203 */
204 virtual double GetRxGainDb() = 0;
205 /**
206 * Apply receiver gain in dB to the received power.
207 * \param rxPowerDb Signal power in dB of arriving packet.
208 * \param mode Mode arriving packet is using.
209 *
210 * \return Updated receive power (in dB) with gain applied.
211 */
212 virtual double ApplyRxGainDb(double rxPowerDb, UanTxMode mode) = 0;
213 /**
214 * Notify this object that a new packet has arrived at this nodes location
215 *
216 * \param packet Packet arriving.
217 * \param rxPowerDb Signal power in dB of arriving packet.
218 * \param txMode Mode arriving packet is using.
219 * \param pdp PDP of arriving signal.
220 */
221 virtual void Receive(Ptr<Packet> packet, double rxPowerDb, UanTxMode txMode, UanPdp pdp) = 0;
222 /**
223 * Transmit a packet from this transducer.
224 *
225 * \param src Source PHY.
226 * \param packet Packet to transmit.
227 * \param txPowerDb Outgoing Tx power of packet.
228 * \param txMode Mode to transmit packet with.
229 */
230 virtual void Transmit(Ptr<UanPhy> src,
231 Ptr<Packet> packet,
232 double txPowerDb,
233 UanTxMode txMode) = 0;
234 /**
235 * Attach this transducer to a channel.
236 *
237 * \param chan The channel
238 */
239 virtual void SetChannel(Ptr<UanChannel> chan) = 0;
240 /**
241 * Get the attached channel.
242 *
243 * \return The channel.
244 */
245 virtual Ptr<UanChannel> GetChannel() const = 0;
246 /**
247 * Attach a physical network layer above this transducer.
248 *
249 * More than one physical layer may be attached.
250 *
251 * \param phy The physical layer.
252 */
253 virtual void AddPhy(Ptr<UanPhy> phy) = 0;
254 /**
255 * Get the list of physical layer above this transducer.
256 *
257 * \return List of attached physical layers.
258 */
259 virtual const UanPhyList& GetPhyList() const = 0;
260 /**
261 * Clears all pointer references.
262 */
263 virtual void Clear() = 0;
264
265}; // class UanTransducer
266
267} // namespace ns3
268
269#endif /* UAN_TRANSDUCER_H */
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
Class consisting of packet arrival information (Time, RxPower, mode, PDP).
Ptr< Packet > m_packet
The arrived packet.
UanPdp m_pdp
The propagation delay profile.
Time GetArrivalTime() const
Get the packet arrival time.
const UanTxMode & GetTxMode() const
Get the transmission mode of the packet.
double m_rxPowerDb
The received power, in dB.
double GetRxPowerDb() const
Get the received signal strength.
UanPacketArrival(Ptr< Packet > packet, double rxPowerDb, UanTxMode txMode, UanPdp pdp, Time arrTime)
Constructor.
UanPdp GetPdp() const
Get the propagation delay profile.
~UanPacketArrival()
Destructor.
Time m_arrTime
The arrival time.
UanTxMode m_txMode
The transmission mode.
UanPacketArrival()
Default constructor.
Ptr< Packet > GetPacket() const
Get the arriving packet.
The power delay profile returned by propagation models.
Virtual base for Transducer objects.
State
Transducer state.
@ TX
Transmitting.
virtual bool IsRx() const =0
Is the state receiving (or available for reception)?
virtual void AddPhy(Ptr< UanPhy > phy)=0
Attach a physical network layer above this transducer.
virtual double ApplyRxGainDb(double rxPowerDb, UanTxMode mode)=0
Apply receiver gain in dB to the received power.
std::list< Ptr< UanPhy > > UanPhyList
List of UanPhy objects.
virtual double GetRxGainDb()=0
Get the receiver gain added to signal at receiver in dB.
virtual bool IsTx() const =0
Is the state transmitting?
virtual const ArrivalList & GetArrivalList() const =0
Get the list of overlapped (in time) packets at this transducer.
std::list< UanPacketArrival > ArrivalList
List of arriving packets overlapping in time.
virtual void Receive(Ptr< Packet > packet, double rxPowerDb, UanTxMode txMode, UanPdp pdp)=0
Notify this object that a new packet has arrived at this nodes location.
virtual Ptr< UanChannel > GetChannel() const =0
Get the attached channel.
virtual void Transmit(Ptr< UanPhy > src, Ptr< Packet > packet, double txPowerDb, UanTxMode txMode)=0
Transmit a packet from this transducer.
virtual void Clear()=0
Clears all pointer references.
virtual void SetChannel(Ptr< UanChannel > chan)=0
Attach this transducer to a channel.
virtual const UanPhyList & GetPhyList() const =0
Get the list of physical layer above this transducer.
virtual void SetRxGainDb(double gainDb)=0
Set the receiver gain.
static TypeId GetTypeId()
Register this type.
virtual State GetState() const =0
Get the transducer state.
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:43
Every class exported by the ns3 library is enclosed in the ns3 namespace.