-
Notifications
You must be signed in to change notification settings - Fork 6
/
routesim.cc
52 lines (38 loc) · 923 Bytes
/
routesim.cc
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
#include "context.h"
#include <stdlib.h>
#include "node.h"
#include "link.h"
#include <iomanip>
int main(int argc, char **argv)
{
bool singlestep;
string topofile, eventfile;
if (argc<3 || argc>4 ) {
cerr <<"routesim topologyfile eventfile [singlestep]"<<endl;
exit(-1);
}
singlestep=(argc==4);
topofile=argv[1];
eventfile=argv[2];
SimulationContext c;
c.LoadTopology(topofile);
//cerr << c <<endl;
c.LoadEvents(eventfile);
c.Init();
//cerr << c << endl;
cerr << setprecision(20);
Event *e;
while ((e=c.GetEarliestEvent())) {
if (singlestep) {
cerr << "=============================================================\n"
<< "======Dispatching: "<<*e << endl;
}
c.DispatchEvent(e);
if (singlestep) {
char buf[1024];
cerr << "======Done. Hit Enter to continue";
fflush(stdin);
fgets(buf,1024,stdin);
}
}
}