Giter VIP home page Giter VIP logo

local-connectivity-lab / lcl-ping Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 0.0 361 KB

A Ping library written in Swift for network latency measurement and reachability monitoring. Built with SwiftNIO

Home Page: https://swiftpackageindex.com/Local-Connectivity-Lab/lcl-ping/main/documentation/lclping

License: Apache License 2.0

Swift 98.26% Makefile 0.57% Python 1.17%
latency-monitor latency-test network network-analysis ping reachability swift

lcl-ping's Introduction

Logo

LCLPing is a cross-platform Ping library written in Swift, and for Swift. It is designed to help streamline testing, measuring, and monitoring network reachability and latency for both the client side and server side applications and services.

LCLPing

Apple platform CI Ubuntu CI

Requirements

  • Swift 5.7+
  • macOS 10.15+, iOS 14+, Linux

Getting Started

Swift Package Manager (SPM)

Add the following to your Package.swift file:

.package(url: "https://github.com/Local-Connectivity-Lab/lcl-ping.git", from: "1.0.0")

Then import the module to your project

.target(
    name: "YourAppName",
    .dependencies: [
        .product(name: "LCLPing", package: "lcl-ping")
    ]
)

Basic Usage

// Reachability Test
let isReachable = LCLPing.reachable(via: .icmp, strategy: .multiple, host: "google.com")
print("is reachable: \(isReachable)")
// Run Ping Test

// create ping configuration for each run
let icmpConfig = ICMPPingClient.Configuration(endpoint: .ipv4("127.0.0.1", 0), count: 1)
let httpConfig = try HTTPPingClient.Configuration(url: "http://127.0.0.1:8080", count: 1)

// initialize test client
let icmpClient = ICMPPingClient(configuration: icmpConfig)
let httpClient = HTTPPingClient(configuration: httpConfig)

do {
    // run the test using SwiftNIO EventLoopFuture
    let result = try icmpClient.start().wait()
    print(result)
} catch {
    print("received: \(error)")
}

do {
    let result = try httpClient.start().wait()
    print(result)
} catch {
    print("received: \(error)")
}

You can also run the demo using make demo or swift run Demo if you do not have make installed.

Features

  • Ping via ICMP and HTTP(S)
  • Support IPv4 ICMP and IPv4 and IPv6 for HTTP
  • Flexible and configurable wait time, time-to-live, count, and duration
  • Supports parsing Server-Timing in the HTTP header to account for time taken by server processing

Contributing

Any contribution and pull requests are welcome! However, before you plan to implement some features or try to fix an uncertain issue, it is recommended to open a discussion first. You can also join our Discord channel, or visit our website.

License

LCLPing is released under Apache License. See LICENSE for more details.

lcl-ping's People

Contributors

johnnzhou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

lcl-ping's Issues

Leaking promise

Got the following when trying to run the example:

LCLPing/ICMPPingClient.swift:46: Fatal error: leaking promise created at (file: "LCLPing/ICMPPingClient.swift", line: 46)

Let me know if you need further info.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.