@@ -79,7 +79,7 @@ void NetProbeStreamHandler::probe_signal_send(pcpp::Packet &payload, TestType ty
7979 }
8080 } else if (type == TestType::TCP) {
8181 if (auto tcp = payload.getLayerOfType <pcpp::TcpLayer>(); tcp != nullptr ) {
82- _metrics->process_netprobe_tcp (static_cast < uint32_t >(tcp-> getSrcPort ()), true , name, stamp);
82+ _metrics->process_netprobe_tcp (true , name, stamp);
8383 }
8484 }
8585}
@@ -92,7 +92,7 @@ void NetProbeStreamHandler::probe_signal_recv(pcpp::Packet &payload, TestType ty
9292 }
9393 } else if (type == TestType::TCP) {
9494 if (auto tcp = payload.getLayerOfType <pcpp::TcpLayer>(); tcp != nullptr ) {
95- _metrics->process_netprobe_tcp (static_cast < uint32_t >(tcp-> getDstPort ()), false , name, stamp);
95+ _metrics->process_netprobe_tcp (false , name, stamp);
9696 }
9797 }
9898}
@@ -119,6 +119,7 @@ void NetProbeMetricsBucket::specialized_merge(const AbstractMetricsBucket &o, Me
119119 if (group_enabled (group::NetProbeMetrics::Counters)) {
120120 _targets_metrics[targetId]->attempts += target.second ->attempts ;
121121 _targets_metrics[targetId]->successes += target.second ->successes ;
122+ _targets_metrics[targetId]->connect_failures += target.second ->connect_failures ;
122123 _targets_metrics[targetId]->dns_failures += target.second ->dns_failures ;
123124 _targets_metrics[targetId]->timed_out += target.second ->timed_out ;
124125 }
@@ -143,6 +144,7 @@ void NetProbeMetricsBucket::to_prometheus(std::stringstream &out, Metric::LabelM
143144 if (group_enabled (group::NetProbeMetrics::Counters)) {
144145 target.second ->attempts .to_prometheus (out, target_labels);
145146 target.second ->successes .to_prometheus (out, target_labels);
147+ target.second ->connect_failures .to_prometheus (out, target_labels);
146148 target.second ->dns_failures .to_prometheus (out, target_labels);
147149 target.second ->timed_out .to_prometheus (out, target_labels);
148150 }
@@ -198,6 +200,7 @@ void NetProbeMetricsBucket::to_opentelemetry(metrics::v1::ScopeMetrics &scope, t
198200 if (group_enabled (group::NetProbeMetrics::Counters)) {
199201 target.second ->attempts .to_opentelemetry (scope, start_ts, end_ts, target_labels);
200202 target.second ->successes .to_opentelemetry (scope, start_ts, end_ts, target_labels);
203+ target.second ->connect_failures .to_opentelemetry (scope, start_ts, end_ts, target_labels);
201204 target.second ->dns_failures .to_opentelemetry (scope, start_ts, end_ts, target_labels);
202205 target.second ->timed_out .to_opentelemetry (scope, start_ts, end_ts, target_labels);
203206 }
@@ -252,6 +255,7 @@ void NetProbeMetricsBucket::to_json(json &j) const
252255 if (group_enabled (group::NetProbeMetrics::Counters)) {
253256 target.second ->attempts .to_json (j[" targets" ][targetId]);
254257 target.second ->successes .to_json (j[" targets" ][targetId]);
258+ target.second ->connect_failures .to_json (j[" targets" ][targetId]);
255259 target.second ->dns_failures .to_json (j[" targets" ][targetId]);
256260 target.second ->timed_out .to_json (j[" targets" ][targetId]);
257261 }
@@ -311,9 +315,12 @@ void NetProbeMetricsBucket::process_failure(ErrorType error, const std::string &
311315 break ;
312316 case ErrorType::Timeout:
313317 ++_targets_metrics[target]->timed_out ;
318+ break ;
314319 case ErrorType::SocketError:
315320 case ErrorType::InvalidIp:
316- case ErrorType::ConnectionFailure:
321+ case ErrorType::ConnectFailure:
322+ ++_targets_metrics[target]->connect_failures ;
323+ break ;
317324 default :
318325 break ;
319326 }
@@ -374,12 +381,14 @@ void NetProbeMetricsManager::process_netprobe_icmp(pcpp::IcmpLayer *layer, const
374381
375382 if (layer->getMessageType () == pcpp::ICMP_ECHO_REQUEST) {
376383 if (auto request = layer->getEchoRequestData (); request != nullptr ) {
377- _request_reply_manager->start_transaction ((static_cast <uint32_t >(request->header ->id ) << 16 ) | request->header ->sequence , {{stamp, {0 , 0 }}, target});
384+ auto ping_id = (static_cast <uint32_t >(request->header ->id ) << 16 ) | request->header ->sequence ;
385+ _request_reply_manager->start_transaction (std::to_string (ping_id), {{stamp, {0 , 0 }}, target});
378386 }
379387 live_bucket ()->process_attempts (_deep_sampling_now, target);
380388 } else if (layer->getMessageType () == pcpp::ICMP_ECHO_REPLY) {
381389 if (auto reply = layer->getEchoReplyData (); reply != nullptr ) {
382- auto xact = _request_reply_manager->maybe_end_transaction ((static_cast <uint32_t >(reply->header ->id ) << 16 ) | reply->header ->sequence , stamp);
390+ auto ping_id = (static_cast <uint32_t >(reply->header ->id ) << 16 ) | reply->header ->sequence ;
391+ auto xact = _request_reply_manager->maybe_end_transaction (std::to_string (ping_id), stamp);
383392 if (xact.first == Result::Valid) {
384393 live_bucket ()->new_transaction (_deep_sampling_now, xact.second );
385394 } else if (xact.first == Result::TimedOut) {
@@ -389,16 +398,16 @@ void NetProbeMetricsManager::process_netprobe_icmp(pcpp::IcmpLayer *layer, const
389398 }
390399}
391400
392- void NetProbeMetricsManager::process_netprobe_tcp (uint32_t port, bool send, const std::string &target, timespec stamp)
401+ void NetProbeMetricsManager::process_netprobe_tcp (bool send, const std::string &target, timespec stamp)
393402{
394403 // base event
395404 new_event (stamp);
396405
397406 if (send) {
398- _request_reply_manager->start_transaction (port , {{stamp, {0 , 0 }}, target});
407+ _request_reply_manager->start_transaction (target , {{stamp, {0 , 0 }}, target});
399408 live_bucket ()->process_attempts (_deep_sampling_now, target);
400409 } else {
401- auto xact = _request_reply_manager->maybe_end_transaction (port , stamp);
410+ auto xact = _request_reply_manager->maybe_end_transaction (target , stamp);
402411 if (xact.first == Result::Valid) {
403412 live_bucket ()->new_transaction (_deep_sampling_now, xact.second );
404413 } else if (xact.first == Result::TimedOut) {
0 commit comments