22#include <ns3/angles.h>
23#include <ns3/antenna-model.h>
24#include <ns3/double.h>
26#include <ns3/mobility-model.h>
27#include <ns3/net-device.h>
29#include <ns3/object.h>
30#include <ns3/packet-burst.h>
31#include <ns3/packet.h>
32#include <ns3/propagation-delay-model.h>
33#include <ns3/propagation-loss-model.h>
34#include <ns3/simulator.h>
35#include <ns3/spectrum-phy.h>
36#include <ns3/spectrum-propagation-loss-model.h>
37#include <ns3/spectrum-transmit-filter.h>
66 static TypeId tid =
TypeId(
"ns3::SingleModelSpectrumChannel")
68 .SetGroupName(
"Spectrum")
97 NS_LOG_FUNCTION(
this << txParams->psd << txParams->duration << txParams->txPhy);
121 for (PhyList::const_iterator rxPhyIterator =
m_phyList.begin();
128 if (rxNetDevice && txNetDevice)
131 if (rxNetDevice->GetNode()->GetId() == txNetDevice->GetNode()->GetId())
133 NS_LOG_DEBUG(
"Skipping the pathloss calculation among different antennas of the "
134 "same node, not supported yet by any pathloss model in ns-3.");
144 if ((*rxPhyIterator) != txParams->txPhy)
152 if (senderMobility && receiverMobility)
154 double txAntennaGain = 0;
155 double rxAntennaGain = 0;
156 double propagationGainDb = 0;
157 double pathLossDb = 0;
158 if (rxParams->txAntenna)
160 Angles txAngles(receiverMobility->GetPosition(), senderMobility->GetPosition());
161 txAntennaGain = rxParams->txAntenna->GetGainDb(txAngles);
162 NS_LOG_LOGIC(
"txAntennaGain = " << txAntennaGain <<
" dB");
163 pathLossDb -= txAntennaGain;
166 DynamicCast<AntennaModel>((*rxPhyIterator)->GetAntenna());
169 Angles rxAngles(senderMobility->GetPosition(), receiverMobility->GetPosition());
170 rxAntennaGain = rxAntenna->GetGainDb(rxAngles);
171 NS_LOG_LOGIC(
"rxAntennaGain = " << rxAntennaGain <<
" dB");
172 pathLossDb -= rxAntennaGain;
178 NS_LOG_LOGIC(
"propagationGainDb = " << propagationGainDb <<
" dB");
179 pathLossDb -= propagationGainDb;
181 NS_LOG_LOGIC(
"total pathLoss = " << pathLossDb <<
" dB");
196 double pathGainLinear = std::pow(10.0, (-pathLossDb) / 10.0);
197 *(rxParams->psd) *= pathGainLinear;
208 uint32_t dstNode = rxNetDevice->GetNode()->GetId();
238 params->txPhy->GetMobility(),
239 receiver->GetMobility());
241 receiver->StartRx(params);
Class holding the azimuth and inclination angles of spherical coordinates.
Network layer to device interface.
double CalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account all the PropagationLossModel(s) chained to the current one.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
SpectrumChannel implementation which handles a single spectrum model.
Ptr< const SpectrumModel > m_spectrumModel
SpectrumModel that this channel instance is supporting.
PhyList m_phyList
List of SpectrumPhy instances attached to the channel.
void StartTx(Ptr< SpectrumSignalParameters > params) override
Used by attached PHY instances to transmit signals on the channel.
void DoDispose() override
Destructor implementation.
void RemoveRx(Ptr< SpectrumPhy > phy) override
Remove a SpectrumPhy from a channel.
SingleModelSpectrumChannel()
void AddRx(Ptr< SpectrumPhy > phy) override
Add a SpectrumPhy to a channel, so it can receive packets.
Ptr< NetDevice > GetDevice(std::size_t i) const override
std::size_t GetNDevices() const override
void StartRx(Ptr< SpectrumSignalParameters > params, Ptr< SpectrumPhy > receiver)
Used internally to reschedule transmission after the propagation delay.
static TypeId GetTypeId()
Get the type ID.
Defines the interface for spectrum-aware channel implementations.
TracedCallback< Ptr< SpectrumSignalParameters > > m_txSigParamsTrace
Traced callback for SpectrumSignalParameters in StartTx requests.
void DoDispose() override
Destructor implementation.
Ptr< SpectrumTransmitFilter > m_filter
Transmit filter to be used with this channel.
Ptr< PropagationDelayModel > m_propagationDelay
Propagation delay model to be used with this channel.
Ptr< SpectrumPropagationLossModel > m_spectrumPropagationLoss
Frequency-dependent propagation loss model to be used with this channel.
TracedCallback< Ptr< const SpectrumPhy >, Ptr< const SpectrumPhy >, double > m_pathLossTrace
The PathLoss trace source.
TracedCallback< Ptr< const MobilityModel >, Ptr< const MobilityModel >, double, double, double, double > m_gainTrace
The Gain trace source.
Ptr< PropagationLossModel > m_propagationLoss
Single-frequency propagation loss model to be used with this channel.
double m_maxLossDb
Maximum loss [dB].
Simulation virtual time values and global simulation resolution.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.