-
Notifications
You must be signed in to change notification settings - Fork 0
/
Params.cpp
67 lines (59 loc) · 1.62 KB
/
Params.cpp
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
/**********************************
* FILE NAME: Params.cpp
*
* DESCRIPTION: Definition of Parameter class
**********************************/
#include "Params.h"
/**
* Constructor
*/
Params::Params(): PORTNUM(8001) {}
/**
* FUNCTION NAME: setparams
*
* DESCRIPTION: Set the parameters for this test case
*/
void Params::setparams(char *config_file) {
//trace.funcEntry("Params::setparams");
char CRUD[10];
FILE *fp = fopen(config_file,"r");
fscanf(fp,"MAX_NNB: %d", &MAX_NNB);
fscanf(fp,"\nSINGLE_FAILURE: %d", &SINGLE_FAILURE);
fscanf(fp,"\nDROP_MSG: %d", &DROP_MSG);
fscanf(fp,"\nMSG_DROP_PROB: %lf", &MSG_DROP_PROB);
fscanf(fp,"\nCRUD_TEST: %s", CRUD);
if ( 0 == strcmp(CRUD, "CREATE") ) {
this->CRUDTEST = CREATE_TEST;
}
else if ( 0 == strcmp(CRUD, "READ") ) {
this->CRUDTEST = READ_TEST;
}
else if ( 0 == strcmp(CRUD, "UPDATE") ) {
this->CRUDTEST = UPDATE_TEST;
}
else if ( 0 == strcmp(CRUD, "DELETE") ) {
this->CRUDTEST = DELETE_TEST;
}
//printf("Parameters of the test case: %d %d %d %lf\n", MAX_NNB, SINGLE_FAILURE, DROP_MSG, MSG_DROP_PROB);
EN_GPSZ = MAX_NNB;
STEP_RATE=.25;
MAX_MSG_SIZE = 4000;
globaltime = 0;
dropmsg = 0;
allNodesJoined = 0;
for ( unsigned int i = 0; i < EN_GPSZ; i++ ) {
allNodesJoined += i;
}
fclose(fp);
//trace.funcExit("Params::setparams", SUCCESS);
return;
}
/**
* FUNCTION NAME: getcurrtime
*
* DESCRIPTION: Return time since start of program, in time units.
* For a 'real' implementation, this return time would be the UTC time.
*/
int Params::getcurrtime(){
return globaltime;
}