21 #include "ns3/simulator.h"
23 #include "ns3/pointer.h"
24 #include "ns3/wifi-net-device.h"
26 #include "ns3/propagation-loss-model.h"
27 #include "ns3/propagation-delay-model.h"
28 #include "ns3/mobility-model.h"
46 .SetGroupName (
"Wifi")
48 .AddAttribute (
"PropagationLossModel",
"A pointer to the propagation loss model attached to this channel.",
51 MakePointerChecker<PropagationLossModel> ())
52 .AddAttribute (
"PropagationDelayModel",
"A pointer to the propagation delay model attached to this channel.",
55 MakePointerChecker<PropagationDelayModel> ())
102 Time delay =
m_delay->GetDelay (senderMobility, receiverMobility);
103 double rxPowerDbm =
m_loss->
CalcRxPower (txPowerDbm, senderMobility, receiverMobility);
104 NS_LOG_DEBUG (
"propagation: txPower=" << txPowerDbm <<
"dbm, rxPower=" << rxPowerDbm <<
"dbm, " <<
105 "distance=" << senderMobility->
GetDistanceFrom (receiverMobility) <<
"m, delay=" << delay);
109 if (dstNetDevice == 0)
111 dstNode = 0xffffffff;
120 (*i), copy, rxPowerDbm);
131 if ((rxPowerDbm +
phy->GetRxGain ()) <
phy->GetRxSensitivity ())
133 NS_LOG_INFO (
"Received signal too weak to process: " << rxPowerDbm <<
" dBm");
137 rxPowerW.insert ({std::make_pair (0, 0), (
DbmToW (rxPowerDbm +
phy->GetRxGain ()))});
138 phy->StartReceivePreamble (ppdu, rxPowerW, ppdu->GetTxDuration ());
164 int64_t currentStream = stream;
166 return (currentStream - stream);
Abstract Channel Base Class.
Keep track of the current position and velocity of an object.
double GetDistanceFrom(Ptr< const MobilityModel > position) const
virtual Ptr< Node > GetNode(void) const =0
uint32_t GetId(void) const
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Hold objects of type Ptr<T>.
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.
int64_t AssignStreams(int64_t stream)
If this loss model uses objects of type RandomVariableStream, set the stream numbers to the integers ...
static void ScheduleWithContext(uint32_t context, Time const &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Simulation virtual time values and global simulation resolution.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
uint8_t GetChannelNumber(void) const
Return current channel number.
Ptr< MobilityModel > GetMobility(void) const
Return the mobility model this PHY is associated with.
a channel to interconnect ns3::YansWifiPhy objects.
void SetPropagationLossModel(const Ptr< PropagationLossModel > loss)
Ptr< PropagationDelayModel > m_delay
Propagation delay model.
virtual ~YansWifiChannel()
void Send(Ptr< YansWifiPhy > sender, Ptr< const WifiPpdu > ppdu, double txPowerDbm) const
Ptr< NetDevice > GetDevice(std::size_t i) const override
PhyList m_phyList
List of YansWifiPhys connected to this YansWifiChannel.
Ptr< PropagationLossModel > m_loss
Propagation loss model.
static void Receive(Ptr< YansWifiPhy > receiver, Ptr< WifiPpdu > ppdu, double txPowerDbm)
This method is scheduled by Send for each associated YansWifiPhy.
static TypeId GetTypeId(void)
Get the type ID.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void SetPropagationDelayModel(const Ptr< PropagationDelayModel > delay)
void Add(Ptr< YansWifiPhy > phy)
Adds the given YansWifiPhy to the PHY list.
std::size_t GetNDevices(void) const override
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#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_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double DbmToW(double dBm)
Convert from dBm to Watts.
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Declaration of ns3::WifiPpdu class and ns3::WifiConstPsduMap.