]> johannes.truschnigg.info Git - sqm_lagthrottle/commitdiff
Add helper script to determine the first ICMP ECHOing hop
authorJohannes Truschnigg <johannes@truschnigg.info>
Tue, 15 Mar 2022 11:21:08 +0000 (12:21 +0100)
committerJohannes Truschnigg <johannes@truschnigg.info>
Tue, 15 Mar 2022 11:21:08 +0000 (12:21 +0100)
reflector_detect [new file with mode: 0755]

diff --git a/reflector_detect b/reflector_detect
new file mode 100755 (executable)
index 0000000..63903ba
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+get_first_pingpeer() {
+  traceroute -n "${1}" | while read num peer lat1 _ lat2 _ lat3 _
+  do
+    case "${num}" in
+      [123456789]*)
+        if ping -c 1 -s 1280 -W 2 -w 2 "${peer}" >/dev/null 2>/dev/null
+        then
+          printf '# %s - hop #%d (%s) responds to ICMP ECHO\n' "${1}" "${num}" "${peer}"
+          printf 'PEER %s\n' "${peer}"
+          break
+        fi
+      ;;
+      *)
+        : pass $num $peer
+      ;;
+    esac
+  done
+}
+
+
+for p in 8.8.8.8 1.1.1.1 example.com google.com
+do
+  get_first_pingpeer "${p}"
+done