net ping测试

ping 帮助

1
2
3
4
5
[root@localhost ~]# ping -h
Usage: ping [-LRUbdfnqrvVaA] [-c count] [-i interval] [-w deadline]
[-p pattern] [-s packetsize] [-t ttl] [-I interface or address]
[-M mtu discovery hint] [-S sndbuf]
[ -T timestamp option ] [ -Q tos ] [hop1 ...] destination

详细解释参考

大小实验

-s packetsize

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[root@localhost ~]# ping 192.168.251.1 -s 65530
ping: packet size too large: 65530

[root@localhost ~]# ping 192.168.251.1 -s 65525
WARNING: probably, rcvbuf is not enough to hold preload.
WARNING: packet size 65525 is too large. Maximum is 65507
PING 192.168.251.1 (192.168.251.1) 65525(65553) bytes of data.
ping: local error: Message too long, mtu=1500

[root@localhost ~]# ping 192.168.251.1 -s 65507
WARNING: probably, rcvbuf is not enough to hold preload.
PING 192.168.251.1 (192.168.251.1) 65507(65535) bytes of data.

ping: sendmsg: 没有可用的缓冲区空间
ping: sendmsg: 没有可用的缓冲区空间

# 修改内核参数,后正常
echo 65535 > /proc/sys/net/core/wmem_max

ping MTU

-M mtu discovery hint
MTU只有三个有效值:do, dont, want

1
2
[root@localhost ~]# ping 127.0.0.1 -s 65500 -M 655350
ping: wrong value for -M: do, dont, want are valid ones.

ping间隔

-i interval

1
ping 127.0.0.1 -s 65500 -i $N

间隔 网速(KB/s)
1 65.8
0.1 656.1
0.01 6561.0
0.001 5490.5 ~ 20263.2
0.0001 5294.9 ~ 19997.1

ping flood

洪水ping本地网速可以达到1701554.4KB/s ~ 1.7G/s

1
2
3
4
5
ping 127.0.0.1 -f -s $N

# 修改内核参数
echo 28000000 > /proc/sys/net/core/wmem_max
echo 28000000 > /proc/sys/net/core/rmem_max

默认 有 28字节 然后10倍加大,下一个252,做相应计算

内核 绝对包大小 相对包s 网速(KB/s)
65535000 28 0 2750.1
65535000 280 252 27737.3
65535000 2800 2772 279168.5
65535000 28000 27972 1396855.9
65535000 56000 55972 1701554.4

修改内核参数看对速度是否影响

内核 绝对包大小 相对包s 网速(KB/s)
28 2800 0 262870.5
280 2800 252 217128.3
2800 2800 2772 222468.7
28000 2800 2772 232293.3
280000 2800 2772 268067.9
2800000 2800 2772 232744.8
28000000 2800 2772 242215.2

结论:无明显影响

测试virtualbox的虚拟网卡 virtio-net (非本地)

1
2
3
4
ping 192.168.251.1 -f -s $N
# 修改内核参数
echo 65535000 > /proc/sys/net/core/wmem_max
echo 65535000 > /proc/sys/net/core/rmem_max

默认 有 28字节 然后10倍加大,下一个252,做相应计算

内核 绝对包大小 相对包-s 网速(KB/s) 丢包率(%)
65535000 28 0 19.8 32
65535000 280 252 66.7 32
65535000 2800 2772 540.9 30
65535000 28000 27972 5395.5 29
65535000 56000 55972 10414.2 30