NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
IEEE802_11_Phy.h
1/************************************************************************************
2* Copyright (C) 2023 *
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#ifndef _NETSIM_IEEE802_11_PHY_H_
25#define _NETSIM_IEEE802_11_PHY_H_
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30#include "IEEE802_11.h"
31#include "ErrorModel.h"
32
33 //Default Battery config parameter
34#define BATTERY_RECHARGING_CURRENT_MA_DEFAULT 0
35#define BATTERY_VOLTAGE_V_DEFAULT 0
36#define BATTERY_INITIAL_ENERGY_DEFAULT 0
37#define BATTERY_TRANSMITTING_CURRENT_MA_DEFAULT 0
38#define BATTERY_RECEIVING_CURRENT_MA_DEFAULT 0
39#define BATTERY_IDLEMODE_CURRENT_MA_DEFAULT 0
40#define BATTERY_SLEEPMODE_CURRENT_MA_DEFAULT 0
41
42#define CSRANGEDIFF -3 //db
43
44#include "IEEE802_11_HTPhy.h"
45#include "IEEE802_11_HEPhy.h"
46
47 typedef enum
48 {
49 FHSS_2_4_GHz = 01,
50 DSSS_2_4_GHz = 02,
51 IR_Baseband = 03,
52 OFDM = 04,
53 DSSS = 05,
54 ERP = 06,
55 HT = 07,
56 VHT = 8,
57 HE = 9,
58 }IEEE802_11_PHY_TYPE;
59
60 static const char* strIEEE802_11_ANTENNA_TYPE[] =
61 { "Omnidirectional Antenna", "Sector Antenna", };
62
63 /// Enumeration to represent the DSSS rate
64 typedef enum enum_802_11_DSSS_PLCP_SIGNAL_Field
65 {
66 Rate_1Mbps = 0x0A,
67 Rate_2Mbps = 0x14,
68 Rate_5dot5Mbps = 0x37,
69 Rate_11Mbps = 0x6E,
70 }IEEE802_11_DSSS_PLCP_SIGNAL;
71
73 {
74 double dDataRate;
75 PHY_MODULATION modulation;
76 double dCodeRate;
77 IEEE802_11_DSSS_PLCP_SIGNAL dsssrate;
78 double dProcessingGain;
79 }IEEE802_11_DSSS_PHY,*PIEEE802_11_DSSS_PHY;
80
82 {
83 double dDataRate;
84 double dCodingRate;
85 PHY_MODULATION modulation;
86 int nNBPSC;
87 int nNCBPS;
88 int nNDBPS;
89 }IEEE802_11_OFDM_PHY,*PIEEE802_11_OFDM_PHY;
90
91 /**
92 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93 ********** PHY layer ************
94 Page-1514 IEEE Std 802.11 2012 Table 16-2 DS PHY characteristics
95 Page-1623 IEEE Std 802.11-2012 Table 18-17—OFDM PHY characteristics
96 Page-361 6.5.4.2 Semantics of the service primitive
97 PLME-CHARACTERISTICS
98 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99 */
101 {
102 UINT aSlotTime;
103 UINT aSIFSTime;
104 UINT aCCATime;
105 UINT aPHY_RX_START_Delay;
106 UINT aRxTxTurnaroundTime;
107 UINT aTxPLCPDelay;
108 UINT aRxPLCPDelay;
109 UINT aRxTxSwitchTime;
110 UINT aTxRampOnTime;
111 UINT aTxRampOffTime;
112 UINT aTxRFDelay;
113 UINT aRxRFDelay;
114 UINT aAirPropagationTime;
115 UINT aMACProcessingDelay;
116 UINT aPreambleLength;
117 UINT aPLCPHeaderLength;
118 UINT aMPDUDurationFactor;
119 UINT aMPDUMaxLength;
120 UINT aCWmin;
121 UINT aCWmax;
122 }PLME_CHARACTERISTICS,*PPLME_CHARACTERISTICS;
123#define getSlotTime(phy) (phy->plmeCharacteristics.aSlotTime)
124#define getSIFSTime(phy) (phy->plmeCharacteristics.aSIFSTime)
125
127 {
128 PHY_TX_STATUS radioState;
129 NETSIM_ID peerId;
130 UINT64 transmissionId;
131 UINT64 eventId;
132 }IEEE802_11_RADIO, *ptrIEEE802_11_RADIO;
133
134 typedef struct stru_802_11_Phy_Var
135 {
136 //Config variable
137 UINT nTxPower_mw;
138 IEEE802_11_PROTOCOL PhyProtocol;
139 IEEE802_11_PHY_TYPE PhyType;
140 UINT16 usnChannelNumber;
141 double dFrequency;
142 double dFrequencyBand;
143 double dChannelBandwidth;
144 double dAntennaHeight;
145 double dAntennaGain;
146
147 //For HT/VHT config variable
148 UINT nNTX;
149 UINT nNRX;
150 UINT nGuardInterval;
151
152 // Scetor Antenna Variables
153 ANTENNA_TYPE antennaType;
154 double boresightAngle;
155 double elementGain;
156 double beamwidth;
157 double frontToBackRatio;
158
159 PLME_CHARACTERISTICS plmeCharacteristics;
160
161 //Rate adaptation
162 void* rateAdaptationData;
163
164 //Data Rate
165 double dControlFrameDataRate;
166 double dBroadcastFrameDataRate;
167
168 //CCA
169 IEEE802_11_CCAMODE ccaMode;
170 double dEDThreshold;
171
172 //Radio
173 IEEE802_11_RADIO radio;
174
175 //IFS
176 UINT RIFS;
177 UINT SIFS;
178 UINT PIFS;
179 UINT DIFS;
180 UINT AIFS;
181 UINT EIFS;
182
183 //Power
184 double dCurrentRxSensitivity_dbm;
185
186 //Phy type
187 union{
188 IEEE802_11_DSSS_PHY dsssPhy;
189 IEEE802_11_OFDM_PHY ofdmPhy;
190 IEEE802_11_OFDM_MIMO ofdmPhy_11n;
191 IEEE802_11_OFDM_MIMO ofdmPhy_11ac;
192 IEEE802_11_OFDM_MIMO_HE ofdmPhy_11ax;
193 }PHY_TYPE;
194
195 //MIMO
196 double codingRate;
197 unsigned int NSS; // Number of spatial streams
198 unsigned int NSTS; // Number of space-time streams
199 unsigned int N_HT_DLTF; // Number of Data HT Long Training fields
200 unsigned int NESS; // Number of extension spatial streams
201 unsigned short int nN_HT_DLTF; // Number of Data HT Long Training fields
202 unsigned int N_HT_ELTF; // Number of Extension HT Long Training fields
203 unsigned int N_HT_LTF; // Number of HT Long Training fields (see 20.3.9.4.6)
204 unsigned int MCS;
205 unsigned int NES; // Number of BCC encoders for the Data field
206 unsigned int N_HE_LTF; //HESUOFDM Number of HE long training fields
207 PACKET_STATUS firstpacketstatus;
208
209 double d0;
210 double pld0;
211
212 //Battery
213 bool isDeviceOn;
214 void* battery;
215
216 //BER-Model
217 BER_MODEL_TYPE Ber_Model;
218
219 //Fixed MCS
220 bool Fixed_MCS;
221 int Fixed_Data_Rate_MCS;
222
223 ptrpropagation_info_for_list propagation_info_list;
224
225 UINT64 transmissionId;
226 }IEEE802_PHY_VAR,*PIEEE802_11_PHY_VAR;
227
228#define IEEE802_11_CURR_PHY IEEE802_11_PHY(pstruEventDetails->nDeviceId,pstruEventDetails->nInterfaceId)
229
230 //Propagation macro
231 double GET_RX_POWER_dbm(NETSIM_ID tx, NETSIM_ID txi, NETSIM_ID rx, NETSIM_ID rxi, double time);
232#define GET_RX_POWER_mw(tx, txi, rx, rxi, time) (DBM_TO_MW(GET_RX_POWER_dbm(tx, txi, rx, rxi, time)))
233
234 //Function Prototype
235 int fn_NetSim_IEEE802_11_PHY_Init(NETSIM_ID nDeviceId,NETSIM_ID nInterfaceId);
236 bool isMediumIdle(NETSIM_ID, NETSIM_ID);
237 void fn_NetSim_IEEE802_11_Add_Phy_Header(NetSim_PACKET* packet, UINT64* transmissionId);
238 double get_preamble_time(PIEEE802_11_PHY_VAR phy);
239 int fn_NetSim_IEEE802_11_PhyOut();
240 int fn_NetSim_IEEE802_11_PhyIn();
241 bool fn_NetSim_IEEE802_11_TransmitFrame(NetSim_PACKET* pstruPacket, NETSIM_ID nDevId, NETSIM_ID nInterfaceId);
242 bool fn_NetSim_IEEE802_11_TransmitBroadcastFrame(NetSim_PACKET* pstruPacket, NETSIM_ID nDevId, NETSIM_ID nInterfaceId);
243 int fn_NetSim_IEEE802_11_SetDataRate(NETSIM_ID txId, NETSIM_ID txIf,
244 NETSIM_ID rxId, NETSIM_ID rxIf,
245 NetSim_PACKET* packet, double time);
246 void free_ieee802_11_phy_header(NetSim_PACKET* packet);
247 void copy_ieee802_11_phy_header(NetSim_PACKET* d, NetSim_PACKET* s);
248 int fn_NetSim_IEEE802_11_PropagationModel(NETSIM_ID nodeId, double time);
249 void fn_Update_TxInfo_TxRxPos(NETSIM_ID devId);
250 double fn_NetSim_IEEE802_11_CalculateTransmissionTime(double size, NETSIM_ID nDevId, NETSIM_ID nInterfaceId);
251 double fn_NetSim_IEEE802_11_HTPhy_getCtrlFrameDataRate(PIEEE802_11_PHY_VAR pstruPhy);
252 double fn_NetSim_IEEE802_11_GetMinRxSensitivity(NETSIM_ID txId, NETSIM_ID txIf);
253
254 //Radio
255 bool is_radio_idle(PIEEE802_11_PHY_VAR phy);
256 bool set_radio_state(NETSIM_ID d,
257 NETSIM_ID in,
258 PHY_TX_STATUS state,
259 NETSIM_ID peerId,
260 UINT64 transmissionId);
261 PHY_TX_STATUS get_radio_state(PIEEE802_11_PHY_VAR phy);
262 void set_mac_state_after_txend(PIEEE802_11_MAC_VAR mac);
263 bool CheckFrequencyInterfrence(double dFrequency1,double dFrequency2,double bandwidth);
264
265 //IEEE802.11b
266 void fn_NetSim_IEEE802_11_DSSPhy_SetEDThreshold(PIEEE802_11_PHY_VAR phy);
267 int fn_NetSim_IEEE802_11_DSSPhy_UpdateParameter();
268 int fn_NetSim_IEEE802_11_DSSSPhy_DataRate(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId, NETSIM_ID nReceiverId,NetSim_PACKET* packet,double time);
269 unsigned int get_dsss_phy_max_index();
270 unsigned int get_dsss_phy_min_index();
271 void get_dsss_phy_all_rate(double* rate, UINT* len);
272
273 //IEEE802.11a/g/p
274 void fn_NetSim_IEEE802_11_OFDMPhy_SetEDThreshold(PIEEE802_11_PHY_VAR phy);
275 int fn_NetSim_IEEE802_11_OFDMPhy_UpdateParameter();
276 int fn_NetSim_IEEE802_11_OFDMPhy_DataRate(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId, NETSIM_ID nReceiverId,NetSim_PACKET* packet,double time);
277 unsigned int get_ofdm_phy_max_index();
278 unsigned int get_ofdm_phy_min_index();
279 void get_ofdm_phy_all_rate(int bandwidth_MHz, double* rate, UINT* len);
280
281 //IEEE802.11n
282 void fn_NetSim_IEEE802_11_HTPhy_SetEDThreshold(PIEEE802_11_PHY_VAR phy);
283 int fn_NetSim_IEEE802_11_HTPhy_UpdateParameter();
284 void fn_NetSim_IEEE802_11n_OFDM_MIMO_init(NETSIM_ID nDeviceId,NETSIM_ID nInterfaceId);
285 double get_11n_preamble_time(PIEEE802_11_PHY_VAR phy);
286 double fn_NetSim_IEEE802_11n_TxTimeCalculation(NetSim_PACKET *pstruPacket, NETSIM_ID nDevId, NETSIM_ID nInterfaceId);
287 int fn_NetSim_IEEE802_11_HTPhy_DataRate(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId, NETSIM_ID nReceiverId,NetSim_PACKET* packet,double time);
288 unsigned int get_ht_phy_max_index(IEEE802_11_PROTOCOL protocol,UINT);
289 unsigned int get_ht_phy_min_index(IEEE802_11_PROTOCOL protocol,UINT);
290
291 //IEEE802.11ac
292 void fn_NetSim_IEEE802_11ac_OFDM_MIMO_init(NETSIM_ID nDeviceId,NETSIM_ID nInterfaceId);
293 double get_11ac_preamble_time(PIEEE802_11_PHY_VAR phy);
294 double fn_NetSim_IEEE802_11ac_TxTimeCalculation(NetSim_PACKET *pstruPacket, NETSIM_ID nDevId, NETSIM_ID nInterfaceId);
295 struct stru_802_11_Phy_Parameters_HT* get_phy_parameter_HT(double dChannelBandwidth,UINT NSS);
296
297 //IEEE802.11ax
298
299 void fn_NetSim_IEEE802_11_HEPhy_SetEDThreshold(PIEEE802_11_PHY_VAR phy);
300 int fn_NetSim_IEEE802_11_HEPhy_UpdateParameter();
301 void fn_NetSim_IEEE802_11ax_OFDM_MIMO_init(NETSIM_ID nDeviceId,NETSIM_ID nInterfaceId);
302 double get_11ax_preamble_time(PIEEE802_11_PHY_VAR phy);
303 double fn_NetSim_IEEE802_11ax_TxTimeCalculation(NetSim_PACKET *pstruPacket, NETSIM_ID nDevId, NETSIM_ID nInterfaceId);
304 int fn_NetSim_IEEE802_11_HEPhy_DataRate(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId, NETSIM_ID nReceiverId,NetSim_PACKET* packet,double time);
305 unsigned int get_he_phy_max_index(IEEE802_11_PROTOCOL protocol,UINT);
306 unsigned int get_he_phy_min_index(IEEE802_11_PROTOCOL protocol,UINT);
307 double fn_NetSim_IEEE802_11_HEPhy_getCtrlFrameDataRate(PIEEE802_11_PHY_VAR pstruPhy);
308 struct stru_802_11_Phy_Parameters_HE* get_phy_parameter_HE(double dChannelBandwidth,UINT NSS);
309
310
311
312 //IEEE1609 Interface
313 PIEEE802_11_PHY_VAR IEEE802_11_PHY(NETSIM_ID ndeviceId, NETSIM_ID nInterfaceId);
314 void SET_IEEE802_11_PHY(NETSIM_ID ndeviceId, NETSIM_ID nInterfaceId, PIEEE802_11_PHY_VAR phy);
315
316 //IEEE802_11 Radio Measurements
317 void IEEE_802_11RadioMeasurements_Init();
318 void IEEE_802_11RadioMeasurements_Finish();
319 void IEEE_802_11RadioMeasurements_Log(NetSim_PACKET* packet, NETSIM_ID txid, NETSIM_ID txif, NETSIM_ID rxid, NETSIM_ID rxif);
320#ifdef __cplusplus
321}
322#endif
323#endif //_NETSIM_IEEE802_11_PHY_H_
Data structure for physical layer parameters.
Data structure for physical layer parameters.