linux带宽网速以及流量查询监控

通常情况下:我们说的带宽10M  20M   ;现在网速网速:200KB/s ; 使用了8M的流量等,那么带宽、网速、流量之间有什么关系,他们分别代表什么呢?

①带宽的统计单位是:比特/秒(bps):10M=10Mbps;

②网速是数据传输的速度,单位是:字节/秒(B/s KB/s MB/s):1MB/s=1024KB/s  ;1KB/s=1024B/s

③流量是用户上网发送和接收的数据量总和,单位是:字节(Byte);

比特是信息的最小单位:1字节=8比特(1B=8bit或者1B=8b);1字节/秒=8比特/秒(1B/s=8bps)

1比特(1b or 1位)是信息技术中的最小存储单位,1位代表一个“1”或者“0”;

1B(1字节)是比较小的存储单位:1个英文字母占1个字节;一个汉字占2个字节;

他们之间的换算:10M带宽=1.25MB/s网速:1M带宽=0.125MB/s=128KB/s

10Mbps=10*1024Kbps=10*1024*1024bps=10*1024*1024/8 Byte/s=10/8 MB/s=1.25 MB/s

总结:1M带宽=0.125MBytes/s           

案例:

   5.3 todo method3,环境CentOS7_x86_64:(https://blog.51cto.com/13718210/2418661)
    a. 测试网络带宽常用命令(包含安装使用)
    yum  -y install  iperf
    b. 测试时记得关闭防火墙或者自行配置防火墙规则,为了快速测试,这里就直接关闭防火墙
    systemctl stop  firewalld
    c. 安装完iperf后,在Server端执行
    iperf   -s -i 1 -f  m
    -s表示server,-i表示显示时间间隔,-f表示显示格式化的单位
    打开第二台linux 作为client端,安装iperf:
    执行: iperf -c host_server_ip -i 1 -t 30 -f m
    -c表示客户端,后面接server的地址,-t代表运行的时间
    [root@110_152 ~]# iperf -c 192.168.110.151 -i 1 -t 30 -f m
    ------------------------------------------------------------
    Client connecting to 192.168.110.151, TCP port 5001
    TCP window size: 0.18 MByte (default)
    ------------------------------------------------------------
    [  3] local 192.168.110.152 port 50372 connected with 192.168.110.151 port 5001
    [ ID] Interval       Transfer     Bandwidth
    [  3]  0.0- 1.0 sec   256 MBytes  2149 Mbits/sec
    [  3]  1.0- 2.0 sec   277 MBytes  2325 Mbits/sec
    [  3]  2.0- 3.0 sec   343 MBytes  2875 Mbits/sec
    [  3]  3.0- 4.0 sec   394 MBytes  3308 Mbits/sec
    [  3]  4.0- 5.0 sec   486 MBytes  4077 Mbits/sec
    #todo server 端 bandWidth:
    Server listening on TCP port 5001
    TCP window size: 0.08 MByte (default)
    ------------------------------------------------------------
    [  4] local 192.168.110.151 port 5001 connected with 192.168.110.152 port 50372
    [ ID] Interval       Transfer     Bandwidth
    [  4]  0.0- 1.0 sec   256 MBytes  2145 Mbits/sec
    [  4]  1.0- 2.0 sec   277 MBytes  2325 Mbits/sec
    [  4]  2.0- 3.0 sec   343 MBytes  2876 Mbits/sec
    [  4]  3.0- 4.0 sec   397 MBytes  3330 Mbits/sec
    [  4]  4.0- 5.0 sec   480 MBytes  4027 Mbits/sec
    [  4]  5.0- 6.0 sec   324 MBytes  2721 Mbits/sec
    [  4]  6.0- 7.0 sec   378 MBytes  3173 Mbits/sec
    [  4]  7.0- 8.0 sec   292 MBytes  2447 Mbits/sec
    [  4]  8.0- 9.0 sec   285 MBytes  2393 Mbits/sec
    [  4]  9.0-10.0 sec   537 MBytes  4504 Mbits/sec
    [  4] 10.0-11.0 sec   292 MBytes  2453 Mbits/sec
    [  4] 11.0-12.0 sec   399 MBytes  3347 Mbits/sec

 结论: 2145Mbits=2145Mbps,2145x0.125=268Mbytes网速

原文地址:https://www.cnblogs.com/SunshineKimi/p/12407876.html