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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Alexander Krotov <krotov@iitp.ru>
7 */
8
9#ifndef THOMPSON_SAMPLING_WIFI_MANAGER_H
10#define THOMPSON_SAMPLING_WIFI_MANAGER_H
11
12#include "ns3/random-variable-stream.h"
13#include "ns3/traced-value.h"
14#include "ns3/wifi-remote-station-manager.h"
15
16namespace ns3
17{
18
19/**
20 * @brief Thompson Sampling rate control algorithm
21 * @ingroup wifi
22 *
23 * This class implements Thompson Sampling rate control algorithm.
24 *
25 * It was implemented for use as a baseline in
26 * https://doi.org/10.1109/ACCESS.2020.3023552
27 */
29{
30 public:
31 /**
32 * @brief Get the type ID.
33 * @return the object TypeId
34 */
35 static TypeId GetTypeId();
38
39 int64_t AssignStreams(int64_t stream) override;
40
41 private:
42 WifiRemoteStation* DoCreateStation() const override;
43 void DoReportRxOk(WifiRemoteStation* station, double rxSnr, WifiMode txMode) override;
47 double ctsSnr,
49 double rtsSnr) override;
51 double ackSnr,
53 double dataSnr,
55 uint8_t dataNss) override;
57 uint16_t nSuccessfulMpdus,
58 uint16_t nFailedMpdus,
59 double rxSnr,
60 double dataSnr,
62 uint8_t dataNss) override;
67
68 /**
69 * Initializes station rate tables. If station is already initialized,
70 * nothing is done.
71 *
72 * @param station Station which should be initialized.
73 */
75
76 /**
77 * Draws a new MCS and related parameters to try next time for this
78 * station.
79 *
80 * This method should only be called between TXOPs to avoid sending
81 * multiple frames using different modes. Otherwise it is impossible
82 * to tell which mode was used for succeeded/failed frame when
83 * feedback is received.
84 *
85 * @param station Station for which a new mode should be drawn.
86 */
88
89 /**
90 * Applies exponential decay to MCS statistics.
91 *
92 * @param st Remote STA for which MCS statistics is to be updated.
93 * @param i MCS index.
94 */
95 void Decay(WifiRemoteStation* st, size_t i) const;
96
97 /**
98 * Returns guard interval for the given mode.
99 *
100 * @param st Remote STA
101 * @param mode The WifiMode
102 * @return the guard interval
103 */
105
106 /**
107 * Sample beta random variable with given parameters
108 * @param alpha first parameter of beta distribution
109 * @param beta second parameter of beta distribution
110 * @return beta random variable sample
111 */
112 double SampleBetaVariable(uint64_t alpha, uint64_t beta) const;
113
115 m_gammaRandomVariable; //!< Variable used to sample beta-distributed random variables
116
117 double m_decay; //!< Exponential decay coefficient, Hz
118
119 TracedValue<uint64_t> m_currentRate; //!< Trace rate changes
120};
121
122} // namespace ns3
123
124#endif /* THOMPSON_SAMPLING_WIFI_MANAGER_H */
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:66
Thompson Sampling rate control algorithm.
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.
TracedValue< uint64_t > m_currentRate
Trace rate changes.
Time GetModeGuardInterval(WifiRemoteStation *st, WifiMode mode) const
Returns guard interval for the given mode.
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.
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 DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr, MHz_u 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, MHz_u dataChannelWidth, uint8_t dataNss) override
Typically called per A-MPDU, either when a Block ACK was successfully received or when a BlockAckTime...
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 DoGetDataTxVector(WifiRemoteStation *station, MHz_u allowedWidth) override
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.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Trace classes with value semantics.
a unique identifier for an interface.
Definition type-id.h:49
represent a single transmission mode
Definition wifi-mode.h:40
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...
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Every class exported by the ns3 library is enclosed in the ns3 namespace.
hold per-remote-station state.