NetSim Source Code Help
Loading...
Searching...
No Matches
Database_FTP_Custom.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
16/**
17~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18This function is used to create create applications
19
20Users can model their own mathematical distributions for packet sizes and itnerarrival times
21
22 For Custom
23 2nd parameter: Distribution Type| Distribution input1|Distribution input2|>
24 Details
25 If user selects any of the distributions listed below, then pass the corresponding number for the distribution type
26 Exponential -1
27 Uniform -2
28 Triangular -3
29 Weibull -4
30 Constant -5
31 Distribution input1-Value of Mean if exponential distribution/Upper bound for others
32 Distribution input2-Value of lower bound
33
34 Dont pass any thing if any of the distribution has no distribution input 2.
35 3rd parameter: Distribution Type |Distribution input1|Distribution input2|>
36 Details
37 If user selects any of the distributions listed below, then pass the corresponding number for the distribution type: Refer field -19
38 Exponential -1
39 Uniform -2
40 Triangular-3
41 Weibull-4
42 Constant-5
43
44 Distribution input1-Value of Mean if exponential distribution/Upper bound for others
45 Distribution input2-Value of lower bound
46 Dont pass any thing if any of the distribution has no distribution input 2.
47
48 2)ldArrival-Arrival time of the last frame.
49 3)unsigned long uSeed,unsigned long uSeed1-Seed values for packet size
50 4)unsigned long uSeed2,unsigned long uSeed3-Seed values for inter arrival time
51 Return Value:pointer to an array of long double
52 1st element:packet size
53 2nd element:arrival time
54 3rd,4th element:seed values for packet size
55 5th,6th element:seed values for inter arrival time
56 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57 */
58
60 double* fSize,
61 double* ldArrival,
62 unsigned long* uSeed,
63 unsigned long* uSeed1,
64 unsigned long* uSeed2,
65 unsigned long* uSeed3)
66{
67 double time=0.0;
68 do
69 {
70 fnDistribution(info->packetSizeDistribution, fSize, uSeed,uSeed1,info->dPacketSize);
71 }while(*fSize <= 1.0);
72 //Call the fn in Distribution DLL to generate inter arrival time
73 do
74 {
75 fnDistribution(info->IATDistribution,&time,uSeed,uSeed1,info->dIAT);
76 }while (time <= 0.0);
77 *ldArrival = *ldArrival + time;
78 return 1;
79}
80
81/** This function is used to start the Database, FTP and Custom applications */
83{
84 APP_DATA_INFO* info = (APP_DATA_INFO*)appInfo->appData;
85
86 if (appInfo->dEndTime <= time)
87 return 0;
88
89 NETSIM_ID nSource = appInfo->sourceList[0];
90
91 NETSIM_ID* nDestination = appInfo->destList;
92 UINT destCount = appInfo->nDestCount;
93
94 double arrivalTime = 0;
95 double packetSize = 0;
96
97 fnCreatePort(appInfo);
98
99 //Create the socket buffer
100 fnCreateSocketBuffer(appInfo);
101
102 if (appInfo->nTransmissionType == MULTICAST)
103 {
104 add_multicast_route(appInfo);
105 join_multicast_group(appInfo, time);
106 }
107
108 //Generate the app start event
109 fn_NetSim_TrafficGenerator_Custom((APP_DATA_INFO*)appInfo->appData, &packetSize, &arrivalTime,
110 &(NETWORK->ppstruDeviceList[nSource - 1]->ulSeed[0]),
111 &(NETWORK->ppstruDeviceList[nSource - 1]->ulSeed[1]),
112 &(NETWORK->ppstruDeviceList[nSource - 1]->ulSeed[0]),
113 &(NETWORK->ppstruDeviceList[nSource - 1]->ulSeed[1]));
114
115 if(!appInfo->nPacketId)
116 arrivalTime = 0; // Based on feedback from an impotant customer. This can be modified to start between O to IAT since no network starts
117 // tranmitting packet at time 0.
118
119 if (appInfo->dEndTime <= time + arrivalTime) return 0; // Next packet generation rate is after end time
120
121 pstruEventDetails->dEventTime = time + arrivalTime;
122 pstruEventDetails->dPacketSize = packetSize;
124 pstruEventDetails->nDeviceId = nSource;
134 nSource,
135 destCount,
136 nDestination,
137 ++appInfo->nPacketId,
138 appInfo->nAppType,
139 appInfo->qos,
140 appInfo->sourcePort,
141 appInfo->destPort);
145 return 0;
146}
147
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
void add_multicast_route(ptrAPPLICATION_INFO info)
int fnCreateSocketBuffer(ptrAPPLICATION_INFO appInfo)
int fn_NetSim_TrafficGenerator_Custom(APP_DATA_INFO *info, double *fSize, double *ldArrival, unsigned long *uSeed, unsigned long *uSeed1, unsigned long *uSeed2, unsigned long *uSeed3)
void join_multicast_group(ptrAPPLICATION_INFO info, double time)
int fnDistribution(DISTRIBUTION nDistributionType, double *fDistOut, unsigned long *uSeed, unsigned long *uSeed1, double *args)
Definition: Distribution.c:17
void fnCreatePort(ptrAPPLICATION_INFO info)
@ event_APP_START
Definition: Application.h:54
int fn_NetSim_Application_StartDataAPP(ptrAPPLICATION_INFO appInfo, double time)
#define UINT
Definition: Linux.h:38
#define _declspec(dllexport)
This function is used to trigger the update.
Definition: Linux.h:41
#define PROTOCOL_APPLICATION
Definition: Stack.h:143
#define DEVICE_TYPE(DeviceId)
Definition: Stack.h:773
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
@ MULTICAST
Definition: Stack.h:365
#define fnpAddEvent(pstruEvent)
Definition: main.h:191
Structure for Data information such as packet size and inter arrival time,this is applicable for cust...
Definition: Application.h:140
DISTRIBUTION IATDistribution
Definition: Application.h:143
DISTRIBUTION packetSizeDistribution
Definition: Application.h:141
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
TRANSMISSION_TYPE nTransmissionType
Definition: Application.h:101
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