NetSim Source Code Help
Loading...
Searching...
No Matches
Minstrel.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 "main.h"
11#include "IEEE802_11_Phy.h"
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17//Structure to contain all information related to a data-rate
18typedef struct stru_Rate_Info{
19 double rate; //data-rate
20
21 // Perfect transmission time calculation, or frame calculation
22 // Given a bit rate and a packet length n bytes
24
25 UINT retryCount; //retry limit (constant for each rate)
26 UINT adjustedRetryCount; //retry limit to be used(changes with time)
27 UINT currNumAttempt; //attempts made so far
28 UINT currNumSuccess; //success pkts so far
31
32 double prob; //(# successful pkts / # attempted pkts)
33 //ewma_prob =[prob *(ewma_weight) + ewma_prob_old *(100- ewma_weight)]/100
34 double ewmaProb; //Expected weighted moving average
35 double throughput; //throughput of this rate
36
37 UINT64 totalNumAttempt; //total number of attempts made
38 UINT64 totalNumSuccess; //total number of success pkts
39
40 UINT numSampleSkipped; //Number of Samples skipped
41 int sampleLimit; //Sampling Limit
43
44//Structure to contain information for each remote station
46 double nextStatsUpdate; //time to update next time
47 BOOL isInitialized; //to check if station is intialized
48 UINT maxTpRate; //index of maximum throughput rate
49 UINT maxTp2Rate; //index of 2nd maximum throughput rate
50 UINT maxProbRate; //index of rate with maximum success probability
51 UINT baseRate; //index of lowest rate
52 UINT nRate; //number of rates supported
53 UINT sampleRate; //Index of current sample Rate
54 UINT trRate; //Index of current transmit Rate
55
56 BOOL isSampling; //currently sampling
57 BOOL isDeferredSample; //flag to indicate sample rate is on 2nd stage
58 UINT64 numSampleDeferred; //count the deferred number of samples
59 UINT64 totalPacketCount; //number of total packets (all retries will count as 1)
60 UINT64 samplePacketCount; //number of sampled packets
61 UINT shortRetry; //number of short retries such as control packets
62 UINT longRetry; //number of long retries such as data packets
63 UINT64 totalRetry; //total retry= long + short
64
65 RateInfo* minstrelTable; //minstrel Table
66 UINT** sampleTable; //sample Table of nRate x col int values
67 UINT row,col; //current position in sample table
68 PIEEE802_11_PHY_VAR phy; //NetSim implementation requirement
70
71double updateStatsTime; //Time Interval for updating Minstrel Table ~100ms
72double lookAroundRate; //% of pkts to send with other rates. ~10
73double ewmaWeight; //weight to be given to new value (0,100) ~25%
74UINT sampleCol; //number of columns in Sample Table ~10
75
76//One structure per device
78 Ptr_MinstrelPerRemoteStation *minstrelInfo; //(Array)containing info for each remote connected device
80
81void InitMinstrel(NETSIM_ID nDevId,NETSIM_ID nifid);
84static void InitMinstrelTable(Ptr_MinstrelPerRemoteStation station,double *rate_arr);
96void FreeMinstrel(NETSIM_ID nDevId,NETSIM_ID nifid);
98
99
100#ifdef __cplusplus
101}
102#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 updateStatsTime
Definition: Minstrel.h:71
struct stru_MinstrelWifiStation MinstrelWifiStation
BOOL DoNeedDataRetransmission(NETSIM_ID dev, NETSIM_ID ifid, NETSIM_ID recv)
Definition: Minstrel.c:688
static UINT GetNextSample(Ptr_MinstrelPerRemoteStation station)
void DoReportDataFailed(NETSIM_ID dev, NETSIM_ID ifid, NETSIM_ID recv)
Definition: Minstrel.c:326
static UINT CountRetry(Ptr_MinstrelPerRemoteStation station)
static void UpdateRetry(Ptr_MinstrelPerRemoteStation station)
static void UpdatePacketCounter(Ptr_MinstrelPerRemoteStation station)
void DoReportDataOk(NETSIM_ID dev, NETSIM_ID ifid, NETSIM_ID recv)
Definition: Minstrel.c:310
double lookAroundRate
Definition: Minstrel.h:72
static UINT FindRate(Ptr_MinstrelPerRemoteStation station)
static void InitMinstrelTable(Ptr_MinstrelPerRemoteStation station, double *rate_arr)
struct stru_MinstrelWifiRemoteStation * Ptr_MinstrelPerRemoteStation
void FreeMinstrel(NETSIM_ID nDevId, NETSIM_ID nifid)
Definition: Minstrel.c:738
struct stru_MinstrelWifiRemoteStation MinstrelPerRemoteStation
void DoReportFinalDataFailed(NETSIM_ID dev, NETSIM_ID ifid, NETSIM_ID recv)
Definition: Minstrel.c:674
static void UpdateRate(Ptr_MinstrelPerRemoteStation station)
struct stru_MinstrelWifiStation * Ptr_MinstrelWifiStation
static void UpdateStats(Ptr_MinstrelPerRemoteStation station)
void FreeTables(Ptr_MinstrelPerRemoteStation station)
Definition: Minstrel.c:759
static void InitSampleTable(Ptr_MinstrelPerRemoteStation station)
struct stru_Rate_Info RateInfo
void InitMinstrel(NETSIM_ID nDevId, NETSIM_ID nifid)
Definition: Minstrel.c:175
double ewmaWeight
Definition: Minstrel.h:73
static void CheckInit(Ptr_MinstrelPerRemoteStation station, NETSIM_ID nDevId, NETSIM_ID nifid)
UINT sampleCol
Definition: Minstrel.h:74
PIEEE802_11_PHY_VAR phy
Definition: Minstrel.h:68
Ptr_MinstrelPerRemoteStation * minstrelInfo
Definition: Minstrel.h:78
int sampleLimit
Definition: Minstrel.h:41
double prob
Definition: Minstrel.h:32
UINT prevNumAttempt
Definition: Minstrel.h:29
UINT prevNumSuccess
Definition: Minstrel.h:30
UINT adjustedRetryCount
Definition: Minstrel.h:26
UINT retryCount
Definition: Minstrel.h:25
UINT currNumSuccess
Definition: Minstrel.h:28
UINT currNumAttempt
Definition: Minstrel.h:27
double ewmaProb
Definition: Minstrel.h:34
double rate
Definition: Minstrel.h:19
double perfectTrTime
Definition: Minstrel.h:23
double throughput
Definition: Minstrel.h:35
UINT numSampleSkipped
Definition: Minstrel.h:40
UINT64 totalNumAttempt
Definition: Minstrel.h:37
UINT64 totalNumSuccess
Definition: Minstrel.h:38