Packet Loss Test
This script performs multiple pings to check for packet loss to a specific IP or hostname. It calculates the percentage of successful pings, which helps assess network stability.
# Define target and number of pings
$target = "8.8.8.8" # Replace with the target IP or hostname
$pingCount = 50 # Number of pings to send
$successfulPings = 0
for ($i = 0; $i -lt $pingCount; $i++) {
if (Test-Connection -ComputerName $target -Count 1 -Quiet) {
$successfulPings++
}
}
$packetLossPercentage = (1 - ($successfulPings / $pingCount)) * 100
Write-Output "Packet Loss: $packetLossPercentage%"
• Adjust $target and $pingCount to fit your testing needs.
• Explanation: This script calculates packet loss as a percentage based on the number of successful vs. total pings.
Last updated