Skip to content

NTP protocol support (RFC 5905) #191

Description

@EONRaider

Target: 2.6.0 (Tier 4 — AAA & infrastructure services)

Context

NTP synchronizes clocks, UDP port 123. Fixed-width header, no
options, no variants worth branching on for the common case — one of
the simplest protocols in this whole roadmap, a good first PR to open
the tier.

Deliverable

Add netprotocols.NTP (layer 7, dispatched from udp.port):

  • Decode the 48-byte NTPv3/v4 header (RFC 5905 §7.3): LI/VN/Mode (1
    byte, three bitfields), Stratum, Poll, Precision (1 byte each),
    Root Delay, Root Dispersion, Reference ID (4 bytes each), Reference
    Timestamp, Origin Timestamp, Receive Timestamp, Transmit Timestamp
    (8-byte NTP short/long format each).
  • NTP timestamps are seconds-since-1900 fixed point, not Unix epoch —
    add a display/accessor property that converts to a Python datetime
    or Unix-epoch float (mirroring how this library already surfaces
    hex/enum display helpers alongside raw fields), without silently
    replacing the raw on-wire value.
  • Register udp.port 123 → NTP, best-effort like every other
    port-table entry.

Acceptance criteria

  • NTP decodes the full header including all four timestamps;
    bytes(NTP.decode(x)) == x.
  • A timestamp accessor converts NTP epoch to a usable Python value
    correctly (verify against a known reference timestamp).
  • UDP port 123 dispatches to NTP.
  • Fixture; truncation case.
  • CHANGELOG entry; full ladder green.

References

RFC 5905

Part of #174

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions