狄烁STEC的试验场

hello earth

导航

用批处理测试MTU

一个自动测试MTU的批处理。本地测试结果:

ipaddress:192.168.1.1

try : 1000 [0 , 2000]
try : 1500 [1000 , 2000]
try : 1250 [1000 , 1500]
try : 1375 [1250 , 1500]
try : 1437 [1375 , 1500]
try : 1468 [1437 , 1500]
try : 1484 [1468 , 1500]
try : 1476 [1468 , 1484]
try : 1472 [1468 , 1476]
try : 1474 [1472 , 1476]
try : 1473 [1472 , 1474]
try : 1472 [1472 , 1473]

package: 1472
MTU : 1500

Press any key to continue . . .

脚本:

@echo off
chcp 437>nul
set /p ip=ipaddress:
if %ip%.==. goto:eof
echo.

set con=
for /f "tokens=1 delims= " %%a in ('ping %ip% -n 1 ^| find "Reply"') do set con=%%a
if %con%.==. goto:discon

set min=0
set max=2000

:test
call:try %min% %max%
if %df%.==. (
if %min%==%package% goto:result
set min=%package%
) else (
set max=%package%
)
goto:test
goto:eof

:result
echo.
echo package: %package%
set /a mtu=%package% + 28
echo MTU : %mtu%
echo.
pause
goto:eof

:try
set /a package=(%1+%2)/2
echo try : %package% [%1 , %2]
call:ping %package%
goto:eof

goto:eof
:ping
set df=
for /f "tokens=1 delims= " %%a in ('ping %ip% -f -l %1 -n 1 ^| find "DF"') do set df=%%a
goto:eof

:discon
echo Error: can not connect to %ip%
echo.
pause

posted on 2011-04-02 11:30  狄烁STEC  阅读(955)  评论(0编辑  收藏  举报