+
+
+
+ Kein WebGL? Kein Problem.
+Diese Version nutzt ein Canvas-Emulator-Setup, das auch ohne WebGL läuft. Sollte das Canvas dennoch nicht unterstützt sein, aktualisieren Sie Ihren Browser.
+diff --git a/route3.php b/route3.php new file mode 100644 index 0000000..8640f33 --- /dev/null +++ b/route3.php @@ -0,0 +1,673 @@ +&1'; + $rawOutput = shell_exec($command); + if ($rawOutput === null) { + $error = 'Traceroute konnte nicht ausgeführt werden. Ist das Kommando verfügbar?'; + } else { + $traceData = parseTraceroute($rawOutput); + if (empty($traceData)) { + $error = 'Keine Hops gefunden. Prüfen Sie den Hostnamen oder versuchen Sie es später erneut.'; + } + } + } +} + +if (empty($traceData)) { + $traceData = getSampleTrace(); + if ($error === '') { + $error = 'Es werden Beispieldaten angezeigt. Starten Sie eine Abfrage, um echte Traceroute-Daten zu sehen.'; + } +} + +$positions = generateHelixLayout(count($traceData)); +$traceWithPositions = array_map(function ($hop, $index) use ($positions) { + return $hop + [ + 'position' => $positions[$index] ?? ['x' => 0, 'y' => 0, 'z' => 0], + ]; +}, $traceData, array_keys($traceData)); + +function parseTraceroute(string $raw): array +{ + $lines = preg_split('/\r?\n/', trim($raw)); + if (!$lines) { + return []; + } + + $hops = []; + foreach ($lines as $line) { + if (!preg_match('/^\s*(\d+)\s+(.+)/', $line, $parts)) { + continue; + } + + $hopNumber = (int) $parts[1]; + $rest = $parts[2]; + + preg_match('/([0-9a-fA-F:\.\-]+|\*)/', $rest, $ipMatch); + $ip = $ipMatch[1] ?? '*'; + $ip = $ip === '*' ? 'Zeitüberschreitung' : $ip; + + preg_match_all('/(\d+\.\d+)\s+ms/', $rest, $latencyMatches); + $latencies = array_map('floatval', $latencyMatches[1] ?? []); + $avgLatency = !empty($latencies) ? round(array_sum($latencies) / count($latencies), 2) : null; + + $hops[] = [ + 'hop' => $hopNumber, + 'ip' => $ip, + 'avgLatency' => $avgLatency, + 'raw' => trim($line), + ]; + } + + return $hops; +} + +function getSampleTrace(): array +{ + return [ + ['hop' => 1, 'ip' => '192.168.0.1', 'avgLatency' => 1.23, 'raw' => '1 192.168.0.1 1.12 ms 1.20 ms 1.38 ms'], + ['hop' => 2, 'ip' => '10.12.34.1', 'avgLatency' => 9.87, 'raw' => '2 10.12.34.1 9.44 ms 9.90 ms 10.29 ms'], + ['hop' => 3, 'ip' => '172.16.5.4', 'avgLatency' => 18.54, 'raw' => '3 172.16.5.4 18.12 ms 18.45 ms 18.71 ms'], + ['hop' => 4, 'ip' => '198.51.100.12', 'avgLatency' => 27.42, 'raw' => '4 198.51.100.12 27.03 ms 27.54 ms 27.68 ms'], + ['hop' => 5, 'ip' => '203.0.113.5', 'avgLatency' => 36.18, 'raw' => '5 203.0.113.5 35.82 ms 36.19 ms 36.52 ms'], + ['hop' => 6, 'ip' => '93.184.216.34', 'avgLatency' => 48.91, 'raw' => '6 93.184.216.34 48.44 ms 48.90 ms 49.39 ms'], + ]; +} + +function generateHelixLayout(int $count): array +{ + $positions = []; + $radius = 160; + $heightStep = 70; + $angleStep = pi() / 3; + + for ($i = 0; $i < $count; $i++) { + $angle = $i * $angleStep; + $y = ($i - ($count - 1) / 2) * $heightStep; + $positions[] = [ + 'x' => cos($angle) * $radius, + 'y' => $y, + 'z' => sin($angle) * $radius, + ]; + } + + return $positions; +} +?> + + +
+ + +