A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
yans-wifi-helper.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 * Sébastien Deronne <sebastien.deronne@gmail.com>
8 */
9
10#include "yans-wifi-helper.h"
11
12#include "ns3/error-rate-model.h"
13#include "ns3/frame-capture-model.h"
14#include "ns3/interference-helper.h"
15#include "ns3/log.h"
16#include "ns3/names.h"
17#include "ns3/preamble-detection-model.h"
18#include "ns3/propagation-delay-model.h"
19#include "ns3/propagation-loss-model.h"
20#include "ns3/wifi-net-device.h"
21#include "ns3/yans-wifi-phy.h"
22
23namespace ns3
24{
25
26NS_LOG_COMPONENT_DEFINE("YansWifiHelper");
27
31
34{
36 helper.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
37 helper.AddPropagationLoss("ns3::LogDistancePropagationLossModel");
38 return helper;
39}
40
43{
46 for (auto i = m_propagationLoss.begin(); i != m_propagationLoss.end(); ++i)
47 {
49 if (prev)
50 {
51 prev->SetNext(cur);
52 }
53 if (m_propagationLoss.begin() == i)
54 {
55 channel->SetPropagationLossModel(cur);
56 }
57 prev = cur;
58 }
60 channel->SetPropagationDelayModel(delay);
61 return channel;
62}
63
64int64_t
66{
67 return c->AssignStreams(stream);
68}
69
71 : WifiPhyHelper(1), // YANS phy is not used for 11be devices
72 m_channel(nullptr)
73{
74 m_phys.front().SetTypeId("ns3::YansWifiPhy");
75 SetInterferenceHelper("ns3::InterferenceHelper");
76 SetErrorRateModel("ns3::TableBasedErrorRateModel");
77}
78
79void
84
85void
86YansWifiPhyHelper::SetChannel(std::string channelName)
87{
89 m_channel = channel;
90}
91
92std::vector<Ptr<WifiPhy>>
94{
95 Ptr<YansWifiPhy> phy = m_phys.front().Create<YansWifiPhy>();
97 phy->SetInterferenceHelper(interference);
98 Ptr<ErrorRateModel> error = m_errorRateModel.front().Create<ErrorRateModel>();
99 phy->SetErrorRateModel(error);
100 if (m_frameCaptureModel.front().IsTypeIdSet())
101 {
102 auto frameCapture = m_frameCaptureModel.front().Create<FrameCaptureModel>();
103 phy->SetFrameCaptureModel(frameCapture);
104 }
105 if (m_preambleDetectionModel.front().IsTypeIdSet())
106 {
107 auto preambleDetection = m_preambleDetectionModel.front().Create<PreambleDetectionModel>();
108 phy->SetPreambleDetectionModel(preambleDetection);
109 }
110 phy->SetChannel(m_channel);
111 phy->SetDevice(device);
112 return std::vector<Ptr<WifiPhy>>({phy});
113}
114
115} // namespace ns3
the interface for Wifi's error models
the interface for Wifi's frame capture models
handles interference calculations
static Ptr< T > Find(std::string path)
Given a name path string, look to see if there's an object in the system with that associated to it.
Definition names.h:443
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
the interface for Wifi's preamble detection models
calculate a propagation delay.
Models the propagation loss through a transmission medium.
Smart pointer class similar to boost::intrusive_ptr.
create PHY objects
Definition wifi-helper.h:39
void SetErrorRateModel(std::string type, Args &&... args)
Helper function used to set the error rate model.
void SetInterferenceHelper(std::string type, Args &&... args)
Helper function used to set the interference helper.
std::vector< ObjectFactory > m_frameCaptureModel
frame capture model
std::vector< ObjectFactory > m_preambleDetectionModel
preamble detection model
std::vector< ObjectFactory > m_phys
PHY objects.
std::vector< ObjectFactory > m_errorRateModel
error rate model
ObjectFactory m_interferenceHelper
interference helper
manage and create wifi channel objects for the YANS model.
ObjectFactory m_propagationDelay
propagation delay model
int64_t AssignStreams(Ptr< YansWifiChannel > c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the channel.
YansWifiChannelHelper()
Create a channel helper without any parameter set.
static YansWifiChannelHelper Default()
Create a channel helper in a default working state.
void SetPropagationDelay(std::string name, Ts &&... args)
void AddPropagationLoss(std::string name, Ts &&... args)
Ptr< YansWifiChannel > Create() const
std::vector< ObjectFactory > m_propagationLoss
vector of propagation loss models
Ptr< YansWifiChannel > m_channel
YANS wifi channel.
YansWifiPhyHelper()
Create a PHY helper.
std::vector< Ptr< WifiPhy > > Create(Ptr< Node > node, Ptr< WifiNetDevice > device) const override
void SetChannel(Ptr< YansWifiChannel > channel)
802.11 PHY layer model
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t prev