Commit 9abaa20d authored by Ulysse Beaugnon's avatar Ulysse Beaugnon

the babeld configuration now allows /128 subnets

parent f098a0c4
......@@ -17,7 +17,3 @@ To be done :
Put a section about how to build the package from the sources in the README
http://pdos.csail.mit.edu/p2psim/kingdata/
http://www.eecs.harvard.edu/~syrah/nc/king/lats.n8.gz
http://www.cs.cornell.edu/People/egs/meridian/data.php
......@@ -66,12 +66,14 @@ def router(network, subnet, subnet_size, interface_list,
wireless, hello_interval, state_path, **kw):
logging.info('Starting babel...')
args = ['babeld',
'-C', 'redistribute local ip %s/%s le %s' % (subnet, subnet_size, subnet_size),
'-C', 'redistribute local ip %s/%s le %s' % (subnet, subnet_size, subnet_size),
'-C', 'redistribute local deny',
'-C', 'redistribute ip %s/%s le %s' % (subnet, subnet_size, subnet_size),
'-C', 'redistribute deny',
'-C', 'out local ip %s/%s le %s' % (subnet, subnet_size, subnet_size),
'-C', 'out local deny',
# Route VIFIB ip adresses
'-C', 'in ip %s::/%u le 127' % (utils.ipFromBin(network), len(network)),
'-C', 'in ip %s::/%u' % (utils.ipFromBin(network), len(network)),
# Route only addresse in the 'local' network,
# or other entire networks
#'-C', 'in ip %s' % (config.internal_ip),
......
......@@ -151,7 +151,7 @@ class TunnelManager:
if not self._fast_start_done and len(possiblePeers) > 4:
nSend = min(self._peer_db.db_size, len(possiblePeers))
else:
nSend = min(4, len(possiblePeers))
nSend = min(2, len(possiblePeers))
for ip in random.sample(possiblePeers, nSend):
self._notifyPeer(ip)
......@@ -179,7 +179,7 @@ class TunnelManager:
ip = '%s:%s:%s:%s:%s:%s:%s:%s' % (peerIp[0:4], peerIp[4:8], peerIp[8:12],
peerIp[12:16], peerIp[16:20], peerIp[20:24], peerIp[24:28], peerIp[28:32])
logging.trace('Notifying peer %s' % ip)
self.peer_db.sock.sendto('%s %s\n' % (self._prefix, utils.address_str(self._peer_db.address)), (ip, 326))
self._peer_db.sock.sendto('%s %s\n' % (self._prefix, utils.address_str(self._peer_db.address)), (ip, 326))
except socket.error, e:
logging.debug('Unable to notify %s' % ip)
logging.debug('socket.error : %s' % e)
This diff is collapsed.
This diff is collapsed.
......@@ -110,56 +110,6 @@ void Graph::GetRoutesFrom(int from, int* nRoutes, int* prevs, int* distances)
}
}
void Graph::GetRoutesFromHop(int from, int* nRoutes, int* prevs, int* distances)
{
// init vars
stack<int> order;
for(int i=0; i<size; i++)
{
distances[i] = -1;
nRoutes[i] = 1;
}
distances[from] = 0;
priority_queue<pair<int, int>> remainingNodes;
remainingNodes.push(pair<int, int>(-0, from));
// Get the order
while(!remainingNodes.empty())
{
pair<int, int> p = remainingNodes.top();
int node = p.second;
int d = -p.first;
remainingNodes.pop();
if(d == distances[node])
{
order.push(node);
for(int neighbor : adjacency[node])
{
int neighborDist = d + 1;
if(distances[neighbor] == -1 || distances[neighbor] > neighborDist)
{
distances[neighbor] = neighborDist;
prevs[neighbor] = node;
remainingNodes.push(pair<int, int>(-neighborDist, neighbor));
}
}
}
}
// get the BC
while(!order.empty())
{
int node = order.top();
order.pop();
if(distances[node] != -1 && node != from)
nRoutes[prevs[node]] += nRoutes[node];
}
}
routesResult Graph::GetRouteResult(int node, int nRefresh, double* bc)
{
int nRoutes[size], prevs[size], distances[size];
......@@ -414,4 +364,47 @@ void Graph::GetArity(int* arity)
for(int i=0; i<size; i++)
arity[adjacency[i].size()]++;
}
void Graph::GetArityLat(int arity[][10])
{
for(int i=0; i<10; i++)
for(int a=0; a<=maxPeers; a++)
arity[a][i] = 0;
for(int i=0; i<size; i++)
arity[adjacency[i].size()][max(min((int)(latency->avgLatencyToOthers[i] - 45000)/5000, 9), 0)]++;
}
double Graph::GetAvgDistanceHop()
{
double avgDist = 0;
int distances[size];
for(int from=0; from<size; from++)
{
for(int i=0; i<size; i++)
distances[i] = -1;
distances[from] = 0;
queue<int> remainingNodes;
remainingNodes.push(from);
// Get the order
while(!remainingNodes.empty())
{
int node = remainingNodes.front();
remainingNodes.pop();
avgDist += distances[node];
for(int neighbor : adjacency[node])
if(distances[neighbor] == -1)
{
distances[neighbor] = distances[node] + latency->values[neighbor][node];
remainingNodes.push(neighbor);
}
}
}
return avgDist/(size*size);
}
\ No newline at end of file
......@@ -3,6 +3,7 @@
Latency::Latency(const char* filePath, int size) : size(size)
{
values = new int*[size];
avgLatencyToOthers = new double[size];
for(int i=0; i<size; i++)
{
values[i] = new int[size];
......@@ -26,6 +27,14 @@ Latency::Latency(const char* filePath, int size) : size(size)
values[a-1][b-1] = latency;
}
for(int i=0; i<size; i++)
{
avgLatencyToOthers[i] = 0;
for(int j=0;j<size; j++)
avgLatencyToOthers[i] += values[i][j];
avgLatencyToOthers[i] /= size;
}
fclose(file);
}
......
// To compile : g++ -std=c++0x latency.cpp graph.cpp main.cpp -lpthread
// The best distance for latency : 66.9239 with a full graph
// other dataset : http://pdos.csail.mit.edu/p2psim/kingdata/
// for latency_2 :
// Optimal distance : 16085.3
......@@ -14,6 +13,9 @@ void simulate(int size, int k, int maxPeer, int seed, Latency* latency, const ch
FILE* output = fopen(outName, "wt");
int fno = fileno(output);
double nRoutesKilled = 0;
int arityLatDistrib[maxPeer+1][10];
double avgDistance, unreachable;
double arityDistrib[31], bcArity[31];
Graph graph(size, k, maxPeer, rng, latency);
......@@ -32,16 +34,23 @@ void simulate(int size, int k, int maxPeer, int seed, Latency* latency, const ch
}*/
double avgDistance, unreachable;
double arityDistrib[31], bcArity[31];
graph.Reboot(1.0/(100 + 1.0), i);
//graph.Reboot(1.0/(100 + 1.0), i);
graph.UpdateLowRoutes(avgDistance, unreachable, nRoutesKilled, arityDistrib, bcArity, 1, i);
graph.GetArityLat(arityLatDistrib);
fprintf(output, "%d,%f,%f", i, avgDistance, nRoutesKilled);
for(int j=0; j<=30; j++)
fprintf(output, "%d,%f,%f,A", i, avgDistance, nRoutesKilled);
for(int j=k; j<=30; j++)
fprintf(output, ",%f", arityDistrib[j]);
for(int j=0; j<=30; j++)
fprintf(output, ",B");
for(int j=k; j<=30; j++)
fprintf(output, ",%f", bcArity[j]);
for(int j=0; j<10; j++)
{
fprintf(output, ",L%d", j);
for(int a=k; a<=maxPeer; a++)
fprintf(output, ",%d", arityLatDistrib[a][j]);
}
fprintf(output, "\n");
fflush(output);
fsync(fno);
......@@ -181,11 +190,29 @@ void Optimize(int size, int k, int maxPeer, int seed, Latency* latency, const ch
cout << endl;
}
string computeDist(int size, int k, int maxPeer, int seed, Latency* latency)
{
mt19937 rng(seed);
Graph graph(size, k, maxPeer, rng, latency);
double avgDistLatency = 0;
int nRoutes[size], prevs[size], distances[size];
for(int i=0; i<size; i++)
{
graph.GetRoutesFrom(i, nRoutes, prevs, distances);
for(int j=0; j<size; j++)
avgDistLatency += distances[j];
}
ostringstream out;
out << avgDistLatency / (size*size) << ","
<< graph.GetAvgDistanceHop() << endl;
return out.str();
}
int main(int argc, char** argv)
{
mt19937 rng(time(NULL));
//Latency latencyR("latency/pw-1715/pw-1715-latencies", 1715);
//latencyR.Rewrite(20);
Latency* latency = new Latency("datasets/latency_2_2500", 2500);
//cout << "Optimal distance : " << latency->GetAverageDistance() << endl;
......@@ -193,19 +220,19 @@ int main(int argc, char** argv)
vector<future<void>> threads;
/*for(int i=0; i<1; i++)
for(int i=0; i<1; i++)
{
int seed = rng();
char* out = new char[100];
sprintf(out, "test_optimized_%d.csv", i);
sprintf(out, "out_%d.csv", i);
threads.push_back(async(launch::async, [seed, out, latency]()
{ testOptimized(2500, 10, 30, seed, latency, out); delete[] out; }));
{ simulate(2500, 10, 30, seed, latency, out); delete[] out; }));
}
for(int i=0; i<4; i++)
threads[i].get();*/
threads[i].get();
Optimize(2500, 10, 30, rng(), latency, "out.csv");
//Optimize(2500, 10, 30, rng(), latency, "out.csv");
delete latency;
return 0;
......
......@@ -29,6 +29,7 @@ public:
double GetAverageDistance();
double GetAveragePing();
int** values;
double* avgLatencyToOthers;
private:
int size;
......@@ -46,13 +47,14 @@ public:
void KillMachines(float proportion);
pair<double, double> UpdateLowRoutesArity(int arityToUpdate);
void GetArity(int* arity);
void GetRoutesFromHop(int from, int* nRoutes, int* prevs, int* distances)
void GetRoutesFrom(int from, int* nRoutes, int* prevs, int* distances);
double GetAvgDistanceHop();
void GetArityLat(int arity[][10]);
private:
void SaturateNode(int node);
bool AddEdge(int from);
void RemoveEdge(int from, int to);
void GetRoutesFrom(int from, int* nRoutes, int* prevs, int* distances);
int CountUnreachableFrom(int node);
routesResult GetRouteResult(int node, int nRefresh, double* bc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment