13 #include <satcat5/ptp_dispatch.h>
14 #include <satcat5/ptp_header.h>
21 enum class ClientMode {
35 enum class ClientState {
44 const char* to_string(satcat5::ptp::ClientMode mode);
46 const char* to_string(satcat5::ptp::ClientState state);
73 satcat5::ptp::ClientMode mode = ClientMode::DISABLED);
74 ~
Client() SATCAT5_OPTIONAL_DTOR;
78 { m_clock_local = clk; }
81 {
return m_clock_local; }
84 {
return m_clock_remote; }
94 {
return m_utc_offset; }
103 { m_utc_offset = offset; }
107 void set_mode(satcat5::ptp::ClientMode mode);
109 inline satcat5::ptp::ClientMode
get_mode()
const {
return m_mode;}
110 inline satcat5::ptp::ClientState
get_state()
const {
return m_state;}
149 void client_timeout();
155 void notify_if_complete(
165 void rcvd_pdelay_req(
168 void rcvd_delay_resp(
171 void rcvd_pdelay_resp(
177 void rcvd_pdelay_follow_up(
183 void rcvd_unexpected(
190 bool send_announce();
192 satcat5::ptp::DispatchTo addr,
193 u16 seq_id, u16 flags = 0, u64 tref = 0);
194 bool send_sync_bcast();
196 satcat5::ptp::DispatchTo addr,
197 u16 seq_id, u16 flags = 0, u64 tref = 0);
198 void send_delay_req_sptp();
199 bool send_delay_req(u16 seq_id, u16 flags = 0);
201 bool send_pdelay_req();
217 satcat5::ptp::ClientMode m_mode;
218 satcat5::ptp::ClientState m_state;
223 unsigned m_announce_count;
224 unsigned m_announce_every;
225 unsigned m_sync_count;
226 unsigned m_sync_every;
227 unsigned m_cache_wdog;
228 unsigned m_request_wdog;
Ephemeral Readable interface for a simple array.
Limited read of next N bytes.
Abstract API for writing byte-streams and packets.
Connection metadata for an IPv4 address.
void connect(const satcat5::ip::Addr &dstaddr, const satcat5::eth::VlanTag &vtag=satcat5::eth::VTAG_NONE)
Automatic address resolution using routing table + ARP.
void close() override
Close any open connections and revert to idle.
Protocol handler and dispatch unit for Internet Protocol v4 (IPv4).
Timer objects are polled after a fixed delay or at a regular interval.
Client for the IEEE 1588-2019 Precision Time Protocol (PTP)
satcat5::ip::Dispatch * get_iface() const
Mode and state accessors.
void set_utc_offset(s16 offset)
Immediately adjust the UTC vs.
satcat5::ptp::ClientState get_state() const
Mode and state accessors.
satcat5::ptp::ClockInfo get_clock() const
Get local clock information.
void timer_event() override
Child class MUST override this method.
void set_announce_rate(int rate)
Set the ANNOUNCE message rate to 2^N / sec.
void set_sync_rate(int rate)
Set the SYNC message rate to 2^N / sec.
satcat5::ptp::ClockInfo get_remote() const
Get grandmaster clock information.
void set_pdelay_rate(int rate)
Set the pdelay message rate to 0.9 x 2^N / sec.
satcat5::ptp::ClientMode get_mode() const
Mode and state accessors.
satcat5::ptp::PortId get_source() const
Mode and state accessors.
s16 get_utc_offset() const
Query the current UTC vs.
satcat5::ptp::Time get_time_now()
Read the current time from the network interface.
bool send_sync_unicast(const satcat5::eth::MacAddr &mac, const satcat5::ip::Addr &ip=satcat5::ip::ADDR_NONE, const satcat5::eth::VlanTag &vtag=satcat5::eth::VTAG_NONE)
Send a unicast SYNC message to the designated address.
Client(satcat5::ptp::Interface *ptp_iface, satcat5::ip::Dispatch *ip_dispatch, satcat5::ptp::ClientMode mode=ClientMode::DISABLED)
Set the network interface for this client.
void ptp_rcvd(satcat5::io::LimitedRead &rd)
Dispatch calls this method for each incoming packet.
void set_mode(satcat5::ptp::ClientMode mode)
Mode and state accessors.
void set_clock(const satcat5::ptp::ClockInfo &clk)
Set clock information for outgoing ANNOUNCE messages.
Dispatch and formatting for L2 and L3 PTP messages.
satcat5::ptp::Time ptp_time_now()
Accessors for one-step and two-step timestamps.
Generic API for network ports that support PTP.
Searchable cache of recent Measurement objects.
A source for ptp::Measurement events, usually a ptp::Client.
Helper class for sending unicast Sync messages to an L2 client.
void connect(const satcat5::eth::MacAddr &addr)
Set the destination for outgoing SYNC messages.
void timer_event()
Child class MUST override this method.
SyncUnicastL2(satcat5::ptp::Client *client)
Create this object.
Helper class for sending unicast Sync messages to an L3 client.
SyncUnicastL3(satcat5::ptp::Client *client)
Create this object.
void timer_event()
Child class MUST override this method.
void close()
Close the connection to the remote client.
void connect(const satcat5::ip::Addr &dstaddr)
Set the destination for outgoing SYNC messages.
High-precision timestamp for use with PTP / IEEE1588.
Users should derive custom TLV objects from this base class.
Client-side implementation of the Internet Group Management Protocol (IGMP)
"Readable" I/O interface core definitions
Templated functions for manipulating singly-linked lists.
Core event-processing loop for SatCat5 software.
Define the data structure for a two-way time transfer handshake.
Define the API for generating ptp::Measurement events.
An Ethernet MAC address (with serializable interface).
Header contents for an 802.1Q Virtual-LAN tag.
Client state for an IGMP multicast subscription.
IPv4 address is a 32-bit unsigned integer.
Clock configuration metadata for the ANNOUNCE message.
Timestamps and metadata for a two-way time-transfer handshake.
Struct used for sourcePortIdentity and requestingPortIdentity.