ntp: extend local timestamp for PTP correction
Add two new fields to the NTP_Local_Timestamp structure: - receive duration as the time it takes to receive the ethernet frame, currently known only with HW timestamping - network correction as a generalized PTP correction The PTP correction is provided by transparent clocks in the correction field of PTP messages to remove the receive, processing and queueing delays of network switches and routers. Only one-step end-to-end unicast transparent clocks are useful for NTP-over-PTP. Two-step transparent clocks use follow-up messages and peer-to-peer transparent clocks don't handle delay requests. The RX duration will be included in the network correction to compensate for asymmetric link speeds of the server and client as the NTP RX timestamp corresponds to the end of the reception (in order to compensate for the asymmetry in the normal case when no corrections are applied).
This commit is contained in:
parent
07134f2625
commit
b0267475e3
4 changed files with 13 additions and 5 deletions
|
@ -420,6 +420,8 @@ zero_local_timestamp(NTP_Local_Timestamp *ts)
|
|||
UTI_ZeroTimespec(&ts->ts);
|
||||
ts->err = 0.0;
|
||||
ts->source = NTP_TS_DAEMON;
|
||||
ts->rx_duration = 0.0;
|
||||
ts->net_correction = 0.0;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
@ -1299,6 +1301,8 @@ transmit_packet(NTP_Mode my_mode, /* The mode this machine wants to be */
|
|||
local_tx->ts = local_transmit;
|
||||
local_tx->err = local_transmit_err;
|
||||
local_tx->source = NTP_TS_DAEMON;
|
||||
local_tx->rx_duration = 0.0;
|
||||
local_tx->net_correction = 0.0;
|
||||
}
|
||||
|
||||
if (local_ntp_rx)
|
||||
|
@ -2612,8 +2616,7 @@ NCR_ProcessRxUnknown(NTP_Remote_Address *remote_addr, NTP_Local_Address *local_a
|
|||
UTI_CompareNtp64(&message->receive_ts, &message->transmit_ts) != 0) {
|
||||
ntp_rx = message->originate_ts;
|
||||
local_ntp_rx = &ntp_rx;
|
||||
UTI_ZeroTimespec(&local_tx.ts);
|
||||
local_tx.source = NTP_TS_DAEMON;
|
||||
zero_local_timestamp(&local_tx);
|
||||
interleaved = CLG_GetNtpTxTimestamp(&ntp_rx, &local_tx.ts, &local_tx.source);
|
||||
|
||||
tx_ts = &local_tx;
|
||||
|
|
|
@ -42,6 +42,8 @@ typedef struct {
|
|||
struct timespec ts;
|
||||
double err;
|
||||
NTP_Timestamp_Source source;
|
||||
double rx_duration;
|
||||
double net_correction;
|
||||
} NTP_Local_Timestamp;
|
||||
|
||||
/* This is a private data type used for storing the instance record for
|
||||
|
|
3
ntp_io.c
3
ntp_io.c
|
@ -431,6 +431,9 @@ process_message(SCK_Message *message, int sock_fd, int event)
|
|||
|
||||
SCH_GetLastEventTime(&local_ts.ts, &local_ts.err, NULL);
|
||||
local_ts.source = NTP_TS_DAEMON;
|
||||
local_ts.rx_duration = 0.0;
|
||||
local_ts.net_correction = 0.0;
|
||||
|
||||
sched_ts = local_ts.ts;
|
||||
|
||||
if (message->addr_type != SCK_ADDR_IP) {
|
||||
|
|
|
@ -99,8 +99,8 @@ send_request(NCR_Instance inst, int late_hwts)
|
|||
local_addr.ip_addr.family = IPADDR_UNSPEC;
|
||||
local_addr.if_index = INVALID_IF_INDEX;
|
||||
local_addr.sock_fd = 101;
|
||||
zero_local_timestamp(&local_ts);
|
||||
local_ts.ts = current_time;
|
||||
local_ts.err = 0.0;
|
||||
local_ts.source = NTP_TS_KERNEL;
|
||||
|
||||
NCR_ProcessTxKnown(inst, &local_addr, &local_ts, &req_buffer, req_length);
|
||||
|
@ -122,8 +122,8 @@ process_request(NTP_Remote_Address *remote_addr)
|
|||
local_addr.ip_addr.family = IPADDR_UNSPEC;
|
||||
local_addr.if_index = INVALID_IF_INDEX;
|
||||
local_addr.sock_fd = 100;
|
||||
zero_local_timestamp(&local_ts);
|
||||
local_ts.ts = current_time;
|
||||
local_ts.err = 0.0;
|
||||
local_ts.source = NTP_TS_KERNEL;
|
||||
|
||||
res_length = 0;
|
||||
|
@ -289,8 +289,8 @@ proc_response(NCR_Instance inst, int good, int valid, int updated_sync,
|
|||
local_addr.ip_addr.family = IPADDR_UNSPEC;
|
||||
local_addr.if_index = INVALID_IF_INDEX;
|
||||
local_addr.sock_fd = NTP_LVM_TO_MODE(res->lvm) != MODE_SERVER ? 100 : 101;
|
||||
zero_local_timestamp(&local_ts);
|
||||
local_ts.ts = current_time;
|
||||
local_ts.err = 0.0;
|
||||
local_ts.source = NTP_TS_KERNEL;
|
||||
|
||||
prev_rx_count = inst->report.total_rx_count;
|
||||
|
|
Loading…
Reference in a new issue