## create graph using ip route information ## graph_copy = deepcopy(graph) print "Creating route.local" # parse local / direct routes for entry in collections['ipCidrRoute'].find({"ipCidrRouteProto" : "2", "ipCidrRouteType" : "3", "timestamp": timestamp}): # convert from int to ip representation entry["ip_src"] = int2ip(entry["ip_src"]) entry["ip_dst"] = int2ip(entry["ip_dst"]) graph.addConnectedSubnetByNumber( entry["ip_src"], entry["ipCidrRouteIfIndex"], entry["ip_dst"], entry["mask_dst"], str(entry) ) # parse local / indirect route for entry in collections['ipCidrRoute'].find({"ipCidrRouteProto": "3", "ipCidrRouteType" : "4", "timestamp": timestamp}): #for entry in collections['ipCidrRoute'].find({"ipCidrRouteType" : "4", "timestamp": timestamp}): # convert from int to ip representation entry["ip_src"] = int2ip(entry["ip_src"]) entry["ip_dst"] = int2ip(entry["ip_dst"]) entry["ip_gtw"] = int2ip(entry["ip_gtw"]) # determine interface to reach the new router (aka longest prefix matching) router_ip = IPAddress(entry["ip_gtw"])
graph_copy = deepcopy(graph) print "Creating route.local" # parse local / direct routes for entry in collections['ipCidrRoute'].find({ "ipCidrRouteProto": "2", "ipCidrRouteType": "3", "timestamp": timestamp }): # convert from int to ip representation entry["ip_src"] = int2ip(entry["ip_src"]) entry["ip_dst"] = int2ip(entry["ip_dst"]) graph.addConnectedSubnetByNumber(entry["ip_src"], entry["ipCidrRouteIfIndex"], entry["ip_dst"], entry["mask_dst"], str(entry)) # parse local / indirect route for entry in collections['ipCidrRoute'].find({ "ipCidrRouteProto": "3", "ipCidrRouteType": "4", "timestamp": timestamp }): #for entry in collections['ipCidrRoute'].find({"ipCidrRouteType" : "4", "timestamp": timestamp}): # convert from int to ip representation entry["ip_src"] = int2ip(entry["ip_src"]) entry["ip_dst"] = int2ip(entry["ip_dst"]) entry["ip_gtw"] = int2ip(entry["ip_gtw"])
if_phy_info["ifDescr"], str(entry) ) graph_copy = deepcopy(graph) print "Creating route.local" # parse local / direct routes for entry in collection.find( { "type": "ipCidrRoute", "ipCidrRouteProto" : "2", "ipCidrRouteType" : "3", "timestamp": timestamp } ): graph.addConnectedSubnetByNumber( entry["ip_src"], entry["ipCidrRouteIfIndex"], entry["ip_dst"], entry["mask_dst"], str(entry) ) # parse local / indirect route for entry in collection.find( { "type": "ipCidrRoute", "ipCidrRouteProto" : "3", "ipCidrRouteType" : "4", "timestamp": timestamp } ): # determine interface to reach the new router (aka longest prefix matching) router_ip = IPAddress(entry["ip_gtw"]) interface_number = None interface_netmask = None interface_netaddress = None print "getting interface"