diff options
author | Miroslav Lichvar <mlichvar@redhat.com> | 2014-10-05 03:10:15 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2014-10-05 03:11:53 +0200 |
commit | 760d035699c4a878f9109544c1d35ea0d5f6b76c (patch) | |
tree | e36b94993b03ea937b625e46047b871f62defd93 | |
parent | cd738711782d5860eeab4e7cefdd1f72dfb83810 (diff) | |
download | busybox-w32-760d035699c4a878f9109544c1d35ea0d5f6b76c.tar.gz busybox-w32-760d035699c4a878f9109544c1d35ea0d5f6b76c.tar.bz2 busybox-w32-760d035699c4a878f9109544c1d35ea0d5f6b76c.zip |
ntpd: calculate offset to jitter ratio before updating jitter
The offset to jitter ratio is now calculated before updating
jitter to make the test more sensitive.
function old new delta
ntp_init 460 474 +14
update_local_clock 752 764 +12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 26/0) Total: 26 bytes
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/ntpd.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c index 838a367fe..2d4f076d9 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c | |||
@@ -1488,12 +1488,19 @@ update_local_clock(peer_t *p) | |||
1488 | 1488 | ||
1489 | } else { /* abs_offset <= STEP_THRESHOLD */ | 1489 | } else { /* abs_offset <= STEP_THRESHOLD */ |
1490 | 1490 | ||
1491 | /* The ratio is calculated before jitter is updated to make | ||
1492 | * poll adjust code more sensitive to large offsets. | ||
1493 | */ | ||
1494 | G.offset_to_jitter_ratio = abs_offset / G.discipline_jitter; | ||
1495 | |||
1491 | /* Compute the clock jitter as the RMS of exponentially | 1496 | /* Compute the clock jitter as the RMS of exponentially |
1492 | * weighted offset differences. Used by the poll adjust code. | 1497 | * weighted offset differences. Used by the poll adjust code. |
1493 | */ | 1498 | */ |
1494 | etemp = SQUARE(G.discipline_jitter); | 1499 | etemp = SQUARE(G.discipline_jitter); |
1495 | dtemp = SQUARE(offset - G.last_update_offset); | 1500 | dtemp = SQUARE(offset - G.last_update_offset); |
1496 | G.discipline_jitter = SQRT(etemp + (dtemp - etemp) / AVG); | 1501 | G.discipline_jitter = SQRT(etemp + (dtemp - etemp) / AVG); |
1502 | if (G.discipline_jitter < G_precision_sec) | ||
1503 | G.discipline_jitter = G_precision_sec; | ||
1497 | 1504 | ||
1498 | switch (G.discipline_state) { | 1505 | switch (G.discipline_state) { |
1499 | case STATE_NSET: | 1506 | case STATE_NSET: |
@@ -1570,10 +1577,6 @@ update_local_clock(peer_t *p) | |||
1570 | } | 1577 | } |
1571 | } | 1578 | } |
1572 | 1579 | ||
1573 | if (G.discipline_jitter < G_precision_sec) | ||
1574 | G.discipline_jitter = G_precision_sec; | ||
1575 | G.offset_to_jitter_ratio = abs_offset / G.discipline_jitter; | ||
1576 | |||
1577 | G.reftime = G.cur_time; | 1580 | G.reftime = G.cur_time; |
1578 | G.ntp_status = p->lastpkt_status; | 1581 | G.ntp_status = p->lastpkt_status; |
1579 | G.refid = p->lastpkt_refid; | 1582 | G.refid = p->lastpkt_refid; |
@@ -2111,6 +2114,7 @@ static NOINLINE void ntp_init(char **argv) | |||
2111 | bb_error_msg_and_die(bb_msg_you_must_be_root); | 2114 | bb_error_msg_and_die(bb_msg_you_must_be_root); |
2112 | 2115 | ||
2113 | /* Set some globals */ | 2116 | /* Set some globals */ |
2117 | G.discipline_jitter = G_precision_sec; | ||
2114 | G.stratum = MAXSTRAT; | 2118 | G.stratum = MAXSTRAT; |
2115 | if (BURSTPOLL != 0) | 2119 | if (BURSTPOLL != 0) |
2116 | G.poll_exp = BURSTPOLL; /* speeds up initial sync */ | 2120 | G.poll_exp = BURSTPOLL; /* speeds up initial sync */ |