NetSim Source Code Help
Loading...
Searching...
No Matches
Minstrel_ht.h
Go to the documentation of this file.
1/************************************************************************************
2* Copyright (C) 2020 *
3* TETCOS, Bangalore. India *
4* *
5* The code Minstrel Rate Control algorithm is provided per GNU GPLv2 licensing *
6* *
7* Author: Dhruvang *
8* *
9* ---------------------------------------------------------------------------------*/
10//#include "Minstrel.h"
11//#include "IEEE802_11_HTPhy.h"
12#include "IEEE802_11_Phy.h"
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
19{
20 int nIndex;
21 int MCS;
22 double dRxSensitivity;
24 double dCodingRate;
25 int nNBPSC;
26 int nNSD;
27 int NSP;
28 int nNCBPS;
29 int nNDBPS;
30 int NES;
31 double dGI;
32 double dDataRate;
34
36 UINT streams; //number of spatial streams
37 UINT sgi; //short guard Interval
38 UINT chWidth; //bandwidth
39 bool isVht;
41
42 double* rate; //rates supported by this group
43 double* trTime; //transmission time for the rates
45
46typedef struct stru_HtRateInfo{
47 /**
48 * Perfect transmission time calculation, or frame calculation.
49 * Given a bit rate and a packet length n bytes.
50 */
52 double rate;
53
54 BOOL supported; //!< If the rate is supported.
55
56 UINT retryCount; //!< Retry limit.
57 UINT adjustedRetryCount; //!< Adjust the retry limit for this rate.
58 double prob; //!< Current probability within last time interval. (# frame success )/(# total frames)
59
60 BOOL retryUpdated; //!< If number of retries was updated already.
61
62 /**
63 * Exponential weighted moving average of probability.
64 * EWMA calculation:
65 * ewma_prob =[prob *(100 - ewma_level) + (ewma_prob_old * ewma_level)]/100
66 */
67 double ewmaProb;
68 double throughput; //!< Throughput of this rate (in pkts per second).
69 double ewmsdProb; //!< Exponential weighted moving standard deviation of probability.
70
71 UINT numSampleSkipped; //number of skipped stats updates
72 UINT currNumAttempt; //attempts made so far
73 UINT currNumSuccess; //success pkts so far
74 UINT prevNumAttempt; //transmission made with previous rate
75 UINT prevNumSuccess; //successful transmission made with previous rate
76 UINT64 totalNumAttempt; //total number of attempts made
77 UINT64 totalNumSuccess; //total number of success pkts
78
79
81
82typedef struct stru_GroupInfo{
83 UINT col; //sample table row
84 UINT row; //sample table col
85 BOOL supported; //if the group is supported
86 UINT streams; //number of special streams
87 UINT sgi; //short guard interval
88 UINT chWidth; //bandwidth
89
90 UINT maxTpRate; //index of rate with max throughput in this group
91 UINT maxTpRate2; //index of rate with 2nd max throughput in this group
92 UINT maxProbRate; //index of rate with max transmission probability in this group
93
94 Ptr_HtRateInfo rateTable; //Info of rates supported by this group
96
101 //variables for HT-info
102 UINT sampleGroup; //!< The group that the sample rate belongs to.
103 UINT sampleWait; //!< How many transmission attempts to wait until a new sample.
104 UINT sampleTries; //!< Number of sample tries after waiting sampleWait.
105 UINT sampleCount; //!< Max number of samples per update interval.
106 UINT sampleSlow; //!< Number of times a slow rate was sampled.
107
108 double avgAmpduLen; //!< Average number of MPDUs in an A-MPDU.
109 double ampduLen; //!< Number of MPDUs tried since last update
110 UINT ampduPacketCount; //!< Number of A-MPDUs transmitted since last update
111 Ptr_GroupInfo groupTable; //!< Table of groups with stats.
112 UINT nGroup; //Number of groups in the station
113 UINT nGroupRate; //number of rates supported
114 BOOL isVht; //If this station is VHT(802.11ac)
115
116 //General variables
117 BOOL isInitialized; //Check if station is Initialized
118 BOOL isSampling; //Check if we are sampling
119 double nextStatsUpdate; //Scheduled time for next
120 UINT trRate; //Index of the transmission rate
121 UINT sampleRate; //Index of the sample rate
122 UINT maxTpRate; //Index of the max rate
123 UINT maxTpRate2; //Index of the 2nd best throughput
124 UINT maxProbRate; //Index of the max probability rate
127 UINT totalRetry; //total number of retries
128 UINT** sampleTable; //sample table for the station
129
130 UINT64 totalPacketCount; //total packet count of the station
131 UINT64 samplePacketCount; //sample packet count of the station
132 PIEEE802_11_PHY_VAR phy; //NetSim implementation requirement
134
135
141
142double ht_updateStatsTime; //Time Interval for updating Minstrel Table
143double ht_lookAroundRate; //% of pkts to send with other rates. ~10
144double ht_ewmaWeight; //weight to be given to new value (0,100) ~25%
145UINT ht_sampleCol; //number of columns in Sample Table
146
147
148void Ht_InitMinstrel(NETSIM_ID nDevId,NETSIM_ID nifid);
161static double CalculateEwmsd(double oldEwmsd, double currentProb, double ewmaProb, double ewmaWeight);
162static double CalculateThroughput(Ptr_MinstrelHtPerRemoteStation station,UINT grpId, UINT rateId);
167
168
169#ifdef __cplusplus
170}
171#endif
unsigned int NETSIM_ID
Definition: Animation.h:45
#define UINT64
Definition: Linux.h:37
BOOL
Definition: Linux.h:62
#define UINT
Definition: Linux.h:38
double ewmaWeight
Definition: Minstrel.h:73
static struct stru_802_11_Phy_Parameters_HT a
static double CalculateEwmsd(double oldEwmsd, double currentProb, double ewmaProb, double ewmaWeight)
static void UpdateRate(Ptr_MinstrelHtPerRemoteStation station)
static void CheckInit(Ptr_MinstrelHtPerRemoteStation station, NETSIM_ID devid, NETSIM_ID ifid)
static UINT CountRetries(Ptr_MinstrelHtPerRemoteStation station)
void Ht_InitMinstrel(NETSIM_ID nDevId, NETSIM_ID nifid)
Definition: Minstrel_ht.c:40
static UINT GetLowestIndex(Ptr_MinstrelHtPerRemoteStation station)
static void SetStationThRate(Ptr_MinstrelHtPerRemoteStation station)
static UINT GetNextSample(Ptr_MinstrelHtPerRemoteStation station)
double ht_ewmaWeight
Definition: Minstrel_ht.h:144
struct stru_HtPerRemoteStation MinstrelHtPerRemoteStation
double ht_lookAroundRate
Definition: Minstrel_ht.h:143
struct stru_HtRateInfo * Ptr_HtRateInfo
struct stru_HtPerRemoteStation * Ptr_MinstrelHtPerRemoteStation
struct stru_MinstrelHtWifiStation MinstrelHtWifiStation
static void SetNextSample(Ptr_MinstrelHtPerRemoteStation station)
UINT ht_sampleCol
Definition: Minstrel_ht.h:145
static double CalculateThroughput(Ptr_MinstrelHtPerRemoteStation station, UINT grpId, UINT rateId)
struct stru_GroupInfo GroupInfo
static void UpdateStats(Ptr_MinstrelHtPerRemoteStation station)
struct stru_GroupInfo * Ptr_GroupInfo
static void InitGroupTable(Ptr_MinstrelHtPerRemoteStation station)
struct stru_HtRateInfo HtRateInfo
static UINT FindRate(Ptr_MinstrelHtPerRemoteStation station)
struct stru_MinstrelHtWifiStation * Ptr_MinstrelHtWifiStation
static void CalculateRetransmits(Ptr_MinstrelHtPerRemoteStation station, UINT index)
static void InitSampleTable(Ptr_MinstrelHtPerRemoteStation station)
struct stru_McsGroup McsGroup
static UINT GetHighestIndex(Ptr_MinstrelHtPerRemoteStation station)
static void UpdateRetry(Ptr_MinstrelHtPerRemoteStation station)
static void SetStationProbRate(Ptr_MinstrelHtPerRemoteStation station)
static void UpdatePacketCounter(Ptr_MinstrelHtPerRemoteStation station, UINT success, UINT failed)
double ht_updateStatsTime
Definition: Minstrel_ht.h:142
enum enum_Modulation PHY_MODULATION
Data structure for physical layer parameters.
Ptr_HtRateInfo rateTable
Definition: Minstrel_ht.h:94
PIEEE802_11_PHY_VAR phy
Definition: Minstrel_ht.h:132
double avgAmpduLen
Average number of MPDUs in an A-MPDU.
Definition: Minstrel_ht.h:108
UINT sampleCount
Max number of samples per update interval.
Definition: Minstrel_ht.h:105
UINT sampleWait
How many transmission attempts to wait until a new sample.
Definition: Minstrel_ht.h:103
UINT ampduPacketCount
Number of A-MPDUs transmitted since last update.
Definition: Minstrel_ht.h:110
double ampduLen
Number of MPDUs tried since last update.
Definition: Minstrel_ht.h:109
UINT sampleTries
Number of sample tries after waiting sampleWait.
Definition: Minstrel_ht.h:104
UINT sampleSlow
Number of times a slow rate was sampled.
Definition: Minstrel_ht.h:106
UINT sampleGroup
The group that the sample rate belongs to.
Definition: Minstrel_ht.h:102
Ptr_GroupInfo groupTable
Table of groups with stats.
Definition: Minstrel_ht.h:111
UINT numSampleSkipped
Definition: Minstrel_ht.h:71
BOOL supported
If the rate is supported.
Definition: Minstrel_ht.h:54
double throughput
Throughput of this rate (in pkts per second).
Definition: Minstrel_ht.h:68
UINT adjustedRetryCount
Adjust the retry limit for this rate.
Definition: Minstrel_ht.h:57
UINT retryCount
Retry limit.
Definition: Minstrel_ht.h:56
double prob
Current probability within last time interval. (# frame success )/(# total frames)
Definition: Minstrel_ht.h:58
double ewmsdProb
Exponential weighted moving standard deviation of probability.
Definition: Minstrel_ht.h:69
double perfectTrTime
Definition: Minstrel_ht.h:51
UINT64 totalNumSuccess
Definition: Minstrel_ht.h:77
UINT64 totalNumAttempt
Definition: Minstrel_ht.h:76
BOOL retryUpdated
If number of retries was updated already.
Definition: Minstrel_ht.h:60
double * trTime
Definition: Minstrel_ht.h:43
double * rate
Definition: Minstrel_ht.h:42
bool isSupported
Definition: Minstrel_ht.h:40
Ptr_MinstrelHtPerRemoteStation * minstrelHtInfo
Definition: Minstrel_ht.h:139