porting iperf to Android platform

本文档详细介绍了将iperf网络性能测试工具移植到Android平台的过程。包括下载源代码、文件复制与重命名、添加必要的头文件及Makefile配置等步骤。
AI助手已提取文章相关产品:

http://blog.chinaunix.net/u3/103613/showart_2037838.html

下面的文档描述如何移植 iperf 到 android 平台中

1. download iperf source code

latest iperf version from the below link:
http://sourceforge.net/projects/iperf/
and then unzip it.
tar zxvf iperf_2.0.4.orig.tar.gz

2. copy iperf-2.0.4
copy iperf-2.0.4 folder to external/ in cupcake or other Android version, and rename it as iperf.

3. add header files
add two header files in iperf folder
iperf/include/iperf-int.h
iperf/config.h
you can get it if you build iperf source code in iperf formal package.


4. add Makefile
add a new Android.mk in iperf folder for Android environment.
and the context is as belows:

#
# Copyright (C) 2008 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LOCAL_PATH := $(call my-dir)

OBJS += compat/error.c
OBJS += compat/snprintf.c
OBJS += compat/inet_ntop.c
OBJS += compat/inet_pton.c
OBJS += compat/signal.c
OBJS += compat/Thread.c
OBJS += compat/string.c
OBJS += compat/gettimeofday.c
OBJS += src/gnu_getopt.c
OBJS += src/gnu_getopt_long.c
OBJS += src/tcp_window_size.c
OBJS += src/service.c
OBJS += src/sockets.c
OBJS += src/stdio.c
OBJS += src/ReportCSV.c
OBJS += src/Locale.c
OBJS += src/ReportDefault.c
OBJS += src/Reporter.c
OBJS += src/Extractor.c
OBJS += src/SocketAddr.c
OBJS += compat/delay.cpp
OBJS += src/Server.cpp
OBJS += src/Client.cpp
OBJS += src/List.cpp
OBJS += src/Launch.cpp
OBJS += src/PerfSocket.cpp
OBJS += src/Settings.cpp
OBJS += src/Listener.cpp
OBJS += src/main.cpp

INCLUDES = $(LOCAL_PATH)/include

L_CFLAGS = -DHAVE_CONFIG_H

########################


include $(CLEAR_VARS)
LOCAL_MODULE := iperf
#LOCAL_SHARED_LIBRARIES := libc libcutils libutils libnetutils libstdc++
LOCAL_CFLAGS := $(L_CFLAGS)
LOCAL_SRC_FILES := $(OBJS)
LOCAL_C_INCLUDES := $(INCLUDES)
include $(BUILD_EXECUTABLE)
########################


4. do modification
do some modification which blocks the build.
4.1 util.h
because Android environment has also one util.h, and Make system will select it instead of util.h in iperf folder,
so we need let Make system select local util.h. one easy method is to use below sentence.
#include "include/util.h"
instead of
#include "util.h"

4.2 headers.h
for iperf/include/headers.h
#ifndef NDEBUG
#define NDEBUG
#endif
instead of
#define NDEBUG

4.3 Listener.cpp
for iperf/src/Listener.cpp
delete the below since we don't care about ipv6 currently.
mreq.ipv6mr_interface = 0;

您可能感兴趣的与本文相关内容

Iperf 是一个网络性能测试工具。Iperf可以测试TCP和UDP带宽质量。Iperf可以测量最大TCP带宽,具有多种参数和UDP特性。Iperf可以报告带宽,延迟抖动和数据包丢失。 功能介绍 TCP 测量网络带宽 报告MSS/MTU值的大小和观测值 支持TCP窗口值通过套接字缓冲 当P线程或Win32线程可用时,支持多线程。客户端与服务端支持同时多重连接 UDP 客户端可以创建指定带宽的UDP流 测量丢包 测量延迟 支持多播 当P线程可用时,支持多线程。客户端与服务端支持同时多重连接(不支持Windows) 在适当的地方,选项中可以使用K(kilo-)和M(mega-)。例如131072字节可以用128K代替。 可以指定运行的总时间,甚至可以设置传输的数据总量。 在报告中,为数据选用最合适的单位。 服务器支持多重连接,而不是等待一个单线程测试。 在指定时间间隔重复显示网络带宽,波动和丢包情况。 服务器端可作为后台程序运行。 服务器端可作为Windows 服务运行。 使用典型数据流来测试链接层压缩对于可用带宽的影响。 参数与说明 命令行选项 环境变量选项 描述 客户端与服务器端选项 -f, --format [bkmaBKMA] $IPERF_FORMAT 格式化带宽数输出。支持的格式有: 'b' = bits/sec 'B' = Bytes/sec 'k' = Kbits/sec 'K' = KBytes/sec 'm' = Mbits/sec 'M' = MBytes/sec 'g' = Gbits/sec 'G' = GBytes/sec 'a' = adaptive bits/sec 'A' = adaptive Bytes/sec 自适应格式是kilo-和mega-二者之一。除了带宽之外的字段都输出为字节,除非指定输出的格式,默认的参数是a。 注意:在计算字节byte时,Kilo = 1024, Mega = 1024^2,Giga = 1024^3。通常,在网络中,Kilo = 1000, Mega = 1000^2, and Giga = 1000^3,所以,Iperf也按此来计算比特(位)。如果这些困扰了你,那么请使用-f b参数,然后亲自计算一下。 -i, --interval # $IPERF_INTERVAL 设置每次报告之间的时间间隔,单位为秒。如果设置为非零值,就会按照此时间间隔输出测试报告。默认值为零。 -l, --len #[KM] $IPERF_LEN 设置读写缓冲区的长度。TCP方式默认为8KB,UDP方式默认为1470字节。 -m, --print_mss $IPERF_PRINT_MSS 输出TCP MSS值(通过TCP_MAXSEG支持)。MSS值一般比MTU值小40字节。通常情况 -p, --port # $IPERF_PORT 设置端口,与服务器端的监听端口一致。默认是5001端口,与ttcp的一样。 -u, --udp $IPERF_UDP 使用UDP方式而不是TCP方式。参看-b选项。 -w, --window #[KM] $TCP_WINDOW_SIZE 设置套接字缓冲区为指定大小。对于TCP方式,此设置为TCP窗口大小。对于UDP方式,此设置为接受UDP数据包的缓冲区大小,限制可以接受数据包的最大值。 -B, --bind host $IPERF_BIND 绑定到主机的多个地址中的一个。对于客户端来说,这个参数设置了出栈接口。对于服务器端来说,这个参数设置入栈接口。这个参数只用于具有多网络接口的主机。在Iperf的UDP模式下,此参数用于绑定和加入一个多播组。使用范围在224.0.0.0至239.255.255.255的多播地址。参考-T 参数。 -C, --compatibility $IPERF_COMPAT 与低版本的Iperf使用时,可以使用兼容模式。不需要两端同时使用兼容模式,但是强烈推荐两端同时使用兼容模式。某些情况下,使用某些数据流可以引起1.7版本的服务器端崩溃或引起非预期的连接尝试。 -M, --mss #[KM} $IPERF_MSS 通过TCP_MAXSEG选项尝试设置TCP最大信息段的值。MSS值的大小通常是TCP/IP头减去40字节。在以太网中,MSS值 为1460字节(MTU1500字节)。许多操作系统不支持此选项。 -N, --nodelay $IPERF_NODELAY 设置TCP无延迟选项,禁用Nagle's运算法则。通常情况此选项对于交互程序,例如telnet,是禁用的。 -V (fro
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值