28 #include "ns3/mobility-model.h"
30 #include "ns3/pointer.h"
31 #include "ns3/propagation-delay-model.h"
32 #include "ns3/propagation-loss-model.h"
33 #include "ns3/simulator.h"
34 #include "ns3/wifi-net-device.h"
47 TypeId(
"ns3::YansWifiChannel")
51 .AddAttribute(
"PropagationLossModel",
52 "A pointer to the propagation loss model attached to this channel.",
55 MakePointerChecker<PropagationLossModel>())
56 .AddAttribute(
"PropagationDelayModel",
57 "A pointer to the propagation delay model attached to this channel.",
60 MakePointerChecker<PropagationDelayModel>());
106 Time delay =
m_delay->GetDelay(senderMobility, receiverMobility);
107 double rxPowerDbm =
m_loss->
CalcRxPower(txPowerDbm, senderMobility, receiverMobility);
109 << txPowerDbm <<
"dbm, rxPower=" << rxPowerDbm <<
"dbm, "
111 <<
"m, delay=" << delay);
116 dstNode = 0xffffffff;
120 dstNode = dstNetDevice->GetNode()->GetId();
140 uint16_t txWidth = ppdu->GetTransmissionChannelWidth();
141 if ((rxPowerDbm +
phy->GetRxGain()) <
phy->GetRxSensitivity() +
RatioToDb(txWidth / 20.0))
143 NS_LOG_INFO(
"Received signal too weak to process: " << rxPowerDbm <<
" dBm");
148 {std::make_pair(0, 0), (
DbmToW(rxPowerDbm +
phy->GetRxGain()))});
149 phy->StartReceivePreamble(ppdu, rxPowerW, ppdu->GetTxDuration());
175 int64_t currentStream = stream;
177 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
Ptr< T > GetObject() 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, const Time &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.
Ptr< MobilityModel > GetMobility() const
Return the mobility model this PHY is associated with.
uint8_t GetChannelNumber() const
Return current channel number.
a channel to interconnect ns3::YansWifiPhy objects.
void SetPropagationLossModel(const Ptr< PropagationLossModel > loss)
Ptr< PropagationDelayModel > m_delay
Propagation delay model.
~YansWifiChannel() override
static TypeId GetTypeId()
Get the type ID.
static void Receive(Ptr< YansWifiPhy > receiver, Ptr< const WifiPpdu > ppdu, double txPowerDbm)
This method is scheduled by Send for each associated YansWifiPhy.
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.
std::size_t GetNDevices() const override
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.
#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 RatioToDb(double ratio)
Convert from ratio to dB.
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.