NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
Minstrel_ht.h
1/************************************************************************************
2* Copyright (C) 2023 *
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;
23 PHY_MODULATION nModulation;
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;
33}a;
34
36 UINT streams; //number of spatial streams
37 UINT sgi; //short guard Interval
38 UINT chWidth; //bandwidth
39 bool isVht;
40 bool isSupported;
41
42 double* rate; //rates supported by this group
43 double* trTime; //transmission time for the rates
44}McsGroup;
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
80}HtRateInfo,*Ptr_HtRateInfo;
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
95}GroupInfo,*Ptr_GroupInfo;
96
98 NETSIM_ID remoteStationId;
99 NETSIM_ID stationId;
100 NETSIM_ID stationInterface;
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
125 UINT longRetry;
126 UINT shortRetry;
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
133}MinstrelHtPerRemoteStation,*Ptr_MinstrelHtPerRemoteStation;
134
135
137 NETSIM_ID devId;
138 NETSIM_ID interfaceId;
139 Ptr_MinstrelHtPerRemoteStation *minstrelHtInfo;
140}MinstrelHtWifiStation,*Ptr_MinstrelHtWifiStation;
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);
149static void CheckInit(Ptr_MinstrelHtPerRemoteStation station,NETSIM_ID devid,NETSIM_ID ifid);
150static void InitSampleTable(Ptr_MinstrelHtPerRemoteStation station);
151static void InitGroupTable(Ptr_MinstrelHtPerRemoteStation station);
152static void UpdatePacketCounter(Ptr_MinstrelHtPerRemoteStation station,UINT success,UINT failed);
153static void UpdateRetry(Ptr_MinstrelHtPerRemoteStation station);
154static void UpdateStats(Ptr_MinstrelHtPerRemoteStation station);
155static void UpdateRate(Ptr_MinstrelHtPerRemoteStation station);
156static UINT FindRate(Ptr_MinstrelHtPerRemoteStation station);
157static void SetStationThRate(Ptr_MinstrelHtPerRemoteStation station);
158static void SetStationProbRate(Ptr_MinstrelHtPerRemoteStation station);
159static UINT GetNextSample(Ptr_MinstrelHtPerRemoteStation station);
160static void SetNextSample(Ptr_MinstrelHtPerRemoteStation station);
161static double CalculateEwmsd(double oldEwmsd, double currentProb, double ewmaProb, double ewmaWeight);
162static double CalculateThroughput(Ptr_MinstrelHtPerRemoteStation station,UINT grpId, UINT rateId);
163static void CalculateRetransmits(Ptr_MinstrelHtPerRemoteStation station,UINT index);
164static UINT CountRetries(Ptr_MinstrelHtPerRemoteStation station);
165static UINT GetLowestIndex(Ptr_MinstrelHtPerRemoteStation station);
166static UINT GetHighestIndex(Ptr_MinstrelHtPerRemoteStation station);
167
168
169#ifdef __cplusplus
170}
171#endif
Data structure for physical layer parameters.
double avgAmpduLen
Average number of MPDUs in an A-MPDU.
UINT sampleCount
Max number of samples per update interval.
UINT sampleWait
How many transmission attempts to wait until a new sample.
UINT ampduPacketCount
Number of A-MPDUs transmitted since last update.
double ampduLen
Number of MPDUs tried since last update.
UINT sampleTries
Number of sample tries after waiting sampleWait.
UINT sampleSlow
Number of times a slow rate was sampled.
UINT sampleGroup
The group that the sample rate belongs to.
Ptr_GroupInfo groupTable
Table of groups with stats.
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
BOOL retryUpdated
If number of retries was updated already.
Definition Minstrel_ht.h:60