https://github.com/local-connectivity-lab/lcl-ping
A Ping library written in Swift for network latency measurement and reachability monitoring. Built with SwiftNIO
https://github.com/local-connectivity-lab/lcl-ping
latency-monitor latency-test network network-analysis ping reachability swift
Last synced: 3 months ago
JSON representation
A Ping library written in Swift for network latency measurement and reachability monitoring. Built with SwiftNIO
- Host: GitHub
- URL: https://github.com/local-connectivity-lab/lcl-ping
- Owner: Local-Connectivity-Lab
- License: apache-2.0
- Created: 2023-08-22T07:04:05.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-14T04:51:07.000Z (6 months ago)
- Last Synced: 2025-07-20T21:26:38.616Z (3 months ago)
- Topics: latency-monitor, latency-test, network, network-analysis, ping, reachability, swift
- Language: Swift
- Homepage: https://swiftpackageindex.com/Local-Connectivity-Lab/lcl-ping/main/documentation/lclping
- Size: 364 KB
- Stars: 23
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
---
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

## Requirements
- Swift 5.7+
- macOS 10.15+, iOS 14+, Linux## Getting Started
### Swift Package Manager (SPM)
Add the following to your `Package.swift` file:
```code
.package(url: "https://github.com/Local-Connectivity-Lab/lcl-ping.git", from: "1.0.0")
```Then import the module to your project
```code
.target(
name: "YourAppName",
.dependencies: [
.product(name: "LCLPing", package: "lcl-ping")
]
)
```### Basic Usage
```swift
// Reachability Test
let isReachable = LCLPing.reachable(via: .icmp, strategy: .multiple, host: "google.com")
print("is reachable: \(isReachable)")
``````swift
// 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](/Sources/Demo/README.md) 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](https://discord.com/invite/gn4DKF83bP), or visit our [website](https://seattlecommunitynetwork.org/).## License
LCLPing is released under Apache License. See [LICENSE](/LICENSE) for more details.