默认情况下,两次 ping 之间的时间延迟等于 1 秒。我需要将两次 ping 之间的延迟减少到 500 毫秒(0.5 秒)。有没有办法做到这一点?
n8t*_*8te 18
C:\Program Files (x86)\Nmap
nping --delay 500ms --count 0 <target ip address>
--count 0
选项将其设置为连续 ping)....来自Nping 参考指南:
Usage: nping [Probe mode] [Options] {target specification}
....
....
TIMING AND PERFORMANCE:
Options which take <time> are in seconds, or append 'ms' (milliseconds),
's' (seconds), 'm' (minutes), or 'h' (hours) to the value (e.g. 30m, 0.25h).
--delay <time> : Adjust delay between probes.
--rate <rate> : Send num packets per second.
Run Code Online (Sandbox Code Playgroud)
Sim*_*onS 16
您可以在 中创建一个无限循环,在PowerShell
那里发送 1 个 ping 并在发送后等待 500 毫秒。
while ($true) { Test-Connection ServerName -Count 1 ; Start-Sleep -MilliSeconds 500 }
Run Code Online (Sandbox Code Playgroud)
您也可以将其包装在一个函数中并放入您的 PowerShell 配置文件中以随时使用它
Function New-Ping {
Param(
[Parameter(Mandatory)]
[string]$ComputerName,
[Parameter(Mandatory)]
[int]$Intervall
)
while ($true) {
Test-Connection $ComputerName -Count 1
Start-Sleep -MilliSeconds $Intervall
}
}
Run Code Online (Sandbox Code Playgroud)
并从内部像这样使用它PowerShell
:
New-Ping ServerName 500
Run Code Online (Sandbox Code Playgroud)
你也可以cmd.exe
像这样使用它:
C:\WINDOWS\system32>powershell new-ping SRV 500
Source Destination IPV4Address IPV6Address Bytes Time(ms)
------ ----------- ----------- ----------- ----- --------
CP SRV 10.0.0.226 32 0
CP SRV 10.0.0.226 32 0
CP SRV 10.0.0.226 32 0
Run Code Online (Sandbox Code Playgroud)
您可以通过按 CTRL + C 来结束无限循环
pbi*_*ies 16
在 Linux 上是可能的(最近最短时间更改为 200ms = 0.2):
ping -i 0.2 server.com
Run Code Online (Sandbox Code Playgroud)
根可以发出更短的时间:
ping -i 0.01 server.com
Run Code Online (Sandbox Code Playgroud)
您无法在 Windows 命令行中更改每个 ping 请求之间的时间。你需要一个第三方工具,比如 fping 或 TruePing
另请参阅https://serverfault.com/questions/200468/how-can-i-set-a-short-timeout-with-the-ping-command
$cnt=0; while ($cnt -le 9) {$cnt++; Start-Sleep -MilliSeconds 500; Test-Connection 1.1.1.1 -Count 1}
Run Code Online (Sandbox Code Playgroud)
$cnt=0;while($cnt -le 9){$cnt++;Test-Connection 1.1.1.1 -Cou 1; sleep -M 500}
Run Code Online (Sandbox Code Playgroud)
来自@wasif-hasan 的超级高尔夫版本评论建议:
0..9|%{test-Connection 1.1.1.1 -cou 1;sleep -m 500}
Run Code Online (Sandbox Code Playgroud)
Source Destination IPV4Address IPV6Address Bytes Time(ms)
------ ----------- ----------- ----------- ----- --------
LAME_SLUG 1.1.1.1 1.1.1.1 2606:4700:4700::1111 32 18
LAME_SLUG 1.1.1.1 1.1.1.1 2606:4700:4700::1111 32 20
LAME_SLUG 1.1.1.1 1.1.1.1 2606:4700:4700::1111 32 15
LAME_SLUG 1.1.1.1 1.1.1.1 2606:4700:4700::1111 32 17
LAME_SLUG 1.1.1.1 1.1.1.1 2606:4700:4700::1111 32 15
LAME_SLUG 1.1.1.1 1.1.1.1 2606:4700:4700::1111 32 19
LAME_SLUG 1.1.1.1 1.1.1.1 2606:4700:4700::1111 32 16
LAME_SLUG 1.1.1.1 1.1.1.1 2606:4700:4700::1111 32 16
LAME_SLUG 1.1.1.1 1.1.1.1 2606:4700:4700::1111 32 18
LAME_SLUG 1.1.1.1 1.1.1.1 2606:4700:4700::1111 32 19
Run Code Online (Sandbox Code Playgroud)
PowerShell 的一些进一步阅读:
[?]而| $cnt+
[?]测试连接
[?]开始-睡眠 | 睡觉
[?]删除变量 | 房车
@echo off
:loop
pathping 127.1 -n -q 1 -p 500 >nul 2>nul
ping 151.101.193.69 -n 1 -4 & goto=:loop
Run Code Online (Sandbox Code Playgroud)
@echo off & setlocal:环形 路径 127.1 -n -q 1 -p 500 >nul 2>nul ping 1.1.1.1 -n 1 -4 & set /a "_cnt+=1+0" if %_cnt% leq 10 (goto:loop) else goto:eof
pathping
从 Microsoft使用并随 Windows 提供
@echo off & setlocal:loop pathping 127.1 -n -q 1 -p 500 >nul 2>nul ping 1.1.1.1 -n 1 -4 & set /a "_cnt+=1+0" if %_cnt% leq 10 (goto:loop)else goto:eof
C:\Users\ecker>where pathping
C:\Windows\System32\PATHPING.EXE
Run Code Online (Sandbox Code Playgroud)
Obs.:当指定-p 时,ping 将单独发送到每个中间跃点。当-w被指定时,多个坪可以并行发送。因此,可以选择小于等待周期 * 跳数的超时参数。
cmd/bat 的一些进一步阅读:
[?] PathPing
归档时间: |
|
查看次数: |
10150 次 |
最近记录: |