5 Commits
Author SHA1 Message Date
Nils Andreas Svee 735dc7fd74 feat(measurement): implement ICMP measurement engine 2026-10-04 23:47:04 +07:00
Nils Andreas Svee 831d02ba38 feat(measurement): add core data models 2026-10-04 23:46:54 +07:00
Nils Andreas Svee e61922dd18 refactor(time): implement ClockSample from SystemTime 2026-10-04 23:46:54 +07:00
Nils Andreas Svee 6e19f68194 feat(settings): add network settings for measurement sockets 2026-10-04 23:46:54 +07:00
Nils Andreas Svee fca0967563 refactor(time): consolidate ClockId usage via the public time::Clock trait
Rust CI / cargo fmt (push) Successful in 15s
Rust CI / cargo clippy (push) Failing after 35s
Rust CI / cargo check (x86_64-unknown-linux-gnu) (push) Failing after 32s
Rust CI / cargo check (x86_64-unknown-linux-musl) (push) Failing after 9s
Rust CI / cargo test (x86_64-unknown-linux-gnu) (push) Failing after 41s
Rust CI / cargo test (x86_64-unknown-linux-musl) (push) Failing after 7s
Rust CI / cargo doc (push) Successful in 37s
Supply chain / actionlint (push) Successful in 8s
Supply chain / cargo-deny bans licenses sources (push) Failing after 1m47s
Supply chain / cargo-deny advisories (push) Failing after 1m49s
Remove direct `rustix::time::ClockId` imports by centralizing its dependency within the `time` module.
2026-10-04 23:46:54 +07:00
9 changed files with 35 additions and 18 deletions

No files matched your search

+20 -1
View File
@@ -22,6 +22,10 @@ mod time;
mod util;
use crate::baseliner::Baseliner;
use crate::measurement::icmp::{IcmpBinding, IcmpEngine};
use crate::measurement::model::{
MeasurementSource, MeasurementStream, MeasurementStreamId, ProbeSchedule,
};
use crate::metrics::{Metric, Metrics, MetricsSender};
use crate::pinger::{InFlightProbeCache, PingListener, PingSender};
use crate::pinger_icmp::{PingerICMPEchoListener, PingerICMPEchoSender};
@@ -34,7 +38,7 @@ use crate::settings::Settings;
use ::log::{info, warn};
use flume::RecvTimeoutError;
use std::collections::HashMap;
use std::net::IpAddr;
use std::net::{IpAddr, Ipv4Addr};
use std::str::FromStr;
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
use std::sync::{Arc, Mutex, RwLock};
@@ -246,6 +250,21 @@ fn run(settings: &Settings) -> anyhow::Result<()> {
let start_time = Instant::now();
let probe_id = probe_identifier();
let (ie_txt, _) = flume::unbounded();
let mut engine = IcmpEngine::new(start_time, &settings.network, ie_txt)?;
engine.set_bindings(vec![IcmpBinding::new(
MeasurementStream {
id: MeasurementStreamId(0),
peer: IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)),
source: MeasurementSource::IcmpEcho,
},
ProbeSchedule {
period: Duration::from_secs(1),
offset: Duration::from_secs(0),
},
)])?;
engine.run()?;
let ReflectorSetup {
peers: reflector_peers,
pool: reflector_pool,
+3 -6
View File
@@ -2,10 +2,7 @@ use std::{
collections::{HashMap, HashSet},
io,
net::IpAddr,
sync::{
Arc, Mutex,
atomic::{AtomicBool, Ordering},
},
sync::{Arc, Mutex, atomic::Ordering},
thread,
time::{Duration, Instant, SystemTime},
};
@@ -62,7 +59,7 @@ pub enum IcmpError {
#[error("probe interval must be non-zero for stream {0:?}")]
InvalidInterval(MeasurementStreamId),
#[error("probe offset must be non-zero for stream {0:?}")]
#[error("probe offset must be less than the period for stream {0:?}")]
InvalidOffset(MeasurementStreamId),
#[error(
@@ -116,7 +113,7 @@ pub struct IcmpEngine {
impl IcmpEngine {
pub fn new(
origin: Instant,
#[allow(unused)] settings: NetworkSettings,
#[allow(unused)] settings: &NetworkSettings,
observation_tx: Sender<MeasurementEvent>,
) -> Result<Self, IcmpError> {
#[allow(unused_mut)]
+2 -2
View File
@@ -1,2 +1,2 @@
mod icmp;
mod model;
pub(crate) mod icmp;
pub(crate) mod model;
+9 -4
View File
@@ -1,5 +1,4 @@
use std::{
intrinsics::simd::SimdAlign::Element,
net::IpAddr,
time::{Duration, Instant},
};
@@ -37,14 +36,15 @@ pub struct ProbeSchedule {
impl ProbeSchedule {
pub(crate) fn next_probe_at(&self, origin: Instant, now: Instant) -> Instant {
const NANOS_PER_SEC: u128 = 1_000_000_000;
let first = origin + self.offset;
if now < first {
return first;
}
let elapsed = now.duration_since(first);
let elapsed_ns = elapsed.as_nanos();
let elapsed_ns = now.duration_since(first).as_nanos();
let period_ns = self.period.as_nanos();
let remainder = elapsed_ns % period_ns;
@@ -54,7 +54,12 @@ impl ProbeSchedule {
period_ns - remainder
};
now + Duration::from_nanos_u128(until_next)
let until_next = Duration::new(
(until_next / NANOS_PER_SEC) as u64,
(until_next % NANOS_PER_SEC) as u32,
);
now + until_next
}
}
-1
View File
@@ -7,7 +7,6 @@ use crate::settings::{MeasurementType, ObservabilityProtocol};
use crate::time::{ClockSample, Realtime};
use flume::{Receiver, RecvTimeoutError, Sender};
use log::{error, info, warn};
use rustix::time::ClockId;
use std::fmt::Write;
use std::net::{IpAddr, TcpStream, UdpSocket};
use std::sync::Arc;
-1
View File
@@ -14,7 +14,6 @@ use crate::time::{ClockSample, Monotonic};
use icmp_socket2::Icmpv4Message;
use icmp_socket2::Icmpv4Packet;
use icmp_socket2::packet::WithEchoRequest;
use rustix::time::ClockId;
pub struct PingerICMPEchoListener {}
-1
View File
@@ -11,7 +11,6 @@ use crate::time::{ClockSample, Realtime};
use icmp_socket2::Icmpv4Message;
use icmp_socket2::Icmpv4Packet;
use icmp_socket2::packet::WithTimestampRequest;
use rustix::time::ClockId;
use std::net::IpAddr;
use std::time::Instant;
-1
View File
@@ -17,7 +17,6 @@ use crate::time::{ClockSample, Realtime};
use crate::util::{ArcRwLock, RwLockExt};
use flume::{Receiver, Sender};
use log::{debug, info, warn};
use rustix::time::ClockId;
use std::fs::File;
use std::io::Write;
use std::net::IpAddr;
+1 -1
View File
@@ -9,7 +9,7 @@ use std::{
use rustix::time::{ClockId, clock_gettime};
trait Clock {
pub trait Clock {
const ID: ClockId;
}