NetSim Source Code Help
Loading...
Searching...
No Matches
Incumbent.c
Go to the documentation of this file.
1#include "main.h"
2#include "802_22.h"
3/** This function is used to start the Incumbent operation and is also used to
4 generate the time for which incumbent operates. */
6{
7 NETSIM_ID nDeviceId;
8 NETSIM_ID nInterfaceId;
9 int nIncumbentId;
10 INCUMBENT* pstruIncumbent;
11 BS_PHY* pstruBSPHY;
12
13 nDeviceId = pstruEventDetails->nDeviceId;
14 nInterfaceId = pstruEventDetails->nInterfaceId;
15 pstruBSPHY = DEVICE_PHYVAR(nDeviceId,nInterfaceId);
16 nIncumbentId = atoi((char*)pstruEventDetails->szOtherDetails);
19
20 pstruIncumbent = ((BS_MAC*)(NETWORK->ppstruDeviceList[nDeviceId-1]->ppstruInterfaceList[nInterfaceId-1]->pstruMACLayer->MacVar))->pstruIncumbent[nIncumbentId];
21
22 //Generate the time for which incumbent operation will run
24 &(pstruIncumbent->dPrevOperationalTime),
25 &DEVICE(1)->ulSeed[0],
26 &DEVICE(1)->ulSeed[1],
27 pstruIncumbent->nOperationalTime,
28 0.0);
29
30 //Add Incumbent operation to CR metrics
31 if(pstruBSPHY->pstruOpratingChannel && fnIsinRange(pstruIncumbent->nStartFrequeny,pstruIncumbent->nEndFrequency,
33 {
35 }
36 else
40 // Add an event for incumbent operation end
44 sprintf(pstruEventDetails->szOtherDetails,"%d",nIncumbentId);
47
48 return 1;
49}
50/** This function is used to end the Incumbent operation and is also used to
51 generate the time for which incumbent is idle. */
53{
54 NETSIM_ID nDeviceId;
55 NETSIM_ID nInterfaceId;
56 int nIncumbentId;
57 INCUMBENT* pstruIncumbent;
58 BS_PHY* pstruBSPHY;
59
60 nDeviceId = pstruEventDetails->nDeviceId;
61 nInterfaceId = pstruEventDetails->nInterfaceId;
62 pstruBSPHY = DEVICE_PHYVAR(nDeviceId,nInterfaceId);
63 nIncumbentId = atoi((char*)pstruEventDetails->szOtherDetails);
66
67 pstruIncumbent = ((BS_MAC*)(NETWORK->ppstruDeviceList[nDeviceId-1]->ppstruInterfaceList[nInterfaceId-1]->pstruMACLayer->MacVar))->pstruIncumbent[nIncumbentId];
68
69 //Generate the time for which incumbent is idle
71 &(pstruIncumbent->dPrevOperationalInterval),
72 &DEVICE(1)->ulSeed[0],
73 &DEVICE(1)->ulSeed[1],
74 pstruIncumbent->nOperationalIntervalTime,
75 0.0);
76 //Add Incumbent operation to CR metrics
77 if(pstruBSPHY->pstruOpratingChannel && fnIsinRange(pstruIncumbent->nStartFrequeny,pstruIncumbent->nEndFrequency,
79 pstruIncumbent->struIncumbentMetrics.dInterferenceStartTime >= 0.0)
80 {
83 }
84 else
88 // Add an event for incumbent operation start
92 sprintf(pstruEventDetails->szOtherDetails,"%d",nIncumbentId);
95 return 1;
96}
int fnIsinRange(double l1, double u1, double l2, double u2)
@ INCUMBENT_OPERATION_START
Definition: 802_22.h:147
@ INCUMBENT_OPERATION_END
Definition: 802_22.h:148
@ IncumbentStatus_OPERATIOAL
Definition: 802_22.h:255
@ IncumbentStatus_NONOPERATIONAL
Definition: 802_22.h:254
unsigned int NETSIM_ID
Definition: Animation.h:45
int fn_NetSim_CR_IncumbentEnd()
Definition: Incumbent.c:52
int fn_NetSim_CR_IncumbentStart()
Definition: Incumbent.c:5
#define fnpFreeMemory(p)
Definition: Memory.h:36
#define fnpAllocateMemory(count, size)
Definition: Memory.h:34
#define DEVICE(DeviceId)
Definition: Stack.h:769
int fn_NetSim_Utils_Distribution(int nDistributionType, double *fDistOut, unsigned long *uSeed, unsigned long *uSeed1, double fFirstArg, double fSecondArg)
#define DEVICE_PHYVAR(DeviceId, InterfaceId)
Definition: Stack.h:797
EXPORTED struct stru_NetSim_Network * NETWORK
Definition: Stack.h:742
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
Definition: Stack.h:837
#define fnpAddEvent(pstruEvent)
Definition: main.h:191
struct stru_802_22_Channel * pstruOpratingChannel
Currently operating channel.
Definition: 802_22.h:840
double dUpperFrequency
Definition: 802_22.h:925
double dLowerFrequency
Definition: 802_22.h:926
Structure for incumbent.
Definition: 802_22.h:1009
INCUMBENT_METRICS struIncumbentMetrics
Definition: 802_22.h:1021
double dPrevOperationalInterval
Definition: 802_22.h:1018
double dPrevOperationalTime
Definition: 802_22.h:1017
int nOperationalIntervalTime
Definition: 802_22.h:1014
DISTRIBUTION nOperationalDistribution
Definition: 802_22.h:1015
INCUMBENT_STATUS nIncumbentStatus
Definition: 802_22.h:1016
unsigned int nInterferenceTime
Definition: 802_22.h:644
struct stru_NetSim_Interface ** ppstruInterfaceList
Definition: Stack.h:717
NETSIM_ID nSubEventType
Definition: Stack.h:757
NETSIM_ID nDeviceId
Definition: Stack.h:750
NETSIM_ID nInterfaceId
Definition: Stack.h:751
struct stru_NetSim_MacLayer * pstruMACLayer
Definition: Stack.h:698
struct stru_NetSim_Device ** ppstruDeviceList
Definition: Stack.h:737