/dev/null 2>&1'; exec($checkCmd, $output, $returnCode); if ($returnCode !== 0) { // Fallback zu traceroute wenn traceroute6 nicht verfügbar if ($isValidIPv6) { $tracerouteCmd = 'traceroute'; exec('command -v traceroute > /dev/null 2>&1', $output, $returnCode); } if ($returnCode !== 0) { $error = 'Traceroute ist auf diesem System nicht verfügbar.'; } } if ($error === '') { // Führe traceroute mit Timeout aus (max 30 Sekunden) $command = 'timeout 30 ' . $tracerouteCmd . ' -n -m 20 -w 2 ' . escapeshellarg($sanitizedHost) . ' 2>&1'; $rawOutput = shell_exec($command); if ($rawOutput === null || trim($rawOutput) === '') { $error = 'Traceroute konnte nicht ausgeführt werden oder lieferte keine Ausgabe.'; } 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 = generateGalaxyLayout(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) { // Überspringe Header-Zeilen und leere Zeilen if (!preg_match('/^\s*\d+\s+/', $line)) { continue; } // Extrahiere die Hop-Nummer if (!preg_match('/^\s*(\d+)\s+/', $line, $hopMatch)) { continue; } $hopNumber = (int) $hopMatch[1]; // Extrahiere Latenz-Werte (unterstützt verschiedene Formate) preg_match_all('/(\d+(?:\.\d+)?)\s*ms/', $line, $latencyMatches); $latencies = array_map('floatval', $latencyMatches[1] ?? []); $avgLatency = !empty($latencies) ? round(array_sum($latencies) / count($latencies), 2) : null; // Extrahiere IP-Adresse (IPv4, IPv6 oder *) $ip = 'Zeitüberschreitung'; // Versuche IPv4 zu finden if (preg_match('/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/', $line, $ipMatch)) { $ip = $ipMatch[1]; } // Versuche IPv6 zu finden (verschiedene Formate) elseif (preg_match('/([0-9a-fA-F]{1,4}:+[0-9a-fA-F:]+)/', $line, $ipMatch)) { $ip = $ipMatch[1]; } // Prüfe auf * (Timeout) elseif (preg_match('/\s+\*\s+/', $line)) { $ip = 'Zeitüberschreitung'; } $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 generateGalaxyLayout(int $count): array { $positions = []; $radiusStep = 28; $angleOffset = pi() * (3 - sqrt(5)); // Golden angle $heightStep = 12; for ($i = 0; $i < $count; $i++) { $radius = ($i + 1) * 4 + ($i % 2 === 0 ? $radiusStep : $radiusStep * 0.6); $angle = $i * $angleOffset; $y = ($i - $count / 2) * $heightStep; $positions[] = [ 'x' => cos($angle) * $radius, 'y' => $y, 'z' => sin($angle) * $radius, ]; } return $positions; } ?> HyperTracer 3D

HyperTracer 3D

Hop 1:
WebGL konnte nicht initialisiert werden. Bitte verwenden Sie einen modernen Browser oder aktivieren Sie WebGL.