⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

NtpClient

Struct NtpClient 

Source
pub struct NtpClient {
    pub filter: ClockFilter,
    pub drift: DriftEstimator,
    pub poll_interval: u32,
    pub stratum: u8,
    pub step_applied: bool,
    pub start_ms: u64,
}
Expand description

NTP client managing time synchronization with one or more servers.

Fields§

§filter: ClockFilter

Clock filter for selecting best sample

§drift: DriftEstimator

Drift estimator for frequency compensation

§poll_interval: u32

Current poll interval in seconds

§stratum: u8

Our stratum level (one more than best server’s stratum)

§step_applied: bool

Whether a step correction has been applied since boot

§start_ms: u64

Measurement start time in ms (for drift tracking)

Implementations§

Source§

impl NtpClient

Source

pub fn new() -> Self

Create a new NTP client.

Source

pub fn create_request(&self, transmit_ts: NtpTimestamp) -> [u8; 48]

Create a client request packet for the given transmit timestamp.

Source

pub fn process_response( &mut self, response: &[u8], t1: &NtpTimestamp, t4: &NtpTimestamp, ) -> Option<NtpMeasurement>

Process a server response and return the computed measurement.

  • response: the raw 48-byte NTP response
  • t1: our original transmit timestamp
  • t4: our receive timestamp (when we got the response)
Source

pub fn adjust_clock(&mut self) -> i64

Decide whether to step (instant jump) or slew (gradual adjust) the clock, and apply the correction via the RTC integration point.

Returns the applied correction in milliseconds.

Source

pub fn get_poll_interval(&self) -> u32

Get the current poll interval in seconds.

Trait Implementations§

Source§

impl Default for NtpClient

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for NtpClient

§

impl RefUnwindSafe for NtpClient

§

impl Send for NtpClient

§

impl Sync for NtpClient

§

impl Unpin for NtpClient

§

impl UnwindSafe for NtpClient

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.