From what I understand using this article, "To measure Jitter, we take the difference between samples, then divide by the number of samples (minus 1).". This means we will have to take the data in array and do a little math on it.
Using there example, These latencies: 136, 184, 115, 148, 125 - We take the first two, subtract them, and do that for all examples down the line to get the difference.
48, 69, 33, 23 will be our differences. From here we need to find the "Mean" of all 4 results. To do this we add them all up them (173) then divide by 4. This is what my script does. Check out all the notes I left in the script.
Jitter.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
For help on any of the commands do the following:
call /?
set /?
for /?
if /?
find /?
- So on.