Repository: Zoxc/crusader
Branch: master
Commit: 5d1e6e76fb9b
Files: 64
Total size: 1002.4 KB
Directory structure:
gitextract_275plfem/
├── .dockerignore
├── .gitattributes
├── .github/
│ └── workflows/
│ ├── ci.yml
│ ├── release.md
│ └── release.yml
├── .gitignore
├── CHANGELOG.md
├── LICENSE-APACHE
├── LICENSE-MIT
├── README.md
├── android/
│ ├── .gitignore
│ ├── Cargo.toml
│ ├── app/
│ │ ├── build.gradle
│ │ └── src/
│ │ └── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── zoxc/
│ │ │ └── crusader/
│ │ │ └── MainActivity.java
│ │ └── res/
│ │ └── values/
│ │ ├── colors.xml
│ │ └── themes.xml
│ ├── build.gradle
│ ├── debugInstall.ps1
│ ├── gradle/
│ │ └── wrapper/
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradle.properties
│ ├── gradlew
│ ├── gradlew.bat
│ ├── settings.gradle
│ └── src/
│ └── lib.rs
├── data/
│ ├── v0.crr
│ ├── v1.crr
│ └── v2.crr
├── docker/
│ ├── README.md
│ ├── remote-static.Dockerfile
│ └── server-static.Dockerfile
├── docs/
│ ├── BUILDING.md
│ ├── CLI.md
│ ├── LOCAL_TESTS.md
│ ├── RESULTS.md
│ └── TROUBLESHOOTING.md
├── media/
│ ├── Crusader Screen Shots.md
│ └── batch_add_border.sh
└── src/
├── Cargo.toml
├── crusader/
│ ├── Cargo.toml
│ └── src/
│ └── main.rs
├── crusader-gui/
│ ├── Cargo.toml
│ └── src/
│ └── main.rs
├── crusader-gui-lib/
│ ├── Cargo.toml
│ └── src/
│ ├── client.rs
│ └── lib.rs
└── crusader-lib/
├── Cargo.toml
├── UFL.txt
├── assets/
│ ├── vue.js
│ └── vue.prod.js
├── build.rs
└── src/
├── common.rs
├── discovery.rs
├── file_format.rs
├── latency.rs
├── lib.rs
├── peer.rs
├── plot.rs
├── protocol.rs
├── remote.html
├── remote.rs
├── serve.rs
└── test.rs
================================================
FILE CONTENTS
================================================
================================================
FILE: .dockerignore
================================================
/src/target
================================================
FILE: .gitattributes
================================================
src/crusader-lib/assets/* linguist-vendored
================================================
FILE: .github/workflows/ci.yml
================================================
name: ci
on:
push:
branches: [master]
pull_request:
env:
CARGO_INCREMENTAL: 0
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Build server-only binary
run: cargo build -p crusader --no-default-features
working-directory: src
- name: Build
run: cargo build
working-directory: src
- name: Lint
run: cargo clippy --all -- -D warnings
working-directory: src
- name: Format
run: cargo fmt --all -- --check
working-directory: src
android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Install Rust targets
run: >
rustup target add
aarch64-linux-android
armv7-linux-androideabi
x86_64-linux-android
i686-linux-android
- name: Install cargo-ndk
run: cargo install cargo-ndk
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- name: Build Android Rust crates
working-directory: android
run: cargo ndk -t arm64-v8a -o app/src/main/jniLibs/ -- build
- name: Build Android APK
working-directory: android
run: ./gradlew buildDebug
# Wait for a new cargo ndk release for better clippy support
#- name: Lint
# run: cargo ndk -t arm64-v8a -- clippy --all -- -D warnings
# working-directory: android
- name: Format
run: cargo fmt --all -- --check
working-directory: android
================================================
FILE: .github/workflows/release.md
================================================
Crusader has pre-built binaries for a number of operating systems. Download the appropriate binary below for your OS.
================================================
FILE: .github/workflows/release.yml
================================================
name: release
on:
push:
tags:
- "v*"
env:
CARGO_INCREMENTAL: 0
jobs:
create-release:
name: create-release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.release.outputs.upload_url }}
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- name: Get the release version from the tag
shell: bash
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Create GitHub release
id: release
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.TAG_NAME }}
release_name: Automated build of ${{ env.TAG_NAME }}
prerelease: true
body_path: .github/workflows/release.md
release-assets:
name: Release assets
needs: create-release
runs-on: ${{ matrix.build.os }}
strategy:
fail-fast: false
matrix:
build:
- os: ubuntu-latest
target: arm-unknown-linux-musleabihf
friendly: Linux-ARM-32-bit
exe_postfix:
cargo: cross
gui: false
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
friendly: Linux-ARM-64-bit
exe_postfix:
cargo: cross
gui: false
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
friendly: Linux-X86-64-bit
exe_postfix:
cargo: cargo
gui: false
- os: macos-latest
target: aarch64-apple-darwin
friendly: macOS-ARM-64-bit
exe_postfix:
cargo: cargo
gui: true
- os: macos-latest
target: x86_64-apple-darwin
friendly: macOS-X86-64-bit
exe_postfix:
cargo: cargo
gui: true
- os: windows-latest
target: i686-pc-windows-msvc
friendly: Windows-X86-32-bit
exe_postfix: .exe
cargo: cargo
gui: true
- os: windows-latest
target: x86_64-pc-windows-msvc
friendly: Windows-X86-64-bit
exe_postfix: .exe
cargo: cargo
gui: true
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
target: ${{ matrix.build.target }}
- name: Install cross
if: matrix.build.cargo == 'cross'
run: cargo install cross
- name: Install and use musl
if: matrix.build.os == 'ubuntu-latest' && matrix.build.cargo != 'cross'
run: |
sudo apt-get install -y --no-install-recommends musl-tools
echo "CC=musl-gcc" >> $GITHUB_ENV
echo "AR=ar" >> $GITHUB_ENV
- name: Build command line binary
if: ${{ !matrix.build.gui }}
run: ${{ matrix.build.cargo }} build -p crusader --target ${{ matrix.build.target }} --release
working-directory: src
env:
RUSTFLAGS: "-C target-feature=+crt-static"
- name: Build
if: matrix.build.gui
run: ${{ matrix.build.cargo }} build --target ${{ matrix.build.target }} --release
working-directory: src
env:
RUSTFLAGS: "-C target-feature=+crt-static"
- name: Build output
shell: bash
run: |
staging="Crusader-${{ matrix.build.friendly }}"
mkdir -p "$staging"
cp src/target/${{ matrix.build.target }}/release/crusader${{ matrix.build.exe_postfix }} "$staging/"
- name: Copy GUI binary
if: matrix.build.gui
shell: bash
run: |
cp src/target/${{ matrix.build.target }}/release/crusader-gui${{ matrix.build.exe_postfix }} "crusader-${{ matrix.build.friendly }}/"
- name: Archive output
if: matrix.build.os == 'windows-latest'
shell: bash
run: |
staging="Crusader-${{ matrix.build.friendly }}"
7z a "$staging.zip" "$staging"
echo "ASSET=$staging.zip" >> $GITHUB_ENV
- name: Archive output
if: matrix.build.os != 'windows-latest'
shell: bash
run: |
staging="Crusader-${{ matrix.build.friendly }}"
tar czf "$staging.tar.gz" "$staging"
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
- name: Upload archive
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_name: ${{ env.ASSET }}
asset_path: ${{ env.ASSET }}
asset_content_type: application/octet-stream
release-android-assets:
name: Android APK
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install Rust targets
run: >
rustup target add
aarch64-linux-android
armv7-linux-androideabi
x86_64-linux-android
i686-linux-android
- name: Install cargo-ndk
run: cargo install cargo-ndk
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- name: Build Android Rust crates
working-directory: android
run: >
cargo ndk
-t arm64-v8a
-t armeabi-v7a
-t x86_64
-t x86
-o app/src/main/jniLibs/ -- build --release
- name: Decode Keystore
env:
ENCODED_STRING: ${{ secrets.KEYSTORE }}
run: echo "$ENCODED_STRING" | base64 -di > ../android.keystore
- name: Build Android APK
working-directory: android
run: ./gradlew build
env:
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
- name: Upload APK
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_name: Crusader-Android.apk
asset_path: android/app/build/outputs/apk/release/app-release.apk
asset_content_type: application/octet-stream
================================================
FILE: .gitignore
================================================
/src/target
================================================
FILE: CHANGELOG.md
================================================
# CHANGELOG
The **Crusader Network Tester** measures network rates and latency
in the presence of upload and download traffic.
It produces plots of the traffic rates,
latency and packet loss.
This file lists the changes that have occurred since January 2024 in the project.
## Unreleased
## 0.3.2 - 2024-10-03
* Fix saved raw data path printed after a test
* Avoid duplicate legends when plotting transferred bytes
* Make `--plot-transferred` increase default plot height
* Fix unique output path generation
## 0.3.1 - 2024-09-30
* Increase samples used for clock synchronization and idle latency measurement
* Clock synchronization now uses the average of the lowest 1/3rd of samples
* Adjust for clock drift in tests
* Fix connecting to servers on non-standard port with peers
* Make discovery more robust by sending multiple packets
## 0.3 - 2024-09-16
* Show throughput, latency, and packet loss summaries in plots and with the `test` command
* Rename both option to bidirectional
* Rename `--latency-peer-server` to `--latency-peer-address`
* Continuous clock synchronization with the latency monitor
* Support opening result files in the GUI by drag and drop
* Add `--out-name` command line option to specify result filename prefix
* Change filename prefix for both raw result and plots to `test`
* Add file dialog to save options in GUI
* Add buttons to save and load from the `crusader-results` folder in GUI
* Add an `export` command line command to convert result files to JSON
* Change timeout when connecting a peer to the server to 8 seconds
* Hide advanced parameters in GUI
* Add a reset parameters button in GUI
* Add an option to measure latency-only for the client in the GUI
* Don't allow peers to connect with the regular server
* Added average lines in GUI
## 0.2 - 2024-08-29
* Added support for local discovery of server and peers using UDP port 35483
* The `test` command line option `--latency-peer` is renamed to `--latency-peer-server`.
A new flag `--latency-peer` will instead search for a local peer.
* Improved error messages
* Fix date/time display in remote web page
* Rename the `Latency` tab to `Monitor`
* Change default streams from 16 to 8.
* Change default throughput sample interval from 20 ms to 60 ms.
* Change default load duration from 5 s to 10 s.
* Change default grace duration from 5 s to 10 s.
* Fix serving from link-local interfaces on Linux
* Fix peers on link-local interfaces
* Show download and upload plots for aggregate tests in the GUI
* Added a shortcut (space) to stop the latency monitor
* Change timeout when connecting to servers and peers to 8 seconds
* Added average lines to the plot output
* Show interface IPs when starting servers
## 0.1 - 2024-08-21
* Added `crusader remote` command to start a web server listening on port 35482.
It allows starting tests on a separate machine and
displays the resulting charts in the web page.
* Use system fonts in GUI
* Improved error handling and error messages
* Added `--idle` option to the client to test without traffic
* Save results in a `crusader-results` folder
* Allow building of a server-only binary
* Generated files will use a YYYY-MM-DD HH.MM.SS format
* Rename bandwidth to throughput
* Rename sample rate to sample interval
* Rename `Both` to `Aggregate` and `Total` to `Round-trip` in plots
## 0.0.12 - 2024-07-31
* Create UDP server for each server IP (fixes #22)
* Improved error handling for log messages
* Changed date format to use YYYY-MM-DD in logs
## 0.0.11 - 2024-07-29
* Log file includes timestamps and version number
* Added peer latency measurements
* Added version to title bar of GUI
* Added `plot_max_bandwidth` and `plot_max_latency` command line options
## 0.0.10 - 2024-01-09
* Specify plot title
* Ignore ENOBUFS error
================================================
FILE: LICENSE-APACHE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
================================================
FILE: LICENSE-MIT
================================================
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
================================================
FILE: README.md
================================================
# Crusader Network Tester
[](https://github.com/Zoxc/crusader/releases)
[](https://hub.docker.com/r/zoxc/crusader)
[](https://github.com/Zoxc/crusader/blob/master/LICENSE-MIT)
[](https://github.com/Zoxc/crusader/blob/master/LICENSE-APACHE)

The **Crusader Network Tester** measures network throughput, latency and packet loss
in the presence of upload and download traffic.
It also incorporates a continuous latency tester for
monitoring background responsiveness.
Crusader makes throughput measurements using TCP on port 35481
and latency tests using UDP port 35481.
The remote web server option uses TCP port 35482.
Local server discovery uses UDP port 35483.
**Pre-built binaries** for Windows, Mac, Linux,
and Android are available on the
[Releases](https://github.com/Zoxc/crusader/releases) page.
The GUI is not prebuilt for Linux and must be built from source.
**Documentation** See the [Documentation](#documentation)
section below.
**Status:** The latest Crusader release version is shown above.
The [pre-built binaries](https://github.com/Zoxc/crusader/releases)
always provide the latest version.
See the [CHANGELOG.md](./CHANGELOG.md) file for details.
## Crusader GUI
A test run requires two separate computers,
both running Crusader:
a **server** that listens for connections, and
a **client** that initiates the test.
The Crusader GUI incorporates both the server and
the client and allows you to interact with results.
To use it, download the proper binary from the
[Releases](https://github.com/Zoxc/crusader/releases) page.
When you open the `crusader-gui` you see this window.
Enter the address of another computer that's
running the Crusader server, then click **Start test**.
When the test is complete, the **Result** tab shows a
chart like the second image below.
An easy way to use Crusader is to download
the Crusader GUI onto two computers, then
start the server on one computer, and the client on the other.

The Crusader GUI has five tabs:
* **Client tab**
Runs the Crusader client program.
The options shown above are described in the
[Command-line options](./docs/CLI.md) page.
* **Server tab**
Runs the Crusader server, listening for connections from other clients
* **Remote tab**
Starts a webserver (default port 35482).
A browser that connects to that port can initiate
a test to a Crusader server.
* **Monitor tab**
Continually displays the latency to the selected
Crusader server until stopped.
* **Result tab**
Displays the result of the most recent client run
## The Result Tab

A Crusader test creates three bursts of traffic.
By default, it generates ten seconds each of
download only, upload only, then bi-directional traffic.
Each burst is separated by several seconds of idle time.
The Crusader Result tab displays the results of the test with
three plots (see image above):
* The **Throughput** plot shows the bursts of traffic.
Green is download (from server to client),
blue is upload, and
the purple line is the instantaneous
sum of the download plus upload.
* The **Latency** plot shows the corresponding latency.
Green shows the (uni-directional) time from the server to the client.
Blue is the (uni-directional) time from the client to the server.
Black shows the sum from the client to the server
and back (round-trip time).
* The **Packet Loss** plot has green and blue marks
that indicate times when packets were lost.
For more details, see the
[Understanding Crusader Results](./docs/RESULTS.md) page.
## Documentation
* [This README](./README.md)
* [Understanding Crusader Results](./docs/RESULTS.md)
* [Local Testing](./docs/LOCAL_TESTS.md)
* [Command-line Options](./docs/CLI.md)
* [Building Crusader from source](./docs/BUILDING.md)
* [Troubleshooting](./docs/TROUBLESHOOTING.md)
* [Docker container](https://hub.docker.com/r/zoxc/crusader)
for the server is available on
[dockerhub](https://hub.docker.com/r/zoxc/crusader).
================================================
FILE: android/.gitignore
================================================
.gradle
/target
/app/build
/app/src/main/jniLibs
================================================
FILE: android/Cargo.toml
================================================
[package]
name = "crusader-android"
version = "0.1.0"
edition = "2021"
resolver = "2"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
log = "0.4"
eframe = { version = "0.28.1", features = ["wgpu"] }
crusader-gui-lib = { path = "../src/crusader-gui-lib" }
crusader-lib = { path = "../src/crusader-lib" }
winit = "0.29.15"
jni = "0.19.0"
ndk-context = "0.1"
[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.11.0"
android-activity = { version = "0.5", features = ["game-activity"] }
[patch.crates-io]
winit = { git = "https://github.com/Zoxc/winit", branch = "crusader2" }
egui = { git = "https://github.com/Zoxc/egui", branch = "crusader2" }
epaint = { git = "https://github.com/Zoxc/egui", branch = "crusader2" }
emath = { git = "https://github.com/Zoxc/egui", branch = "crusader2" }
egui_plot = { git = "https://github.com/Zoxc/egui_plot", branch = "crusader" }
[lib]
name = "main"
crate-type = ["cdylib"]
================================================
FILE: android/app/build.gradle
================================================
plugins {
id 'com.android.application'
}
android {
compileSdk 31
defaultConfig {
applicationId "zoxc.crusader"
minSdk 28
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
storeFile = file("../../../android.keystore")
storePassword System.getenv("SIGNING_STORE_PASSWORD")
keyAlias System.getenv("SIGNING_KEY_ALIAS")
keyPassword System.getenv("SIGNING_KEY_PASSWORD")
}
}
buildTypes {
release {
minifyEnabled false
signingConfig signingConfigs.release
}
debug {
minifyEnabled false
//packagingOptions {
// doNotStrip '**/*.so'
//}
//debuggable true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'com.google.android.material:material:1.5.0'
implementation "androidx.games:games-activity:2.0.2"
// To use the Games Controller Library
//implementation "androidx.games:games-controller:1.1.0"
// To use the Games Text Input Library
//implementation "androidx.games:games-text-input:1.1.0"
}
================================================
FILE: android/app/src/main/AndroidManifest.xml
================================================
================================================
FILE: android/app/src/main/java/zoxc/crusader/MainActivity.java
================================================
package zoxc.crusader;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.WindowInsetsControllerCompat;
import com.google.androidgamesdk.GameActivity;
import android.os.Bundle;
import android.content.pm.PackageManager;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.util.Log;
import android.content.Intent;
import android.net.Uri;
import android.app.Activity;
import android.view.inputmethod.InputMethodManager;
import android.provider.OpenableColumns;
import android.database.Cursor;
import android.content.Context;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
public class MainActivity extends GameActivity {
static {
System.loadLibrary("main");
}
public void showKeyboard(boolean show) {
InputMethodManager input = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
if (show) {
input.showSoftInput(getWindow().getDecorView().getRootView(), 0);
} else {
input.hideSoftInputFromWindow(getWindow().getDecorView().getRootView().getWindowToken(), 0);
}
}
public void loadFile() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
startActivityForResult(intent, ACTIVITY_LOAD_FILE);
}
public void saveFile(boolean image, String name, byte[] data) {
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
if (image) {
intent.setType("image/png");
} else {
intent.setType("application/octet-stream");
}
intent.putExtra(Intent.EXTRA_TITLE, name);
saveFileData = data;
saveImage = image;
startActivityForResult(intent, ACTIVITY_CREATE_FILE);
}
private byte[] saveFileData = null;
private boolean saveImage;
private static final int ACTIVITY_LOAD_FILE = 1;
private static final int ACTIVITY_CREATE_FILE = 2;
static native void fileLoaded(String name, byte[] data);
static native void fileSaved(boolean image, String name);
@Override
public void onActivityResult(int requestCode, int resultCode,
Intent resultData) {
super.onActivityResult(requestCode, resultCode, resultData);
if (requestCode == ACTIVITY_CREATE_FILE) {
if (resultCode == Activity.RESULT_OK && resultData != null) {
Uri uri = resultData.getData();
String name = getName(uri);
try {
OutputStream stream = getContentResolver().openOutputStream(uri);
stream.write(saveFileData);
stream.close();
fileSaved(saveImage, name);
}
catch(Exception e) {}
}
saveFileData = null;
}
if (requestCode == ACTIVITY_LOAD_FILE
&& resultCode == Activity.RESULT_OK
&& resultData != null) {
Uri uri = resultData.getData();
String name = getName(uri);
try {
InputStream stream = getContentResolver().openInputStream(uri);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int read;
byte[] byte_buffer = new byte[0x1000];
while ((read = stream.read(byte_buffer, 0, byte_buffer.length)) != -1) {
buffer.write(byte_buffer, 0, read);
}
stream.close();
byte[] data = buffer.toByteArray();
fileLoaded(name, data);
}
catch(Exception e) {}
}
}
public String getName(Uri uri) {
Cursor cursor = getContentResolver().query(uri, null, null, null, null, null);
String name = "";
try {
if (cursor != null && cursor.moveToFirst()) {
int column = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
if (column != -1) {
name = cursor.getString(column);
}
return name;
}
} finally {
cursor.close();
}
return name;
}
}
================================================
FILE: android/app/src/main/res/values/colors.xml
================================================
#FFBB86FC#FF6200EE#FF3700B3#FF03DAC5#FF018786#FF000000#FFFFFFFF#FFE6E6E6
================================================
FILE: android/app/src/main/res/values/themes.xml
================================================
================================================
FILE: android/build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.1.2' apply false
id 'com.android.library' version '7.1.2' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
================================================
FILE: android/debugInstall.ps1
================================================
$ErrorActionPreference = "Stop"
cargo ndk -t arm64-v8a -o app/src/main/jniLibs/ -- build --release
if ($lastexitcode -ne 0) {
throw "Error"
}
./gradlew.bat buildDebug
if ($lastexitcode -ne 0) {
throw "Error"
}
./gradlew.bat installDebug
if ($lastexitcode -ne 0) {
throw "Error"
}
================================================
FILE: android/gradle/wrapper/gradle-wrapper.properties
================================================
#Mon May 02 15:39:12 BST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
================================================
FILE: android/gradle.properties
================================================
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
================================================
FILE: android/gradlew
================================================
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# 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
#
# https://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.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"
================================================
FILE: android/gradlew.bat
================================================
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: android/settings.gradle
================================================
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
include ':app'
================================================
FILE: android/src/lib.rs
================================================
#![allow(
clippy::field_reassign_with_default,
clippy::option_map_unit_fn,
clippy::missing_safety_doc
)]
use crusader_gui_lib::Tester;
use crusader_lib::file_format::RawResult;
use eframe::egui::{self, vec2, Align, FontFamily, Layout};
use jni::{
objects::{JClass, JObject, JString},
sys::{jboolean, jbyteArray},
JNIEnv,
};
use std::{
error::Error,
io::Cursor,
path::Path,
sync::{Arc, Mutex},
};
#[cfg(target_os = "android")]
use {
android_activity::AndroidApp,
crusader_lib::test::PlotConfig,
eframe::{NativeOptions, Renderer, Theme},
log::Level,
std::fs,
winit::platform::android::EventLoopBuilderExtAndroid,
};
struct App {
tester: Tester,
keyboard_shown: bool,
}
impl eframe::App for App {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
use eframe::egui::FontFamily::Proportional;
use eframe::egui::FontId;
use eframe::egui::TextStyle::*;
let mut style = ctx.style();
let style_ = Arc::make_mut(&mut style);
style_.spacing.button_padding = vec2(10.0, 0.0);
style_.spacing.interact_size.y = 40.0;
style_.spacing.item_spacing = vec2(10.0, 10.0);
style_.text_styles = [
(Heading, FontId::new(26.0, Proportional)),
(Body, FontId::new(16.0, Proportional)),
(Monospace, FontId::new(16.0, FontFamily::Monospace)),
(Button, FontId::new(16.0, Proportional)),
(Small, FontId::new(16.0, Proportional)),
]
.into();
ctx.set_style(style);
egui::CentralPanel::default().show(ctx, |ui| {
let mut rect = ui.max_rect();
rect.set_top(rect.top() + 40.0);
rect.set_height(rect.height() - 60.0);
let mut ui = ui.child_ui(rect, Layout::left_to_right(Align::Center), None);
ui.vertical(|ui| {
ui.heading("Crusader Network Benchmark");
ui.separator();
SAVED_FILE.lock().unwrap().take().map(|(image, name)| {
if !image {
self.tester.save_raw(Path::new(&name).to_owned());
}
});
LOADED_FILE.lock().unwrap().take().map(|(name, data)| {
RawResult::load_from_reader(Cursor::new(data))
.map(|data| self.tester.load_file(Path::new(&name).to_owned(), data));
});
self.tester.show(ctx, ui);
});
});
if ctx.wants_keyboard_input() != self.keyboard_shown {
show_keyboard(ctx.wants_keyboard_input()).unwrap();
self.keyboard_shown = ctx.wants_keyboard_input();
}
}
}
fn show_keyboard(show: bool) -> Result<(), Box> {
let context = ndk_context::android_context();
let vm = unsafe { jni::JavaVM::from_raw(context.vm().cast())? };
let activity: JObject = (context.context() as jni::sys::jobject).into();
let env = vm.attach_current_thread()?;
env.call_method(activity, "showKeyboard", "(Z)V", &[show.into()])?
.v()?;
Ok(())
}
fn save_file(image: bool, name: String, data: Vec) -> Result<(), Box> {
let context = ndk_context::android_context();
let vm = unsafe { jni::JavaVM::from_raw(context.vm().cast())? };
let activity: JObject = (context.context() as jni::sys::jobject).into();
let env = vm.attach_current_thread()?;
env.call_method(
activity,
"saveFile",
"(ZLjava/lang/String;[B)V",
&[
image.into(),
env.new_string(name).unwrap().into(),
env.byte_array_from_slice(&data).unwrap().into(),
],
)?
.v()?;
Ok(())
}
static SAVED_FILE: Mutex