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