@@ -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