File 批处理文件抖动测试
我想创建一个批处理文件,在执行ping命令后自动将“抖动”结果输出到屏幕 C:\Ping Google.comFile 批处理文件抖动测试,file,batch-file,request,ping,jitter,File,Batch File,Request,Ping,Jitter,我想创建一个批处理文件,在执行ping命令后自动将“抖动”结果输出到屏幕 C:\Ping Google.com Reply from 172.217.11.174: bytes=32 time=9ms TTL=56 Reply from 172.217.11.174: bytes=32 time=9ms TTL=56 Reply from 172.217.11.174: bytes=32 time=9ms TTL=56 Reply from 172.217.11.174: bytes=32 ti
Reply from 172.217.11.174: bytes=32 time=9ms TTL=56
Reply from 172.217.11.174: bytes=32 time=9ms TTL=56
Reply from 172.217.11.174: bytes=32 time=9ms TTL=56
Reply from 172.217.11.174: bytes=32 time=9ms TTL=56
有一个计算器,如果可以复制/粘贴到该方块/字段中,就会显示抖动结果
据我所知,“抖动是来自Ping的每个返回消息之间的差异(Δ时间或δ时间)的测量。”
我想把它输出到屏幕上,而不是复制/粘贴到那个网站上 根据我的理解,“为了测量抖动,我们取样本之间的差值,然后除以样本数(减1)。”。这意味着我们将不得不在数组中获取数据,并对其进行一些计算 例如,这些延迟:136、184、115、148、125-我们取前两个,减去它们,然后对所有的例子都这样做,以得到差值 48、69、33、23将是我们的分歧。从这里我们需要找到所有4个结果的“平均值”。为此,我们将它们相加(173),然后除以4。这就是我的脚本所做的。查看我在脚本中留下的所有注释 抖动.bat
@ECHO OFF
@Setlocal EnableDelayedExpansion
Rem | Configuration
Rem | Address - The Address You Wish To PING
Rem | PingAmount - The Amount Of Times To Ping Each Cycle
set "Address=google.com"
set "PingAmount=10"
:LOOP
Set "SUM1=0"
Set "SUM2=0"
Set "WHOLE=0"
Set "MEAN=0"
Set "RUN=0"
set "MAX=0"
Set "TOTAL=0"
Echo Waiting For Ping Data...
Rem | Change The Ping Command To Strings
FOR /F "tokens=1-4,5,*" %%A in ('Ping -n %PingAmount% "%Address%" ^| Find /I "Reply"') DO (
Rem | This is optional; Will Display Whole "Ping"
Echo %%A %%B %%C %%D [%%E] %%F
Rem | Grab Only "Time="
FOR /F "tokens=1,* delims==" %%G in ('echo %%E') DO (
Rem | Edit "Time=" String To Extract Only The Time
Set "String=%%H"
Set String=!String:ms=!%
Rem | Do Math
IF "!WHOLE!"=="2" (
Rem | Compare Strings & Sort
If "!SUM1!"=="!String!" (
Set "MAX=!Sum1!"
Set "MIN=!String!"
) ELSE (
Rem | Find Largest
for %%A in (!SUM1!, !String!) do (
set n=%%A
if !n! GTR !MAX! set MAX=!n!
)
Rem | Find Smallest
for %%A in (!SUM1!, !String!) do (
set n=%%A
if !n! LSS !MAX! set MIN=!n!
)
Rem | Subtract 1st string from new
Set /a "SUM2=!MAX!-!MIN!"
)
Rem | Add Each Differences
Set /a "TOTAL=TOTAL+!SUM2!"
Rem | Save Last Response
Set "SUM1=!String!"
) ELSE (
Rem | First Cycle, Set First String
Set "SUM1=!String!"
Rem | Disable This Check
Set "WHOLE=2"
)
)
)
Rem | Do Math
Set /a "TRESULTS=!PingAmount!-1"
set /a "MEAN=!TOTAL!/!TRESULTS!"
Rem | Display Jitter
Echo The Jitter For The Above Arry Is: Jitter=!MEAN!ms
Echo(
goto LOOP
有关任何命令的帮助,请执行以下操作:
呼叫/?
设置/?
获取/?
如果/?
查找/?
- 等等