NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
CDMA_Channel.c
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 * Author: Shashi Kant Suman *
12 * *
13 * ---------------------------------------------------------------------------------*/
14#include "main.h"
15#include "CDMA.h"
16#include "Cellular.h"
17
18/**
19 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 This function is used to form the CDMA channel based on the following
21 assumption.
22 1. One call class : All MS requires same target SNR
23 2. Co-located MS: MS are uniformly distributed on area covered by BTS.
24 3. Hard handover
25 max number of call handle is given by formula below
26
27 dProcessingGain = (BSMac->CDMAVar.dChipRate)/dCDMA_DATARATE*1.0
28 dTau = BSMac->CDMAVar.dChipRate/dProcessingGain*1.0
29 dMaxNoOfCallHandled = 1.0/(1+dNeu)
30 dMaxNoOfCallHandled *= (1+dTau)/dTau
31 dMaxNoOfCallHandled = dMaxNoOfCallHandled/BSMac->CDMAVar.dVoiceActivityFactor
32
33 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34 */
35_declspec(dllexport) int fn_NetSim_FormCDMAChannel(NETSIM_ID nBTSId,Cellular_BS_MAC* BSMac,int nCDMA_ETA,int nCDMA_SIGMA,double dCDMA_DATARATE)
36{
37 static int nChannelId=1;
38 Cellular_CHANNEL *tempChannel1,*tempChannel2; //Temp channel used for assignment
39 int nLoop1; //Loop counter
40 int nMaxNoOfCallHandled; //Max number of call handled by the CDMA system
41 double dMaxNoOfCallHandled;
42 double dNeu; //Path loss exponent
43 double dTau; //desired lower bound of SNR
44 double dTemp; // Temp for calculation channel number
45 double dPower; // Power used to calculate other cell interference
46 double dProcessingGain; //Processing gain of CDMA system
47 double dCDMA_TARGETSNR=BSMac->CDMAVar.dTargetSNR;
48
49
50 if(nCDMA_SIGMA==0)
51 nCDMA_SIGMA=12;
52 /* Calculate the other cell interface factor based on
53 * the path loss exponent. The value are taken from the
54 * book "CDMA: Principles of spread spectrum" by Andy Viterbe.
55 */
56 switch(nCDMA_ETA)
57 {
58 default:
59 case 3:
60 dTemp = 0.77;
61 break;
62 case 4:
63 dTemp = 0.44;
64 break;
65 case 5:
66 dTemp = 0.30;
67 break;
68 }
69
70 dPower = nCDMA_SIGMA* nCDMA_SIGMA/2.0;
71 dPower = dPower*log(10)*log(10)/100.0;
72 dNeu = pow(2.71828,dPower);
73 dNeu *= dTemp;
74 dCDMA_TARGETSNR = pow(10,dCDMA_TARGETSNR/10.0);
75
76 //Calculate the processing gain = Chip rate/Data rate
77 dProcessingGain = (BSMac->CDMAVar.dChipRate)/dCDMA_DATARATE*1.0;
78 dTau = BSMac->CDMAVar.dChipRate/dProcessingGain*1.0;
79 dMaxNoOfCallHandled = 1.0/(1+dNeu);
80 dMaxNoOfCallHandled *= (1+dTau)/dTau;
81 dMaxNoOfCallHandled = dMaxNoOfCallHandled/BSMac->CDMAVar.dVoiceActivityFactor;
82 nMaxNoOfCallHandled = (int)ceil(dMaxNoOfCallHandled);
83 for(nLoop1=0;nLoop1<nMaxNoOfCallHandled;nLoop1++)
84 {
85 //Assigning memory for temporary channel
86 tempChannel1 = calloc(1,sizeof* tempChannel1);
87 tempChannel1->nAllocationFlag=0; // Initially all channel is free
88 tempChannel1->nChannelId = nChannelId++;
89 tempChannel1->nBTSId=nBTSId;
90 if(nLoop1 == 0) // First Channel (Pilot channel)
91 {
92 // Setting first channel of BTS (Pilot channel) = Temporary channel
93 BSMac->pstruChannelList = tempChannel1;
94 tempChannel1->nChannelType = ChannelType_Pilot; // First channel is pilot channel
95 tempChannel2=tempChannel1;
96 }
97 else // All channel except first (Traffic channel).
98 {
99 // Appending temporary channel to BTS channel list for Traffic channel
100 tempChannel1 ->nChannelType = ChannelType_TRAFFICCHANNEL;
101 tempChannel2->pstru_NextChannel = tempChannel1;
102 tempChannel2 = tempChannel1;
103 }
104 }
105 BSMac->nAllocatedChannel = 0; // Initially no channel is busy
106 BSMac->nRACHChannel=1;
107 BSMac->nFreeChannel=nMaxNoOfCallHandled; // Initially all channel is free
108 BSMac->nTrafficChannel=nMaxNoOfCallHandled-1;
109 BSMac->nChannelCount = nMaxNoOfCallHandled; // Total number of channel
110 return 1;
111}
CELLULAR_CHANNEL_TYPE nChannelType
Definition Cellular.h:137