NetSim Source Code Help
Loading...
Searching...
No Matches
IEEE802_11ac.c
Go to the documentation of this file.
1/************************************************************************************
2 * Copyright (C) 2020 *
3 * TETCOS, Bangalore. India *
4 * *
5 * Tetcos owns the intellectual property rights in the Product and its content. *
6 * The copying, redistribution, reselling or publication of any or all of the *
7 * Product or its content without express prior written consent of Tetcos is *
8 * prohibited. Ownership and / or any other right relating to the software and all *
9 * intellectual property rights therein shall remain at all times with Tetcos. *
10 * *
11 * Author: Shashi Kant Suman *
12 * *
13 * ---------------------------------------------------------------------------------*/
14#include "main.h"
15#include "IEEE802_11.h"
16#include "IEEE802_11_Phy.h"
17
18/**
19This function is called to initialize the MIMO and OFDM parameters relevant to
20IEEE802.11ac.
21This function is called from the "fn_NetSim_WLAN_PHY_Configuration()" for HT PHY.
22Initialize time parameters as per the Table 20-5—Timing-related constants 802.11n-2009 pdf
23also initialize 802.11ac PHY header relevant parameters.
24*/
26{
27 UINT nNSTS_MAX = 8;
28 UINT nNSS_MAX = 8;
29 PIEEE802_11_PHY_VAR phy = IEEE802_11_PHY(nDeviceId,nInterfaceId);
30
31 // Initialize OFDM timing parameters According Table 20-5—Timing-related constants 802.11n-2009 pdf
32
33 if(phy->dChannelBandwidth == 20)
34 {
36 phy->PHY_TYPE.ofdmPhy_11ac.nNSD = 52; // NSD Number of complex data numbers
37 phy->PHY_TYPE.ofdmPhy_11ac.nNSP = 4; // NSP Number of pilot values
38 phy->PHY_TYPE.ofdmPhy_11ac.nNST = 56; // 52 + 4
39 phy->PHY_TYPE.ofdmPhy_11ac.nNSR = 28; // NSR Highest data subcarrier index
40 phy->PHY_TYPE.ofdmPhy_11ac.nFFT = 64; // FFT length
41 }
42 else if(phy->dChannelBandwidth == 40)
43 {
45 phy->PHY_TYPE.ofdmPhy_11ac.nNSD = 108; // NSD Number of complex data numbers
46 phy->PHY_TYPE.ofdmPhy_11ac.nNSP = 6; // NSP Number of pilot values
47 phy->PHY_TYPE.ofdmPhy_11ac.nNST = 114; // 108 + 6
48 phy->PHY_TYPE.ofdmPhy_11ac.nNSR = 58; // NSR Highest data subcarrier index
49 phy->PHY_TYPE.ofdmPhy_11ac.nFFT = 128; // FFT length
50 }
51 else if(phy->dChannelBandwidth == 80)
52 {
54 phy->PHY_TYPE.ofdmPhy_11ac.nNSD = 234; // NSD Number of complex data numbers
55 phy->PHY_TYPE.ofdmPhy_11ac.nNSP = 8; // NSP Number of pilot values
56 phy->PHY_TYPE.ofdmPhy_11ac.nNST = 242; // 234 + 8
57 phy->PHY_TYPE.ofdmPhy_11ac.nNSR = 122; // NSR Highest data subcarrier index
58 phy->PHY_TYPE.ofdmPhy_11ac.nFFT = 256; // FFT length
59 }
60 else if(phy->dChannelBandwidth == 160)
61 {
63 phy->PHY_TYPE.ofdmPhy_11ac.nNSD = 468; // NSD Number of complex data numbers
64 phy->PHY_TYPE.ofdmPhy_11ac.nNSP = 16; // NSP Number of pilot values
65 phy->PHY_TYPE.ofdmPhy_11ac.nNST = 484; // 468 + 16
66 phy->PHY_TYPE.ofdmPhy_11ac.nNSR = 250; // NSR Highest data subcarrier index
67 phy->PHY_TYPE.ofdmPhy_11ac.nFFT = 512; // FFT length
68 }
69
70 // Assign all the timing relevent parameters
71 phy->PHY_TYPE.ofdmPhy_11ac.dDeltaF = phy->dChannelBandwidth / (phy->PHY_TYPE.ofdmPhy_11ac.nFFT * 1.0);//SubcarrierFrequencySpacing 312.5KHz (20 MHz/64) or (40 MHz/128)
72 phy->PHY_TYPE.ofdmPhy_11ac.dTDFT = 3.2; // IDFT/DFT period 3.2 MicroSecs
73 phy->PHY_TYPE.ofdmPhy_11ac.dTGI = phy->PHY_TYPE.ofdmPhy_11ac.dTDFT/4; // 3.2/4 = 0.8 MicroSecs Guard interval duration 0.8 = TDFT/4
74 phy->PHY_TYPE.ofdmPhy_11ac.dTGI2 = phy->PHY_TYPE.ofdmPhy_11ac.dTGI * 2; // 0.8 * 2 = 1.6 MicroSecs Double guard interval 1.6
75 phy->PHY_TYPE.ofdmPhy_11ac.dTGIS = phy->PHY_TYPE.ofdmPhy_11ac.dTDFT/8; // Short guard interval duration dDFT/8 = 0.4
76 phy->PHY_TYPE.ofdmPhy_11ac.nTL_STF = 8; // Non-VHT short training sequence duration 8 = 10*TDFT/4
77 phy->PHY_TYPE.ofdmPhy_11ac.nTHT_GF_STF = 8; // HT-greenfield short training field duration 8 =10* TDFT/4
78 phy->PHY_TYPE.ofdmPhy_11ac.nTL_LTF = 8; // Non-HT long training field duration 8 =2 * TDFT + TGI2
79 phy->PHY_TYPE.ofdmPhy_11ac.dTSYM = 4.0; //TSYM: Symbol interval 4 = TDFT + TGI
80 phy->PHY_TYPE.ofdmPhy_11ac.dTSYMS = 3.6; // TSYMS: Short GI symbol interval = TDFT+TGIS 3.6
81 phy->PHY_TYPE.ofdmPhy_11ac.nTL_SIG = 4; // Non-HT SIGNAL field duration 4
84 phy->PHY_TYPE.ofdmPhy_11ac.nTHT_STF = 4; // HT short training field duration 4
85 phy->PHY_TYPE.ofdmPhy_11ac.nTHT_LTF1 = 8; // First HT long training field duration 4 in HT-mixed format, 8 in HTgreenfield format
86
87 if(phy->nGuardInterval == 400)
89 else
91
92 // Set the STBC coding
93 phy->PHY_TYPE.ofdmPhy_11n.nSTBC = 0;
94
95 // Check and Set NSS value, it should be minimum of transmit and received antenna count
96 phy->NSS = min((phy->nNTX < phy->nNRX ? phy->nNTX: phy->nNRX),nNSS_MAX);
97
98 // Set NSTS value
99 phy->NSTS = min(phy->NSS + phy->PHY_TYPE.ofdmPhy_11n.nSTBC,nNSTS_MAX);
100
101 // Set HT_ELTFs Table 20-13—Number of HT-ELTFs required for extension spatial streams
102 phy->N_HT_ELTF = phy->NESS;
103 if(phy->NESS%2 !=0)
104 phy->N_HT_ELTF += 1;
105
106 // Set total HT_LTF = HT_DLTF + HT_ELTF
107 phy->N_HT_LTF = phy->N_HT_DLTF + phy->N_HT_ELTF;
108 if(phy->N_HT_LTF > 9) // Max is 9
109 phy->N_HT_LTF = 9;
110
112}
113
114/**
115~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
116This function is used to calculate the transmission time. If flag=1, then preamble time is
117also taken into consideration. else only the time required to transmit the packetsize
118specified will be returned.
119For Short GI
120TXTIME = TGF_HT_PREAMBLE + THT_SIG + TSYMS * NSYM + SignalExtension
121For Regular/ Long GI
122TXTIME = TGF_HT_PREAMBLE + THT_SIG + TSYM * NSYM + SignalExtension
123TGF_HT_PREAMBLE is the duration of the preamble in HT_greenfield format, given by
124TGF_HT_PREAMBLE = THT_GF_STF + THT_ LTF1 + (NLTF – 1)THT_ LTFs
125TSYM, TSYMS, THT-SIG, TL-STF, THT-STF, THT-GF-STF, TL-LTF, THT-LTF1 and THT-LTFs defined in Table20-5 Timing-related constants
126SignalExtension is 0 microsecs when TXVECTOR parameter NO_SIG_EXTN is TRUE and is the duration of signal extension as defined by aSignalExtension in
127Table 20- 4 when TXVECTOR parameter NO_SIG_EXTN is FALSE NLTF is defined in Equation (20-22)
128NSYM is the total number of data symbols in the data portion, which may be calculated according to Equation (20-95)
129For BCC coding
130NSYM = mSTBC * ceil ( (8*length + 16 + 6*NES)/(mSTBC*NDBPS) )
131For LDPC
132NSYM = Navbits / NCBPS
133length is the number of octets in the data portion of the PPDU
134mSTBC is equal to 2 when STBC is used, and otherwise 1
135NES and NCBPS are defined in Table 20-6
136NDBPS is defined in Table 20-28
137Navbits is defined in Equation (20-39)
138~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139*/
141{
142 double dTxTime = 0.0;
143 double dNSYM, dTempNum = 0.0;
144 int mSTBC = 1, nNDBPS, nNCBPS;
145 int nNavbits = 1;
146 PIEEE802_11_PHY_VAR pstruPhy = IEEE802_11_PHY(nDevId,nInterfaceId);
147 double dPacketLength = pstruPacket->pstruPhyData->dPayload;
148
149 if(isIEEE802_11_CtrlPacket(pstruPacket)) // Other than WLAN control packets
150 {
151 nNDBPS = pstruPhy->PHY_TYPE.ofdmPhy_11ac.nNDBPS/pstruPhy->NSS;
152 nNCBPS = pstruPhy->PHY_TYPE.ofdmPhy_11ac.nNCBPS/pstruPhy->NSS;
153 }
154 else
155 {
156 nNDBPS = pstruPhy->PHY_TYPE.ofdmPhy_11ac.nNDBPS;
157 nNCBPS = pstruPhy->PHY_TYPE.ofdmPhy_11ac.nNCBPS;
158 }
159
160
162 {
163 dTempNum = (8 * dPacketLength) + 16 + ( 6 * pstruPhy->NESS) ;
164 if(pstruPhy->PHY_TYPE.ofdmPhy_11ac.nSTBC)
165 mSTBC = 2;
166
167 dTempNum = 8*dPacketLength;
168 dNSYM = mSTBC* ( dTempNum/(mSTBC * nNDBPS));
169 dTxTime = pstruPhy->PHY_TYPE.ofdmPhy_11ac.dTSYMS * dNSYM ;
170 return dTxTime;
171 }
172 else
173 {
174 dNSYM = nNavbits * nNCBPS;
175 dTxTime = pstruPhy->PHY_TYPE.ofdmPhy_11ac.dTSYMS * dNSYM ;
176 return dTxTime;
177 }
178}
179
181{
182 double dTGF_HT_PREAMBLE;
183 int nSignalExtension = 0;
184
185 dTGF_HT_PREAMBLE = phy->PHY_TYPE.ofdmPhy_11ac.nTHT_GF_STF \
189
190 return dTGF_HT_PREAMBLE +
193 nSignalExtension;
194}
unsigned int NETSIM_ID
Definition: Animation.h:45
PIEEE802_11_PHY_VAR IEEE802_11_PHY(NETSIM_ID ndeviceId, NETSIM_ID nInterfaceId)
bool isIEEE802_11_CtrlPacket(NetSim_PACKET *packet)
double fn_NetSim_IEEE802_11_HTPhy_getCtrlFrameDataRate(PIEEE802_11_PHY_VAR pstruPhy)
@ VHT_CBW160
160 MHz
@ HT_CBW40
40 MHz
@ VHT_CBW80
80 MHz
@ HT_CBW20
20 MHz and 40 MHz upper and 40 MHz lower modes
@ LONG_GI
Long GI is not used in the packet 800ns.
@ SHORT_GI
Short GI is used in the packet 400ns.
@ BCC_CODING
Binary convolutional code -BCC.
double get_11ac_preamble_time(PIEEE802_11_PHY_VAR phy)
Definition: IEEE802_11ac.c:180
void fn_NetSim_IEEE802_11ac_OFDM_MIMO_init(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId)
Definition: IEEE802_11ac.c:25
double fn_NetSim_IEEE802_11ac_TxTimeCalculation(NetSim_PACKET *pstruPacket, NETSIM_ID nDevId, NETSIM_ID nInterfaceId)
Definition: IEEE802_11ac.c:140
#define UINT
Definition: Linux.h:38
#define min(a, b)
Definition: Linux.h:106
int nTHT_STF
HT short training field duration 4.
int nTVHT_SIGA
HT SIGNAL field duration = 2TSYM = 8.
int nNSR
NSR Highest data subcarrier index.
double dTGI2
Double guard interval 1.6.
int nTHT_LTF1
First HT long training field duration 4 in HT-mixed format, 8 in HTgreenfield format.
double dTGI
Guard interval duration 0.8 = TDFT/4
double dTSYM
TSYM: Symbol interval 4 = TDFT + TGI
int nNSD
NSD Number of complex data numbers.
int nNST
NST Total number of subcarriers.
int nTVHT_SIGB
HT SIGNAL field duration = TSYM = 4.
double dDeltaF
dSubcarrierFrequencySpacing; // 312.5KHz (20 MHz/64) or (40 MHz/128)
int nTL_STF
Non-HT short training sequence duration 8 = 10*TDFT/4.
int nNSP
NSP Number of pilot values.
double dTGIS
Short guard interval duration dDFT/8 0.4.
double dTSYMS
dShortGIsymbolInterval; // TSYMS: Short GI symbol interval N/A 3.6 = TDFT+TGIS 3.6
int nTHT_GF_STF
HT-greenfield short training field duration 8 =10* TDFT/4.
int nTL_LTF
Non-HT long training field duration 8 =2 * TDFT + TGI2
double dTDFT
IDFT/DFT period 3.2
int nTL_SIG
Non-HT SIGNAL field duration 4
IEEE802_11_OFDM_MIMO ofdmPhy_11n
union stru_802_11_Phy_Var::@4 PHY_TYPE
unsigned int N_HT_LTF
unsigned int N_HT_DLTF
IEEE802_11_OFDM_MIMO ofdmPhy_11ac
unsigned int N_HT_ELTF
struct stru_NetSim_Packet_PhyLayer * pstruPhyData
Definition: Packet.h:277