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 // end of class UanPacketArrival
125};
126
127/**
128 * @ingroup uan
129 *
130 * Virtual base for Transducer objects.
131 *
132 * The Transducer was added to support classes such as UanPhyDual.
133 * In a generic Phy setting, this class functions to hold information about all
134 * possibly interfering packets.
135 */
136class UanTransducer : public Object
137{
138 public:
139 /**
140 * Register this type.
141 * @return The object TypeId.
142 */
143 static TypeId GetTypeId();
144
145 /** Transducer state. */
146 enum State
147 {
148 TX, //!< Transmitting.
149 RX //!< Receiving.
150 };
151
152 /** List of arriving packets overlapping in time. */
153 typedef std::list<UanPacketArrival> ArrivalList;
154 /** List of UanPhy objects. */
155 typedef std::list<Ptr<UanPhy>> UanPhyList;
156
157 /**
158 * Get the transducer state.
159 *
160 * @return State (TX or RX) of this transducer.
161 */
162 virtual State GetState() const = 0;
163
164 /**
165 * Is the state receiving (or available for reception)?
166 *
167 * @return True if this transducer is available for receiving
168 * an incoming packet.
169 */
170 virtual bool IsRx() const = 0;
171 /**
172 * Is the state transmitting?
173 *
174 * @return True if there is a packet being transmitted from this transducer.
175 */
176 virtual bool IsTx() const = 0;
177 /**
178 * Get the list of overlapped (in time) packets at this transducer.
179 *
180 * @return List of all packets currently crossing this node in the water.
181 */
182 virtual const ArrivalList& GetArrivalList() const = 0;
183 /**
184 * Set the receiver gain.
185 *
186 * @param gainDb Gain added at receiver, in dB.
187 */
188 virtual void SetRxGainDb(double gainDb) = 0;
189 /**
190 * Get the receiver gain added to signal at receiver in dB.
191 *
192 * @return The gain (in dB).
193 */
194 virtual double GetRxGainDb() = 0;
195 /**
196 * Apply receiver gain in dB to the received power.
197 * @param rxPowerDb Signal power in dB of arriving packet.
198 * @param mode Mode arriving packet is using.
199 *
200 * @return Updated receive power (in dB) with gain applied.
201 */
202 virtual double ApplyRxGainDb(double rxPowerDb, UanTxMode mode) = 0;
203 /**
204 * Notify this object that a new packet has arrived at this nodes location
205 *
206 * @param packet Packet arriving.
207 * @param rxPowerDb Signal power in dB of arriving packet.
208 * @param txMode Mode arriving packet is using.
209 * @param pdp PDP of arriving signal.
210 */
211 virtual void Receive(Ptr<Packet> packet, double rxPowerDb, UanTxMode txMode, UanPdp pdp) = 0;
212 /**
213 * Transmit a packet from this transducer.
214 *
215 * @param src Source PHY.
216 * @param packet Packet to transmit.
217 * @param txPowerDb Outgoing Tx power of packet.
218 * @param txMode Mode to transmit packet with.
219 */
220 virtual void Transmit(Ptr<UanPhy> src,
221 Ptr<Packet> packet,
222 double txPowerDb,
223 UanTxMode txMode) = 0;
224 /**
225 * Attach this transducer to a channel.
226 *
227 * @param chan The channel
228 */
229 virtual void SetChannel(Ptr<UanChannel> chan) = 0;
230 /**
231 * Get the attached channel.
232 *
233 * @return The channel.
234 */
235 virtual Ptr<UanChannel> GetChannel() const = 0;
236 /**
237 * Attach a physical network layer above this transducer.
238 *
239 * More than one physical layer may be attached.
240 *
241 * @param phy The physical layer.
242 */
243 virtual void AddPhy(Ptr<UanPhy> phy) = 0;
244 /**
245 * Get the list of physical layer above this transducer.
246 *
247 * @return List of attached physical layers.
248 */
249 virtual const UanPhyList& GetPhyList() const = 0;
250 /**
251 * Clears all pointer references.
252 */
253 virtual void Clear() = 0;
254
255 // end of class UanTransducer
256};
257
258} // namespace ns3
259
260#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:49
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.