NetSim Source Code Help
Loading...
Searching...
No Matches
IEEE802_11_Phy.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"
28#include "IEEE802_11_PhyFrame.h"
29#include "NetSim_utility.h"
30#include "Medium.h"
31
33double ofdmphy_get_min_rxSensitivity(double bandwidth);
34double HTPhy_get_min_rxSensitivity(double bandwidth, UINT NSS);
36
37#define SPEED_OF_LIGHT 299.792458 // meter per micro sec
39{
40 NETSIM_ID tx=packet->nTransmitterId;
41 NETSIM_ID rx=packet->nReceiverId;
43 return d/SPEED_OF_LIGHT;
44}
45
46/**
47~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48This function is used to configure the PhySical Layer parameters of device.
49Configure the Preamble and PLCP header length.
50Configure Control and broadcast frame data rate.
51Calculate DIFS, EIFS and RIFS values.
52Assign CS Threshold Value.
53~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
54*/
56{
57 PIEEE802_11_PHY_VAR pstruPhyVar=IEEE802_11_PHY(nDeviceId,nInterfaceId);
58
59 //Turn on the radio
60 pstruPhyVar->radio.radioState = RX_ON_IDLE;
61
62 switch(pstruPhyVar->PhyType)
63 {
64 case OFDM: //Table 18-17—OFDM PHY characteristics page 1623
65 switch((int)pstruPhyVar->dChannelBandwidth)
66 {
67 case 20:
68 pstruPhyVar->plmeCharacteristics.aPLCPHeaderLength = 4 ; //MicroSecs
69 pstruPhyVar->plmeCharacteristics.aPreambleLength = 16; //MicroSecs
70 pstruPhyVar->plmeCharacteristics.aCCATime = 4; //MicroSecs
71 pstruPhyVar->plmeCharacteristics.aMACProcessingDelay = 2;//MicroSecs
73 pstruPhyVar->plmeCharacteristics.aMPDUMaxLength = 4095;
74 pstruPhyVar->plmeCharacteristics.aPHY_RX_START_Delay = 25;//MicroSecs
75 pstruPhyVar->plmeCharacteristics.aRxPLCPDelay = 1; //MicroSecs
76 pstruPhyVar->plmeCharacteristics.aRxRFDelay = 1; //MicroSecs
77 pstruPhyVar->plmeCharacteristics.aRxTxSwitchTime = 1; // MicroSecs
78 pstruPhyVar->plmeCharacteristics.aRxTxTurnaroundTime = 2;//MicroSecs
79 pstruPhyVar->plmeCharacteristics.aTxPLCPDelay = 1; //MicroSecs
80 pstruPhyVar->plmeCharacteristics.aTxRampOnTime = 1; //MicroSecs
81 //Assign Control frame and broadcast frame data rate
84 break;
85 case 10:
86 pstruPhyVar->plmeCharacteristics.aPLCPHeaderLength = 8 ; //MicroSecs
87 pstruPhyVar->plmeCharacteristics.aPreambleLength = 32; //MicroSecs
88 pstruPhyVar->plmeCharacteristics.aCCATime = 8; //MicroSecs
89 pstruPhyVar->plmeCharacteristics.aMACProcessingDelay = 2;//MicroSecs
91 pstruPhyVar->plmeCharacteristics.aMPDUMaxLength = 4095;
92 pstruPhyVar->plmeCharacteristics.aPHY_RX_START_Delay = 49;//MicroSecs
93 pstruPhyVar->plmeCharacteristics.aRxPLCPDelay = 1; //MicroSecs
94 pstruPhyVar->plmeCharacteristics.aRxRFDelay = 1; //MicroSecs
95 pstruPhyVar->plmeCharacteristics.aRxTxSwitchTime = 1; // MicroSecs
96 pstruPhyVar->plmeCharacteristics.aRxTxTurnaroundTime = 2;//MicroSecs
97 pstruPhyVar->plmeCharacteristics.aTxPLCPDelay = 1; //MicroSecs
98 pstruPhyVar->plmeCharacteristics.aTxRampOnTime = 1; //MicroSecs
99 //Assign Control frame and broadcast frame data rate
102 break;
103 case 5:
104 pstruPhyVar->plmeCharacteristics.aPLCPHeaderLength = 16; //MicroSecs
105 pstruPhyVar->plmeCharacteristics.aPreambleLength = 64; //MicroSecs
106 pstruPhyVar->plmeCharacteristics.aCCATime = 16; //MicroSecs
107 pstruPhyVar->plmeCharacteristics.aMACProcessingDelay = 2;//MicroSecs
109 pstruPhyVar->plmeCharacteristics.aMPDUMaxLength = 4095;
110 pstruPhyVar->plmeCharacteristics.aPHY_RX_START_Delay = 97;//MicroSecs
111 pstruPhyVar->plmeCharacteristics.aRxPLCPDelay = 1; //MicroSecs
112 pstruPhyVar->plmeCharacteristics.aRxRFDelay = 1; //MicroSecs
113 pstruPhyVar->plmeCharacteristics.aRxTxSwitchTime = 1; // MicroSecs
114 pstruPhyVar->plmeCharacteristics.aRxTxTurnaroundTime = 2;//MicroSecs
115 pstruPhyVar->plmeCharacteristics.aTxPLCPDelay = 1; //MicroSecs
116 pstruPhyVar->plmeCharacteristics.aTxRampOnTime = 1; //MicroSecs
117 //Assign Control frame and broadcast frame data rate
120 break;
121 }
123 break;
124 case HT:
125 fn_NetSim_IEEE802_11n_OFDM_MIMO_init(nDeviceId,nInterfaceId);
127 break;
128 case VHT:
129 fn_NetSim_IEEE802_11ac_OFDM_MIMO_init(nDeviceId,nInterfaceId);
131 break;
132 case DSSS:
133 default:
134 pstruPhyVar->plmeCharacteristics.aPLCPHeaderLength = 48; //MicroSecs
135 pstruPhyVar->plmeCharacteristics.aPreambleLength = 144; //MicroSecs
136 pstruPhyVar->plmeCharacteristics.aCCATime = 15; //MicroSecs
137 pstruPhyVar->plmeCharacteristics.aMACProcessingDelay = 2;//MicroSecs
139 pstruPhyVar->plmeCharacteristics.aMPDUMaxLength = 8192;
140 pstruPhyVar->plmeCharacteristics.aPHY_RX_START_Delay = 192;//MicroSecs
141 pstruPhyVar->plmeCharacteristics.aRxPLCPDelay = 1; //MicroSecs
142 pstruPhyVar->plmeCharacteristics.aRxRFDelay = 1; //MicroSecs
143 pstruPhyVar->plmeCharacteristics.aRxTxSwitchTime = 4; // MicroSecs
144 pstruPhyVar->plmeCharacteristics.aRxTxTurnaroundTime = 5;//MicroSecs
145 pstruPhyVar->plmeCharacteristics.aTxPLCPDelay = 1; //MicroSecs
146 pstruPhyVar->plmeCharacteristics.aTxRampOnTime = 1; //MicroSecs
150 break;
151 }
152
153 pstruPhyVar->SIFS = pstruPhyVar->plmeCharacteristics.aSIFSTime;
154 pstruPhyVar->DIFS = pstruPhyVar->plmeCharacteristics.aSIFSTime + (2 * pstruPhyVar->plmeCharacteristics.aSlotTime);
155 pstruPhyVar->EIFS = pstruPhyVar->plmeCharacteristics.aSIFSTime + pstruPhyVar->DIFS + (int) (ACK_SIZE * 8.0 / pstruPhyVar->dControlFrameDataRate) + 1;
156 pstruPhyVar->PIFS = pstruPhyVar->plmeCharacteristics.aSIFSTime + pstruPhyVar->plmeCharacteristics.aSlotTime;
157 return 0;
158}
159
161{
163 return medium_isIdle(d, mac->parentInterfaceId);
164}
165
167{
168 double dPreambleTime = 0;
169 switch(phy->PhyProtocol)
170 {
171 case IEEE_802_11b:
172 case IEEE_802_11a:
173 case IEEE_802_11g:
174 case IEEE_802_11p:
176 break;
177 case IEEE_802_11n:
178 dPreambleTime = get_11n_preamble_time(phy);
179 break;
180 case IEEE_802_11ac:
181 dPreambleTime = get_11ac_preamble_time(phy);
182 break;
183 default:
184 fnNetSimError("Unknown phy protocol %d in %s.",phy->PhyProtocol,__FUNCTION__);
185 }
186 return dPreambleTime;
187}
188
190{
193
196 double time = pstruEventDetails->dEventTime;
197 double dTransmissionTime;
198 double dPropagationDelay;
199 double dPreambleTime;
200 int flag=0;
201 NetSim_PACKET* last=NULL;
202 bool transmitflag;
203 UINT64 transmissionId = 0;
204 while(packet)
205 {
206 NETSIM_ID destId = packet->nReceiverId;
207 NETSIM_ID destif = fn_NetSim_Stack_GetConnectedInterface(srcid, srcif, destId);
208
209 last = packet;
210
212 packet->pstruPhyData->dStartTime=time;
213 packet->pstruPhyData->dEndTime=time;
214
216 packet->pstruPhyData->dOverhead=0;
218 packet->pstruPhyData->dOverhead;
219
221 destId, destif,
222 packet, packet->pstruPhyData->dArrivalTime);
223
224 fn_NetSim_IEEE802_11_Add_Phy_Header(packet, &transmissionId);
225
227
228 if(!flag)
229 dPreambleTime = get_preamble_time(phy);
230 else
231 dPreambleTime = 0;
232
236 dPropagationDelay = 0.01;
237
238 time+=dTransmissionTime+dPreambleTime;
239 packet->pstruPhyData->dStartTime=time;
240 packet->pstruPhyData->dEndTime=packet->pstruPhyData->dStartTime+dPropagationDelay;
241
244 {
248 }
249 packet = packet->pstruNextPacket;
250 flag=1;
251 }
252
253 if (!validate_processing_time(time,
256 return -1;
257 packet = pstruEventDetails->pPacket;
258 if (packet == NULL) { return -2; }
259 // Transmit the packet
260 if(packet->nReceiverId)
261 {
262 transmitflag = fn_NetSim_IEEE802_11_TransmitFrame(packet,srcid,srcif);
263 if(!isIEEE802_11_CtrlPacket(packet) &&
264 !isMulticastPacket(packet) &&
265 !isBroadcastPacket(packet))
267 else if(packet->nControlDataType == WLAN_RTS)
269
270 if(!transmitflag) //Packet is not transmitted
272 }
273 else
274 {
275 transmitflag = fn_NetSim_IEEE802_11_TransmitBroadcastFrame(packet,srcid,srcif);
276
277 if (!transmitflag)
278 {
279 NETSIM_ID srcSendIf = get_send_interface_id(packet);
280 PIEEE802_11_MAC_VAR srcMac = IEEE802_11_MAC(packet->nTransmitterId, srcSendIf);
282 }
284 }
285 return 0;
286}
287
289{
293 PIEEE802_11_MAC_VAR srcMac;
294 PIEEE802_11_PHY_VAR srcPhy;
295 PACKET_STATUS status;
296 NETSIM_ID ifid;
297 bool morefrag;
298
299 morefrag = is_more_fragment_coming(packet);
300
301 //Wireshark
304 {
308 }
309
312 packet->nTransmitterId);
313
314 NETSIM_ID srcSendIf = get_send_interface_id(packet);
315 srcPhy = IEEE802_11_PHY(packet->nTransmitterId, ifid);
316 srcMac = IEEE802_11_MAC(packet->nTransmitterId, srcSendIf);
317 if (morefrag)
318 {
319 if (is_first_packet(packet))
320 {
321 }
322 }
323 else
324 {
325 if (set_radio_state(packet->nTransmitterId, ifid,
327 hdr->transmissionId))
329
330
331 }
333
334 double pdbm = GET_RX_POWER_dbm(packet->nTransmitterId,
335 ifid,
338 packet->pstruPhyData->dArrivalTime);
339 if (pdbm < srcPhy->dCurrentRxSensitivity_dbm)
340 {
342 RX_ON_IDLE, packet->nTransmitterId,
343 hdr->transmissionId);
344 return -1; // dest is not in range
345 }
346
347
348
349 if (isIEEE802_11_CtrlPacket(packet) || !morefrag)
351 RX_ON_IDLE, packet->nTransmitterId,
352 hdr->transmissionId);
353
354
359
361 {
362 if(!isIEEE802_11_CtrlPacket(packet) && is_first_packet(packet))
364
366 fn_NetSim_Metrics_Add(packet);
368 goto RET_PHYIN;
369 }
370
371 status = packet->nPacketStatus;
372 if(status == PacketStatus_Error)
373 {
374 if(!isIEEE802_11_CtrlPacket(packet) && is_first_packet(packet))
376
377 // call function to write packet trace and calculate metrics
381 fn_NetSim_Metrics_Add(packet);
383 goto RET_PHYIN;
384 }
385 else //Packet is not error. Continue
386 {
387 // call function to write packet trace and calculate metrics
391 fn_NetSim_Metrics_Add(packet);
392 }
393
395 packet->pstruPhyData->dStartTime =packet->pstruPhyData->dEndTime;
397 packet->pstruPhyData->dPacketSize = packet->pstruPhyData->dPayload;
398 packet->pstruPhyData->dOverhead = 0;
399 packet->pstruPhyData->dEndTime =packet->pstruPhyData->dEndTime;
400 // Add MAC IN event
401 switch(packet->nControlDataType)
402 {
403 case WLAN_ACK:
404 pstruEventDetails->nSubEventType = RECEIVE_ACK;
405 break;
406 case WLAN_BlockACK:
407 pstruEventDetails->nSubEventType = RECEIVE_BLOCK_ACK;
408 break;
409 case WLAN_RTS:
410 pstruEventDetails->nSubEventType = RECEIVE_RTS;
411 break;
412 case WLAN_CTS:
413 pstruEventDetails->nSubEventType = RECEIVE_CTS;
414 break;
415 default:
416 pstruEventDetails->nSubEventType = RECEIVE_MPDU;
417 break;
418 }
419
421 if (machdr->recvInterfaceId)
423
425 pstruEventDetails->pPacket = packet;
427RET_PHYIN:
428 if (!morefrag)
429 {
431 }
432 return 0;
433}
434
436{
437 PIEEE802_11_PHY_VAR pstruPhy = IEEE802_11_PHY(d, in);
438
439 switch (pstruPhy->PhyProtocol)
440 {
441 case IEEE_802_11b:
444 break;
445 case IEEE_802_11a:
446 case IEEE_802_11g:
447 case IEEE_802_11p:
450 break;
451 case IEEE_802_11n:
452 case IEEE_802_11ac:
455 break;
456 default:
457 fnNetSimError("IEEE802.11--- Unknown phy protocol type %d in %s\n", pstruPhy->PhyProtocol, __FUNCTION__);
458 break;
459 }
460}
461
462/**
463Calculate and return Transmission time for one packet.
464*/
466{
467 double dTxTime = 0.0;
468 PIEEE802_11_PHY_VAR pstruPhy = IEEE802_11_PHY(nDevId,nInterfaceId);
469
470 switch (pstruPhy->PhyProtocol)
471 {
472 case IEEE_802_11b:
473 return ceil(size *(8 / pstruPhy->PHY_TYPE.dsssPhy.dDataRate));
474 break;
475 case IEEE_802_11a:
476 case IEEE_802_11g:
477 case IEEE_802_11p:
478 return ceil(size *(8 / pstruPhy->PHY_TYPE.ofdmPhy.dDataRate));
479 case IEEE_802_11n:
480 case IEEE_802_11ac:
481 return (ceil(size * (8 * 1000.0 / pstruPhy->PHY_TYPE.ofdmPhy_11n.dDataRate))) / 1000.0;
482 default:
483 fnNetSimError("IEEE802.11--- Unknown phy protocol type %d in Calculate Transmission Time\n", pstruPhy->PhyProtocol);
484 break;
485 }
486 return dTxTime;
487}
488
489
490bool CheckFrequencyInterfrence(double dFrequency1,double dFrequency2,double bandwidth)
491{
492 if(dFrequency1 > dFrequency2)
493 {
494 if( (dFrequency1 - dFrequency2) >= bandwidth )
495 return false; // no interference
496 else
497 return true; // interference
498 }
499 else
500 {
501 if( (dFrequency2 - dFrequency1) >= bandwidth )
502 return false; // no interference
503 else
504 return true; // interference
505 }
506}
507
508/**
509Transmit the packet in the Medium, i.e from Physical out to Physical In.
510While transmitting check whether the Receiver radio state is CHANNEL_IDLE and also
511is the receiver is reachable, that is not an out off reach. If both condition
512satisfied then add the PHY IN EVENT, else drop the frame.
513*/
515{
516 PIEEE802_11_PHY_VAR srcPhy=IEEE802_11_PHY(nDevId,nInterfaceId);
517 PIEEE802_11_PHY_VAR destPhy;
518
519 NetSim_PACKET *pstruPacketList=pstruPacket;
521 NetSim_EVENTDETAILS pevent;
522 NETSIM_ID destId=pstruPacket->nReceiverId;
523 NETSIM_ID destif=fn_NetSim_Stack_GetConnectedInterface(nDevId,nInterfaceId,destId);
524
525 destPhy=IEEE802_11_PHY(destId,destif);
526 if (destPhy == NULL)
527 {
528 fnNetSimError("No dest phy layer is found for device %d:%d in function %s",
529 destId, destif, __FUNCTION__);
530 return false;
531 }
532
533 //Update the transmitter and receiver
534 while(pstruPacketList)
535 {
536 pstruPacketList->nReceiverId = destId;
537 pstruPacketList->nTransmitterId = nDevId;
538 pstruPacketList=pstruPacketList->pstruNextPacket;
539 }
540
541 if (!set_radio_state(nDevId, nInterfaceId, TRX_ON_BUSY, destId, hdr->transmissionId))
542 return false; // src is off
543
544 // Change the Receiver state
545 if (set_radio_state(destId, destif, RX_ON_BUSY, nDevId, hdr->transmissionId))
546 {
547 fn_NetSim_IEEE802_11_CSMA_UpdateNAV(destId, destif, pstruPacket);
548 }
549
551 pstruPacketList=pstruPacket;
552 while(pstruPacketList)
553 {
554 pstruPacket=pstruPacketList;
555 pstruPacketList = pstruPacketList->pstruNextPacket;
556 pstruPacket->pstruNextPacket=NULL;
557
558 memcpy(&pevent,pstruEventDetails,sizeof* pstruEventDetails);
559 pevent.dEventTime = pstruPacket->pstruPhyData->dEndTime;
560 pevent.dPacketSize = pstruPacket->pstruPhyData->dPacketSize;
561 if(pstruPacket->pstruAppData)
562 {
563 pevent.nApplicationId = pstruPacket->pstruAppData->nApplicationId;
564 pevent.nSegmentId = pstruPacket->pstruAppData->nSegmentId;
565 }
566 else
567 {
568 pevent.nApplicationId = 0;
569 pevent.nSegmentId = 0;
570 }
571 pevent.nDeviceId = destId;
572 pevent.nDeviceType = DEVICE_TYPE(destId);
574 pevent.nInterfaceId = destif;
575 pevent.nPacketId = pstruPacket->nPacketId;
577 pevent.pPacket=pstruPacket;
578 pevent.nSubEventType = 0;
579 fnpAddEvent(&pevent);
580
581 wlanphy_update_medium_param(nDevId, nInterfaceId);
582 medium_notify_packet_send(pstruPacket,
583 nDevId,
584 nInterfaceId,
585 destId,
586 destif);
587 }
588 return true;
589}
590
592{
593 bool isTransmitted = false;
594 NetSim_LINKS* link;
595 NETSIM_ID i;
596 link=DEVICE_PHYLAYER(nDevId,nInterfaceId)->pstruNetSimLinks;
597 switch(link->nLinkType)
598 {
599 case LinkType_P2MP:
600 {
601 if(link->puniDevList.pstrup2MP.nCenterDeviceId !=nDevId)
602 {
603 bool transmitflag;
606 transmitflag = fn_NetSim_IEEE802_11_TransmitFrame(packet,nDevId,nInterfaceId);
607 if (!transmitflag)
609 else
610 isTransmitted = true;
611 }
612 else
613 {
614 for(i=0;i<link->puniDevList.pstrup2MP.nConnectedDeviceCount-1;i++)
615 {
616 bool transmitflag;
618 packet->nReceiverId=link->puniDevList.pstrup2MP.anDevIds[i];
619 transmitflag = fn_NetSim_IEEE802_11_TransmitFrame(packet,nDevId,nInterfaceId);
620 if(!transmitflag)
622 else
623 isTransmitted = true;
624 }
625 }
626 }
627 break;
628 case LinkType_MP2MP:
629 for(i=0;i<link->puniDevList.pstruMP2MP.nConnectedDeviceCount;i++)
630 {
631 if(link->puniDevList.pstruMP2MP.anDevIds[i]!=nDevId)
632 {
633 bool transmitflag;
636 transmitflag = fn_NetSim_IEEE802_11_TransmitFrame(packet,nDevId,nInterfaceId);
637 if(!transmitflag)
639 else
640 isTransmitted = true;
641 }
642 }
643 break;
644 case LinkType_P2P:
645 {
646 bool transmitflag;
648 if(link->puniDevList.pstruP2P.nFirstDeviceId!=nDevId)
650 else if(link->puniDevList.pstruP2P.nSecondDeviceId!=nDevId)
652 transmitflag = fn_NetSim_IEEE802_11_TransmitFrame(packet,nDevId,nInterfaceId);
653 if(!transmitflag)
655 else
656 isTransmitted = true;
657 }
658 break;
659 default:
660 fnNetSimError("Unknown link type in %s",__FUNCTION__);
661 break;
662 }
663 return isTransmitted;
664}
665
666/**
667This function used to compute the data rate with respect to the total received power
668set the received power value using received power range table for modulation(dbm)
669*/
671 NETSIM_ID rxId, NETSIM_ID rxIf,
672 NetSim_PACKET* packet, double time)
673{
674 rxIf;
675 PIEEE802_11_PHY_VAR phy = IEEE802_11_PHY(txId, txIf);
676
677 switch (phy->PhyProtocol)
678 {
679 case IEEE_802_11b:
680 fn_NetSim_IEEE802_11_DSSSPhy_DataRate(txId, txIf, rxId, packet, time);
681 break;
682 case IEEE_802_11a:
683 case IEEE_802_11g:
684 case IEEE_802_11p:
685 fn_NetSim_IEEE802_11_OFDMPhy_DataRate(txId, txIf, rxId, packet, time);
686 break;
687 case IEEE_802_11n:
688 case IEEE_802_11ac:
689 fn_NetSim_IEEE802_11_HTPhy_DataRate(txId, txIf, rxId, packet, time);
690 break;
691 default:
692 fnNetSimError("IEEE802.11--- Unknown protocol %d in %s\n", phy->PhyProtocol, __FUNCTION__);
693 break;
694 }
695 return 0;
696}
697
699{
700 PIEEE802_11_PHY_VAR phy = IEEE802_11_PHY(txId, txIf);
701 double dInterferenceThreshold = 0.0;
702 switch (phy->PhyProtocol)
703 {
704 case IEEE_802_11b:
705 dInterferenceThreshold = DSSSPhy_get_min_rxSensitivity();
706 break;
707 case IEEE_802_11a:
708 case IEEE_802_11g:
709 case IEEE_802_11p:
710 dInterferenceThreshold = ofdmphy_get_min_rxSensitivity(phy->dChannelBandwidth);
711 break;
712 case IEEE_802_11n:
713 case IEEE_802_11ac:
714 dInterferenceThreshold = HTPhy_get_min_rxSensitivity(phy->dChannelBandwidth, phy->NSS);
715 break;
716 default:
717 fnNetSimError("IEEE802.11--- Unknown protocol %d in %s\n", phy->PhyProtocol, __FUNCTION__);
718 break;
719 }
720 return dInterferenceThreshold;
721}
unsigned int NETSIM_ID
Definition: Animation.h:45
HT
Definition: CLI.h:31
void fn_NetSim_IEEE802_11_CSMA_UpdateNAV(NETSIM_ID d, NETSIM_ID in, NetSim_PACKET *packet)
Definition: CSMACA.c:721
void fn_NetSim_IEEE802_11_CSMACA_AddAckTimeOut(NetSim_PACKET *packet, NETSIM_ID devId, NETSIM_ID devIf)
Definition: CSMACA.c:546
bool isMediumIdle()
Definition: CSMACD_Phy.c:17
#define GET_RX_POWER_dbm(tx, rx, time)
PIEEE802_11_MAC_VAR IEEE802_11_MAC(NETSIM_ID ndeviceId, NETSIM_ID nInterfaceId)
PIEEE802_11_PHY_VAR IEEE802_11_PHY(NETSIM_ID ndeviceId, NETSIM_ID nInterfaceId)
bool validate_processing_time(double time, NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId)
void fn_NetSim_IEEE802_11_OFDMPhy_SetEDThreshold(PIEEE802_11_PHY_VAR phy)
int fn_NetSim_IEEE802_11_OFDMPhy_DataRate(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId, NETSIM_ID nReceiverId, NetSim_PACKET *packet, double time)
bool is_more_fragment_coming(NetSim_PACKET *packet)
bool is_first_packet(NetSim_PACKET *packet)
#define CONTRL_FRAME_RATE_11A_AND_G
Control frame data rate for IEEE 802.11a/g in Mbps.
Definition: IEEE802_11.h:50
@ IEEE_802_11ac
Definition: IEEE802_11.h:72
@ IEEE_802_11b
Definition: IEEE802_11.h:67
@ IEEE_802_11n
Definition: IEEE802_11.h:70
@ IEEE_802_11g
Definition: IEEE802_11.h:68
@ IEEE_802_11p
Definition: IEEE802_11.h:69
@ IEEE_802_11a
Definition: IEEE802_11.h:66
#define CONTRL_FRAME_RATE_11P
Control frame data rate for IEEE 802.11p in Mbps.
Definition: IEEE802_11.h:51
void fn_NetSim_IEEE802_11_RTS_CTS_AddCTSTimeOut(NetSim_PACKET *packet, NETSIM_ID devId, NETSIM_ID devIf)
Definition: RTS_CTS.c:153
NETSIM_ID get_send_interface_id(NetSim_PACKET *packet)
bool isIEEE802_11_CtrlPacket(NetSim_PACKET *packet)
#define CONTRL_FRAME_RATE_11B
Control frame data rate for IEEE 802.11b in Mbps.
Definition: IEEE802_11.h:49
int fn_NetSim_IEEE802_11_DSSSPhy_DataRate(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId, NETSIM_ID nReceiverId, NetSim_PACKET *packet, double time)
void fn_NetSim_IEEE802_11_DSSPhy_SetEDThreshold(PIEEE802_11_PHY_VAR phy)
void fn_NetSim_IEEE802_11_HTPhy_SetEDThreshold(PIEEE802_11_PHY_VAR phy)
int fn_NetSim_IEEE802_11_HTPhy_DataRate(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId, NETSIM_ID nReceiverId, NetSim_PACKET *packet, double time)
#define ACK_SIZE
10 bytes header 4 bytes FCS
@ WLAN_RTS
@ WLAN_BlockACK
@ WLAN_CTS
@ WLAN_ACK
void set_mac_state_after_txend(PIEEE802_11_MAC_VAR mac)
double DSSSPhy_get_min_rxSensitivity()
static double calculate_propagation_delay(NetSim_PACKET *packet)
int fn_NetSim_IEEE802_11_SetDataRate(NETSIM_ID txId, NETSIM_ID txIf, NETSIM_ID rxId, NETSIM_ID rxIf, NetSim_PACKET *packet, double time)
bool fn_NetSim_IEEE802_11_TransmitBroadcastFrame(NetSim_PACKET *pstruPacket, NETSIM_ID nDevId, NETSIM_ID nInterfaceId)
double fn_NetSim_IEEE802_11_CalculateTransmissionTime(double size, NETSIM_ID nDevId, NETSIM_ID nInterfaceId)
int fn_NetSim_IEEE802_11_PhyOut()
#define SPEED_OF_LIGHT
double HTPhy_get_min_rxSensitivity(double bandwidth, UINT NSS)
double ofdmphy_get_min_rxSensitivity(double bandwidth)
int fn_NetSim_IEEE802_11_PHY_Init(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId)
bool fn_NetSim_IEEE802_11_TransmitFrame(NetSim_PACKET *pstruPacket, NETSIM_ID nDevId, NETSIM_ID nInterfaceId)
static void wlanphy_update_medium_param(NETSIM_ID d, NETSIM_ID in)
double fn_NetSim_IEEE802_11_GetMinRxSensitivity(NETSIM_ID txId, NETSIM_ID txIf)
int fn_NetSim_IEEE802_11_PhyIn()
double get_preamble_time(PIEEE802_11_PHY_VAR phy)
bool CheckFrequencyInterfrence(double dFrequency1, double dFrequency2, double bandwidth)
@ OFDM
@ VHT
@ DSSS
double get_11ac_preamble_time(PIEEE802_11_PHY_VAR phy)
Definition: IEEE802_11ac.c:180
bool set_radio_state(NETSIM_ID d, NETSIM_ID in, PHY_TX_STATUS state, NETSIM_ID peerId, UINT64 transmissionId)
#define IEEE802_11_CURR_PHY
void fn_NetSim_IEEE802_11n_OFDM_MIMO_init(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId)
Definition: IEEE802_11n.c:35
void fn_NetSim_IEEE802_11_Add_Phy_Header(NetSim_PACKET *packet, UINT64 *transmissionId)
double get_11n_preamble_time(PIEEE802_11_PHY_VAR phy)
Definition: IEEE802_11n.c:113
void fn_NetSim_IEEE802_11ac_OFDM_MIMO_init(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId)
Definition: IEEE802_11ac.c:25
#define UINT64
Definition: Linux.h:37
#define UINT
Definition: Linux.h:38
#define fnNetSimError(x,...)
Definition: Linux.h:56
bool medium_isIdle(NETSIM_ID d, NETSIM_ID in)
Definition: Medium.c:560
void medium_notify_packet_received(NetSim_PACKET *packet)
Definition: Medium.c:551
void medium_update_datarate(NETSIM_ID d, NETSIM_ID in, double r_mbps)
Definition: Medium.c:229
void medium_update_modulation(NETSIM_ID d, NETSIM_ID in, PHY_MODULATION m, double coderate)
Definition: Medium.c:216
void medium_notify_packet_send(NetSim_PACKET *packet, NETSIM_ID txId, NETSIM_ID txIf, NETSIM_ID rxId, NETSIM_ID rxIf)
Definition: Medium.c:538
NETSIM_UTILITY_EXPORT WIRESHARKTRACE wireshark_trace
#define PACKET_PHYPROTOCOLDATA(pPacket)
Definition: Packet.h:299
bool isMulticastPacket(NetSim_PACKET *packet)
bool isBroadcastPacket(NetSim_PACKET *packet)
@ PacketStatus_Error
Definition: Packet.h:102
@ PacketStatus_NoError
Definition: Packet.h:101
@ PacketStatus_Collided
Definition: Packet.h:103
#define DEVICE_MACLAYER(DeviceId, InterfaceId)
Definition: Stack.h:786
#define DEVICE_TYPE(DeviceId)
Definition: Stack.h:773
@ PHY_MEDIUM_WIRELESS
Definition: Stack.h:242
@ MAC_PROTOCOL_IEEE802_11
Definition: Stack.h:208
@ MAC_IN_EVENT
Definition: Stack.h:107
@ PHYSICAL_IN_EVENT
Definition: Stack.h:105
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
Definition: Stack.h:837
NETSIM_ID fn_NetSim_Stack_GetConnectedInterface(NETSIM_ID devId, NETSIM_ID ifid, NETSIM_ID conId)
#define DEVICE_PHYLAYER(DeviceId, InterfaceId)
Definition: Stack.h:788
@ LinkType_P2P
Definition: Stack.h:315
@ LinkType_P2MP
Definition: Stack.h:316
@ LinkType_MP2MP
Definition: Stack.h:317
#define DEVICE_POSITION(DeviceId)
Definition: Stack.h:790
#define fn_NetSim_Metrics_Add(packet)
Definition: Stack.h:998
double fn_NetSim_Utilities_CalculateDistance(NetSim_COORDINATES *coordinate1, NetSim_COORDINATES *coordinates2)
@ RX_ON_BUSY
Definition: Wireless.h:76
@ TRX_ON_BUSY
Definition: Wireless.h:77
@ RX_ON_IDLE
Definition: Wireless.h:75
#define fn_NetSim_Packet_FreePacket(pstruPacket)
Definition: main.h:177
enum enum_PacketStatus PACKET_STATUS
Definition: main.h:128
#define fn_NetSim_WritePacketTrace(pstruPacket)
Definition: main.h:188
#define fnpAddEvent(pstruEvent)
Definition: main.h:191
#define fn_NetSim_Packet_CopyPacketList(pstruPacket)
Definition: main.h:184
NETSIM_ID parentInterfaceId
Definition: IEEE802_11.h:223
double dCurrentRxSensitivity_dbm
IEEE802_11_PHY_TYPE PhyType
IEEE802_11_OFDM_MIMO ofdmPhy_11n
IEEE802_11_RADIO radio
union stru_802_11_Phy_Var::@4 PHY_TYPE
IEEE802_11_DSSS_PHY dsssPhy
PACKET_STATUS firstpacketstatus
IEEE802_11_PROTOCOL PhyProtocol
IEEE802_11_OFDM_PHY ofdmPhy
PLME_CHARACTERISTICS plmeCharacteristics
PHY_TX_STATUS radioState
PHY_MODULATION modulation
PHY_MODULATION modulation
NETSIM_ID nApplicationId
Definition: Stack.h:752
EVENT_TYPE nEventType
Definition: Stack.h:747
NETSIM_ID nProtocolId
Definition: Stack.h:748
struct stru_NetSim_Packet * pPacket
Definition: Stack.h:754
NETSIM_ID nSubEventType
Definition: Stack.h:757
NETSIM_ID nDeviceId
Definition: Stack.h:750
long long int nPacketId
Definition: Stack.h:755
netsimDEVICE_TYPE nDeviceType
Definition: Stack.h:749
NETSIM_ID nInterfaceId
Definition: Stack.h:751
PACKET_STATUS nPacketErrorFlag
Definition: Packet.h:236
PHYSICAL_LAYER_MEDIUM nPhyMedium
Definition: Packet.h:237
long long int nPacketId
Definition: Packet.h:256
struct stru_NetSim_Packet_AppLayer * pstruAppData
Definition: Packet.h:273
PACKET_STATUS nPacketStatus
Definition: Packet.h:272
struct stru_NetSim_Packet_PhyLayer * pstruPhyData
Definition: Packet.h:277
NETSIM_ID nReceiverId
Definition: Packet.h:266
unsigned int nControlDataType
Definition: Packet.h:258
struct stru_NetSim_Packet * pstruNextPacket
Definition: Packet.h:278
NETSIM_ID nTransmitterId
Definition: Packet.h:265
struct stru_NetSim_Packet_MACLayer * pstruMacData
Definition: Packet.h:276
PPCAP_WRITER ** pcapWriterlist
void(* convert_sim_to_real_packet)(void *netsim_packet, void *pcap_handle, double dTime)