NetSim Source Code Help
Loading...
Searching...
No Matches
IEEE802_11n.c
Go to the documentation of this file.
1/************************************************************************************
2* Copyright (C) 2021 *
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* This source code is licensed per the NetSim license agreement. *
12* *
13* No portion of this source code may be used as the basis for a derivative work, *
14* or used, for any purpose other than its intended use per the NetSim license *
15* agreement. *
16* *
17* This source code and the algorithms contained within it are confidential trade *
18* secrets of TETCOS and may not be used as the basis for any other software, *
19* hardware, product or service. *
20* *
21* Author: Shashi Kant Suman *
22* *
23* ----------------------------------------------------------------------------------*/
24#include "main.h"
25#include "IEEE802_11.h"
26#include "IEEE802_11_Phy.h"
27
28/**
29This function is called to initialize the MIMO and OFDM parameters relevant to
30IEEE802.11n.
31This function is called from the "fn_NetSim_WLAN_PHY_Configuration()" for HT PHY.
32Initialize time parameters as per the Table 20-5—Timing-related constants 802.11n-2009 pdf
33also initialize 802.11n PHY header relevant parameters.
34*/
36{
37 UINT nNSTS_MAX = 4;
38 UINT nNSS_MAX = 4;
39 PIEEE802_11_PHY_VAR phy = IEEE802_11_PHY(nDeviceId,nInterfaceId);
40
41 // Initialize OFDM timing parameters According Table 20-5—Timing-related constants 802.11n-2009 pdf
42
43 if(phy->dChannelBandwidth == 20)
44 {
46 phy->PHY_TYPE.ofdmPhy_11n.nNSD = 52; // NSD Number of complex data numbers
47 phy->PHY_TYPE.ofdmPhy_11n.nNSP = 4; // NSP Number of pilot values
48 phy->PHY_TYPE.ofdmPhy_11n.nNST = 56; // 52 + 4
49 phy->PHY_TYPE.ofdmPhy_11n.nNSR = 28; // NSR Highest data subcarrier index
50 phy->PHY_TYPE.ofdmPhy_11n.nFFT = 64; // FFT length
51 }
52 else
53 {
55 phy->PHY_TYPE.ofdmPhy_11n.nNSD = 108; // NSD Number of complex data numbers
56 phy->PHY_TYPE.ofdmPhy_11n.nNSP = 6; // NSP Number of pilot values
57 phy->PHY_TYPE.ofdmPhy_11n.nNST = 114; // 108 + 6
58 phy->PHY_TYPE.ofdmPhy_11n.nNSR = 58; // NSR Highest data subcarrier index
59 phy->PHY_TYPE.ofdmPhy_11n.nFFT = 128; // FFT length
60 }
61
62 // Assign all the timing relevant parameters
63 phy->PHY_TYPE.ofdmPhy_11n.dDeltaF = phy->dChannelBandwidth/ (phy->PHY_TYPE.ofdmPhy_11n.nFFT * 1.0);//SubcarrierFrequencySpacing 312.5KHz (20 MHz/64) or (40 MHz/128)
64 phy->PHY_TYPE.ofdmPhy_11n.dTDFT = 3.2; // IDFT/DFT period 3.2 MicroSecs
65 phy->PHY_TYPE.ofdmPhy_11n.dTGI = phy->PHY_TYPE.ofdmPhy_11n.dTDFT/4; // 3.2/4 = 0.8 MicroSecs Guard interval duration 0.8 = TDFT/4
66 phy->PHY_TYPE.ofdmPhy_11n.dTGI2 = phy->PHY_TYPE.ofdmPhy_11n.dTGI * 2; // 0.8 * 2 = 1.6 MicroSecs Double guard interval 1.6
67 phy->PHY_TYPE.ofdmPhy_11n.dTGIS = phy->PHY_TYPE.ofdmPhy_11n.dTDFT/8; // Short guard interval duration dDFT/8 = 0.4
68 phy->PHY_TYPE.ofdmPhy_11n.nTL_STF = 8; // Non-HT short training sequence duration 8 = 10*TDFT/4
69 phy->PHY_TYPE.ofdmPhy_11n.nTHT_GF_STF = 8; // HT-greenfield short training field duration 8 =10* TDFT/4
70 phy->PHY_TYPE.ofdmPhy_11n.nTL_LTF = 8; // Non-HT long training field duration 8 =2 * TDFT + TGI2
71 phy->PHY_TYPE.ofdmPhy_11n.dTSYM = 4.0; //TSYM: Symbol interval 4 = TDFT + TGI
72 phy->PHY_TYPE.ofdmPhy_11n.dTSYMS = 3.6; // TSYMS: Short GI symbol interval = TDFT+TGIS 3.6
73 phy->PHY_TYPE.ofdmPhy_11n.nTL_SIG = 4; // Non-HT SIGNAL field duration 4
74 phy->PHY_TYPE.ofdmPhy_11n.nTHT_SIG = 8; // HT SIGNAL field duration 8 = 2TSYM 8
75 phy->PHY_TYPE.ofdmPhy_11n.nTHT_STF = 4; // HT short training field duration 4
76 phy->PHY_TYPE.ofdmPhy_11n.nTHT_LTF1 = 8; // First HT long training field duration 4 in HT-mixed format, 8 in HTgreenfield format
77 phy->PHY_TYPE.ofdmPhy_11n.nTHT_LTFs = 4; // Second, and subsequent, HT long training fields
78
79 if(phy->nGuardInterval == 400)
81 else
83
84 // Set the STBC coding
85 phy->PHY_TYPE.ofdmPhy_11n.nSTBC = 0;
86 // Check and Set NSS value, it should be minimum of transmit and received antenna count
87 phy->NSS = min((phy->nNTX < phy->nNRX ? phy->nNTX: phy->nNRX),nNSS_MAX);
88
89 // Set NSTS value
90 phy->NSTS = min(phy->NSS + phy->PHY_TYPE.ofdmPhy_11n.nSTBC,nNSTS_MAX);
91
92 // Set HT_DLTFs Table 20-12—Number of HT-DLTFs required for data space-time streams
93 phy->N_HT_DLTF = phy->NSTS;
94 if(phy->NSTS == 3)
95 phy->N_HT_DLTF = 4;
96
97 // Set NESS NESS + NSTS <= 4
98 phy->NESS = nNSTS_MAX - phy->NSTS;
99
100 // Set HT_ELTFs Table 20-13—Number of HT-ELTFs required for extension spatial streams
101 phy->N_HT_ELTF = phy->NESS;
102 if(phy->NESS == 3)
103 phy->N_HT_ELTF = 4;
104
105 // Set total HT_LTF = HT_DLTF + HT_ELTF
106 phy->N_HT_LTF = phy->N_HT_DLTF + phy->N_HT_ELTF;
107 if(phy->N_HT_LTF > 5) // Max is 5
108 phy->N_HT_LTF = 5;
109
111}
112
114{
115 double dTGF_HT_PREAMBLE;
116 int nSignalExtension = 0;
117
118 dTGF_HT_PREAMBLE = phy->PHY_TYPE.ofdmPhy_11n.nTHT_GF_STF \
120 + ((phy->N_HT_LTF - 1) * phy->PHY_TYPE.ofdmPhy_11n.nTHT_LTFs);
121
122 return dTGF_HT_PREAMBLE +
124 nSignalExtension;
125}
unsigned int NETSIM_ID
Definition: Animation.h:45
PIEEE802_11_PHY_VAR IEEE802_11_PHY(NETSIM_ID ndeviceId, NETSIM_ID nInterfaceId)
double fn_NetSim_IEEE802_11_HTPhy_getCtrlFrameDataRate(PIEEE802_11_PHY_VAR pstruPhy)
@ HT_CBW40
40 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.
void fn_NetSim_IEEE802_11n_OFDM_MIMO_init(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId)
Definition: IEEE802_11n.c:35
double get_11n_preamble_time(PIEEE802_11_PHY_VAR phy)
Definition: IEEE802_11n.c:113
#define UINT
Definition: Linux.h:38
#define min(a, b)
Definition: Linux.h:106
int nTHT_STF
HT short training field duration 4.
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.
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_SIG
HT SIGNAL field duration 8 = 2TSYM 8.
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
int nTHT_LTFs
Second, and subsequent, HT long training fields duration 4
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
unsigned int N_HT_ELTF