LoginSignup
0
0

Android用のiperf3

Posted at

About this

Android用のiperfバイナリを作成する機会があったので手順を記載したもの。

Prerequisites

  • Docker
  • adb

Build

Dockerfileを作ってビルドを実施した。
作成したイメージの中にiperf3のバイナリファイルができているので、イメージ作成後、docker cpで取得する。

コマンド
$ mkdir work
$ cd work
$ vi Dokerfile ## 下のほうに記載している内容のファイルを作成する
$ docker buildx build --no-cache -t iperf:3.17.1 --load 3.17.1
$ docker run -d -t --name iperf3 iperf:3.17.1
$ docker cp iperf3:/iperf/src/iperf3 .
$ docker rm -f iperf3
$ docker rmi iperf:3.17.1

Usage

作成したiperf3バイナリファイルは、adbコマンドでandroid端末に転送し、adb shellコマンドで端末にログインしすることで操作できる。

コマンド
PS> adb push iperf3 /data/local/tmp/
PS> adb shell
(Android)# cd /data/local/tmp
(Android)# chmod 777 /data/local/tmp/iperf3
(Android)# ./iperf3 -version

adbコマンドがない場合は、インストールする

コマンド
PS> winget install Google.PlatformTools

Dockerfile

Dockerfile
FROM ubuntu:24.04

RUN apt update
# for Android NDK
RUN apt install -y unzip binutils wget
# for iperf build
RUN apt install -y git make file wget

# Install Android NDK
# 
# Please specify the optimal NDK version from following URL.
# https://developer.android.com/ndk/downloads
WORKDIR /
RUN wget -q https://dl.google.com/android/repository/android-ndk-r26d-linux.zip && \
    unzip android-ndk-r26d-linux.zip

# Clone iperf
WORKDIR /
RUN git clone https://github.com/esnet/iperf && \
    cd iperf/ && \
    git checkout -b 3.17.1 refs/tags/3.17.1

# Patch
# https://github.com/esnet/iperf/pull/1687
WORKDIR /iperf/
RUN git remote add patch https://github.com/tqfx/iperf && \
    git fetch patch && \
    git cherry-pick -n 6f1e96ffe230b38efcf92856bfd9535279c93586

# Build
WORKDIR /iperf/
ENV PATH="${PATH}:/android-ndk-r26d/:/android-ndk-r26d/toolchains/llvm/prebuilt/linux-x86_64/bin/"
# Please check API level.
# https://developer.android.com/guide/topics/manifest/uses-sdk-element?hl=ja#api-level-table
RUN ./configure --host=aarch64-linux-android CC=aarch64-linux-android30-clang CXX=aarch64-linux-android30-clang++ CFLAGS=-static CXXFLAGS=-static
RUN make
RUN file src/iperf3

Android NDK Version

API level

patch

  • Commit: 6f1e96ffe230b38efcf92856bfd9535279c93586
  • iper v3.16から-P/--parallelオプションがサポートされた(PR#1591)影響で、build時にpthreadsが必要となったが、Android NDKを使ったbuildに失敗する事象(Issue#1641)が出ていた
  • PR#1651で修正コミットがマージされているが、この修正でもエラーが解消されてないようで、追加のPR#1687がでており、v3.17.1にはマージされていなかったためcherry-pickした
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0