NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
Database_FTP_Custom.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 "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
59_declspec(dllexport) int fn_NetSim_TrafficGenerator_Custom(APP_DATA_INFO* info,
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 */
82int fn_NetSim_Application_StartDataAPP(ptrAPPLICATION_INFO appInfo, double time)
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;
123 pstruEventDetails->nApplicationId = appInfo->id;
124 pstruEventDetails->nDeviceId = nSource;
125 pstruEventDetails->nDeviceType = DEVICE_TYPE(nSource);
126 pstruEventDetails->nEventType = TIMER_EVENT;
127 pstruEventDetails->nInterfaceId = 0;
128 pstruEventDetails->nProtocolId = PROTOCOL_APPLICATION;
129 pstruEventDetails->nSegmentId = 0;
130 pstruEventDetails->nSubEventType = event_APP_START;
131 pstruEventDetails->pPacket =
132 fn_NetSim_Application_GeneratePacket(appInfo,
133 pstruEventDetails->dEventTime,
134 nSource,
135 destCount,
136 nDestination,
137 ++appInfo->nPacketId,
138 appInfo->nAppType,
139 appInfo->qos,
140 appInfo->sourcePort,
141 appInfo->destPort);
142 pstruEventDetails->szOtherDetails = appInfo;
143 pstruEventDetails->nPacketId = appInfo->nPacketId;
144 fnpAddEvent(pstruEventDetails);
145 return 0;
146}
147