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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 * Ghada Badawy <gbadawy@gmail.com>
19 * Sébastien Deronne <sebastien.deronne@gmail.com>
20 */
21
22#include "yans-wifi-phy.h"
23
24#include "interference-helper.h"
25#include "yans-wifi-channel.h"
26
27#include "ns3/log.h"
28
29namespace ns3
30{
31
32NS_LOG_COMPONENT_DEFINE("YansWifiPhy");
33
35
36TypeId
38{
39 static TypeId tid =
40 TypeId("ns3::YansWifiPhy")
42 .SetGroupName("Wifi")
43 .AddConstructor<YansWifiPhy>()
44 .AddTraceSource("SignalArrival",
45 "Trace start of all signal arrivals, including weak signals",
47 "ns3::YansWifiPhy::SignalArrivalCallback");
48 return tid;
49}
50
52{
53 NS_LOG_FUNCTION(this);
54}
55
56void
58{
60 // add dummy band for Yans
61 m_interference->AddBand({{0, 0}, {0, 0}});
62}
63
65{
66 NS_LOG_FUNCTION(this);
67}
68
69void
71{
72 NS_LOG_FUNCTION(this);
73 m_channel = nullptr;
75}
76
79{
80 return m_channel;
81}
82
83void
85{
86 NS_LOG_FUNCTION(this << channel);
87 m_channel = channel;
88 m_channel->Add(this);
89}
90
91void
93{
94 NS_LOG_FUNCTION(this << ppdu);
95 NS_LOG_DEBUG("Start transmission: signal power before antenna gain="
96 << GetPowerDbm(ppdu->GetTxVector().GetTxPowerLevel()) << "dBm");
97 m_signalTransmissionCb(ppdu, ppdu->GetTxVector());
98 m_channel->Send(this, ppdu, GetTxPowerForTransmission(ppdu) + GetTxGain());
99}
100
101void
103{
104 NS_LOG_FUNCTION(this << ppdu);
105 m_signalArrivalCb(ppdu, rxPowerDbm, ppdu->GetTxDuration());
106}
107
108uint16_t
109YansWifiPhy::GetGuardBandwidth(uint16_t currentChannelWidth) const
110{
111 NS_ABORT_MSG("Guard bandwidth not relevant for Yans");
112 return 0;
113}
114
115std::tuple<double, double, double>
117{
118 NS_ABORT_MSG("Tx mask rejection params not relevant for Yans");
119 return std::make_tuple(0.0, 0.0, 0.0);
120}
121
123YansWifiPhy::GetBand(uint16_t /*bandWidth*/, uint8_t /*bandIndex*/)
124{
125 return {{0, 0}, {0, 0}};
126}
127
130{
131 return WHOLE_WIFI_SPECTRUM;
132}
133
136{
137 return {0, 0};
138}
139
140} // namespace ns3
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
802.11 PHY layer model
Definition: wifi-phy.h:65
virtual void SetInterferenceHelper(const Ptr< InterferenceHelper > helper)
Sets the interference helper.
Definition: wifi-phy.cc:662
double GetTxGain() const
Return the transmission gain (dB).
Definition: wifi-phy.cc:593
TracedCallback< Ptr< const WifiPpdu >, const WifiTxVector & > m_signalTransmissionCb
Signal Transmission callback.
Definition: wifi-phy.h:1361
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
Definition: wifi-phy.cc:704
void DoDispose() override
Destructor implementation.
Definition: wifi-phy.cc:425
Ptr< InterferenceHelper > m_interference
Pointer to a helper responsible for interference computations.
Definition: wifi-phy.h:1320
double GetTxPowerForTransmission(Ptr< const WifiPpdu > ppdu) const
Compute the transmit power for the next transmission.
Definition: wifi-phy.cc:2255
802.11 PHY layer model
Definition: yans-wifi-phy.h:48
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
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const override
WifiSpectrumBandInfo GetBand(uint16_t 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.
std::tuple< double, double, double > GetTxMaskRejectionParams() const override
~YansWifiPhy() override
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:49
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#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:46
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.
std::pair< uint64_t, uint64_t > WifiSpectrumBandFrequencies
typedef for a pair of start and stop frequencies in Hz to represent a band
constexpr FrequencyRange WHOLE_WIFI_SPECTRUM
Identifier for the frequency range covering the whole wifi spectrum.
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 (MHz) and maxFrequency (MHz).
WifiSpectrumBandInfo structure containing info about a spectrum band.