def asns_in_traceroute(traceroute, asndb):
"""
Extract ASNs of hops in traceroute and return them as list.
"""
asns = []
for sent, recvd in traceroute:
# Is the response an ICMP TTL Exceeded packet?
if recvd.haslayer(scapy.ICMP) and recvd.payload.type == 11:
asn, _ = asndb.lookup(recvd.src)
if asn is not None:
asns.append(asn)
return asns
评论列表
文章目录