12#define HT_GROUP_RATES 8
13#define VHT_GROUP_RATES 10
14#define HT_BANDWIDTHS 2
15#define VHT_BANDWIDTHS 4
21#define GetRateId(index,isVht) (isVht ? (index%VHT_GROUP_RATES):(index%HT_GROUP_RATES))
22#define GetGroupId(index,isVht) (isVht ? (index/VHT_GROUP_RATES):(index/HT_GROUP_RATES))
23#define GetIndex(grpId,rateId,isVht) (isVht ? (grpId*VHT_GROUP_RATES + rateId):(grpId*HT_GROUP_RATES + rateId))
24#define IsEqual(b1,g1,s1,b2,g2,s2) ((b1 == b2 && g1 == g2 && s1 ==s2) ? true:false)
26#define SEED_r &NETWORK->ppstruDeviceList[0]->ulSeed[0],&NETWORK->ppstruDeviceList[0]->ulSeed[1]
27#define rand01() (fn_NetSim_Utilities_GenerateRandomNo(SEED_r)/NETSIM_RAND_MAX)
28#define tSlot(phy) (phy->plmeCharacteristics.aSlotTime)
29#define ackTime(phy) (phy->plmeCharacteristics.aSIFSTime + get_preamble_time(phy) + (getAckSize(phy) * 8)/phy->dControlFrameDataRate)
30#define firstTransmissionTime(phy,byte,rate) (phy->plmeCharacteristics.aSIFSTime + get_preamble_time(phy)+ byte*8/rate)
31#define transmissionTime(phy,byte,rate) (byte*8/rate)
51 htWifiStation->
devId = nDevId;
123 random_var = (i+random_var)%station->
nGroupRate;
125 while(station->
sampleTable[random_var][j] != 10000){
126 random_var = (random_var + 1)%station->
nGroupRate;
135 UINT i,j,ch,sgi,nss,maxCh,maxNss,startid;
146 for(ch=20;ch<=maxCh;ch*=2){
147 for(sgi=400;sgi<=800;sgi*=2){
154 for(nss=1;nss<=maxNss;nss++){
211 UINT groupId, rateId;
218 station->
ampduLen += success + failed;
287 for(i=0;i<station->
nGroup;i++){
301 tempProb = tempProb/18000;
361 UINT maxTpRateId, maxTpGrpId, maxTp2RateId, maxTp2GrpId, maxProbRateId, maxProbGrpId;
448 if(sampleRate > maxTp2Rate || (sampleStream <= maxTpStream -1 && sampleRate > maxProbRate)){
480 UINT grpmaxThId,grpmaxTh2Id;
481 double grpmaxTh,grpmaxThProb,grpmaxTh2,grpmaxTh2Prob,th,prob;
491 for(i=0;i<station->
nGroup;i++){
509 if(th > grpmaxTh || (th == grpmaxTh && prob > grpmaxThProb)){
510 grpmaxTh2 = grpmaxTh;
511 grpmaxTh2Prob = grpmaxThProb;
512 grpmaxTh2Id = grpmaxThId;
519 else if(th > grpmaxTh2 || (th == grpmaxTh2 && prob > grpmaxTh2Prob)){
521 grpmaxTh2Prob = prob;
530 if(grpmaxTh > maxTh || (grpmaxTh == maxTh && grpmaxThProb > maxThProb)){
533 maxTh2Prob = maxThProb;
537 maxThProb = grpmaxThProb;
539 else if(grpmaxTh > maxTh2 || (grpmaxTh == maxTh2 && grpmaxThProb > maxTh2Prob)){
541 maxTh2Prob = grpmaxThProb;
542 maxTh2Id = grpmaxThId;
545 if(grpmaxTh2 > maxTh2 || (grpmaxTh2 == maxTh2 && grpmaxTh2Prob > maxTh2Prob)){
547 maxTh2Prob = grpmaxTh2Prob;
548 maxTh2Id = grpmaxTh2Id;
559 UINT i,j,grpmaxProbId;
561 double th,prob,grpmaxProb,grpmaxProbTh;
566 for(i=0;i<station->
nGroup;i++){
580 if(th > grpmaxProbTh){
587 if(prob > grpmaxProb){
596 if(grpmaxProb > 0.75){
597 if(grpmaxProbTh > maxProbTh){
598 maxProbTh = grpmaxProbTh;
599 maxProb = grpmaxProb;
604 if(grpmaxProb > maxProb){
605 maxProbTh = grpmaxProbTh;
606 maxProb = grpmaxProb;
640 double diff, incr, tmp;
643 diff = currentProb - ewmaProb;
645 tmp = oldEwmsd * oldEwmsd;
646 tmp = (100-
ewmaWeight)* (tmp + diff * incr) / 100;
660 return (
max(ewmaProb,0.9)*8*1500*nPackets)/TrTime;
669 double cwTime,txTime,dataTxTime,rate;
686 cwTime = (
tSlot(station->
phy)*cw)>>1;
687 cw =
min((cw<<1)| 1,cwMax);
688 cwTime += (
tSlot(station->
phy)*cw)>>1;
689 cw =
min((cw<<1)| 1,cwMax);
691 txTime = cwTime + 2*(dataTxTime +
ackTime(station->
phy));
694 cwTime = (
tSlot(station->
phy)*cw)>>1;
695 cw =
min((cw<<1)| 1,cwMax);
696 txTime += dataTxTime +
ackTime(station->
phy) + cwTime;
728 while(!(
int)grpId < (
int)station->
nGroup &&
732 if(grpId == station->
nGroup)
745 int grpId = station->
nGroup -1;
767 UINT W = station->groupTable[grpId].chWidth;
768 UINT S = station->groupTable[grpId].streams;
770 if(station->groupTable[grpId].sgi == 800){
782#pragma message(__LOC__"Implement the HT_Minstrel_Free")
PIEEE802_11_PHY_VAR IEEE802_11_PHY(NETSIM_ID ndeviceId, NETSIM_ID nInterfaceId)
struct stru_802_11_Phy_Parameters_HT * get_phy_parameter_HT(double dChannelBandwidth, UINT NSS)
#define fnNetSimError(x,...)
static Ptr_MinstrelPerRemoteStation getMinstrelInfo(NETSIM_ID dev, NETSIM_ID ifid, NETSIM_ID recv)
#define GetIndex(grpId, rateId, isVht)
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)
static UINT GetLowestIndex(Ptr_MinstrelHtPerRemoteStation station)
static void SetStationThRate(Ptr_MinstrelHtPerRemoteStation station)
static UINT GetNextSample(Ptr_MinstrelHtPerRemoteStation station)
void DoReportAmpduStatus(NETSIM_ID devid, NETSIM_ID ifid, NETSIM_ID recvid, UINT success, UINT failed)
#define GetRateId(index, isVht)
#define transmissionTime(phy, byte, rate)
#define GetGroupId(index, isVht)
BOOL Ht_DoNeedDataRetransmission(NETSIM_ID devid, NETSIM_ID ifid, NETSIM_ID recvid)
struct stru_802_11_Phy_Parameters_HT getTxRate(NETSIM_ID devid, NETSIM_ID ifid, NETSIM_ID recvid)
void HT_Minstrel_Free(NETSIM_ID nDevId, NETSIM_ID nifid)
#define firstTransmissionTime(phy, byte, rate)
static void SetNextSample(Ptr_MinstrelHtPerRemoteStation station)
static Ptr_MinstrelHtPerRemoteStation getMinstrelInfo(NETSIM_ID dev, NETSIM_ID ifid, NETSIM_ID recv)
static double CalculateThroughput(Ptr_MinstrelHtPerRemoteStation station, UINT grpId, UINT rateId)
#define IsEqual(b1, g1, s1, b2, g2, s2)
static void UpdateStats(Ptr_MinstrelHtPerRemoteStation station)
static void InitGroupTable(Ptr_MinstrelHtPerRemoteStation station)
static UINT FindRate(Ptr_MinstrelHtPerRemoteStation station)
static void CalculateRetransmits(Ptr_MinstrelHtPerRemoteStation station, UINT index)
static void InitSampleTable(Ptr_MinstrelHtPerRemoteStation station)
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)
struct stru_HtPerRemoteStation * Ptr_MinstrelHtPerRemoteStation
struct stru_MinstrelHtWifiStation * Ptr_MinstrelHtWifiStation
double ht_updateStatsTime
EXPORTED double ldEventTime
EXPORTED struct stru_NetSim_Network * NETWORK
Data structure for physical layer parameters.
IEEE802_11_PHY_TYPE PhyType
void * rateAdaptationData
double avgAmpduLen
Average number of MPDUs in an A-MPDU.
NETSIM_ID remoteStationId
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.
NETSIM_ID stationInterface
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.
double throughput
Throughput of this rate (in pkts per second).
UINT retryCount
Retry limit.
double prob
Current probability within last time interval. (# frame success )/(# total frames)
double ewmsdProb
Exponential weighted moving standard deviation of probability.
BOOL retryUpdated
If number of retries was updated already.
Ptr_MinstrelHtPerRemoteStation * minstrelHtInfo