Skip to content

An easy to use Swift wrapper for iPerf3

License

Notifications You must be signed in to change notification settings

gewill/iperf-swift

This branch is 28 commits ahead of igorskh/iperf-swift:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

939a061 · Jan 7, 2024

History

58 Commits
Nov 8, 2020
Jan 7, 2024
Nov 8, 2020
Nov 8, 2020
Feb 18, 2023
Aug 11, 2023
Aug 14, 2023
Dec 20, 2023

Repository files navigation

Swift wrapper for iPerf

An easy to use Swift wrapper for iPerf.

Usage

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()
    }
}

OpenSSL

Need compiling OpenSSL, see https://github.com/x2on/OpenSSL-for-iPhone

Sync iPerf

Thanks to ndfred sync.sh

  1. Run sync.sh
  2. Add #include <File.h> in /Sources/IperfCLib/include/iperf.h and Sources/IperfCLib/include/iperf_util.h
  3. Add #ifdef __linux__ inSources/IperfCLib/include/flowlabel.h
  4. Add #if defined(HAVE_SSL) in Sources/IperfCLib/include/iperf_auth.h

License

iperf-swift is released under the MIT license. iperf is released under the BSD license. See LICENSE for details.

About

An easy to use Swift wrapper for iPerf3

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 94.5%
  • Swift 5.4%
  • Shell 0.1%