21 #include <ns3/object.h> 22 #include <ns3/simulator.h> 24 #include <ns3/packet.h> 25 #include <ns3/packet-burst.h> 26 #include <ns3/net-device.h> 28 #include <ns3/double.h> 29 #include <ns3/mobility-model.h> 30 #include <ns3/spectrum-phy.h> 31 #include <ns3/spectrum-propagation-loss-model.h> 32 #include <ns3/propagation-loss-model.h> 33 #include <ns3/propagation-delay-model.h> 34 #include <ns3/antenna-model.h> 35 #include <ns3/angles.h> 65 static TypeId tid =
TypeId (
"ns3::SingleModelSpectrumChannel")
67 .SetGroupName (
"Spectrum")
85 NS_LOG_FUNCTION (
this << txParams->psd << txParams->duration << txParams->txPhy);
109 for (PhyList::const_iterator rxPhyIterator =
m_phyList.begin ();
113 if ((*rxPhyIterator) != txParams->txPhy)
118 NS_LOG_LOGIC (
"copying signal parameters " << txParams);
121 if (senderMobility && receiverMobility)
123 double txAntennaGain = 0;
124 double rxAntennaGain = 0;
125 double propagationGainDb = 0;
126 double pathLossDb = 0;
127 if (rxParams->txAntenna != 0)
130 txAntennaGain = rxParams->txAntenna->GetGainDb (txAngles);
131 NS_LOG_LOGIC (
"txAntennaGain = " << txAntennaGain <<
" dB");
132 pathLossDb -= txAntennaGain;
138 rxAntennaGain = rxAntenna->GetGainDb (rxAngles);
139 NS_LOG_LOGIC (
"rxAntennaGain = " << rxAntennaGain <<
" dB");
140 pathLossDb -= rxAntennaGain;
145 NS_LOG_LOGIC (
"propagationGainDb = " << propagationGainDb <<
" dB");
146 pathLossDb -= propagationGainDb;
148 NS_LOG_LOGIC (
"total pathLoss = " << pathLossDb <<
" dB");
150 m_gainTrace (senderMobility, receiverMobility, txAntennaGain, rxAntennaGain, propagationGainDb, pathLossDb);
158 double pathGainLinear = std::pow (10.0, (-pathLossDb) / 10.0);
159 *(rxParams->psd) *= pathGainLinear;
177 uint32_t dstNode = netDev->GetNode ()->GetId ();
184 rxParams, *rxPhyIterator);
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Simulation virtual time values and global simulation resolution.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
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...
virtual void StartRx(Ptr< SpectrumSignalParameters > params)=0
Notify the SpectrumPhy instance of an incoming signal.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
TracedCallback< Ptr< const SpectrumPhy >, Ptr< const SpectrumPhy >, double > m_pathLossTrace
The PathLoss trace source.
virtual void AddRx(Ptr< SpectrumPhy > phy)
Add a SpectrumPhy to a channel, so it can receive packets.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
double m_maxLossDb
Maximum loss [dB].
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
void StartRx(Ptr< SpectrumSignalParameters > params, Ptr< SpectrumPhy > receiver)
Used internally to reschedule transmission after the propagation delay.
virtual void DoDispose()
Destructor implementation.
Ptr< SpectrumPropagationLossModel > m_spectrumPropagationLoss
Frequency-dependent propagation loss model to be used with this channel.
static void ScheduleWithContext(uint32_t context, Time const &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static TypeId GetTypeId(void)
Get the type ID.
virtual void StartTx(Ptr< SpectrumSignalParameters > params)
Used by attached PHY instances to transmit signals on the channel.
virtual std::size_t GetNDevices(void) const
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
Vector GetPosition(void) const
Ptr< PropagationLossModel > m_propagationLoss
Single-frequency propagation loss model to be used with this channel.
SingleModelSpectrumChannel()
Network layer to device interface.
TracedCallback< Ptr< SpectrumSignalParameters > > m_txSigParamsTrace
Traced callback for SpectrumSignalParameters in StartTx requests.
SpectrumChannel implementation which handles a single spectrum model.
Defines the interface for spectrum-aware channel implementations.
Ptr< PropagationDelayModel > m_propagationDelay
Propagation delay model to be used with this channel.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
struct holding the azimuth and inclination angles of spherical coordinates.
PhyList m_phyList
List of SpectrumPhy instances attached to the channel.
a unique identifier for an interface.
TracedCallback< Ptr< const MobilityModel >, Ptr< const MobilityModel >, double, double, double, double > m_gainTrace
The Gain trace source.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
virtual void DoDispose(void)
Destructor implementation.
Ptr< const SpectrumModel > m_spectrumModel
SpectrumModel that this channel instance is supporting.
virtual Ptr< NetDevice > GetDevice(std::size_t i) const