-
Notifications
You must be signed in to change notification settings - Fork 0
/
basestation.h
253 lines (219 loc) · 8.14 KB
/
basestation.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
//basestation.h
#define _FILE_OFFSET_BITS 64
#define STRINGIZING(x) #x
#include "basic.h"
#include "list.h"
typedef struct settings_struct {
double sampletime; // inter-sample time
double arrivalmean1; // arrival mean class 1
double arrivalmean2; // arrival mean class 2
double servicemeanclet1; // clet1 stands for cloudlet class 1
double servicemeanclet2; // clet2 stands for cloudlet class 2
double servicemeanc1; // c1 stands for cloud class 1
double servicemeanc2; // c2 stands for cloud class 2
double migrationdelay; // migration mean delay
double simulationlength;
double starttoprint; // time when start to print statistic (usually 0.0)
int capacity; // max number of jobs at the same time in service
int threshold;
int seed;
int arrivalstream1;
int arrivalstream2;
int leavestreamclet1;
int leavestreamclet2;
int leavestreamc1;
int leavestreamc2;
int migrationdelaystream;
int iteration; // number of run's iterations
int finalvaluefiles;
int printinters; //print throughput, interarrival and interdeparture
} settings_struct;
typedef struct folder_struct { // folders and paths
char *folderSIMULATIONS;
char *folderACTUAL;
char *pathThroughputMean;
char *pathResponseTimeMean;
char *pathCloudletResponseTimeMean;
char *pathCloudResponseTimeMean;
char *pathMigrationPercentageMean;
char *pathClass1ResponseTimeMean;
char *pathClass2ResponseTimeMean;
char *pathClass1CletJobsMean;
char *pathClass2CletJobsMean;
char *pathClass1JobsMean;
char *pathClass1CJobsMean;
char *pathClass2CJobsMean;
char *pathClass2JobsMean;
char *pathJobsMean;
char *pathUtilizationMean;
char *pathJoinedUsers;
char *pathLeavedUsers;
char *pathArrivalFreq;
char *pathThroughput;
char *pathInterdeparture;
char *pathInterarrival;
} folder_struct;
typedef struct fd_struct { //file descriptors
int fdThroughputMean;
int fdResponseTimeMean;
int fdClass1ResponseTimeMean;
int fdClass2ResponseTimeMean;
int fdClass1CletJobsMean;
int fdClass2CletJobsMean;
int fdClass1JobsMean;
int fdClass1CJobsMean;
int fdClass2CJobsMean;
int fdClass2JobsMean;
int fdJobsMean;
int fdUtilizationMean;
int fdJoinedUsers;
int fdLeavedUsers;
int fdGeneralInfo;
} fd_struct;
typedef struct fdFinalValue_struct {
int fdThroughputMeanFinal;
int fdResponseTimeMeanFinal;
int fdClass1ResponseTimeMeanFinal;
int fdClass2ResponseTimeMeanFinal;
int fdClass1CletJobsMeanFinal;
int fdClass2CletJobsMeanFinal;
int fdClass1JobsMeanFinal;
int fdClass1CJobsMeanFinal;
int fdClass2CJobsMeanFinal;
int fdClass2JobsMeanFinal;
int fdJobsMeanFinal;
int fdUtilizationMeanFinal;
int fdJoinedUsersFinal;
int fdLeavedUsersFinal;
int fdMigrationProbabilityFinal;
} fdFinalValue_struct;
typedef struct fdRun_struct {
int fdThroughputMeanTemp;
int fdResponseTimeMeanTemp;
int fdResponseCloudletTimeMeanTemp;
int fdResponseCloudTimeMeanTemp;
int fdMigrationPercentageMeanTemp;
int fdClass1ResponseTimeMeanTemp;
int fdClass2ResponseTimeMeanTemp;
int fdClass1CletJobsMeanTemp;
int fdClass2CletJobsMeanTemp;
int fdClass1JobsMeanTemp;
int fdClass1CJobsMeanTemp;
int fdClass2CJobsMeanTemp;
int fdClass2JobsMeanTemp;
int fdJobsMeanTemp;
int fdUtilizationMeanTemp;
int fdJoinedUsersTemp;
int fdLeavedUsersTemp;
int fdArrivalFreqTemp;
int fdThroughputTemp;
int fdInterdepartureTemp;
int fdInterarrivalTemp;
} fdRun_struct;
typedef struct fptr_struct { // file pointers
FILE* fptrThroughputMean;
FILE* fptrResponseTimeMean;
FILE* fptrClass1ResponseTimeMean;
FILE* fptrClass2ResponseTimeMean;
FILE* fptrClass1CletJobsMean;
FILE* fptrClass2CletJobsMean;
FILE* fptrClass1JobsMean;
FILE* fptrClass1CJobsMean;
FILE* fptrClass2CJobsMean;
FILE* fptrClass2JobsMean;
FILE* fptrJobsMean;
FILE* fptrUtilizationMean;
FILE* fptrJoinedUsers;
FILE* fptrLeavedUsers;
} fptr_struct;
typedef struct stats_struct {
double universalTime; //E' il current time.
double UtilizationMean; //
double UtilizationMeanLastUpdate; //Tempo nel quale è stata aggiornata per l'ultima volta-
double ThroughputMean; //la rispettiva variabile.
double Class1CletJobsMean; //Con Clet si intende cloudlet.
double Class1CletJobsMeanLastUpdate; //
double Class2CletJobsMean; //
double Class2CletJobsMeanLastUpdate; //
double Class1JobsMean; //
double Class1JobsMeanLastUpdate; //
double Class1CJobsMean; //Con C si intende cloud.
double Class1CJobsMeanLastUpdate; //
double Class2CJobsMean; //
double Class2CJobsMeanLastUpdate; //
double Class2JobsMean; //
double Class2JobsMeanLastUpdate; //
double JobsMean; //
double JobsMeanLastUpdate; //
double ResponseTimeMean; //
double CloudletResponseTimeMean; //
double CloudResponseTimeMean; //
double Class1ResponseTimeMean; //
double Class2ResponseTimeMean; //
double LastArrivalTime; //
double LastDepartureTime; //
int samples; //
int ArrivedJobsFromLastSample; //
int LeavedJobsFromLastSample; //
int ArrivedJobsFromBigBang; //
int LeavedJobsFromBigBang; //
int LeavedClass1JobsFromBigBang; //
int LeavedClass2JobsFromBigBang; //
int ArrivedClass2CletJobsFromBigBang; //
int MigratedJobsFromBigBang; //
int Class1CletJobs; //Il numero di jobs della rispettiva classe nel-
int Class2CletJobs; //rispettivo server al tempo universalTime.
int Class1CJobs; //
int Class2CJobs; //
} stats_struct;
void checksettings(settings_struct*);
void initoutputfiles(folder_struct,fd_struct*);
void initoutputfilesFinalValue(folder_struct,fdFinalValue_struct*);
void initEventList(list*,settings_struct settingsSettings);
void samplingEvent(list*,settings_struct,stats_struct *,fdRun_struct);
void C1ArrivalEvent(list*,settings_struct,stats_struct*,fdRun_struct);
void C2ArrivalEvent(list*,settings_struct,stats_struct*,fdRun_struct);
void Clet1DepartureEvent(stats_struct*,double,settings_struct,fdRun_struct);
void Clet2DepartureEvent(stats_struct*,double,settings_struct,fdRun_struct);
void C1DepartureEvent(stats_struct*,double,settings_struct,fdRun_struct);
void C2DepartureEvent(stats_struct*,double,settings_struct,fdRun_struct);
void updateResponseTimeMean(double arrivalTime, stats_struct *);
void updateClass1ResponseTimeMean(double arrivalTime, stats_struct *);
void updateClass2ResponseTimeMean(double arrivalTime, stats_struct *);
void updateUtilization(settings_struct, stats_struct *);
void updateClass1CletJobsMean(stats_struct *statsStruct);
void updateClass2CletJobsMean(stats_struct *statsStruct);
void updateClass1JobsMean(stats_struct *statsStruct);
void updateClass1CJobsMean(stats_struct *statsStruct);
void updateClass2CJobsMean(stats_struct *statsStruct);
void updateClass2JobsMean(stats_struct *statsStruct);
void updateJobsMean(stats_struct *statsStruct);
void updateInterarrival(settings_struct settingsStruct,stats_struct *statsStruct,fdRun_struct fdRunStruct);
void updateInterdeparture(settings_struct settingsStruct,stats_struct *statsStruct,fdRun_struct fdRunStruct);
void printFinalInformations(uintmax_t,uintmax_t,struct tm,fd_struct,settings_struct);
void getElapsedTime(struct timeval,struct timeval,uintmax_t *,uintmax_t *);
void closeFiles(fd_struct);
void closeRunFiles(fdRun_struct);
void closeFinalValueFiles(fdFinalValue_struct);
void createFolders(struct tm lt, folder_struct*);
void initRunOutputFiles(int,folder_struct,fdRun_struct*);
void mergeRunFiles(settings_struct,folder_struct,fd_struct);
void openOnlyReadFiles(int,folder_struct,fptr_struct*);
void samplingFinalValue(settings_struct,stats_struct,fdFinalValue_struct);
void closeOnlyReadFiles(fptr_struct);
void wellfordOnePass(double*,double,int);
void wellfordSamplePath(double*,double,double,double);
double getWellfordOnePass(double,double,int);
double getWellfordSamplePath(double,double,double,double);
void readAndWrite(int,uintmax_t *,
int8_t *,FILE *,
int ,off_t *,
char **,size_t *,uintmax_t *);
void addNewLine(uintmax_t, int, int);
void addC1departure(list*, stats_struct, settings_struct);
void addClet1departure(list *, stats_struct, settings_struct);
void addArrival1(list*, stats_struct, settings_struct);
void addC2departure(list *, stats_struct, settings_struct);
void addClet2departure(list *, stats_struct, settings_struct);
void addArrival2(list *, stats_struct, settings_struct);
void migrateClass2FromCletToC(list *,settings_struct, stats_struct);