NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
Minstrel_he.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: HESUOFDM@IITM *
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} b; //HESUOFDM@IITM
34
36 UINT streams; //number of spatial streams
37 UINT sgi; //short guard Interval
38 UINT chWidth; //bandwidth
39 bool isHe;
40 bool isSupported;
41
42 double* rate; //rates supported by this group
43 double* trTime; //transmission time for the rates
44}HE_McsGroup; //HESUOFDM@IITM
45
46typedef struct stru_HeRateInfo{
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}HeRateInfo,*Ptr_HeRateInfo;
81
82typedef struct stru_HE_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_HeRateInfo rateTable; //Info of rates supported by this group
95}HE_GroupInfo,*Ptr_HE_GroupInfo; //HESUOFDM-4 needs a change of name
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_HE_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 isHe; //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}MinstrelHePerRemoteStation,*Ptr_MinstrelHePerRemoteStation;
134
135
137 NETSIM_ID devId;
138 NETSIM_ID interfaceId;
139 Ptr_MinstrelHePerRemoteStation *minstrelHeInfo;
140}MinstrelHeWifiStation,*Ptr_MinstrelHeWifiStation;
141
142double he_updateStatsTime; //Time Interval for updating Minstrel Table
143double he_lookAroundRate; //% of pkts to send with other rates. ~10
144double he_ewmaWeight; //weight to be given to new value (0,100) ~25%
145UINT he_sampleCol; //number of columns in Sample Table
146
147
148void He_InitMinstrel(NETSIM_ID nDevId,NETSIM_ID nifid);
149static void He_CheckInit(Ptr_MinstrelHePerRemoteStation station,NETSIM_ID devid,NETSIM_ID ifid);
150static void He_InitSampleTable(Ptr_MinstrelHePerRemoteStation station);
151static void He_InitGroupTable(Ptr_MinstrelHePerRemoteStation station);
152static void He_UpdatePacketCounter(Ptr_MinstrelHePerRemoteStation station,UINT success,UINT failed);
153static void He_UpdateRetry(Ptr_MinstrelHePerRemoteStation station);
154static void He_UpdateStats(Ptr_MinstrelHePerRemoteStation station);
155static void He_UpdateRate(Ptr_MinstrelHePerRemoteStation station);
156static UINT He_FindRate(Ptr_MinstrelHePerRemoteStation station);
157static void He_SetStationThRate(Ptr_MinstrelHePerRemoteStation station);
158static void He_SetStationProbRate(Ptr_MinstrelHePerRemoteStation station);
159static UINT He_GetNextSample(Ptr_MinstrelHePerRemoteStation station);
160static void He_SetNextSample(Ptr_MinstrelHePerRemoteStation station);
161static double He_CalculateEwmsd(double oldEwmsd, double currentProb, double ewmaProb, double ewmaWeight);
162static double He_CalculateThroughput(Ptr_MinstrelHePerRemoteStation station,UINT grpId, UINT rateId);
163static void He_CalculateRetransmits(Ptr_MinstrelHePerRemoteStation station,UINT index);
164static UINT He_CountRetries(Ptr_MinstrelHePerRemoteStation station);
165static UINT He_GetLowestIndex(Ptr_MinstrelHePerRemoteStation station);
166static UINT He_GetHighestIndex(Ptr_MinstrelHePerRemoteStation station);
167
168
169#ifdef __cplusplus
170}
171#endif
Data structure for physical layer parameters.
Ptr_HE_GroupInfo groupTable
Table of groups with stats.
UINT sampleSlow
Number of times a slow rate was sampled.
UINT sampleWait
How many transmission attempts to wait until a new sample.
double ampduLen
Number of MPDUs tried since last update.
double avgAmpduLen
Average number of MPDUs in an A-MPDU.
UINT sampleGroup
The group that the sample rate belongs to.
UINT ampduPacketCount
Number of A-MPDUs transmitted since last update.
UINT sampleTries
Number of sample tries after waiting sampleWait.
UINT sampleCount
Max number of samples per update interval.
UINT retryCount
Retry limit.
Definition Minstrel_he.h:56
BOOL retryUpdated
If number of retries was updated already.
Definition Minstrel_he.h:60
BOOL supported
If the rate is supported.
Definition Minstrel_he.h:54
double perfectTrTime
Definition Minstrel_he.h:51
UINT adjustedRetryCount
Adjust the retry limit for this rate.
Definition Minstrel_he.h:57
double throughput
Throughput of this rate (in pkts per second).
Definition Minstrel_he.h:68
double prob
Current probability within last time interval. (# frame success )/(# total frames)
Definition Minstrel_he.h:58
double ewmsdProb
Exponential weighted moving standard deviation of probability.
Definition Minstrel_he.h:69