ntp: make burst interval proportional to polling interval

If the polling interval is shorter than 8 seconds, set the burst
interval to the 1/4th of the polling interval instead of the 2-second
constant. This should make the burst option and command useful with
very short polling intervals.
This commit is contained in:
Miroslav Lichvar 2018-06-21 16:46:30 +02:00
parent e15c7cd236
commit 5b75d4afef

View file

@ -226,12 +226,10 @@ static ARR_Instance broadcasts;
/* Adjustment of the peer polling interval */ /* Adjustment of the peer polling interval */
#define PEER_SAMPLING_ADJ 1.1 #define PEER_SAMPLING_ADJ 1.1
/* Spacing between samples in burst mode for one server/peer */ /* Maximum spacing between samples in the burst mode as an absolute
#define BURST_INTERVAL 2.0 value and ratio to the normal polling interval */
#define MAX_BURST_INTERVAL 2.0
/* Time to wait before retransmitting in burst mode, if we did not get #define MAX_BURST_POLL_RATIO 0.25
a reply to the previous probe */
#define BURST_TIMEOUT 2.0
/* Number of samples in initial burst */ /* Number of samples in initial burst */
#define IBURST_GOOD_SAMPLES 4 #define IBURST_GOOD_SAMPLES 4
@ -852,7 +850,7 @@ get_transmit_delay(NCR_Instance inst, int on_tx, double last_tx)
case MD_BURST_WAS_ONLINE: case MD_BURST_WAS_ONLINE:
case MD_BURST_WAS_OFFLINE: case MD_BURST_WAS_OFFLINE:
/* Burst modes */ /* Burst modes */
delay_time = on_tx ? BURST_TIMEOUT : BURST_INTERVAL; delay_time = MIN(MAX_BURST_INTERVAL, MAX_BURST_POLL_RATIO * delay_time);
break; break;
default: default:
assert(0); assert(0);