NetSim Source Code Help
Loading...
Searching...
No Matches
USMAP.c
Go to the documentation of this file.
1#include "main.h"
2#include "802_22.h"
3typedef struct stru_ExtentedUSMAPIE
4{
8/** The US-MAP message defines the access to the upstream channel using US-MAP IEs */
10{
11 int nIECount = 0;
12 int nLoop,nLoop1;
13 USMAP_IE* pstruUSIE[MAX_SID];
14 BS_MAC* pstruBSMAC = (BS_MAC*)DEVICE_MACVAR(nDeviceId,nInterfaceId);
15 BS_PHY* pstruBSPHY = (BS_PHY*)DEVICE_PHYVAR(nDeviceId,nInterfaceId);
16 UPLINKALLOCINFO* pstruInfo = pstruBSMAC->uplinkAllocInfo;
17 memset(pstruUSIE,0,sizeof(USMAP_IE*)*MAX_SID);
18 pstruBSMAC->pstruUSMAP = fnpAllocateMemory(1,sizeof(USMAP));
21 fn_NetSim_CR_UpdateInfo(pstruBSMAC,pstruBSPHY);
22 //Prepare US-MAP IE for BW-request
23 pstruUSIE[0] = fnpAllocateMemory(1,sizeof *pstruUSIE[0]);
24 pstruUSIE[0]->nSID = 0;//Broadcast
25 pstruUSIE[0]->nUIUC = 3;
26 pstruUSIE[0]->UIUC_2_3.nSubChannelCount = 6;
27 nIECount++;
28 //Loop through allocation info
29 while(pstruInfo)
30 {
31 if(pstruUSIE[pstruInfo->nSID] == NULL)
32 {
33 nIECount++;
34 pstruUSIE[pstruInfo->nSID] = fnpAllocateMemory(1,sizeof *pstruUSIE[pstruInfo->nSID]);
35 }
36 pstruUSIE[pstruInfo->nSID]->nSID = pstruInfo->nSID;
37 pstruUSIE[pstruInfo->nSID]->nUIUC = pstruBSMAC->nUIUC;
38 pstruUSIE[pstruInfo->nSID]->UIUC.nDuration += pstruInfo->nSlotAllocated;
39 pstruInfo = pstruInfo->next;
40 }
41 pstruBSMAC->pstruUSMAP->nIECount = nIECount;
42 pstruBSMAC->pstruUSMAP->pstruUSMAPIE = fnpAllocateMemory(nIECount,sizeof(USMAP_IE*));
43 nLoop1 = 0;
44 for(nLoop=0;nLoop<MAX_SID && nIECount;nLoop++)
45 {
46 if(pstruUSIE[nLoop])
47 {
48 nIECount--;
49 pstruBSMAC->pstruUSMAP->pstruUSMAPIE[nLoop1++] = pstruUSIE[nLoop];
50 }
51 }
52 return fn_NetSim_CR_GenerateBroadcastCtrlPacket(nDeviceId,nInterfaceId,MMM_US_MAP);
53}
54/** The US-MAP message defines the access to the upstream channel using US-MAP IEs */
56{
57 int nSlot=0;
58 unsigned int nLoop;
59 USMAP* pstruUSMAP;
60 double dTime;
64 CPE_PHY* pstruCPEPhy = DEVICE_PHYVAR(nDeviceId,nInterfaceId);
65 SYMBOL_PARAMETER* pstruSymbol = pstruCPEPhy->pstruSymbol;
66 BS_MAC* pstruBSMac = DEVICE_MACVAR(pstruCPEMAC->nBSID,pstruCPEMAC->nBSInterface);
67 BS_PHY* pstruBSPhy = DEVICE_PHYVAR(pstruCPEMAC->nBSID,pstruCPEMAC->nBSInterface);
69 dTime = pstruUSMAP->nAllocationStartTime*pstruSymbol->dSymbolDuration+pstruBSPhy->dTTG;
70 dTime += pstruBSMac->dFrameStartTime;
71 nSlot = pstruSymbol->nOFDMSlots-pstruUSMAP->pstruUSMAPIE[0]->UIUC_2_3.nSubChannelCount;
72 //Update the allocated byted
73 for(nLoop=0;nLoop<pstruUSMAP->nIECount;nLoop++)
74 {
75 if(pstruUSMAP->pstruUSMAPIE[nLoop]->nSID == pstruCPEMAC->nSID)
76 {
77 if(pstruUSMAP->pstruUSMAPIE[nLoop]->nUIUC >= 13 && pstruUSMAP->pstruUSMAPIE[nLoop]->nUIUC <= 61)
78 {
79 pstruCPEMAC->BWRequestInfo->dBytesAllocated = pstruUSMAP->pstruUSMAPIE[nLoop]->UIUC.nDuration*pstruSymbol->nBitsCountInOneSlot/8.0;
80 pstruCPEMAC->BWRequestInfo->dStartTime = dTime + nSlot*pstruSymbol->dSymbolDuration/pstruSymbol->nOFDMSlots;
81 }
82 }
83 else
84 {
85 switch(pstruUSMAP->pstruUSMAPIE[nLoop]->nUIUC)
86 {
87 case 0:
88 case 1:
89 break;
90 case 2:
91 case 3:
92 nSlot += pstruUSMAP->pstruUSMAPIE[nLoop]->UIUC_2_3.nSubChannelCount;
93 break;
94 case 4:
95 case 5:
96 case 6:
97 nSlot += pstruUSMAP->pstruUSMAPIE[nLoop]->UIUC_4_6.nSubChannelCount;
98 nSlot += pstruUSMAP->pstruUSMAPIE[nLoop]->UIUC_4_6.nSubSymbolsCount*pstruSymbol->nOFDMSlots;
99 break;
100 case 8:
101 nSlot += pstruUSMAP->pstruUSMAPIE[nLoop]->UIUC_8.nSubChannelCount;
102 break;
103 case 7:
104 case 9:
105 case 62:
106 break;
107 default:
108 nSlot += pstruUSMAP->pstruUSMAPIE[nLoop]->UIUC.nDuration;
109 break;
110 }
111 }
112 }
113 //Create an event to form US-Burst
122 return 0;
123}
124
@ MMM_US_MAP
Upstream access definition, defines the access to the upstream information.
Definition: 802_22.h:177
@ FORM_US_BURST
Definition: 802_22.h:152
NetSim_PACKET * fn_NetSim_CR_GenerateBroadcastCtrlPacket(int nDeviceId, int nInterfaceId, MANAGEMENT_MESSAGE nMessageType)
#define MAX_SID
Definition: 802_22.h:75
int fn_NetSim_CR_UpdateInfo(BS_MAC *pstruBSMAC, BS_PHY *pstruBSPHY)
unsigned int NETSIM_ID
Definition: Animation.h:45
#define fnpAllocateMemory(count, size)
Definition: Memory.h:34
#define DEVICE_PHYVAR(DeviceId, InterfaceId)
Definition: Stack.h:797
@ TIMER_EVENT
Definition: Stack.h:114
#define DEVICE_MACVAR(DeviceId, InterfaceId)
Definition: Stack.h:798
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
Definition: Stack.h:837
NetSim_PACKET * fn_NetSim_CR_FormUSMAP(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId)
Definition: USMAP.c:9
struct stru_ExtentedUSMAPIE ExtendedUSIE
int fn_NetSim_CR_CPE_ProcessUSMAP()
Definition: USMAP.c:55
#define fnpAddEvent(pstruEvent)
Definition: main.h:191
struct stru_802_22_UplinkAlloctioninfo * uplinkAllocInfo
Definition: 802_22.h:808
unsigned int nUIUC
Definition: 802_22.h:809
USMAP * pstruUSMAP
Definition: 802_22.h:801
double dFrameStartTime
Definition: 802_22.h:807
double dTTG
Transmit Transition Gap. 105-333 micro sec. default 210 microsec.
Definition: 802_22.h:851
SYMBOL_PARAMETER * pstruSymbolParameter
Definition: 802_22.h:854
CPE structure for IEEE 802.22 MAC.
Definition: 802_22.h:869
struct stru_802_22_CPE_BWRequestInfo * BWRequestInfo
Definition: 802_22.h:890
NETSIM_ID nBSInterface
Definition: 802_22.h:871
NETSIM_ID nBSID
Definition: 802_22.h:870
unsigned int nSID
Unique station idetifier.
Definition: 802_22.h:873
CPE structure for CPE PHY.
Definition: 802_22.h:902
SYMBOL_PARAMETER * pstruSymbol
Same parameter as BS have.
Definition: 802_22.h:910
unsigned int nUPlinkFrameStartSymbol
Definition: 802_22.h:990
int nOFDMSlots
OFDM Slot = 1 symbol * 1 subChannel.
Definition: 802_22.h:982
double dSymbolDuration
Tsym = Tfft + Tcp in microsec.
Definition: 802_22.h:966
struct stru_802_22_USMAPIE ** pstruUSMAPIE
Definition: 802_22.h:1156
unsigned int nAllocationStartTime
Definition: 802_22.h:1154
MANAGEMENT_MESSAGE nManagementMessageType
Definition: 802_22.h:1152
struct stru_802_22_USMAPIE::struUIUC_2_3 UIUC_2_3
struct stru_802_22_USMAPIE::struUIUC_8 UIUC_8
unsigned int nSID
Definition: 802_22.h:1163
struct stru_802_22_USMAPIE::struUIUC_4_6 UIUC_4_6
unsigned int nUIUC
Definition: 802_22.h:1164
struct stru_802_22_USMAPIE::struUIUC UIUC
struct stru_ExtentedUSMAPIE * pstruNext
Definition: USMAP.c:6
USMAP_IE * pstruUSMAPIE
Definition: USMAP.c:5
NETSIM_ID nApplicationId
Definition: Stack.h:752
EVENT_TYPE nEventType
Definition: Stack.h:747
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
NETSIM_ID nInterfaceId
Definition: Stack.h:751
struct stru_NetSim_Packet_MACLayer * pstruMacData
Definition: Packet.h:276