NetSim Source Code Help
Loading...
Searching...
No Matches
Handover.c
Go to the documentation of this file.
1
2/************************************************************************************
3 * Copyright (C) 2020 *
4 * TETCOS, Bangalore. India *
5 * *
6 * Tetcos owns the intellectual property rights in the Product and its content. *
7 * The copying, redistribution, reselling or publication of any or all of the *
8 * Product or its content without express prior written consent of Tetcos is *
9 * prohibited. Ownership and / or any other right relating to the software and all *
10 * intellectual property rights therein shall remain at all times with Tetcos. *
11 * *
12 * Author: Shashi Kant Suman *
13 * *
14 * ---------------------------------------------------------------------------------*/
15#include "main.h"
16#include "GSM.h"
17#include "Cellular.h"
18#include "../Application/Application.h"
19/**
20 As the mobile stations moves out of one cell to the next, it must be possible to hand the call over
21 from the base station of the first cell, to that of the next with no discernable disruption to the call.
22 It is necessary to ensure it can be performed reliably and without disruption to any calls.
23 Failure for it to perform reliably can result in dropped calls.
24 When the handover occurs it is necessary to re-route the call to the relevant base station along with
25 changing the communication between the mobile and the base station to a new channel. All of this needs
26 to be undertaken without any noticeable interruption to the call.
27*/
28int fn_NetSim_Cellular_HandoverCall(NETSIM_ID nMSId,NETSIM_ID nMSInterface,double time)
29{
30 Cellular_MS_MAC* MSMac=DEVICE_MACVAR(nMSId,nMSInterface);
31 //Send channel request to new BTS
32 NetSim_PACKET* request;
33 Cellular_PACKET* gsmPacket=calloc(1,sizeof* gsmPacket);
34 Cellular_CHANNEL_REQUEST* requestData=calloc(1,sizeof* requestData);
35 unsigned int nProtocol=DEVICE_MACLAYER(nMSId,nMSInterface)->nMacProtocolId;
36 if(MSMac->pstruAllocatedChannel==NULL)
37 return 0;
41 nMSId,
42 MSMac->nNewBTS,
43 1,
44 nProtocol);
45 request->pstruMacData->Packet_MACProtocol=gsmPacket;
46 gsmPacket->controlData=requestData;
47 requestData->nApplicationId=MSMac->nApplicationId;
48 requestData->nMSId=nMSId;
49 requestData->nDestId=MSMac->pstruAllocatedChannel->nDestId;
51 //Add packet to physical out
64 return 1;
65}
66/** This function is called as a response for handover */
68{
71 Cellular_CHANNEL_RESPONSE* response=gsmPacket->controlData;
72 if(response->nAllocationFlag==1)
73 {
74 //Release old channel
79
80 MSMac->pstruAllocatedChannel=response->channel;
83 }
84 else
85 {
91 Cellular_PACKET* gsmPacket=calloc(1,sizeof* gsmPacket);
93 gsmPacket->nTimeSlot=MSMac->pstruAllocatedChannel->nTimeSlot;
94 packet->pstruMacData->Packet_MACProtocol=gsmPacket;
99 }
100 return 1;
101}
102/** This function is called to drop a call */
104{
105 unsigned int nProtocol=pstruEventDetails->nProtocolId;
106 unsigned int nSubevent=pstruEventDetails->nSubEventType;
110 if(MSMac->pstruAllocatedChannel==NULL)
111 return 1;
112 //Drop call
113 if(MSMac->nSourceFlag==1)
114 {
115 ((APP_CALL_INFO*)appInfo->appData)->fn_BlockCall(appInfo,
120 }
122 {
126 }
128 {
132 }
133 //Release old channel
138 //Drop call
139 MSMac->pstruAllocatedChannel=NULL;
140 MSMac->nApplicationId=0;
141 MSMac->nSourceFlag=0;
144 {
146 MSMac->MSMetrics.nCallDropeed++;
147 }
148 return 1;
149}
unsigned int NETSIM_ID
Definition: Animation.h:45
#define CELLULAR_PACKET_TYPE(protocol, type)
Definition: Cellular.h:66
NetSim_PACKET * fn_NetSim_Cellular_createPacket(double time, unsigned int nPacketType, NETSIM_ID nSourceId, NETSIM_ID nDestinationId, double dSize, MAC_LAYER_PROTOCOL protocol)
int fn_NetSim_Cellular_MoveMS(NETSIM_ID nDeviceId, NETSIM_ID nBTSId)
@ Subevent_DropCall
Definition: Cellular.h:70
#define CELLULAR_SUBEVENT(protocol, type)
Definition: Cellular.h:73
@ PacketType_DropCall
Definition: Cellular.h:62
@ PacketType_ChannelRequestForHandover
Definition: Cellular.h:61
@ Status_IDLE
Definition: Cellular.h:42
@ Status_CallInProgress
Definition: Cellular.h:47
@ Status_ChannelRequestedForHandover
Definition: Cellular.h:45
int fn_NetSim_Cellular_HandoverCall(NETSIM_ID nMSId, NETSIM_ID nMSInterface, double time)
Definition: Handover.c:28
int fn_NetSim_Cellular_ChannelResponseForHandover()
Definition: Handover.c:67
int fn_NetSim_Cellular_DropCall()
Definition: Handover.c:103
#define calloc(c, s)
Definition: Memory.h:29
#define DEVICE_MACLAYER(DeviceId, InterfaceId)
Definition: Stack.h:786
@ MOBILESTATION
Definition: Stack.h:275
@ MAC_PROTOCOL_GSM
Definition: Stack.h:218
@ MAC_PROTOCOL_CDMA
Definition: Stack.h:217
EXPORTED struct stru_NetSim_Network * NETWORK
Definition: Stack.h:742
@ PHYSICAL_OUT_EVENT
Definition: Stack.h:104
#define DEVICE_MACVAR(DeviceId, InterfaceId)
Definition: Stack.h:798
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
Definition: Stack.h:837
#define fn_NetSim_Packet_FreePacket(pstruPacket)
Definition: main.h:177
#define fnpAddEvent(pstruEvent)
Definition: main.h:191
Structure for Erlang_call application.
Definition: Application.h:313
Structure to store application information.
Definition: Application.h:97
unsigned int nAllocationFlag
Definition: Cellular.h:253
struct stru_Cellular_ChannelList * channel
Definition: Cellular.h:254
NETSIM_ID nApplicationId
Definition: Cellular.h:210
NetSim_PACKET **** pstruPacketList
Definition: Cellular.h:219
unsigned int nSourceFlag
Definition: Cellular.h:211
NetSim_PACKET **** receivedPacketList
Definition: Cellular.h:220
Cellular_CHANNEL * pstruAllocatedChannel
Definition: Cellular.h:216
NETSIM_ID nNewBTS
Definition: Cellular.h:223
Cellular_MS_Metrics MSMetrics
Definition: Cellular.h:228
MS_STATUS nMSStatusFlag
Definition: Cellular.h:209
NETSIM_ID nApplicationId
Definition: Cellular.h:263
unsigned int nTimeSlot
Definition: Cellular.h:261
unsigned int nCallDropeed
Definition: Cellular.h:200
unsigned int nChannelRequestSent
Definition: Cellular.h:193
unsigned int nHandoverRequest
Definition: Cellular.h:198
NETSIM_ID nApplicationId
Definition: Stack.h:752
EVENT_TYPE nEventType
Definition: Stack.h:747
NETSIM_ID nProtocolId
Definition: Stack.h:748
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
netsimDEVICE_TYPE nDeviceType
Definition: Stack.h:749
NETSIM_ID nInterfaceId
Definition: Stack.h:751
void ** appInfo
Definition: Stack.h:739
struct stru_NetSim_Packet * pstruNextPacket
Definition: Packet.h:278
struct stru_NetSim_Packet_MACLayer * pstruMacData
Definition: Packet.h:276