14#ifndef _NETSIM_802_22_H_
15#define _NETSIM_802_22_H_
17#pragma comment(lib,"CognitiveRadio.lib")
18#pragma comment(lib,"Metrics.lib")
19#pragma comment(lib,"NetworkStack.lib")
20#pragma comment(lib,"PropagationModel.lib")
22#include "ErrorModel.h"
23#define CHANNEL_LOSS -1.7
59#define B16_1111111111111111 65535
64#define UPSTREAM_GRANT_MANAGEMENT_BIT 0
65#define FRAGMANET_BIT 1
67#define ARQ_FEEDBACK_BIT 3
68#define BW_REQUEST_BIT 4
71static unsigned long ulIncumbentSeed1 = 12345678;
72static unsigned long ulIncumbentSeed2 = 23456789;
112typedef enum enum_802_22_MAC_Management_Message MANAGEMENT_MESSAGE;
113typedef enum enum_802_22_Modulation MODULATION_TECHNIQUE;
114typedef enum enum_802_22_CodingRate CODING_RATE;
115typedef enum enum_802_22_ChannelState CHANNEL_STATE;
116typedef enum enum_802_22_IncumbentStatus INCUMBENT_STATUS;
117typedef enum enum_802_22_SubEvent SUBEVENT;
123# define FRAGMENT_SIZE 3
124# define MAX_SDU_SIZE 255
125#define SCH_DURATION 160000
126#define SCH_PHY_MODE 2
127#define FCH_PHY_MODE 4
128#define MAX_PHY_MODE 17
130#define MULTIPLEACCESS_OFDMA 1
132unsigned int g_FragmentId;
135enum enum_802_22_ChannelState
137 ChannelState_DISALLOWED,
138 ChannelState_OPERATING,
140 ChannelState_CANDIDATE,
141 ChannelState_PROTECTED,
142 ChannelState_UNCLASSIFIED,
145enum enum_802_22_SubEvent
147 INCUMBENT_OPERATION_START=MAC_PROTOCOL_IEEE802_22*100+1,
148 INCUMBENT_OPERATION_END,
156 TRANSMIT_US_BURST_CONTROL,
170enum enum_802_22_MAC_Management_Message
233 MMM_UCS_NOTIFICATION,
235#define CR_CONTROL_PACKET(MMM) MAC_PROTOCOL_IEEE802_22*100+MMM
238enum enum_802_22_CodingRate
252enum enum_802_22_IncumbentStatus
254 IncumbentStatus_NONOPERATIONAL,
255 IncumbentStatus_OPERATIOAL,
610 unsigned int purpos:1;
613 unsigned int length:11;
614 unsigned int nFragmentId;
620 unsigned int nSlotRequested;
621 unsigned int nSlotAllocated;
629 unsigned int nSCHSent;
630 unsigned int nFCHSent;
631 unsigned int nDSA_REQReceived;
632 unsigned int nDSA_REPSent;
633 unsigned int nDSD_REQReceived;
634 unsigned int nDSC_REQReceived;
635 unsigned int nDSC_REPSent;
636 unsigned int nDSD_REPSent;
637 unsigned int nCHS_REQSent;
642 unsigned int nOperationTime;
643 unsigned int nIdleTime;
644 unsigned int nInterferenceTime;
645 unsigned int nPrevTime;
646 double dInterferenceStartTime;
651 unsigned int nChannelNumber;
660 unsigned int nSCHReceived;
661 unsigned int nFCHReceived;
662 unsigned int nDSA_REQSent;
663 unsigned int nDSC_REQSent;
664 unsigned int nDSD_REQSent;
665 unsigned int nDSA_REPReceived;
666 unsigned int nDSC_REPReceived;
667 unsigned int nDSD_REPReceived;
668 unsigned int nCHS_REQReceived;
669 unsigned int nUCSSent;
676 bool nSelfCoexitenceFlag;
796 NETSIM_ID nIncumbentCount;
797 INCUMBENT** pstruIncumbent;
805 double dSuperframeStartTime;
807 double dFrameStartTime;
811 NetSim_PACKET* pstruFragmentPacketList;
812 NetSim_PACKET* pstruBroadcastPDU;
815 BS_METRICS struBSMetrics;
816 NetSim_PACKET* pstruDSPacketList;
820 unsigned int nSlotCount;
821 unsigned int nUnfilledSlot;
822 NetSim_PACKET* pstruMACPDU;
831 unsigned int nMINFrequency;
833 double dSamplingFactor;
834 PHY_MODULATION nModulation;
835 CODING_RATE nCodingRate;
843 double dAntennaHeight;
845 int nSelfCoexitenceCapability;
850 double dUpstreamChannelChangeResponseWaitTime;
854 SYMBOL_PARAMETER* pstruSymbolParameter;
855 unsigned int nIntraFrameQuietPeriodCycleLength;
856 char szIntraframeQuietPeiordBitmap[17];
857 unsigned int nIntraFrameQuietPeriodDuration;
858 unsigned int nIFQPOffset;
862 USMAP_IE* pstruUSMAPIE;
863 double dBytesRequested;
864 double dBytesAllocated;
871 NETSIM_ID nBSInterface;
891 NetSim_PACKET* pstruQueuedPacketList[MAX_FID];
892 CR_SERVICE* pstruServiceParameter;
893 NetSim_PACKET* pstruUSBurst;
894 NetSim_PACKET* pstruFragmentPacketList;
895 char szCountryCode[4];
896 unsigned int nMaxProbabilityofFalseAlarm;
897 CPE_METRICS struCPEMetrics;
911 unsigned int nIntraFrameQuietPeriodLength;
912 char szIntraFrameQuietPeriodBitmap[17];
913 unsigned int nIntraFrameQuietPeriodDuration;
914 unsigned int nFrameNumber;
916 double dAntennaHeight;
924 unsigned int nChannelNumber;
925 double dUpperFrequency;
926 double dLowerFrequency;
927 double dChannelBandwidth;
928 CHANNEL_STATE nChannelState;
929 CHANNEL_METRICES struChannelMetrics;
936 unsigned int n_PhyMode;
937 MODULATION_TECHNIQUE n_Modulation;
938 CODING_RATE n_CodingRate;
940 double dSpectralEfficency;
952 double dSamplingFactor;
980 int nSubChannelCount;
983 int nBitsCountInOneSlot;
988 unsigned int nUPlinkSymbol;
989 unsigned int nDownLinkSymbol;
990 unsigned int nUPlinkFrameStartSymbol;
1001 int nSymbolsPerFrame;
1013 int nOperationalTime;
1014 int nOperationalIntervalTime;
1015 DISTRIBUTION nOperationalDistribution;
1016 INCUMBENT_STATUS nIncumbentStatus;
1017 double dPrevOperationalTime;
1018 double dPrevOperationalInterval;
1019 double dKeepOutDistance;
1020 NetSim_COORDINATES* position;
1021 INCUMBENT_METRICS struIncumbentMetrics;
1031 unsigned int DIUC:6;
1033 unsigned int length:12;
1034 unsigned int boosting:3;
1041 unsigned int nManagementMessageType:8;
1042 unsigned int nDCDCount:8;
1043 unsigned int nIECount;
1045 unsigned int nPaddingBits:7;
1053 unsigned int nUpstreamBurstProfile;
1054 unsigned int nContentionBasedReservationTimeOut;
1055 unsigned int nBWRequestOpportunitySize;
1056 unsigned int nUCSNotificationRequestOpportunitySize;
1057 unsigned int nInitialRangingCode;
1058 unsigned int nPeriodicRangingCode;
1059 unsigned int nBandwidthRequestCode;
1060 unsigned int nUCSNotificationRequestCode;
1061 unsigned int nStartOfCDMACodeGroups;
1068 unsigned int nManagementMessageType:8;
1069 unsigned int nConfigurationChangeCount:8;
1070 unsigned int nBWRequestBackoffStart:4;
1071 unsigned int nBWRequestBackoffEnd:4;
1072 unsigned int nUCSNotificationBackoffStart:4;
1073 unsigned int nUCSNotificationBackoffEnd:4;
1075 unsigned int nUpstreamBurstProfileCount:6;
1084 unsigned int nRangingDataRatio;
1085 unsigned int nNormalizedCNROverride;
1093 unsigned int nType:8;
1094 unsigned int nLength:8;
1095 unsigned int nUUIC:6;
1096 unsigned int nReserved:2;
1105 unsigned int nDownStreamBurstProfile;
1106 unsigned int EIRP:8;
1109 unsigned int nChannelAction:3;
1110 unsigned int nActionMode:1;
1111 unsigned int nActionSuperframeNumber:8;
1112 unsigned int nActionFrameNumber:4;
1113 unsigned int nBackupChannelCount:4;
1116 unsigned int nElementId:8;
1117 unsigned int nLength:8;
1118 unsigned int nChannelCount:8;
1119 unsigned int* nChannelNumber;
1120 }struBackupChannelList;
1121 unsigned int nMACVersion:8;
1128 unsigned int nManagementMessageType:8;
1129 unsigned int nConfigurationChangeCount:8;
1131 unsigned int nDownStreamBurstProfileCount;
1136 unsigned int nType:8;
1137 unsigned int nLength:8;
1138 unsigned int nDIUC:6;
1139 unsigned int nReserved:2;
1142 unsigned int nDIUCManadatoryExitThershold:8;
1143 unsigned int nDIUCMinimumEntruThershold:8;
1152 MANAGEMENT_MESSAGE nManagementMessageType;
1153 unsigned int nUCDCount:8;
1154 unsigned int nAllocationStartTime:6;
1155 unsigned int nIECount:12;
1163 unsigned int nSID:9;
1164 unsigned int nUIUC:6;
1168 unsigned int nCBPFrameNumber:4;
1171 unsigned int nTimingAdvance:16;
1172 unsigned int nEIRPDensityLevel:8;
1176 unsigned int nChannelNumber:8;
1177 unsigned int nSynchronizationMode:1;
1182 unsigned int nSubChannelCount:4;
1186 unsigned int nSubChannelCount:4;
1187 unsigned int nSubSymbolsCount:4;
1191 void* CDMA_Allocation_IE;
1195 unsigned int nSubChannelCount:4;
1199 void* USMAP_EIRP_Control_IE;
1203 void* US_extended_IE;
1207 unsigned int nBurstType:1;
1208 unsigned int nDuration:12;
1209 unsigned int nMDP:1;
1210 unsigned int nMRT:1;
1211 unsigned int nCMRP:1;
1220 unsigned int nType:1;
1221 unsigned int nBR:20;
1224PROPAGATION_HANDLE propagationHandle;
1226#define GET_RX_POWER_dbm(tx, rx) (propagation_get_received_power_dbm(propagationHandle, tx, 1, rx, 1, pstruEventDetails->dEventTime))
1227#define GET_RX_POWER_mw(tx,rx) (DBM_TO_MW(GET_RX_POWER_dbm(tx,rx)))
1231_declspec(dllexport)
int fn_NetSim_CR_CopyPacket_F(
const NetSim_PACKET* pstruDestPacket,
const NetSim_PACKET* pstruSrcPacket);
1232int fn_NetSim_CR_TransmitP2PPacket(NetSim_PACKET* pstruPacket,NETSIM_ID nDevId,NETSIM_ID nInterface);
1233_declspec(dllexport)
int fn_NetSim_CR_Configure_F(
void** var);
1235 NetSim_EVENTDETAILS *pstruEventDetails_Formal,
char *pszAppPath_Formal,\
1236 char *pszWritePath_Formal,
int nVersion_Type,
void **fnPointer);
1237_declspec(dllexport)
int fn_NetSim_CR_FreePacket_F(
const NetSim_PACKET* pstruPacket);
1238int fn_NetSim_CR_Metrics_F(PMETRICSWRITER metricsWriter);
1239_declspec(dllexport)
int fn_NetSim_CR_Finish_F();
1240int fn_NetSim_CR_PacketArrive();
1241int fn_NetSim_CR_GetFID(QUALITY_OF_SERVICE nQOS);
1242QUALITY_OF_SERVICE fnGetQOS(
char* Qos);
1243int fn_NetSim_CR_AllocBandwidth(NETSIM_ID nSID,QUALITY_OF_SERVICE nQos,UPLINKALLOCINFO** ppstruInfo,
unsigned int nSlotRequired,
unsigned int nTotalSlot);
1244int fn_NetSim_Check_Interference(
unsigned int nChannelNumber,
1246 unsigned int nLowerFrequency,
1247 unsigned int nHigherFrequency);
1248int fn_NetSim_CR_UpdateInfo(BS_MAC* pstruBSMAC,BS_PHY* pstruBSPHY);
1249int fn_NetSim_AddPacketToList(NetSim_PACKET** list,NetSim_PACKET* packet);
1250long long int fn_NetSim_CR_TransmitPacket(NetSim_PACKET* pstruPacket,
int nDevId,
int nInterfaceId,
int nConDevId,
int nConInterface);
1251double fn_NetSim_CR_CalculateTransmissionTime(
double dPacketSize,SYMBOL_PARAMETER* pstruSymbolParameter);
1252_declspec(dllexport)
char* fn_NetSim_CR_Trace_F(
int nSubEvent);
1253int fn_NetSim_CR_InitIncumbent(BS_MAC* pstruBSMAC, NETSIM_ID nDeviceId,NETSIM_ID nInterfaceId);
1254int fn_NetSim_CR_IniScanChannel(BS_MAC* pstruBSMAC,BS_PHY* pstruBSPhy);
1255int fn_NetSim_CR_UpdateOperatingChannel(BS_PHY* pstruBSPhy);
1256int fn_NetSim_CR_StartSCH(
int nBTSId,
int nInterfaceId);
1257int fnIsinRange(
double l1,
double u1,
double l2,
double u2);
1258int fn_NetSim_CR_ConfigIncumbent(
void* xmlNetSimNode,BS_MAC* pstruBSMAC);
1259int fn_NetSim_CR_BroadCastPacket(NetSim_PACKET* pstruPacket,NETSIM_ID nDevId,NETSIM_ID nInterface);
1260int fn_NetSim_CR_MulticastPacket(NetSim_PACKET* pstruPacket, NETSIM_ID nDevId, NETSIM_ID nInterface);
1261NetSim_PACKET* fn_NetSim_CR_GenerateBroadcastCtrlPacket(
int nDeviceId,
int nInterfaceId,MANAGEMENT_MESSAGE nMessageType);
1262int fn_NetSim_CR_FillDSFrame(
unsigned int size,DS_BURST** pstruDSBurst,SYMBOL_PARAMETER* pstruSymbolParameter,
int nFlag,
unsigned int* nSlotRequire);
1263int fn_NetSim_CR_AddPacketToDSBurst(DS_BURST* pstruDSBurst,NetSim_PACKET* pstruPacket);
1264NetSim_PACKET* fn_NetSim_CR_UNFillSlot(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId,
unsigned int nBurstId);
1265int fn_NetSim_CR_UpdateIncumbentMetrics(BS_MAC* pstruBSMAC,BS_PHY* pstruBSPHY,
double dTime);
1268int fn_NetSim_CR_BS_MACIN();
1269int fn_NetSim_CR_CPE_PhysicalOut();
1270_declspec(dllexport)
char* fn_NetSim_CR_Trace(
int nSubEvent);
1271int fn_NetSim_CR_BS_AllocateBandwidth();
1272int fn_NetSim_CR_ScanChannel(BS_MAC* pstruBSMAC,BS_PHY* pstruBSPhy);
1273int fn_NetSim_CR_FormUSBurst();
1274int fn_NetSim_CR_FormChannelSet(BS_PHY* pstruBSPhy);
1275int fn_NetSim_Init_OFDMA(BS_PHY* pstruBSPhy);
1276int fn_NetSim_CR_SSA_Initialization(BS_MAC* pstruBSMAC,BS_PHY* pstruBSPHY);
1277int fn_NetSim_CR_AssociateCPE(NETSIM_ID nDeviceId,NETSIM_ID nInterfaceId);
1278int fn_NetSim_CR_FragmentPacket(NetSim_PACKET* pstruPacket,
double dSDUSize);
1279int fn_NetSim_CR_CreateServiceFlow(NETSIM_ID nDeviceId,NETSIM_ID nInterfaceId,
int nId,NetSim_PACKET* packet,
double dTime);
1280int fn_NetSim_CR_IncumbentStart();
1281int fn_NetSim_CR_IncumbentEnd();
1282int fn_NetSim_CR_TransmitSCH();
1283int fn_NetSim_CR_TransmitFCH();
1284int fn_NetSim_CR_TransmitDSBurst();
1285int fn_NetSim_CR_TransmitUSBurst();
1286int fn_NetSim_CR_QuietPeriod();
1287int fn_NetSim_CR_UpdateChannel();
1288int fn_NetSim_CR_CPE_ProcessSCH(NetSim_PACKET* pstruPacket);
1289int fn_NetSim_CR_CPE_ProcessFCH(NetSim_PACKET* pstruPacket);
1290int fn_NetSim_CR_CPE_ProcessDSMAP();
1291int fn_NetSim_CR_CPE_ProcessUSMAP();
1292int fn_NetSim_CR_CPE_ProcessDSA_RSP();
1293int fn_NetSim_CR_CPE_ProcessDSD_REP();
1294int fn_NetSim_CR_CPE_SwitchChannel();
1295int fn_NetSim_CR_CPE_PackPacket();
1296int fn_NetSim_CR_BS_ForwardDataPacket();
1297int fn_NetSim_CR_BS_ProcessDSAReq();
1298int fn_NetSim_CR_BS_ProcessDSDReq();
1299int fn_NetSim_CR_BS_UCS();
1300NetSim_PACKET* fn_NetSim_CR_FormDSMAP(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId);
1301NetSim_PACKET* fn_NetSim_CR_FormUSMAP(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId);
1302NetSim_PACKET* fn_NetSim_CR_FormUCD(NETSIM_ID nDeviceId,NETSIM_ID nInterfaceId);
1303NetSim_PACKET* fn_NetSim_CR_FormDCD(NETSIM_ID nDeviceId,NETSIM_ID nInterfaceId);
1304int fn_NetSim_CR_FormDSFrame(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId,
double dTime);
1305NetSim_PACKET* fn_NetSim_CR_BS_PackPacket(BS_MAC* pstruBSMac,NetSim_PACKET* pstruPacket);
1306int fn_Netsim_CR_SM_ScheduleQuietPeriod(BS_PHY* pstruBSPhy,SCH* pstruSCH);
1308int fn_NetSim_TerminateServiceFlow(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId, NetSim_PACKET* pstruPacket);
1309int fn_NetSim_CR_CalulateReceivedPower();
int nDSXRequestRetries
3 fixed
int nDSXResponseReties
3 fixed
int nCandidateChannelRefreshTime
unsigned int nDSBurst
Current DS burst.
int nBackupChannelRefreshTime
double dChannelAvailabilityCheckTime
! Wait for BLM-REP timeout. >= 1MAC frame
int nCandidateChannelTransitionTime
int * anSIDFromDevId
Have the list of CPE associated with BS. If SID is set CPE is associated else not.
double T8
Wait for DSA/DSC Acknowledge timeout. Max 300 ms.
DS_BURST ** pstruDSBurst
DS-Burst each is one symbol long.
double dSensingPeriodDuration
int nFalseAlramProbability
double dSensingPeriodInterval
int nWaitBeforeChannelMove
double T7
Wait for DSA/DSC/DSD Response timeout. Max 1 sec.
int nChannelDetectionTime
double dTTG
Transmit Transition Gap. 105-333 micro sec. default 210 µs.
unsigned int nSuperframeNumber
Current super frame number.
unsigned int nFrameNumber
Current super frame number.
double dRTG
Receive Transition Gap.
int nBWRequestBackoffEnd
Final size of BW Request opportunity used by CPEs to contend to send BW requests to BS....
struct stru_802_22_Channel * pstruOpratingChannel
Currently operating channel.
int nBWRequestBackoffStart
Initial size of BW Request opportunity used by CPEs to contend to send BW requests to BS....
unsigned int nMAXFrequency
Maximum frequency <=862 MHz.
struct stru_802_22_Channel * pstruChannelSet
Channel set where BS can operate.
double dDCDInterval
Time between transmission of DCD messages. Max 10 sec.
unsigned int nChannelBandwidth
! Minimum frequency >=54 MHz
CPE structure for IEEE 802.22 MAC.
double T7
Wait for DSA/DSC/DSD Response timeout. Max 1 sec.
int nDSXResponseReties
3 fixed
int nDSXRequestRetries
3 fixed
int nBLM_REPRetries
Number of retries allowed for sending BLMREP. Default 3.
double T16
Wait for bandwidth request grant. Min 10 ms.
double T8
Wait for DSA/DSC Acknowledge timeout. Max 300 ms.
unsigned int nSID
Unique station idetifier.
double T29
Wait for BLM-ACK timeout. Range 10-300 ms.
double T14
Wait for DSx-RSP/DSX-RVD Timeout. Max 200 ms.
CPE structure for CPE PHY.
SYMBOL_PARAMETER * pstruSymbol
Same parameter as BS have.
double T20
Time the CPE searches for preambles on a given channel.
int nBWRequestBackoffStart
Initial size of BW Request opportunity used by CPEs to contend to send BW requests to BS....
int nBWRequestBackoffEnd
Final size of BW Request opportunity used by CPEs to contend to send BW requests to BS....
int nChannelBandwidth
Channel Bandwidth in MHz.
int nTTG
Transmitter-receiver turnaround gap. in TU.
int nRTG
Receiver_transmitter turnaround gap. in TU.
Spectrum Sensing Function output signals.
double dIntercarrierSpacing
Inter carrier spacing ^f (Hz) = Fs/2048 Hz.
int nBitsCountInOneSymbol
Data subCarrier count*Bits based on modulation * coding rate.
double dDataRate
Number of uncoded bits/OFDM symbol duration.
int nUsedSubCarrierCount
Used Sub-carrier count Nt = 1680.
int nDataSubCarrierCount
Data Sub-carrier count Nd = 1440.
int nOFDMSlots
OFDM Slot = 1 symbol * 1 subChannel.
int nChannelBandwidth
Channel Bandwidth in MHz.
double dSubCarrierSpacing
Sub carrier spacing Tfft (micro sec) = 1/^f.
double dTimeUnit
Time Unit TU = Tfft/2048.
double dSymbolDuration
Tsym = Tfft + Tcp in µs.
int nPilotSubCarrierCount
Pilot Sub-carrier count Np = 240.
int nGuardSubcarrierCount
Guard Sub-carrier count Ng = 368.
double dBasicSamplingFrequency
Sampling Frequency Fs (in MHz)
double dCPDuration
Tcp In micro sec.