Optimale MTU ermitteln
#2
oder dies auch power shell

# MTU-Testskript (nur Auswertung, korrigierte Logik)
$TargetHost = "8.8.8.8"
$InterfaceIndex = 15
$CurrentMTU = 1448

function Test-MTU {
param ([int]$PacketSize)
$ping = New-Object System.Net.NetworkInformation.Ping
$buffer = New-Object byte[] $PacketSize
$options = New-Object System.Net.NetworkInformation.PingOptions
$options.DontFragment = $true
try {
$reply = $ping.Send($TargetHost, 2000, $buffer, $options)
return $reply.Status -eq "Success"
} catch { return $false }
}

# Testbereich: 576–1500 (realistischer Bereich)
$low = 576
$high = 1500
$optimalSize = 0

Write-Host "Ermittle optimale MTU für InterfaceIndex $InterfaceIndex (aktuell: $CurrentMTU)..." -ForegroundColor Cyan

while ($low -le $high) {
$mid = [math]::Floor(($low + $high) / 2)
Write-Host "Teste Paketgröße: $mid Bytes..." -ForegroundColor DarkGray
if (Test-MTU -PacketSize $mid) {
$optimalSize = $mid
$low = $mid + 1
} else {
$high = $mid - 1
}
}

$optimalMTU = $optimalSize + 28

Write-Host "`n--- ERGEBNIS ---" -ForegroundColor Green
Write-Host "Aktuelle MTU: $CurrentMTU" -ForegroundColor Yellow
Write-Host "Optimale MTU: $optimalMTU" -ForegroundColor Green
Write-Host "`nEmpfohlener Befehl zum manuellen Setzen der MTU (falls gewünscht):" -ForegroundColor Cyan
Write-Host "Set-NetIPInterface -InterfaceIndex $InterfaceIndex -NlMtu $optimalMTU" -ForegroundColor White
Write-Host "`nHinweis: Teste die Verbindung mit 'ping -f -l $($optimalMTU-28) 8.8.8.8'!" -ForegroundColor Red
Zitieren


Nachrichten in diesem Thema
Optimale MTU ermitteln - von Michael - 09.03.2026, 22:43
RE: Optimale MTU ermitteln - von Michael - 09.03.2026, 23:18
RE: Optimale MTU ermitteln - von Michael - 09.03.2026, 23:27

Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste