Iperf软件平台移植与问题解决
  vDFgA8s10mCM 2023年11月02日 122 0

1、Iperf概述

iperf 是一个基于Client/Server的网络性能测试工具,可以测试TCP、UDP和SCTP带宽质量,能够提供网络吞吐率信息,以及震动、丢包率、最大段和最大传输单元大小等统计信息,帮助我们测试网络性能,定位网络瓶颈

抖动丢包率 --> 适应于UDP测试

带宽测试 --> 适应于TCP和UDP测试

iperf 优点:纯粹的发送、接收,防止硬盘读写影响测试结果。

缺点:无法计算传输时延

iperf测试发送大量包,计算出的抖动值,即为连续发送时延差值的平均值

2、Iperf的ARM平台移植

2.1 下载源码

2.2 解压工程源码

  • 创建工程目录及源码解压

# mkdir /home/zhangj/iperf

# cp iperf-3-current.tar.gz /home/zhangj/iperf

# cd /home/zhangj/iperf

# tar xvzf iperf-3-current.tar.gz

至此,在 /home/zhangj/iperf/ 目录下,解压出 /iperf-3.6 目录,该目录为iperf的工程源码。

2.3 配置源码及编译、安装

  • 配置环境变量

# mkdir /home/zhangj/iperf/install (创建编译生成iperf文件的安装目录)

# export PATH=$PATH:/opt/hisi-linux/x86-arm/arm-hisiv500-linux/bin/

(交叉编译工具路径加入到系统环境变量中,开发环境默认已配置好)

  • 生成MakeFile文件

# ./configure --host=arm  CC=arm-hisiv500-linux-gcc --prefix=/home/zhangj/iperf/install/

--host: 指定交叉编译工具

--prefix: 指定安装目录,编译后的文件会全部放在安装目录中(必须是绝对路径

  • 编译及安装

# make

# make install

  • 去除镜像调试信息,缩减程序大小(约缩减50%左右)

# arm-hisiv500-linux-strip iperf3

2.4 解决编译报错

  • 报错信息如下:

Iperf软件平台移植与问题解决_iperf

  • 参考解决办法:

A、导入环境变量

 export PATH=$PATH:/opt/hisi-linux/x86-arm/arm-hisiv500-linux

B、配置生成Makefile

./configure --host=arm  CC=arm-hisiv500-linux-gcc --prefix=/home/zhangj/iperf/install

C、修改/src/makefile.in文件,去掉“-pg”选项

Iperf软件平台移植与问题解决_linux_02

D、备注更改项,注释掉 config.h文件 中的“#define malloc rpl_malloc” 内容;

2.5 说明

iperf有 iperf2版本(命令iperf iperf3版本(命令iperf3两个版本,两个版本不能混着用,即服务器与客户端使用不同版本的iperf,否则,系统会提示连接错误,信息如下:

“connect failed: Connection refused”

3、Iperf的功能测试

  • 测试1Mbps、4Mbps、8Mbps数据传输功能正常,无丢包情况发生。
  • Iperf3 配置参数如下:

Iperf软件平台移植与问题解决_iperf_03

[root@localhost home]# iperf3 -h
Usage: iperf [-s|-c host] [options]
      iperf [-h|--help] [-v|--version]
 
Server or Client:
  -p,--port      #         server port to listen on/connect to
  -f,--format    [kmgKMG]  format to report: Kbits, Mbits, KBytes,MBytes
  -i,--interval  #         seconds between periodic bandwidthreports
  -F,--file name           xmit/recv thespecified file
  -A,--affinity n/n,m      set CPU affinity
  -B,--bind      <host>    bind to a specific interface
  -V,--verbose             more detailedoutput
  -J,--json                output in JSONformat
 --logfile f               sendoutput to a log file
  -d,--debug               emit debuggingoutput
  -v,--version             show versioninformation and quit
  -h,--help                show this messageand quit
Server specific:
  -s,--server              run in server mode
  -D,--daemon              run the server as a daemon
  -I,--pidfile file        write PID file
  -1,--one-off             handle one clientconnection then exit
Client specific:
  -c,--client    <host>    run in client mode, connecting to<host>
  -u,--udp                 use UDP rather thanTCP
  -b,--bandwidth #[KMG][/#] target bandwidth in bits/sec (0 for unlimited)
                            (default 1 Mbit/secfor UDP, unlimited for TCP)
                            (optional slash andpacket count for burst mode)
  -t,--time      #         time in seconds to transmit for(default 10 secs)
  -n,--bytes     #[KMG]    number of bytes to transmit (instead of -t)
  -k,--blockcount #[KMG]   number of blocks(packets) to transmit (instead of -t or -n)
  -l,--len       #[KMG]    length of buffer to read or write
                            (default 128 KB forTCP, 8 KB for UDP)
 --cport         <port>    bind to a specific client port (TCP andUDP, default: ephemeral port)
  -P,--parallel  #         number of parallel client streams torun
  -R,--reverse             run in reverse mode(server sends, client receives)
  -w,--window    #[KMG]    set window size / socket buffer size
  -C,--congestion <algo>   set TCPcongestion control algorithm (Linux and FreeBSD only)
  -M,--set-mss   #         set TCP/SCTP maximum segment size (MTU- 40 bytes)
  -N,--no-delay            set TCP/SCTP nodelay, disabling Nagle's Algorithm
  -4,--version4            only use IPv4
  -6,--version6            only use IPv6
  -S,--tos N               set the IP 'type ofservice'
  -L,--flowlabel N         set the IPv6 flowlabel (only supported on Linux)
  -Z,--zerocopy            use a 'zero copy'method of sending data
  -O,--omit N              omit the first nseconds
  -T,--title str           prefix every outputline with this string
 --get-server-output       getresults from server
 --udp-counters-64bit      use64-bit counters in UDP test packets
 --no-fq-socket-pacing     disablefair-queuing based socket pacing
                            (Linux only)
 
[KMG] indicates options that support aK/M/G suffix for kilo-, mega-, or giga-
 
iperf3 homepage at:http://software.es.net/iperf/
Report bugs to:     https://github.com/esnet/iperf
  • 实际范例测试

服务器iperf3 -s -i 1

Iperf软件平台移植与问题解决_linux_04

Iperf软件平台移植与问题解决_linux_05

客户端iperf3 -u -c 192.168.1.60 -b 4M -t 10

显示结果如下:

服务器接收显示:

Iperf软件平台移植与问题解决_linux_06

客户端发送显示:

Iperf软件平台移植与问题解决_linux_07

利用网络管理软件监听网络连接状态,Client指定“-u”模式,即以UDP协议传输报文,网路检测结果如下:

Iperf软件平台移植与问题解决_linux_08

当Client连接时,不指定“-u”,则默认以TCP协议传输报文,网路检测结果如下:

Iperf软件平台移植与问题解决_iperf_09

当上述两种模式发送数据完成后,连接与传输网络消失,系统恢复Server对原端口的监听模式,情况如下:

Iperf软件平台移植与问题解决_linux_10

小结:iperf服务器以TCP协议模式监听端口,客户端通过TCP协议连接服务器,但传输使用TCP/UDP协议,则是由客户端发起连接配置时决定的。

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  eVzzROmRiJco   2023年11月19日   21   0   0 linux
  zLxnEsMLk4BL   2023年11月19日   34   0   0 变量名字符串bclinux
  DF5J4hb0hcmT   2023年11月12日   32   0   0 linux
  eVzzROmRiJco   2023年11月19日   20   0   0 内核链表linux