A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
spectrum-wifi-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 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 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19
20#ifndef SPECTRUM_WIFI_HELPER_H
21#define SPECTRUM_WIFI_HELPER_H
22
23#include "wifi-helper.h"
24
25#include <map>
26#include <set>
27
28namespace ns3
29{
30
31class SpectrumChannel;
32class SpectrumWifiPhy;
33
34/**
35 * \brief Make it easy to create and manage PHY objects for the spectrum model.
36 *
37 * The Pcap and ASCII traces generated by the EnableAscii and EnablePcap methods defined
38 * in this class correspond to PHY-level traces and come to us via WifiPhyHelper
39 *
40 * This helper will install an instance of a WifiBandwidthFilter on any SpectrumChannel
41 * added to this helper (via one of the SetChannel methods), unless one has
42 * previously been installed on the channel object.
43 */
45{
46 public:
47 /**
48 * Create a PHY helper.
49 *
50 * \param nLinks the number of links to configure (>1 only for 11be devices)
51 */
52 SpectrumWifiPhyHelper(uint8_t nLinks = 1);
53
54 /**
55 * \param channel the default spectrum channel to associate to this helper
56 *
57 * Every PHY created by a call to Install is associated to this default spectrum channel.
58 */
59 void SetChannel(const Ptr<SpectrumChannel> channel);
60 /**
61 * \param channelName The name of the default spectrum channel to associate to this helper
62 *
63 * Every PHY created by a call to Install is associated to this default spectrum channel.
64 */
65 void SetChannel(const std::string& channelName);
66
67 /**
68 * \param channel the spectrum channel to add to this helper
69 * \param freqRange the frequency range, bounded by a minFrequency and a maxFrequency in MHz
70 *
71 * Every PHY created by a call to Install is added to this spectrum channel.
72 * If a PHY is requested to operate or scan a channel with the specified frequency and width
73 * combination, it will activate that channel and deactivate the current channel for that PHY.
74 */
75 void AddChannel(const Ptr<SpectrumChannel> channel,
76 const FrequencyRange& freqRange = WHOLE_WIFI_SPECTRUM);
77 /**
78 * \param channelName The name of the spectrum channel to add to this helper
79 * \param freqRange the frequency range, bounded by a minFrequency and a maxFrequency in MHz
80 *
81 * Every PHY created by a call to Install is added to this spectrum channel.
82 * If a PHY is requested to operate or scan a channel with the specified frequency and width
83 * combination, it will activate that channel and deactivate the current channel for that PHY.
84 */
85 void AddChannel(const std::string& channelName,
86 const FrequencyRange& freqRange = WHOLE_WIFI_SPECTRUM);
87
88 /**
89 * Add a given spectrum PHY interface to the PHY instance corresponding of a given link.
90 * If no mapping has been specified for a given link, all spectrum PHY interfaces will
91 * be added to the PHY instance of that link.
92 *
93 * \param linkId ID of the link to setup
94 * \param freqRange frequency range handled by of the spectrum PHY interface
95 */
96 void AddPhyToFreqRangeMapping(uint8_t linkId, const FrequencyRange& freqRange);
97
98 /**
99 * Reset mapping of the spectrum PHY interfaces added to the PHY instances.
100 */
102
103 private:
104 /**
105 * \param node the node on which we wish to create a wifi PHY
106 * \param device the device within which this PHY will be created
107 * \returns newly-created PHY objects.
108 *
109 * This method implements the pure virtual method defined in \ref ns3::WifiPhyHelper.
110 */
111 std::vector<Ptr<WifiPhy>> Create(Ptr<Node> node, Ptr<WifiNetDevice> device) const override;
112
113 /**
114 * \brief Install PHY interfaces to the PHY instance of a given link
115 * based on the currently configured mapping (\see AddPhyInterface).
116 *
117 * \param linkId ID of the link to setup
118 * \param phy spectrum PHY instance of the link
119 */
120 void InstallPhyInterfaces(uint8_t linkId, Ptr<SpectrumWifiPhy> phy) const;
121
122 /**
123 * \param channel The channel to inspect to possibly add a WifiBandwidthFilter
124 *
125 * This method will add a WifiBandwidthFilter object to the SpectrumChannel, only if
126 * one has not yet been added.
127 */
129
130 /**
131 * Function that is notified when a spectrum channel switched
132 * \param phy spectrum PHY instance that has switched its channel
133 */
135
136 std::map<FrequencyRange, Ptr<SpectrumChannel>> m_channels; ///< the spectrum channels
137 std::map<uint8_t /* linkId */, std::set<FrequencyRange>>
138 m_interfacesMap; ///< map of the spectrum PHY interfaces to be added to the PHY instance
139 ///< corresponding to a given link ID
140};
141
142} // namespace ns3
143
144#endif /* SPECTRUM_WIFI_HELPER_H */
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Make it easy to create and manage PHY objects for the spectrum model.
std::vector< Ptr< WifiPhy > > Create(Ptr< Node > node, Ptr< WifiNetDevice > device) const override
void ResetPhyToFreqRangeMapping()
Reset mapping of the spectrum PHY interfaces added to the PHY instances.
std::map< uint8_t, std::set< FrequencyRange > > m_interfacesMap
map of the spectrum PHY interfaces to be added to the PHY instance corresponding to a given link ID
void AddChannel(const Ptr< SpectrumChannel > channel, const FrequencyRange &freqRange=WHOLE_WIFI_SPECTRUM)
void InstallPhyInterfaces(uint8_t linkId, Ptr< SpectrumWifiPhy > phy) const
Install PHY interfaces to the PHY instance of a given link based on the currently configured mapping ...
void SetChannel(const Ptr< SpectrumChannel > channel)
static void SpectrumChannelSwitched(Ptr< SpectrumWifiPhy > phy)
Function that is notified when a spectrum channel switched.
void AddPhyToFreqRangeMapping(uint8_t linkId, const FrequencyRange &freqRange)
Add a given spectrum PHY interface to the PHY instance corresponding of a given link.
void AddWifiBandwidthFilter(Ptr< SpectrumChannel > channel)
std::map< FrequencyRange, Ptr< SpectrumChannel > > m_channels
the spectrum channels
create PHY objects
Definition: wifi-helper.h:49
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.
Struct defining a frequency range between minFrequency (MHz) and maxFrequency (MHz).