Skip to content

Commit f24196b

Browse files
committed
bump lcl-ping version
1 parent 506615c commit f24196b

File tree

7 files changed

+210
-161
lines changed

7 files changed

+210
-161
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let package = Package(
99
.macOS(.v11)
1010
],
1111
dependencies: [
12-
.package(url: "https://github.com/Local-Connectivity-Lab/lcl-ping.git", branch: "main"),
12+
.package(url: "https://github.com/Local-Connectivity-Lab/lcl-ping.git", from: "1.0.0"),
1313
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.3"),
1414
.package(url: "https://github.com/jpsim/Yams.git", from: "5.0.6"),
1515
.package(url: "https://github.com/scottrhoyt/SwiftyTextTable.git", from: "0.9.0"),

Sources/Command/CellularSiteCommand.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import ArgumentParser
1616
extension LCLCLI {
1717
struct CelluarSiteCommand: AsyncParsableCommand {
1818
static let configuration = CommandConfiguration(
19-
commandName: "cellular-sites",
20-
abstract: "Get info on SCN cellular sites"
21-
)
19+
commandName: "cellular-sites",
20+
abstract: "Get info on SCN cellular sites"
21+
)
2222
func run() async throws {
2323
let result: Result<[CellularSite]?, CLIError> = await NetworkingAPI
2424
.get(from: NetworkingAPI.Endpoint.site.url)

Sources/Command/LCLCLI.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import Glibc // GlibC Linux platforms
2525
@main
2626
struct LCLCLI: AsyncParsableCommand {
2727
static var configuration: CommandConfiguration = CommandConfiguration(
28-
commandName: "lclping",
28+
commandName: "lcl",
2929
abstract: "A command-line tool from Local Connectivity Lab @UWCSE",
3030
subcommands: [
3131
RegisterCommand.self,
@@ -34,7 +34,6 @@ struct LCLCLI: AsyncParsableCommand {
3434
MeasureCommand.self,
3535
NetworkInterfaceCommand.self,
3636
CelluarSiteCommand.self
37-
],
38-
defaultSubcommand: PingCommand.self
37+
]
3938
)
4039
}

Sources/Command/Measure.swift

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ extension LCLCLI {
2222
@Option(name: .shortAndLong, help: "Show datapoint on SCN's public visualization. Your contribution will help others better understand our coverage.")
2323
var showData: Bool = false
2424

25-
static let configuration = CommandConfiguration(commandName: "measure", abstract: "Run SCN test suite and optionally report the measurement result to SCN.")
25+
static let configuration = CommandConfiguration(
26+
commandName: "measure",
27+
abstract: "Run SCN test suite and optionally report the measurement result to SCN."
28+
)
2629

2730
func run() async throws {
2831
let encoder: JSONEncoder = JSONEncoder()
@@ -70,19 +73,17 @@ extension LCLCLI {
7073
throw CLIError.contentCorrupted
7174
}
7275

73-
let pingOptions = LCLPing.Options()
74-
let pingConfig = LCLPing.PingConfiguration(type: .icmp, endpoint: .ipv4("google.com", 0))
76+
let pingConfig = try ICMPPingClient.Configuration(endpoint: .ipv4("google.com", 0))
7577
let outputFormats: Set<OutputFormat> = [.default]
7678

77-
var ping = LCLPing(options: pingOptions)
79+
let client = ICMPPingClient(configuration: pingConfig)
7880
let speedTest = SpeedTest(testType: .downloadAndUpload)
7981

8082
signal(SIGINT, SIG_IGN)
8183
let stopSignal = DispatchSource.makeSignalSource(signal: SIGINT, queue: .main)
8284
stopSignal.setEventHandler {
8385
print("Exit from SCN Measurement Test")
84-
// picker.exit()
85-
ping.stop()
86+
client.cancel()
8687
speedTest.stop()
8788
return
8889
}
@@ -95,21 +96,13 @@ extension LCLCLI {
9596

9697
let deviceId = UUID().uuidString
9798

98-
var isPingComplete: Bool = false
99-
try await ping.start(pingConfiguration: pingConfig)
100-
switch ping.status {
101-
case .error, .ready, .running:
102-
print("Ping Test encountered some error while running tests")
103-
case .stopped, .finished:
104-
isPingComplete = true
105-
}
99+
let summary = try await client.start().get()
106100

107101
let speedTestResults = try await speedTest.run()
108102
let downloadSummary = prepareSpeedTestSummary(data: speedTestResults.download, unit: .Mbps)
109103
let uploadSummary = prepareSpeedTestSummary(data: speedTestResults.upload, unit: .Mbps)
110-
if isPingComplete {
111-
generatePingSummary(ping.summary, for: .icmp, formats: outputFormats)
112-
}
104+
105+
generatePingSummary(summary, for: .icmp, formats: outputFormats)
113106
generateSpeedTestSummary(downloadSummary, kind: .download, formats: outputFormats, unit: .Mbps)
114107
generateSpeedTestSummary(uploadSummary, kind: .upload, formats: outputFormats, unit: .Mbps)
115108

@@ -123,10 +116,10 @@ extension LCLCLI {
123116
uploadSpeed: uploadSummary.avg,
124117
latitude: selectedSite.latitude,
125118
longitude: selectedSite.longitude,
126-
packetLoss: Double(ping.summary.timeout.count) / Double(ping.summary.totalCount),
127-
ping: ping.summary.avg,
119+
packetLoss: Double(summary.timeout.count) / Double(summary.totalCount),
120+
ping: summary.avg,
128121
timestamp: Date.getCurrentTime(),
129-
jitter: ping.summary.jitter
122+
jitter: summary.jitter
130123
)
131124
let serialized = try encoder.encode(report)
132125
let sig_m = try ECDSA.sign(message: serialized, privateKey: ECDSA.deserializePrivateKey(raw: skData))

0 commit comments

Comments
 (0)