NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
Cellular.h
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#ifndef _NETSIM_CELLULAR_H_
15#define _NETSIM_CELLULAR_H_
16#include "IP_Addressing.h"
17#include "GSM.h"
18#pragma comment(lib,"Mobility.lib")
19typedef struct stru_Cellular_VLR VLR;
20typedef struct stru_Cellular_MSC DEVVAR_MSC;
21typedef struct stru_Cellular_BaseStation_Phy Cellular_BS_PHY;
22typedef struct stru_Cellular_BaseStation_Mac Cellular_BS_MAC;
23typedef struct stru_Cellular_MS_Phy Cellular_MS_PHY;
24typedef struct stru_Cellular_MS_Mac Cellular_MS_MAC;
25typedef struct stru_MS_Metrics Cellular_MS_Metrics;
26typedef struct stru_Cellular_ChannelList Cellular_CHANNEL;
27typedef struct stru_Cellular_ChannelRequest Cellular_CHANNEL_REQUEST;
28typedef struct stru_Cellular_Packet Cellular_PACKET;
29typedef struct stru_Cellular_ChannelResponse Cellular_CHANNEL_RESPONSE;
30
31#define DATA_RATE 0.270 //mbps
32/// Enumeration for cellular channel types
33typedef enum
34{
35 ChannelType_Pilot=0,
36 ChannelType_RACH=0,
37 ChannelType_TRAFFICCHANNEL=1,
38}CELLULAR_CHANNEL_TYPE;
39/// Enumeration for mobile station status
40typedef enum
41{
42 Status_IDLE=0,
43 Status_ChannelRequested,
44 Status_ChannelRequestedForIncoming,
45 Status_ChannelRequestedForHandover,
46 Status_CallRequested,
47 Status_CallInProgress,
48 Status_CallEnd,
49}MS_STATUS;
50/// Emumeration for cellular packetype
51enum enum_cellular_packet_type
52{
53 PacketType_ChannelRequest,
54 PacketType_CallRequest,
55 PacketType_ChannelGranted,
56 PacketType_ChannelUngranted,
57 PacketType_ChannelRequestForIncoming,
58 PacketType_CallAccepted,
59 PacketType_CallRejected,
60 PacketType_ChannelRelease,
61 PacketType_ChannelRequestForHandover,
62 PacketType_DropCall,
63 PacketType_HandoverInfo,
64 PacketType_CallEnd,
65};
66#define CELLULAR_PACKET_TYPE(protocol,type) protocol*100+type
67/// Enumeration for cellular subevent
68enum enum_cellular_subevent
69{
70 Subevent_DropCall,
71 Subevent_TxNextBurst,
72};
73#define CELLULAR_SUBEVENT(protocol,type) protocol*100+type
74/// Data structure for Visitor Location Register
76{
77 NETSIM_ID nMSId;
78 NETSIM_ID nBTSId;
79 NETSIM_ID nInterfaceId;
80 NETSIM_IPAddress MSIP;
81};
82
83/**
84 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
85 The BTS contains a channel list. It is channel list that are to be used by the
86 BTS & their associated MS. This channel list is static through out the simulation
87 and assigned by the FCA function.
88 The channel list is defined by following parameters:-
89 1. Channel Id
90 2. UpLink minimum frequency.
91 3. UpLink maximum frequency
92 4. Down link minimum frequency.
93 5. Down link maximum frequency
94 6. Time slot // This is time slot number between 0-7.
95 7. Allocation flag. // This is a flag stating that channel is free or not.
96 8. Next Channel.
97
98 NOTE:-
99 UpLink Maximum Frequency - UpLink Minimum Frequency = 200 kHz.
100 DownLink Maximum Frequency - DownLink Minimum Frequency = 200 kHz
101 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
102*/
104{
105 NETSIM_ID nChannelId;
106 NETSIM_ID nBTSId;
107
108 /*** only for GSM ***/
109 double dUpLinkMinimumFrequency;
110 double dUpLinkMaximumFrequency;
111 double dDownLinkMinimumFrequency;
112 double dDownLinkMaximumFreqency;
113 int nTimeSlot;
114
115
117 ~~~~~~~~~~~~~~~~~~~~~~~
118 0 for unallocated
119 1 for allocated
120 ~~~~~~~~~~~~~~~~~~~~~~~
121 */
122 NETSIM_ID nMSId; /**<
123 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
124 Id of MS for which this channel is allocated.
125 0 in case free channel.
126 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
127 */
128 NETSIM_ID nDestId;
129
131 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
132 Application id for which this channel is allocated.
133 0 in case of free channel.
134 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135 */
136
137 CELLULAR_CHANNEL_TYPE nChannelType; /**<
138 ~~~~~~~~~~~~~~~~~~~~~~
139 0 for RACH,pilot
140 1 for traffic channel.
141 ~~~~~~~~~~~~~~~~~~~~~~
142 */
143
144
145 struct stru_Cellular_ChannelList *pstru_NextChannel;
146};
147/** Data structure for base station MAC layer */
149{
151 {
152 double dDuplexDistance;
153 char* szDuplexTechnique;
154 char* szHandoverType;
155 }GSMVar;
157 {
158 char* standard;
159 double dTotalBandwidth;
160 double dChipRate;
161 double dVoiceActivityFactor;
162 double dTargetSNR;
163 }CDMAVar;
164 double dChannelDataRate;
165 double dBTSRange;
166 char* szMultipleAccessTechnology;
167 char* szSpeechCoding;
168
169 /*Channel List*/
170 unsigned int nChannelCount;
171 unsigned int nAllocatedChannel;
172 unsigned int nFreeChannel;
173 unsigned int nRACHChannel;
174 unsigned int nTrafficChannel;
175 struct stru_Cellular_ChannelList* pstruChannelList;
176};
177/** Data structure for Mobile switching centre */
179{
180 int nProtocol;
181 unsigned int nBTSCount;
182 unsigned int nMSCount;
183 NETSIM_ID* BTSList;
184 VLR** VLRList;
185 MSC_GSM* gsmVar;
186};
187/** Data structure for mobile station metrics */
189{
190 unsigned int nCallGenerated;
191 unsigned int nCallBlocked;
192 double dCallBlockingProbability;
193 unsigned int nChannelRequestSent;
194 unsigned int nCallRequestSent;
195 unsigned int nCallRequestReceived;
196 unsigned int nCallAccepted;
197 unsigned int nCallRejected;
198 unsigned int nHandoverRequest;
199 double dCallDroppingProbability;
200 unsigned int nCallDropeed;
201};
202/** Data structure for mobile station MAC layer */
204{
205 char* szMobilieNumber;
206 char* szIMEINumber;
207
208 //For UGS Traffic
209 MS_STATUS nMSStatusFlag;
210 NETSIM_ID nApplicationId;
211 unsigned int nSourceFlag;
212
213 //BTS info
214 NETSIM_ID nBTSId;
215 NETSIM_ID nBTSInterface;
216 Cellular_CHANNEL* pstruAllocatedChannel;
217
218 //Packet list
219 NetSim_PACKET**** pstruPacketList; //For each application,source,destination
220 NetSim_PACKET**** receivedPacketList;
221
222 //Handover info
223 NETSIM_ID nNewBTS;
224 NETSIM_ID nLinkId;
225 double dHandoverTime;
226
227 //MS Metrics
228 Cellular_MS_Metrics MSMetrics;
229};
230/** Data structure for mobile station PHYSICAL layer */
232{
233 double dTxPower;
234 char* szModulation;
235};
236/** Data structure for base station PHYSICAL layer */
238{
239 double dTxPower;
240 char* szModulation;
241};
242/** Data structure for Channel request */
244{
245 unsigned int nRequestType;
246 NETSIM_ID nMSId;
247 NETSIM_ID nApplicationId;
248 NETSIM_ID nDestId;
249};
250/** Data structure for channel response */
252{
253 unsigned int nAllocationFlag;
254 struct stru_Cellular_ChannelList* channel;
255};
256/**
257Data structure for cellular packet
258*/
260{
261 unsigned int nTimeSlot;
262
263 NETSIM_ID nApplicationId;
264 //For fragmentation
265 unsigned int isLast;
266 unsigned int nId;
267 NetSim_PACKET* originalPacket;
268
269 void* controlData;
270};
271NetSim_PACKET* fn_NetSim_Cellular_createPacket(double time,
272 unsigned int nPacketType,
273 NETSIM_ID nSourceId,
274 NETSIM_ID nDestinationId,
275 double dSize,
276 MAC_LAYER_PROTOCOL protocol);
277_declspec(dllexport) int fn_NetSim_FormCDMAChannel(NETSIM_ID nBTSId,Cellular_BS_MAC* BSMac,int nCDMA_ETA,int nCDMA_SIGMA,double dCDMA_DATARATE);
278int fn_NetSim_Cellular_MoveMS(NETSIM_ID nDeviceId,NETSIM_ID nBTSId);
279int fn_NetSim_Cellular_Run();
280int fn_NetSim_Cellular_FreePacket(NetSim_PACKET* packet);
281int fn_NetSim_Cellular_FormBurst(NetSim_PACKET* packet,Cellular_MS_MAC* MSMac);
282int fn_NetSim_Cellular_MS_SendChannelRelease(Cellular_CHANNEL* channel,NETSIM_ID nMSId,NETSIM_ID nMSInterface,double time);
283int isCellularChannelAllocated(NETSIM_ID nMSId,NETSIM_ID nInterfaceId,NETSIM_ID nApplicationId);
284int fn_NetSim_Cellular_AddPacketToBuffer(NetSim_PACKET* packet,NETSIM_ID nDeviceId,NETSIM_ID nInterfaceId);
285int fn_NetSim_Cellular_AllocateChannel(NetSim_EVENTDETAILS* pstruEventDetails,NetSim_PACKET* packet);
286int fn_NetSim_Cellular_ChannelResponse(NetSim_PACKET* packet);
287int fn_NetSim_Cellular_MS_ProcessCallRequest();
288int fn_NetSim_Cellular_MS_ProcessCallResponse();
289int fn_NetSim_Cellular_MS_SendChannelRelease(Cellular_CHANNEL* channel,NETSIM_ID nMSId,NETSIM_ID nMSInterface,double time);
290int fn_NetSim_Cellular_DropCall();
291int fn_NetSim_Cellular_MS_ReassembleBurst();
292int fn_NetSim_Cellular_allocateChannel(NetSim_PACKET* packet);
293int fn_NetSim_Cellular_BS_ReleaseChannel();
294int fn_NetSim_GSM_BS_PhyOut();
295int fn_NetSim_Cellular_BS_AssignTimeSlot(NetSim_PACKET* packet,NETSIM_ID nBTSId);
296int fn_NetSim_Cellular_ChannelResponseForHandover();
297int fn_NetSim_Cellular_ForwardToMSC();
298int fn_NetSim_Cellular_HandoverCall(NETSIM_ID nMSId,NETSIM_ID nMSInterface,double time);
299int fn_NetSim_Cellular_InitBTSList(NETSIM_ID nBTSId);
300int fn_NetSim_Cellular_InitVLRList(NETSIM_ID nMSId,NETSIM_ID nMSInterface);
301int fn_NetSim_Cellular_Metrics(PMETRICSWRITER metricsWriter);
302int fn_NetSim_Cellular_MS_PhyOut();
303int fn_NetSim_Cellular_Msc_ProcessPacket();
304int fn_NetSim_Cellular_SendCallend(NETSIM_ID nMSID,NETSIM_ID nMSInterface,NETSIM_ID nDestinationId,double time);
305int fn_NetSim_Cellular_TransmitOnwireline();
306int fn_NetSim_FormGSMChannel(DEVVAR_MSC* mscVar);
307int fn_NetSim_Cellular_CopyPacket(NetSim_PACKET* pstruDestPacket,NetSim_PACKET* pstruSrcPacket);
308#endif
CELLULAR_CHANNEL_TYPE nChannelType
Definition Cellular.h:137
Data structure for Visitor Location Register.
Definition Cellular.h:76