Created
February 2, 2019 15:45
-
-
Save lukas2511/893eb73c6ea359cb777ed8daaab2359a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import scapy.all | |
| import sys | |
| last_sync = 0 | |
| m = 9999 | |
| M = 0 | |
| length = 272 | |
| def pkt_callback(pkt): | |
| global last_sync, m, M | |
| data = bytes(pkt.payload.payload.payload) | |
| if data[0] == 0x00: | |
| last_sync = pkt.time | |
| if data[0] == 0x08: | |
| if last_sync == 0: | |
| return | |
| bars = int((pkt.time - last_sync) * 1000 * 1000) | |
| lat = bars/10 | |
| if lat < m: | |
| m = lat | |
| if lat > M: | |
| M = lat | |
| stats = "min: %5.1f max: %5.1f cur: %5.1f" % (m, M, lat) | |
| if bars > (length-len(stats)-1): | |
| bars = (length-len(stats)-3) * "#" + ">>" | |
| else: | |
| bars = bars * "#" + (length - bars - len(stats) - 1) * "." | |
| sys.stdout.write("\r" + bars + " " + stats) | |
| sys.stdout.flush() | |
| scapy.all.sniff(iface="enp0s20f0u3", prn=pkt_callback, filter="udp and (port 319 or port 320)", store=0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment