A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
thompson-sampling-wifi-manager.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 IITP RAS
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: Alexander Krotov <krotov@iitp.ru>
18 */
19
20#ifndef THOMPSON_SAMPLING_WIFI_MANAGER_H
21#define THOMPSON_SAMPLING_WIFI_MANAGER_H
22
23#include "ns3/random-variable-stream.h"
24#include "ns3/traced-value.h"
25#include "ns3/wifi-remote-station-manager.h"
26
27namespace ns3
28{
29
30/**
31 * \brief Thompson Sampling rate control algorithm
32 * \ingroup wifi
33 *
34 * This class implements Thompson Sampling rate control algorithm.
35 *
36 * It was implemented for use as a baseline in
37 * https://doi.org/10.1109/ACCESS.2020.3023552
38 */
40{
41 public:
42 /**
43 * \brief Get the type ID.
44 * \return the object TypeId
45 */
46 static TypeId GetTypeId();
49
50 int64_t AssignStreams(int64_t stream) override;
51
52 private:
53 WifiRemoteStation* DoCreateStation() const override;
54 void DoReportRxOk(WifiRemoteStation* station, double rxSnr, WifiMode txMode) override;
55 void DoReportRtsFailed(WifiRemoteStation* station) override;
56 void DoReportDataFailed(WifiRemoteStation* station) override;
57 void DoReportRtsOk(WifiRemoteStation* station,
58 double ctsSnr,
59 WifiMode ctsMode,
60 double rtsSnr) override;
62 double ackSnr,
63 WifiMode ackMode,
64 double dataSnr,
65 uint16_t dataChannelWidth,
66 uint8_t dataNss) override;
68 uint16_t nSuccessfulMpdus,
69 uint16_t nFailedMpdus,
70 double rxSnr,
71 double dataSnr,
72 uint16_t dataChannelWidth,
73 uint8_t dataNss) override;
74 void DoReportFinalRtsFailed(WifiRemoteStation* station) override;
75 void DoReportFinalDataFailed(WifiRemoteStation* station) override;
76 WifiTxVector DoGetDataTxVector(WifiRemoteStation* station, uint16_t allowedWidth) override;
78
79 /**
80 * Initializes station rate tables. If station is already initialized,
81 * nothing is done.
82 *
83 * \param station Station which should be initialized.
84 */
85 void InitializeStation(WifiRemoteStation* station) const;
86
87 /**
88 * Draws a new MCS and related parameters to try next time for this
89 * station.
90 *
91 * This method should only be called between TXOPs to avoid sending
92 * multiple frames using different modes. Otherwise it is impossible
93 * to tell which mode was used for succeeded/failed frame when
94 * feedback is received.
95 *
96 * \param station Station for which a new mode should be drawn.
97 */
98 void UpdateNextMode(WifiRemoteStation* station) const;
99
100 /**
101 * Applies exponential decay to MCS statistics.
102 *
103 * \param st Remote STA for which MCS statistics is to be updated.
104 * \param i MCS index.
105 */
106 void Decay(WifiRemoteStation* st, size_t i) const;
107
108 /**
109 * Returns guard interval in nanoseconds for the given mode.
110 *
111 * \param st Remote STA.
112 * \param mode The WifiMode.
113 * \return the guard interval in nanoseconds
114 */
115 uint16_t GetModeGuardInterval(WifiRemoteStation* st, WifiMode mode) const;
116
117 /**
118 * Sample beta random variable with given parameters
119 * \param alpha first parameter of beta distribution
120 * \param beta second parameter of beta distribution
121 * \return beta random variable sample
122 */
123 double SampleBetaVariable(uint64_t alpha, uint64_t beta) const;
124
126 m_gammaRandomVariable; //!< Variable used to sample beta-distributed random variables
127
128 double m_decay; //!< Exponential decay coefficient, Hz
129
130 TracedValue<uint64_t> m_currentRate; //!< Trace rate changes
131};
132
133} // namespace ns3
134
135#endif /* THOMPSON_SAMPLING_WIFI_MANAGER_H */
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Thompson Sampling rate control algorithm.
uint16_t GetModeGuardInterval(WifiRemoteStation *st, WifiMode mode) const
Returns guard interval in nanoseconds for the given mode.
void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode) override
This method is a pure virtual method that must be implemented by the sub-class.
void InitializeStation(WifiRemoteStation *station) const
Initializes station rate tables.
void DoReportDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss) override
This method is a pure virtual method that must be implemented by the sub-class.
void DoReportAmpduTxStatus(WifiRemoteStation *station, uint16_t nSuccessfulMpdus, uint16_t nFailedMpdus, double rxSnr, double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss) override
Typically called per A-MPDU, either when a Block ACK was successfully received or when a BlockAckTime...
TracedValue< uint64_t > m_currentRate
Trace rate changes.
double SampleBetaVariable(uint64_t alpha, uint64_t beta) const
Sample beta random variable with given parameters.
WifiRemoteStation * DoCreateStation() const override
Ptr< GammaRandomVariable > m_gammaRandomVariable
Variable used to sample beta-distributed random variables.
void DoReportFinalRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
void DoReportFinalDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
static TypeId GetTypeId()
Get the type ID.
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint16_t allowedWidth) override
double m_decay
Exponential decay coefficient, Hz.
void DoReportRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
void UpdateNextMode(WifiRemoteStation *station) const
Draws a new MCS and related parameters to try next time for this station.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station) override
void DoReportRtsOk(WifiRemoteStation *station, double ctsSnr, WifiMode ctsMode, double rtsSnr) override
This method is a pure virtual method that must be implemented by the sub-class.
void Decay(WifiRemoteStation *st, size_t i) const
Applies exponential decay to MCS statistics.
Trace classes with value semantics.
Definition: traced-value.h:116
a unique identifier for an interface.
Definition: type-id.h:59
represent a single transmission mode
Definition: wifi-mode.h:51
hold a list of per-remote-station state.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
hold per-remote-station state.