NetSim Source Code Help
Loading...
Searching...
No Matches
BSM.c
Go to the documentation of this file.
1/************************************************************************************
2* Copyright (C) 2020 *
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 "Application.h"
15
17 double* fSize,
18 double* ldArrival,
19 unsigned long* uSeed,
20 unsigned long* uSeed1,
21 unsigned long* uSeed2,
22 unsigned long* uSeed3)
23{
24 double time = 0.0;
25 do
26 {
27 fnDistribution(info->packetSizeDistribution, fSize, uSeed, uSeed1, info->dPacketSize);
28 } while (*fSize <= 1.0);
29 //Call the Distribution DLL to generate inter arrival time
30 do
31 {
32 fnDistribution(info->IATDistribution, &time, uSeed, uSeed1, info->dIAT);
33 } while (time <= 0.0);
34 *ldArrival = *ldArrival + time;
35
36 //generate random time in range of[-5,5]
37 time = NETSIM_RAND_RN(info->dRandomWaitTime*-1, info->dRandomWaitTime);
38 *ldArrival += time;
39 return 1;
40}
41
42/** This function is used to start the Database, FTP and Custom applications */
44{
45 PAPP_BSM_INFO info = (PAPP_BSM_INFO)appInfo->appData;
46
47 if (appInfo->dEndTime <= time)
48 return 0;
49
50 fnCreatePort(appInfo);
51
52 NETSIM_ID nSource = appInfo->sourceList[0];
53 NETSIM_ID* nDest = appInfo->destList;
54 UINT destCount = appInfo->nDestCount;
55
56 double arrivalTime = 0;
57 double packetSize = 0;
58
59 //Create the socket buffer
60 fnCreateSocketBuffer(appInfo);
61
62 //Generate the app start event
64 &packetSize,
65 &arrivalTime,
66 &(NETWORK->ppstruDeviceList[nSource - 1]->ulSeed[0]),
67 &(NETWORK->ppstruDeviceList[nSource - 1]->ulSeed[1]),
68 &(NETWORK->ppstruDeviceList[nSource - 1]->ulSeed[0]),
69 &(NETWORK->ppstruDeviceList[nSource - 1]->ulSeed[1]));
70
71 pstruEventDetails->dEventTime = time + arrivalTime;
72 pstruEventDetails->dPacketSize = packetSize;
82
86 nSource,
87 destCount,
88 nDest,
89 ++appInfo->nPacketId,
90 appInfo->nAppType,
91 appInfo->qos,
92 appInfo->sourcePort,
93 appInfo->destPort);
96
97 return 0;
98}
99
100/* Below function are out of scope for NetSim.
101 * An User can modify these function to implement Vanet packet type.
102 */
103
105{
106 // Add the payload based on SAE J2735 or any other standard
107 // return true after adding.
108 return false;
109}
110
112{
113 //Add the code to process the SAE J2735 packet.
114 //This function is called in Application_IN event.
115}
unsigned int NETSIM_ID
Definition: Animation.h:45
NetSim_PACKET * fn_NetSim_Application_GeneratePacket(ptrAPPLICATION_INFO info, double ldArrivalTime, NETSIM_ID nSourceId, UINT destCount, NETSIM_ID *nDestination, unsigned long long int nPacketId, APPLICATION_TYPE nAppType, QUALITY_OF_SERVICE nQOS, unsigned int sourcePort, unsigned int destPort)
Definition: Application.c:311
int fnCreateSocketBuffer(ptrAPPLICATION_INFO appInfo)
int fnDistribution(DISTRIBUTION nDistributionType, double *fDistOut, unsigned long *uSeed, unsigned long *uSeed1, double *args)
Definition: Distribution.c:17
void fnCreatePort(ptrAPPLICATION_INFO info)
struct stru_Application_BSMInfo * PAPP_BSM_INFO
@ event_APP_START
Definition: Application.h:54
int fn_NetSim_Application_StartBSM(ptrAPPLICATION_INFO appInfo, double time)
Definition: BSM.c:43
int fn_NetSim_Application_BSM(PAPP_BSM_INFO info, double *fSize, double *ldArrival, unsigned long *uSeed, unsigned long *uSeed1, unsigned long *uSeed2, unsigned long *uSeed3)
Definition: BSM.c:16
bool add_sae_j2735_payload(NetSim_PACKET *packet, ptrAPPLICATION_INFO info)
Definition: BSM.c:104
void process_saej2735_packet(NetSim_PACKET *packet)
Definition: BSM.c:111
#define UINT
Definition: Linux.h:38
#define PROTOCOL_APPLICATION
Definition: Stack.h:143
#define DEVICE_TYPE(DeviceId)
Definition: Stack.h:773
#define NETSIM_RAND_RN(max, min)
Definition: Stack.h:861
EXPORTED struct stru_NetSim_Network * NETWORK
Definition: Stack.h:742
@ TIMER_EVENT
Definition: Stack.h:114
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
Definition: Stack.h:837
#define fnpAddEvent(pstruEvent)
Definition: main.h:191
Structure for Data information such as packet size and inter arrival time,this is applicable for Vane...
Definition: Application.h:149
DISTRIBUTION IATDistribution
Definition: Application.h:152
DISTRIBUTION packetSizeDistribution
Definition: Application.h:150
Structure to store application information.
Definition: Application.h:97
NETSIM_ID * destList
Definition: Application.h:106
APPLICATION_TYPE nAppType
Definition: Application.h:102
unsigned int nDestCount
Definition: Application.h:104
unsigned long long int nPacketId
Definition: Application.h:116
QUALITY_OF_SERVICE qos
Definition: Application.h:111
NETSIM_ID * sourceList
Definition: Application.h:105
unsigned long ulSeed[SEED_COUNT]
Definition: Stack.h:715
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
struct stru_NetSim_Device ** ppstruDeviceList
Definition: Stack.h:737