def get_last_ping_reply_ts(path):
"""Returns last ICMP echo response timestamp.
If there are no replies in packets - it returns None.
Args:
packets (list): list packets
Returns:
float|None: last ICMP reply timestamp or None
"""
last_replied_ts = None
for packet in read_pcap(path, lfilter=filter_icmp):
if not filter_icmp(packet):
continue
if packet[scapy.ICMP].type == TYPE_ICMP_REPLY:
last_replied_ts = max(last_replied_ts, packet.time)
return last_replied_ts
评论列表
文章目录