Accept multiple --ip arguments
[re6stnet.git] / simulation / realistic_dataset / main.h
1 #include <iostream>
2 #include <vector>
3 #include <random>
4 #include <queue>
5 #include <stack>
6 #include <unordered_set>
7 #include <future>
8 #include <sstream>
9 #include <unistd.h>
10 #include <limits>
11
12 using namespace std;
13
14 struct routesResult
15 {
16 double avgDistance;
17 int arity;
18 int unreachable;
19 int routesToDelete;
20 stack<int> toDelete;
21 };
22
23 class Latency
24 {
25 public:
26 Latency(const char* filePath, int size);
27 void Rewrite(int n);
28 ~Latency();
29 double GetAverageDistance();
30 double GetAveragePing();
31 int** values;
32 double* avgLatencyToOthers;
33
34 private:
35 int size;
36 };
37
38 class Graph
39 {
40 public:
41 Graph(int size, int k, int maxPeers, mt19937& generator, Latency* latency, double minKillProba, double maxKillProba);
42 Graph(Graph& g);
43 ~Graph() { delete[] adjacency; delete[] generated; delete[] killProba;};
44 int UpdateLowRoutes(double& avgDistance, double& unreachable, double& nRoutesKilled, double* arityDistrib, double* bcArity, int nRefresh, int round);
45 double GetUnAvalaibility();
46 void Reboot();
47 void KillMachines(float proportion);
48 pair<double, double> UpdateLowRoutesArity(int arityToUpdate);
49 void GetArity(int* arity);
50 void GetRoutesFrom(int from, int* nRoutes, int* prevs, int* distances);
51 double GetAvgDistanceHop();
52 void GetArityLat(int arity[][10]);
53 void GetArityKill(int arity[][10]);
54
55 private:
56 void SaturateNode(int node);
57 bool AddEdge(int from);
58 void RemoveEdge(int from, int to);
59 int CountUnreachableFrom(int node);
60 routesResult GetRouteResult(int node, int nRefresh, double* bc);
61
62 mt19937 generator;
63 uniform_int_distribution<int> distrib;
64 int maxPeers;
65 int k;
66 int size;
67
68 unordered_set<int>* adjacency;
69 unordered_set<int>* generated;
70 Latency* latency;
71 double* killProba;
72 };