分页: 1 / 1
我的测网速的脚本( 参数wlan0 或者eth0)
发表于 : 2011-09-19 22:44
由 灭你们村
代码: 全选
#! /bin/bash
net=$1
while true
do
tmp=`ifconfig $net|grep '接收字节'`
#echo $tmp
dspeed=${tmp/接收字节:/}
down_pre=${dspeed/ (*/}
#echo $down_pre
uspeed=${tmp/*发送字节:/}
up_pre=${uspeed/ (*/}
#echo $up_pre
sleep 1
tmp=`ifconfig $net|grep '接收字节'`
#echo $tmp
dspeed=${tmp/接收字节:/}
down_next=${dspeed/ (*/}
#echo $down_next
uspeed=${tmp/*发送字节:/}
up_next=${uspeed/ (*/}
#echo $up_next
declare -i down_speed up_speed
down_speed=$((${down_next}/1024-${down_pre}/1024))
up_speed=$((${up_next}/1024-${up_pre}/1024))
clear
echo "Down-speed:$down_speed KB/s Up-speed:$up_speed KB/s"
echo "Total-down:"$((${down_next}/1024)) "KB Total-up:"$((${up_next}/1024)) "KB"
sleep 1
done
Re: 我的测网速的脚本( 参数wlan0 或者eth0)
发表于 : 2011-09-19 22:49
由 Ubuntu与Linux

顶一个
Re: 我的测网速的脚本( 参数wlan0 或者eth0)
发表于 : 2011-09-19 23:07
由 monk

效果咋样
Re: 我的测网速的脚本( 参数wlan0 或者eth0)
发表于 : 2011-09-19 23:45
由 sk1418
大概看了下脚本,我理解你这个不是测网速,而是前一秒内的上传下载字节数(traffic),虽然是1秒内的,但是和速率无关。
因为如果你看本地的电影10分钟,没什么network traffic, 那你这个脚本不停刷新的数值就很低,但不表示你的网络速度低。
也许是我没仔细看,看错了。
Re: 我的测网速的脚本( 参数wlan0 或者eth0)
发表于 : 2011-09-19 23:47
由 我就是我2
这个。有点长。我一般是watch搞定。
Re: 我的测网速的脚本( 参数wlan0 或者eth0)
发表于 : 2011-09-20 0:09
由 我就是我2
我就是我2 写了:这个。有点长。我一般是watch搞定。
看错了,我这个是监视traffic的。不是测试网速的。
Re: 我的测网速的脚本( 参数wlan0 或者eth0)
发表于 : 2011-09-20 0:11
由 lilydjwg
我就是我2 写了:这个。有点长。我一般是watch搞定。
我直接抬头看看右上角


- 2011-09-20-001000_1366x768_scrot.png (5.18 KiB) 查看 1686 次
Re: 我的测网速的脚本( 参数wlan0 或者eth0)
发表于 : 2011-09-23 19:49
由 灭你们村
sk1418 写了:大概看了下脚本,我理解你这个不是测网速,而是前一秒内的上传下载字节数(traffic),虽然是1秒内的,但是和速率无关。
因为如果你看本地的电影10分钟,没什么network traffic, 那你这个脚本不停刷新的数值就很低,但不表示你的网络速度低。
也许是我没仔细看,看错了。
原理确实如你所说,严格意义上不算是测网速,因为只有前一秒的数据。多测几秒,取平均可能会反映出网络的真实速度。但也不能太长。
脚本在网络速度低于1024 bytes(或者是512 bytes,不太清楚有没有四舍五入)时,是显示网速为0 KB/s的。
Re: 我的测网速的脚本( 参数wlan0 或者eth0)
发表于 : 2011-09-23 19:49
由 SmallV
暴强的ID,
Re: 我的测网速的脚本( 参数wlan0 或者eth0)
发表于 : 2011-09-23 19:50
由 灭你们村
lilydjwg 写了:我就是我2 写了:这个。有点长。我一般是watch搞定。
我直接抬头看看右上角

2011-09-20-001000_1366x768_scrot.png
看着眼熟,我也用过这个。

Re: 我的测网速的脚本( 参数wlan0 或者eth0)
发表于 : 2011-09-23 19:52
由 灭你们村
monk 写了:
效果咋样
直接上图
Re: 我的测网速的脚本( 参数wlan0 或者eth0)
发表于 : 2011-09-23 19:53
由 灭你们村
SmallV 写了:暴强的ID,

见笑了
Re: 我的测网速的脚本( 参数wlan0 或者eth0)
发表于 : 2011-09-23 19:57
由 c43035
lilydjwg 写了:我就是我2 写了:这个。有点长。我一般是watch搞定。
我直接抬头看看右上角

2011-09-20-001000_1366x768_scrot.png
你自己造一个“右上角”来看看。