Browse Source

Add stubs, neighbors, etc to crawl data

* mark networks as stubs that are never seen in the middle of an aspath
 * add number of neighbors to each node
 * fix bug where route was an unbound variable
master
Sebastian Lohff 2 years ago
parent
commit
f898cd8d40
  1. 11
      backend/crawler.py
  2. 2
      backend/gobgp.py

11
backend/crawler.py

@ -53,6 +53,10 @@ def crawl(): @@ -53,6 +53,10 @@ def crawl():
asneigh = ASLastSeenNeighbor(asn=neigh, neighbor=asls)
asneigh.save()
db_neighs.add(neigh)
crawl.endTime = timezone.now()
crawl.save()
log.info("Automated crawl done")
@ -94,6 +98,10 @@ def get_current_network(): @@ -94,6 +98,10 @@ def get_current_network():
log.exception("Could not get data from host %s method %s", host, host.checkMethod)
continue
# add neighbor count
for node, data in net.nodes(data=True):
data["neighbors"] = len(list(net.neighbors(node)))
log.info("Adding last seen neighbor info")
for asls in ASLastSeen.objects.all():
if asls.asn not in net.nodes:
@ -136,6 +144,7 @@ def _populate_node(net, asn): @@ -136,6 +144,7 @@ def _populate_node(net, asn):
node.setdefault("routing_table", set())
node.setdefault("directly_crawled", False)
node.setdefault("online", True)
node.setdefault("stub", True)
return node
@ -162,6 +171,8 @@ def _add_data_to_net(net, data): @@ -162,6 +171,8 @@ def _add_data_to_net(net, data):
if as_path[n] != as_path[n + 1]:
if as_path[n + 1] not in net.nodes:
_populate_node(net, as_path[n + 1])
if as_path[n + 1] not in (as_path[-1], as_path[0]):
net.nodes[as_path[n + 1]]['stub'] = False
net.add_edge(as_path[n], as_path[n + 1])

2
backend/gobgp.py

@ -59,7 +59,7 @@ def get_bgp_data(gobgp_host): @@ -59,7 +59,7 @@ def get_bgp_data(gobgp_host):
"path": as_path,
"nexthop": next_hop,
}
entry["routes"].append(route)
entry["routes"].append(route)
data.append(entry)
return data

Loading…
Cancel
Save