A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
yans-wifi-phy.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005,2006 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 * Ghada Badawy <gbadawy@gmail.com>
8 * Sébastien Deronne <sebastien.deronne@gmail.com>
9 */
10
11#include "yans-wifi-phy.h"
12
13#include "interference-helper.h"
14#include "yans-wifi-channel.h"
15
16#include "ns3/log.h"
17
18namespace ns3
19{
20
21NS_LOG_COMPONENT_DEFINE("YansWifiPhy");
22
24
25TypeId
27{
28 static TypeId tid =
29 TypeId("ns3::YansWifiPhy")
31 .SetGroupName("Wifi")
32 .AddConstructor<YansWifiPhy>()
33 .AddTraceSource("SignalArrival",
34 "Trace start of all signal arrivals, including weak signals",
36 "ns3::YansWifiPhy::SignalArrivalCallback");
37 return tid;
38}
39
44
45void
47{
49 // add dummy band for Yans
50 m_interference->AddBand({{{0, 0}}, {{0, 0}}});
51}
52
57
58void
65
68{
69 return m_channel;
70}
71
72void
74{
75 NS_LOG_FUNCTION(this << channel);
76 m_channel = channel;
77 m_channel->Add(this);
78}
79
80void
82{
83 NS_LOG_FUNCTION(this << ppdu);
84 NS_LOG_DEBUG("Start transmission: signal power before antenna gain="
85 << GetPower(ppdu->GetTxVector().GetTxPowerLevel()) << "dBm");
86 m_signalTransmissionCb(ppdu, ppdu->GetTxVector());
87 m_channel->Send(this, ppdu, GetTxPowerForTransmission(ppdu) + GetTxGain());
88}
89
90void
92{
93 NS_LOG_FUNCTION(this << ppdu);
94 m_signalArrivalCb(ppdu, rxPowerDbm, ppdu->GetTxDuration());
95}
96
98YansWifiPhy::GetGuardBandwidth(MHz_u currentChannelWidth) const
99{
100 NS_ABORT_MSG("Guard bandwidth not relevant for Yans");
101 return 0;
102}
103
104std::tuple<dBr_u, dBr_u, dBr_u>
106{
107 NS_ABORT_MSG("Tx mask rejection params not relevant for Yans");
108 return std::make_tuple(0.0, 0.0, 0.0);
109}
110
112YansWifiPhy::GetBand(MHz_u /*bandWidth*/, uint8_t /*bandIndex*/)
113{
114 return {{{0, 0}}, {{0, 0}}};
115}
116
122
125{
126 return {0, 0};
127}
128
129void
131{
132 NS_LOG_FUNCTION(this);
133 NS_ABORT_MSG_IF(GetOperatingChannel().GetNSegments() > 1,
134 "operating channel made of non-contiguous segments cannot be used with Yans");
135}
136
137} // namespace ns3
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
802.11 PHY layer model
Definition wifi-phy.h:55
virtual void SetInterferenceHelper(const Ptr< InterferenceHelper > helper)
Sets the interference helper.
Definition wifi-phy.cc:672
dB_u GetTxGain() const
Return the transmission gain.
Definition wifi-phy.cc:603
TracedCallback< Ptr< const WifiPpdu >, const WifiTxVector & > m_signalTransmissionCb
Signal Transmission callback.
Definition wifi-phy.h:1363
void DoDispose() override
Destructor implementation.
Definition wifi-phy.cc:430
Ptr< InterferenceHelper > m_interference
Pointer to a helper responsible for interference computations.
Definition wifi-phy.h:1322
dBm_u GetTxPowerForTransmission(Ptr< const WifiPpdu > ppdu) const
Compute the transmit power for the next transmission.
Definition wifi-phy.cc:2287
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
Definition wifi-phy.cc:1075
dBm_u GetPower(uint8_t powerLevel) const
Get the power of the given power level.
Definition wifi-phy.cc:714
802.11 PHY layer model
WifiSpectrumBandFrequencies ConvertIndicesToFrequencies(const WifiSpectrumBandIndices &indices) const override
This is a helper function to convert start and stop indices to start and stop frequencies.
Ptr< YansWifiChannel > m_channel
YansWifiChannel that this YansWifiPhy is connected to.
FrequencyRange GetCurrentFrequencyRange() const override
Get the frequency range of the current RF interface.
void StartTx(Ptr< const WifiPpdu > ppdu) override
std::tuple< dBr_u, dBr_u, dBr_u > GetTxMaskRejectionParams() const override
MHz_u GetGuardBandwidth(MHz_u currentChannelWidth) const override
WifiSpectrumBandInfo GetBand(MHz_u bandWidth, uint8_t bandIndex=0) override
Get the info of a given band.
TracedCallback< Ptr< const WifiPpdu >, double, Time > m_signalArrivalCb
Signal Arrival callback.
void SetChannel(const Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
~YansWifiPhy() override
void FinalizeChannelSwitch() override
Method that can be overridden by subclasses to perform operations after the channel is actually switc...
void SetInterferenceHelper(const Ptr< InterferenceHelper > helper) override
Sets the interference helper.
Ptr< Channel > GetChannel() const override
Return the Channel this WifiPhy is connected to.
void DoDispose() override
Destructor implementation.
static TypeId GetTypeId()
Get the type ID.
void TraceSignalArrival(Ptr< const WifiPpdu > ppdu, double rxPowerDbm, Time duration)
Logs the arrival of a PPDU, including its power and duration.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition abort.h:38
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition abort.h:97
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#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.
Definition object-base.h:35
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
constexpr FrequencyRange WHOLE_WIFI_SPECTRUM
Identifier for the frequency range covering the whole wifi spectrum.
double MHz_u
MHz weak type.
Definition wifi-units.h:31
std::pair< Hz_u, Hz_u > WifiSpectrumBandFrequencies
typedef for a pair of start and stop frequencies to represent a band
std::pair< uint32_t, uint32_t > WifiSpectrumBandIndices
typedef for a pair of start and stop sub-band indices
Struct defining a frequency range between minFrequency and maxFrequency.
WifiSpectrumBandInfo structure containing info about a spectrum band.