ntp: add burst option
When the burst option is specified in the server/pool directive and the current poll is longer than the minimum poll, initiate on each poll a burst with 1 good sample and 2 or 4 total samples according to the difference between the current and minimum poll.
This commit is contained in:
parent
7d100b89fc
commit
d0eb9427c2
7 changed files with 28 additions and 0 deletions
1
candm.h
1
candm.h
|
@ -252,6 +252,7 @@ typedef struct {
|
|||
#define REQ_ADDSRC_TRUST 0x20
|
||||
#define REQ_ADDSRC_REQUIRE 0x40
|
||||
#define REQ_ADDSRC_INTERLEAVED 0x80
|
||||
#define REQ_ADDSRC_BURST 0x100
|
||||
|
||||
typedef struct {
|
||||
IPAddr ip_addr;
|
||||
|
|
1
client.c
1
client.c
|
@ -1109,6 +1109,7 @@ process_cmd_add_server_or_peer(CMD_Request *msg, char *line)
|
|||
(data.params.auto_offline ? REQ_ADDSRC_AUTOOFFLINE : 0) |
|
||||
(data.params.iburst ? REQ_ADDSRC_IBURST : 0) |
|
||||
(data.params.interleaved ? REQ_ADDSRC_INTERLEAVED : 0) |
|
||||
(data.params.burst ? REQ_ADDSRC_BURST : 0) |
|
||||
(data.params.sel_options & SRC_SELECT_PREFER ? REQ_ADDSRC_PREFER : 0) |
|
||||
(data.params.sel_options & SRC_SELECT_NOSELECT ? REQ_ADDSRC_NOSELECT : 0) |
|
||||
(data.params.sel_options & SRC_SELECT_TRUST ? REQ_ADDSRC_TRUST : 0) |
|
||||
|
|
1
cmdmon.c
1
cmdmon.c
|
@ -801,6 +801,7 @@ handle_add_source(NTP_Source_Type type, CMD_Request *rx_message, CMD_Reply *tx_m
|
|||
params.auto_offline = ntohl(rx_message->data.ntp_source.flags) & REQ_ADDSRC_AUTOOFFLINE ? 1 : 0;
|
||||
params.iburst = ntohl(rx_message->data.ntp_source.flags) & REQ_ADDSRC_IBURST ? 1 : 0;
|
||||
params.interleaved = ntohl(rx_message->data.ntp_source.flags) & REQ_ADDSRC_INTERLEAVED ? 1 : 0;
|
||||
params.burst = ntohl(rx_message->data.ntp_source.flags) & REQ_ADDSRC_BURST ? 1 : 0;
|
||||
params.sel_options =
|
||||
(ntohl(rx_message->data.ntp_source.flags) & REQ_ADDSRC_PREFER ? SRC_SELECT_PREFER : 0) |
|
||||
(ntohl(rx_message->data.ntp_source.flags) & REQ_ADDSRC_NOSELECT ? SRC_SELECT_NOSELECT : 0) |
|
||||
|
|
|
@ -51,6 +51,7 @@ CPS_ParseNTPSourceAdd(char *line, CPS_NTP_Source *src)
|
|||
src->params.online = 1;
|
||||
src->params.auto_offline = 0;
|
||||
src->params.presend_minpoll = SRC_DEFAULT_PRESEND_MINPOLL;
|
||||
src->params.burst = 0;
|
||||
src->params.iburst = 0;
|
||||
src->params.min_stratum = SRC_DEFAULT_MINSTRATUM;
|
||||
src->params.poll_target = SRC_DEFAULT_POLLTARGET;
|
||||
|
@ -84,6 +85,8 @@ CPS_ParseNTPSourceAdd(char *line, CPS_NTP_Source *src)
|
|||
|
||||
if (!strcasecmp(cmd, "auto_offline")) {
|
||||
src->params.auto_offline = 1;
|
||||
} else if (!strcasecmp(cmd, "burst")) {
|
||||
src->params.burst = 1;
|
||||
} else if (!strcasecmp(cmd, "iburst")) {
|
||||
src->params.iburst = 1;
|
||||
} else if (!strcasecmp(cmd, "offline")) {
|
||||
|
|
|
@ -83,6 +83,13 @@ With this option, the interval between the first four requests sent to the
|
|||
server will be 2 seconds instead of the interval specified by the *minpoll*
|
||||
option, which allows *chronyd* to make the first update of the clock shortly
|
||||
after start.
|
||||
*burst*:::
|
||||
With this option, *chronyd* will shorten the interval between up to four
|
||||
requests to 2 seconds when it cannot get a good measurement from the server.
|
||||
The number of requests in the burst is limited by the current polling interval
|
||||
to keep the average interval at or above the minimum interval, i.e. the current
|
||||
interval needs to be at least two times longer than the minimum interval in
|
||||
order to allow a burst with two requests.
|
||||
*key* _ID_:::
|
||||
The NTP protocol supports the inclusion of checksums in the packets, to prevent
|
||||
computers having their system time upset by rogue packets being sent to them.
|
||||
|
|
14
ntp_core.c
14
ntp_core.c
|
@ -88,6 +88,7 @@ struct NCR_Instance_Record {
|
|||
SCH_TimeoutID tx_timeout_id; /* Timeout ID for next transmission */
|
||||
int tx_suspended; /* Boolean indicating we can't transmit yet */
|
||||
|
||||
int auto_burst; /* If 1, initiate a burst on each poll */
|
||||
int auto_offline; /* If 1, automatically go offline if server/peer
|
||||
isn't responding */
|
||||
|
||||
|
@ -236,6 +237,10 @@ static ARR_Instance broadcasts;
|
|||
#define IBURST_GOOD_SAMPLES 4
|
||||
#define IBURST_TOTAL_SAMPLES SOURCE_REACH_BITS
|
||||
|
||||
/* Number of samples in automatic burst */
|
||||
#define BURST_GOOD_SAMPLES 1
|
||||
#define MAX_BURST_TOTAL_SAMPLES 4
|
||||
|
||||
/* Time to wait after sending packet to 'warm up' link */
|
||||
#define WARM_UP_DELAY 2.0
|
||||
|
||||
|
@ -557,6 +562,7 @@ NCR_GetInstance(NTP_Remote_Address *remote_addr, NTP_Source_Type type, SourcePar
|
|||
result->max_delay_ratio = CLAMP(0.0, params->max_delay_ratio, MAX_MAXDELAYRATIO);
|
||||
result->max_delay_dev_ratio = CLAMP(0.0, params->max_delay_dev_ratio, MAX_MAXDELAYDEVRATIO);
|
||||
result->offset_correction = params->offset;
|
||||
result->auto_burst = params->burst;
|
||||
result->auto_offline = params->auto_offline;
|
||||
result->poll_target = params->poll_target;
|
||||
|
||||
|
@ -1121,6 +1127,14 @@ transmit_timeout(void *arg)
|
|||
if (inst->burst_total_samples_to_go <= 0)
|
||||
take_offline(inst);
|
||||
break;
|
||||
case MD_ONLINE:
|
||||
/* Start a new burst if the burst option is enabled and the average
|
||||
polling interval including the burst will not fall below the
|
||||
minimum polling interval */
|
||||
if (inst->auto_burst && inst->local_poll > inst->minpoll && inst->local_poll > 1)
|
||||
NCR_InitiateSampleBurst(inst, BURST_GOOD_SAMPLES,
|
||||
MIN(1 << (inst->local_poll - inst->minpoll),
|
||||
MAX_BURST_TOTAL_SAMPLES));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ typedef struct {
|
|||
int online;
|
||||
int auto_offline;
|
||||
int presend_minpoll;
|
||||
int burst;
|
||||
int iburst;
|
||||
int min_stratum;
|
||||
int poll_target;
|
||||
|
|
Loading…
Reference in a new issue