|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
28 #include "ns3/double.h"
29 #include "ns3/string.h"
32 #include "ns3/traced-callback.h"
33 #include "ns3/trace-source-accessor.h"
34 #include "ns3/simulator.h"
80 NS_LOG_WARN (
"Calculating SINR for unsupported modulation type");
83 double intKp = -
DbToKp (rxPowerDb);
84 UanTransducer::ArrivalList::const_iterator it = arrivalList.begin ();
85 for (; it != arrivalList.end (); it++)
88 if (std::abs ( (
double) it->GetTxMode ().GetCenterFreqHz () - (
double) mode.
GetCenterFreqHz ())
89 < (
double)(it->GetTxMode ().GetBandwidthHz () / 2 + mode.
GetBandwidthHz () / 2) - 0.5)
96 it->GetPacket ()->PeekHeader (ch2);
103 << mode.
GetName () <<
" Int mode: " << it->GetTxMode ().GetName () <<
" Separation: "
104 << std::abs ( (
double) it->GetTxMode ().GetCenterFreqHz () - (
double) mode.
GetCenterFreqHz ())
105 <<
" Combined bandwidths: " << (
double)(it->GetTxMode ().GetBandwidthHz () / 2 + mode.
GetBandwidthHz () / 2) - 0.5);
108 intKp +=
DbToKp (it->GetRxPowerDb ());
112 double totalIntDb =
KpToDb (intKp +
DbToKp (ambNoiseDb));
114 NS_LOG_DEBUG (
Now ().As (
Time::S) <<
" Calculating SINR: RxPower = " << rxPowerDb <<
" dB. Number of interferers = " << arrivalList.size () <<
" Interference + noise power = " << totalIntDb <<
" dB. SINR = " << rxPowerDb - totalIntDb <<
" dB.");
115 return rxPowerDb - totalIntDb;
122 m_phy1 = CreateObject<UanPhyGen> ();
123 m_phy2 = CreateObject<UanPhyGen> ();
163 .SetGroupName (
"Uan")
165 .AddAttribute (
"CcaThresholdPhy1",
166 "Aggregate energy of incoming signals to move to CCA Busy state dB of Phy1.",
169 MakeDoubleChecker<double> ())
170 .AddAttribute (
"CcaThresholdPhy2",
171 "Aggregate energy of incoming signals to move to CCA Busy state dB of Phy2.",
174 MakeDoubleChecker<double> ())
175 .AddAttribute (
"TxPowerPhy1",
176 "Transmission output power in dB of Phy1.",
179 MakeDoubleChecker<double> ())
180 .AddAttribute (
"TxPowerPhy2",
181 "Transmission output power in dB of Phy2.",
184 MakeDoubleChecker<double> ())
185 .AddAttribute (
"SupportedModesPhy1",
186 "List of modes supported by Phy1.",
190 .AddAttribute (
"SupportedModesPhy2",
191 "List of modes supported by Phy2.",
195 .AddAttribute (
"PerModelPhy1",
196 "Functor to calculate PER based on SINR and TxMode for Phy1.",
199 MakePointerChecker<UanPhyPer> ())
200 .AddAttribute (
"PerModelPhy2",
201 "Functor to calculate PER based on SINR and TxMode for Phy2.",
204 MakePointerChecker<UanPhyPer> ())
205 .AddAttribute (
"SinrModelPhy1",
206 "Functor to calculate SINR based on pkt arrivals and modes for Phy1.",
209 MakePointerChecker<UanPhyCalcSinr> ())
210 .AddAttribute (
"SinrModelPhy2",
211 "Functor to calculate SINR based on pkt arrivals and modes for Phy2.",
214 MakePointerChecker<UanPhyCalcSinr> ())
215 .AddTraceSource (
"RxOk",
216 "A packet was received successfully.",
218 "ns3::UanPhy::TracedCallback")
219 .AddTraceSource (
"RxError",
220 "A packet was received unsuccessfully.",
222 "ns3::UanPhy::TracedCallback")
223 .AddTraceSource (
"Tx",
224 "Packet transmission beginning.",
226 "ns3::UanPhy::TracedCallback")
258 m_phy1->SendPacket (pkt, modeNum);
265 m_phy2->SendPacket (pkt, modeNum -
m_phy1->GetNModes ());
271 m_phy1->RegisterListener (listener);
272 m_phy2->RegisterListener (listener);
285 m_phy1->SetReceiveOkCallback (cb);
286 m_phy2->SetReceiveOkCallback (cb);
292 m_phy1->SetReceiveErrorCallback (cb);
293 m_phy2->SetReceiveErrorCallback (cb);
300 m_phy1->SetTxPowerDb (txpwr);
301 m_phy2->SetTxPowerDb (txpwr);
307 m_phy1->SetTxPowerDb (txpwr);
312 m_phy2->SetTxPowerDb (txpwr);
318 m_phy1->SetRxThresholdDb (thresh);
319 m_phy2->SetRxThresholdDb (thresh);
324 m_phy1->SetCcaThresholdDb (thresh);
325 m_phy2->SetCcaThresholdDb (thresh);
331 m_phy1->SetCcaThresholdDb (thresh);
336 m_phy2->SetCcaThresholdDb (thresh);
343 NS_LOG_WARN (
"Warning: Dual Phy only returns TxPowerDb of Phy 1");
344 return m_phy1->GetTxPowerDb ();
350 return m_phy1->GetTxPowerDb ();
356 return m_phy2->GetTxPowerDb ();
362 return m_phy1->GetRxThresholdDb ();
368 NS_LOG_WARN (
"Dual Phy only returns CCAThreshold of Phy 1");
369 return m_phy1->GetCcaThresholdDb ();
374 return m_phy1->GetCcaThresholdDb ();
379 return m_phy2->GetCcaThresholdDb ();
385 return m_phy1->IsStateIdle ();
390 return m_phy2->IsStateIdle ();
396 return m_phy1->IsStateRx ();
402 return m_phy2->IsStateRx ();
408 return m_phy1->IsStateTx ();
414 return m_phy1->GetPacketRx ();
420 return m_phy2->GetPacketRx ();
426 return m_phy2->IsStateTx ();
431 return m_phy1->IsStateSleep () &&
m_phy2->IsStateSleep ();
436 return m_phy1->IsStateIdle () &&
m_phy2->IsStateIdle ();
456 return m_phy1->IsStateCcaBusy () ||
m_phy2->IsStateCcaBusy ();
461 return m_phy1->GetChannel ();
466 return m_phy1->GetDevice ();
477 m_phy1->SetDevice (device);
478 m_phy2->SetDevice (device);
494 m_phy1->NotifyIntChange ();
495 m_phy2->NotifyIntChange ();
501 m_phy1->SetTransducer (trans);
502 m_phy2->SetTransducer (trans);
507 NS_LOG_WARN (
"DualPhy Returning transducer of Phy1");
508 return m_phy1->GetTransducer ();
533 m_phy1->GetAttribute (
"SupportedModes", modeValue);
534 return modeValue.
Get ();
541 m_phy2->GetAttribute (
"SupportedModes", modeValue);
542 return modeValue.
Get ();
561 m_phy1->GetAttribute (
"PerModel", perValue);
569 m_phy2->GetAttribute (
"PerModel", perValue);
589 m_phy1->GetAttribute (
"SinrModel", sinrValue);
597 m_phy2->GetAttribute (
"SinrModel", sinrValue);
631 NS_FATAL_ERROR (
"GetPacketRx not valid for UanPhyDual. Must specify GetPhy1PacketRx or GetPhy2PacketRx");
632 return Create<Packet> ();
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< UanPhyCalcSinr > GetSinrModelPhy2(void) const
Get the SINR calculator.
double GetCcaThresholdPhy1(void) const
Get the CCA threshold signal strength required to detect channel busy.
double GetTxPowerDbPhy2(void) const
Get the current transmit power, in dB.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
The power delay profile returned by propagation models.
virtual void DoDispose()
Destructor implementation.
void SetModesPhy1(UanModesList modes)
Set the available modes.
void SetTxPowerDbPhy1(double txpwr)
Set the transmit power.
virtual void SetMac(Ptr< UanMac > mac)
Set the MAC forwarding messages to this Phy.
virtual void NotifyTransStartTx(Ptr< Packet > packet, double txPowerDb, UanTxMode txMode)
Called when a transmission is beginning on the attached transducer.
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_rxErrLogger
A packet was received unsuccessfully.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual double GetCcaThresholdDb(void)
Get the CCA threshold signal strength required to detect channel busy.
virtual UanTxMode GetMode(uint32_t n)
Get a specific transmission mode.
virtual uint32_t GetNModes(void)
Get the number of transmission modes supported by this Phy.
void SetTxPowerDbPhy2(double txpwr)
Set the transmit power.
void RxErrFromSubPhy(Ptr< Packet > pkt, double sinr)
Handle callback and logger for packets received with error.
virtual void StartRxPacket(Ptr< Packet > pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp)
Packet arriving from channel: i.e.
virtual bool IsStateCcaBusy(void)
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
virtual void SetEnergyModelCallback(DeviceEnergyModel::ChangeStateCallback callback)
Set the DeviceEnergyModel callback for UanPhy device.
virtual double CalcSinrDb(Ptr< Packet > pkt, Time arrTime, double rxPowerDb, double ambNoiseDb, UanTxMode mode, UanPdp pdp, const UanTransducer::ArrivalList &arrivalList) const
Calculate the SINR value for a packet.
UanPhyCalcSinrDual()
Constructor.
uint32_t GetBandwidthHz(void) const
Get the transmission signal bandwidth.
Hold objects of type Ptr<T>.
virtual void SetDevice(Ptr< UanNetDevice > device)
Set the device hosting this Phy.
void SetPerModelPhy1(Ptr< UanPhyPer > per)
Set the error probability model.
virtual bool IsStateTx(void)
Container for UanTxModes.
void SetCcaThresholdPhy1(double thresh)
Set the threshold for detecting channel busy.
AttributeValue implementation for UanModesList.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
virtual void SetChannel(Ptr< UanChannel > channel)
Attach to a channel.
Base class for UAN Phy models.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
uint32_t GetCenterFreqHz(void) const
Get the transmission center frequency.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
void SetCcaThresholdPhy2(double thresh)
Set the threshold for detecting channel busy.
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_rxOkLogger
A packet was received successfully.
Ptr< Packet > GetPhy2PacketRx(void) const
Get the packet currently being received.
virtual double GetRxThresholdDb(void)
Get the minimum received signal strength required to receive a packet without errors.
UanModesList GetModesPhy1(void) const
Get the list of available modes.
virtual void SendPacket(Ptr< Packet > pkt, uint32_t modeNum)
Send a packet using a specific transmission mode.
virtual void SetRxThresholdDb(double thresh)
Set the minimum SINR threshold to receive a packet without errors.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
virtual void Clear(void)
Clear all pointer references.
double GetCcaThresholdPhy2(void) const
Get the CCA threshold signal strength required to detect channel busy.
Ptr< UanPhyCalcSinr > GetSinrModelPhy1(void) const
Get the SINR calculator.
Ptr< UanPhyPer > GetPerModelPhy2(void) const
Get the error probability model.
void SetSinrModelPhy1(Ptr< UanPhyCalcSinr > calcSinr)
Set the SINR calculator.
virtual ~UanPhyDual()
Dummy destructor.
static TypeId GetTypeId()
Register this type.
void SetPerModelPhy2(Ptr< UanPhyPer > per)
Set the error probability model.
virtual void RegisterListener(UanPhyListener *listener)
Register a UanPhyListener to be notified of common UanPhy events.
Ptr< Packet > GetPhy1PacketRx(void) const
Get the packet currently being received.
#define NS_UNUSED(x)
Mark a local variable as unused.
UanModesList Get(void) const
virtual ~UanPhyCalcSinrDual()
Destructor.
@ OTHER
Unspecified/undefined.
virtual Ptr< UanNetDevice > GetDevice(void) const
Get the device hosting this Phy.
Simulation virtual time values and global simulation resolution.
virtual void SetReceiveOkCallback(RxOkCallback cb)
Set the callback to be used when a packet is received without error.
Abstraction of packet modulation information.
virtual bool IsStateBusy(void)
static UanModesList GetDefaultModes(void)
Get the default transmission modes.
virtual void EnergyDepletionHandler(void)
Handle the energy depletion event.
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_txLogger
A packet was sent from this Phy.
static TypeId GetTypeId(void)
Register this type.
RxErrCallback m_recErrCb
Callback when packet received with errors.
virtual void SetTxPowerDb(double txpwr)
Set the transmit power.
virtual void NotifyIntChange(void)
Called when there has been a change in the amount of interference this node is experiencing from othe...
Ptr< UanPhyPer > GetPerModelPhy1(void) const
Get the error probability model.
double KpToDb(double kp) const
Convert kilopascals to dB re 1 uPa.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Hold variables of type string.
virtual double GetTxPowerDb(void)
Get the current transmit power, in dB.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
double GetTxPowerDbPhy1(void) const
Get the current transmit power, in dB.
Ptr< const AttributeChecker > MakeUanModesListChecker(void)
Interface for PHY event listener.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
void SetModesPhy2(UanModesList modes)
Set the available modes.
void RxOkFromSubPhy(Ptr< Packet > pkt, double sinr, UanTxMode mode)
Handle callback and logger for packets received without error.
virtual Ptr< UanChannel > GetChannel(void) const
Get the attached channel.
virtual bool IsStateRx(void)
std::list< UanPacketArrival > ArrivalList
List of arriving packets overlapping in time.
RxOkCallback m_recOkCb
Callback when packet received without errors.
virtual Ptr< UanTransducer > GetTransducer(void)
Get the attached transducer.
virtual bool IsStateSleep(void)
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
std::string GetName(void) const
Get the mode name.
Class used for calculating SINR of packet in UanPhy.
ModulationType GetModType(void) const
Get the modulation type of the mode.
Ptr< UanPhy > m_phy2
Second Phy layer.
void SetSinrModelPhy2(Ptr< UanPhyCalcSinr > calcSinr)
Set the SINR calculator.
Ptr< UanPhy > m_phy1
First Phy layer.
virtual void SetCcaThresholdDb(double thresh)
Set the threshold for detecting channel busy.
virtual void DoDispose(void)
Destructor implementation.
virtual bool IsStateIdle(void)
virtual void SetReceiveErrorCallback(RxErrCallback cb)
Set the callback to be used when a packet is received with errors.
Ptr< Packet > GetPacketRx(void) const
Get the packet currently being received.
virtual void SetTransducer(Ptr< UanTransducer > trans)
Attach a transducer to this Phy.
virtual void EnergyRechargeHandler(void)
Handle the energy recharge event.
Default SINR model for UanPhyDual.
double DbToKp(double db) const
Convert dB re 1 uPa to kilopascals.
UanModesList GetModesPhy2(void) const
Get the list of available modes.
Ptr< const AttributeAccessor > MakeUanModesListAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.