-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
81 lines (67 loc) · 1.72 KB
/
main.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* MPTCP-sim simulator entry point
*/
#include "clock.h"
#include "eventlist.h"
#include "logfile.h"
#include "test.h"
using namespace std;
int parseArgs(int argc, char *argv[], ArgList &args);
void
printUsage()
{
cerr << "Usage:" << endl;
cerr << "./htsim --expt=XX [--<arg1>=<value> --<arg2>=<value> ...]" << endl;
cerr << endl << "Experiment List" << endl;
print_experiment_list();
}
int
main(int argc,
char *argv[])
{
ArgList args;
parseArgs(argc, argv, args);
string logpath = "data/htsim-log";
if (args.find("logfile") != args.end()) {
logpath = args["logfile"];
}
uint32_t rngSeed = 1729;
parseInt(args, "rngseed", rngSeed);
srand(rngSeed);
uint32_t expt = 0;
parseInt(args, "expt", expt);
if (expt == 0) {
printUsage();
return 0;
}
EventList &eventlist = EventList::Get();
Logfile logfile(logpath);
/* Run desired experiment. Complete list defined in <test.h> */
if (run_experiment(expt, args, logfile)) {
cerr << "Unknown experiment number\n";
exit(0);
}
// Run the simulation!
Clock c;
while (eventlist.doNextEvent()) {}
cerr << "\nExiting successfully!" << endl;
return 0;
}
int
parseArgs(int argc,
char *argv[],
ArgList &args)
{
for (int i = 1; i < argc; i++) {
if (argv[i][0] != '-' || argv[i][1] != '-') {
cerr << "Ignoring argument (" << i << ") : " << argv[i] << endl;
continue;
}
char *tok = strchr(argv[i], '=');
string arg = string(argv[i] + 2, tok - argv[i] - 2);
string val = string(tok + 1);
cerr << arg << " : " << val << endl;
args[arg] = val;
}
return 0;
}