An easy to use Swift wrapper for iPerf.
An application using this package: iPerf SwiftUI
Package implements iPerf server and client.
Usage example:
class IperfRunnerController: ObservableObject, Identifiable {
private var iperfRunner: IperfRunner?
@Published var isDeleted = false
@Published var runnerState: IperfRunnerState = .ready
@Published var debugDescription: String = ""
@Published var displayError: Bool = false
@Published var results = [IperfIntervalResult]() {
didSet {
objectWillChange.send()
}
}
func onResultReceived(result: IperfIntervalResult) {
if result.streams.count > 0 {
results.append(result)
}
}
func onErrorReceived(error: IperfError) {
DispatchQueue.main.async {
self.displayError = error != .IENONE
self.debugDescription = error.debugDescription
}
}
func onNewState(state: IperfRunnerState) {
if state != .unknown && state != runnerState {
DispatchQueue.main.async {
self.runnerState = state
}
}
}
func start() {
self.formInput = formInput
results = []
debugDescription = ""
iperfRunner = IperfRunner(with: IperfConfiguration())
iperfRunner!.start(
onResultReceived,
onErrorReceived,
onNewState
)
}
func stop() {
iperfRunner!.stop()
}
}
Need compiling OpenSSL, see https://github.com/x2on/OpenSSL-for-iPhone
Sync iPerf
Thanks to ndfred sync.sh
- Run
sync.sh
- Add
#include <File.h>
in/Sources/IperfCLib/include/iperf.h
andSources/IperfCLib/include/iperf_util.h
- Add
#ifdef __linux__
inSources/IperfCLib/include/flowlabel.h
- Add
#if defined(HAVE_SSL)
inSources/IperfCLib/include/iperf_auth.h
iperf-swift is released under the MIT license. iperf is released under the BSD license. See LICENSE for details.