-
Notifications
You must be signed in to change notification settings - Fork 2
/
params.c
46 lines (36 loc) · 933 Bytes
/
params.c
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
/**********************
*
* Progam Name: MP1. Membership Protocol
*
* Current file: params.c
* About this file: Setting Parameters.
*
***********************/
#include "params.h"
short PORTNUM = 8001;
extern int globaltime;
/*
Set all the parameters.
*/
void setparams(char *config_file){
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);
printf("%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;
fclose(fp);
return;
}
/*
Return time since start of program, in time units.
For a 'real' implementation, this return time would be the UTC time.
*/
int getcurrtime(){
return globaltime;
}