Commit 150b92a3 authored by Ulysse Beaugnon's avatar Ulysse Beaugnon

A peer now only advertise one route for its /64 instead of 3 (/64, /128, /128 anycast)

parent 4f82d0fa
......@@ -2,14 +2,15 @@ Bug :
possible bug in the upnp refresh, when refreshing after a too long time
To be done :
Choose the db size and who peers are deleted
Choose the db size and how peers are deleted
find out who to have an automatic recovery without declare
Test the package
PB : at the beggining a node tries to find 10 other nodes so ask for 10 bootsrap nodes
This slow the beginning !!
at the beggining a node tries to find 10 other nodes so ask for 10 bootsrap nodes
This slow the beginning and might overload the server
If their is too many nodes flaged as bad, the node never ask for some bootstrap peer
When a node arrive it is in nobody DB => very slow beginning. It should advertise itself more
When a node arrive it is in nobody DB => very slow beginning. It should advertise itself more.
check the ips attributed
remove decalre
......
......@@ -119,8 +119,8 @@ class PeerManager:
except sqlite3.IntegrityError, e:
if e.args[0] != 'column prefix is not unique':
raise
#except Exception, e:
# logging.info('Unable to bootstrap : %s' % e)
except Exception, e:
logging.info('Unable to bootstrap : %s' % e)
return False
def usePeer(self, prefix):
......
......@@ -62,12 +62,14 @@ def client(server_address, pipe_fd, hello_interval, encrypt, *args, **kw):
return openvpn(hello_interval, encrypt, *remote, **kw)
def router(network, internal_ip, interface_list,
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' % (internal_ip),
'-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',
# Route VIFIB ip adresses
'-C', 'in ip %s::/%u' % (utils.ipFromBin(network), len(network)),
# Route only addresse in the 'local' network,
......
......@@ -135,7 +135,7 @@ class TunnelManager:
iface = line[-1]
subnet_size = int(line[1], 16)
logging.trace('Route on iface %s detected to %s/%s'
% (iface, ip, subnet_size))
% (iface, line[0], subnet_size))
if iface in self._iface_to_prefix.keys():
self._connection_dict[self._iface_to_prefix[iface]].routes += 1
if iface in self._iface_list and self._net_len < subnet_size < 128:
......@@ -168,7 +168,7 @@ class TunnelManager:
if self._peer_db.address:
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.debug('Notifying peer %s' % ip)
logging.trace('Notifying peer %s' % ip)
sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
sock.sendto('%s %s\n' % (self._prefix, utils.address_str(self._peer_db.address)), (ip, 326))
except socket.error, e:
......
......@@ -153,8 +153,9 @@ def main():
interface_list = list(tunnel_manager.free_interface_set) \
+ config.iface_list + list(iface
for _, _, iface in config.pp)
router = plib.router(network, internal_ip, interface_list, config.wireless,
config.hello, os.path.join(config.state, 'babeld.state'),
subnet = utils.ipFromBin((network + prefix).ljust(128, '0'))
router = plib.router(network, subnet, len(prefix) + len(network), interface_list,
config.wireless, config.hello, os.path.join(config.state, 'babeld.state'),
stdout=os.open(os.path.join(config.log, 'babeld.log'),
os.O_WRONLY | os.O_CREAT | os.O_TRUNC), stderr=subprocess.STDOUT)
......
......@@ -110,6 +110,56 @@ 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];
......
......@@ -89,6 +89,8 @@ void testOptimized(int size, int k, int maxPeer, int seed, Latency* latency, con
fflush(output);
fsync(fno);
graph.Reboot(1.0/(2500 + 1.0), i);
cout << "\r" << i+1 << "/" << 3000;
cout.flush();
}
......@@ -121,9 +123,7 @@ void Optimize(int size, int k, int maxPeer, int seed, Latency* latency, const ch
double nRoutesKilled = 0;
int arityDistrib[maxPeer+1];
//graph.Reboot(1.0/(100 + 1.0), i);
for(int i=0; i<3000; i++)
for(int i=0; i<1000; i++)
{
vector<future<pair<double, double>>> threads;
for(int a=0; a<range; a++)
......@@ -172,6 +172,8 @@ void Optimize(int size, int k, int maxPeer, int seed, Latency* latency, const ch
fflush(output);
fsync(fno);
graph->Reboot(1.0/(2500 + 1.0), i);
cout << "\r" << i+1 << "/" << 3000;cout.flush();
}
......@@ -191,7 +193,7 @@ 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];
......@@ -201,9 +203,9 @@ int main(int argc, char** argv)
}
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;
......
......@@ -46,6 +46,7 @@ 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)
private:
void SaturateNode(int node);
......
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