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