[Git][NTPsec/ntpsec][master] Add lost packet count to rawstats

Hal Murray gitlab at mg.gitlab.com
Tue Dec 22 12:48:24 UTC 2015


Hal Murray pushed to branch master at NTPsec / ntpsec


Commits:
6c5c9e06 by Hal Murray at 2015-12-22T04:47:31Z
Add lost packet count to rawstats

- - - - -


5 changed files:

- docs/includes/mon-commands.txt
- include/ntp.h
- include/ntpd.h
- ntpd/ntp_proto.c
- ntpd/ntp_util.c


Changes:

=====================================
docs/includes/mon-commands.txt
=====================================
--- a/docs/includes/mon-commands.txt
+++ b/docs/includes/mon-commands.txt
@@ -134,7 +134,7 @@ show the offset, delay, dispersion and RMS jitter, all in seconds.
 ---------------------------------------------------------------------------------
 5628 54575.160 128.4.1.1 192.168.1.5 3565350574.400229473
     3565350574.442385200 3565350574.442436000 3565350575.154505763
-    0 4 4 1 8 -21 0.000000 0.000320 PPS
+    0 4 4 1 8 -21 0.000000 0.000320 PPS 0
 ---------------------------------------------------------------------------------
 +
 |==============================================================================
@@ -153,9 +153,10 @@ show the offset, delay, dispersion and RMS jitter, all in seconds.
 |1                   |1-15, 16: not synced              |stratum
 |8                   |log~2~ seconds                    |poll
 |-21                 |log~2~ seconds                    |precision
-|0.000000            |seconds                           |total roundtrip delay to the primary reference clock
-|0.000320            |seconds                           |total dispersion to the primary reference clock
+|0.000000            |seconds                           |total roundtrip delay from the remote server to the primary reference clock
+|0.000320            |seconds                           |total dispersion from the remote server to the primary reference clock
 |.PPS.               |IP or text                        |refid, association ID
+| 0                  |integer                           |lost packets since last response
 |==============================================================================
 +
 The first two fields show the date (Modified Julian Day) and time


=====================================
include/ntp.h
=====================================
--- a/include/ntp.h
+++ b/include/ntp.h
@@ -361,6 +361,7 @@ struct peer {
 	/*
 	 * End of clear-to-zero area
 	 */
+	u_int   outcount;       /* packets sent without reply */
 	u_long	update;		/* receive epoch */
 #define end_clear_to_zero update
 	int	unreach;	/* watchdog counter */


=====================================
include/ntpd.h
=====================================
--- a/include/ntpd.h
+++ b/include/ntpd.h
@@ -287,7 +287,7 @@ extern	void	record_loop_stats (double, double, double, double, int);
 extern	void	record_clock_stats (sockaddr_u *, const char *);
 extern	int	mprintf_clock_stats(sockaddr_u *, const char *, ...)
 			NTP_PRINTF(2, 3);
-extern	void	record_raw_stats (sockaddr_u *srcadr, sockaddr_u *dstadr, l_fp *t1, l_fp *t2, l_fp *t3, l_fp *t4, int leap, int version, int mode, int stratum, int ppoll, int precision, double root_delay, double root_dispersion, uint32_t refid);
+extern	void	record_raw_stats (sockaddr_u *srcadr, sockaddr_u *dstadr, l_fp *t1, l_fp *t2, l_fp *t3, l_fp *t4, int leap, int version, int mode, int stratum, int ppoll, int precision, double root_delay, double root_dispersion, uint32_t refid, u_int outcount);
 extern	void	check_leap_file	(int is_daily_check, uint32_t ntptime, const time_t * systime);
 extern	void	record_crypto_stats (sockaddr_u *, const char *);
 #ifdef DEBUG


=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -1580,6 +1580,7 @@ process_packet(
 	pleap = PKT_LEAP(pkt->li_vn_mode);
 	pversion = PKT_VERSION(pkt->li_vn_mode);
 	pstratum = PKT_TO_STRATUM(pkt->stratum);
+	if (peer->outcount) peer->outcount--;  /* dup, peer with shorter poll */
 
 	/*
 	 * Capture the header values in the client/peer association..
@@ -1588,7 +1589,7 @@ process_packet(
 	    &peer->dstadr->sin : NULL,
 	    &p_org, &p_rec, &p_xmt, &peer->dst,
 	    pleap, pversion, pmode, pstratum, pkt->ppoll, pkt->precision,
-	    p_del, p_disp, pkt->refid);
+	    p_del, p_disp, pkt->refid, peer->outcount);
 	peer->leap = pleap;
 	peer->stratum = min(pstratum, STRATUM_UNSPEC);
 	peer->pmode = pmode;
@@ -1597,6 +1598,7 @@ process_packet(
 	peer->rootdisp = p_disp;
 	peer->refid = pkt->refid;		/* network byte order */
 	peer->reftime = p_reftime;
+	peer->outcount = 0;
 
 	/*
 	 * First, if either burst mode is armed, enable the burst.
@@ -3136,6 +3138,7 @@ peer_xmit(
 		intercept_sendpkt(__func__, &peer->srcadr, peer->dstadr, sys_ttl[peer->ttl],
 		    &xpkt, sendlen);
 		peer->sent++;
+		peer->outcount++;
 		peer->throttle += (1 << peer->minpoll) - 2;
 
 		/*


=====================================
ntpd/ntp_util.c
=====================================
--- a/ntpd/ntp_util.c
+++ b/ntpd/ntp_util.c
@@ -548,7 +548,9 @@ record_raw_stats(
 	int	precision,
 	double	root_delay,	/* seconds */
 	double	root_dispersion,/* seconds */
-	uint32_t	refid
+	uint32_t	refid,
+	u_int	outcount
+
 	)
 {
 	l_fp	now;
@@ -562,13 +564,14 @@ record_raw_stats(
 	day = now.l_ui / 86400 + MJD_1900;
 	now.l_ui %= 86400;
 	if (rawstats.fp != NULL) {
-		fprintf(rawstats.fp, "%lu %s %s %s %s %s %s %s %d %d %d %d %d %d %.6f %.6f %s\n",
+		fprintf(rawstats.fp, "%lu %s %s %s %s %s %s %s %d %d %d %d %d %d %.6f %.6f %s %d\n",
 		    day, ulfptoa(&now, 3),
 		    stoa(srcadr), dstadr ?  stoa(dstadr) : "-",
 		    ulfptoa(t1, 9), ulfptoa(t2, 9),
 		    ulfptoa(t3, 9), ulfptoa(t4, 9),
 		    leap, version, mode, stratum, ppoll, precision,
-		    root_delay, root_dispersion, refid_str(refid, stratum));
+		    root_delay, root_dispersion, refid_str(refid, stratum),
+		    outcount);
 		fflush(rawstats.fp);
 	}
 }



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/6c5c9e0643f5b113a91ebf7a9e6f404adceecf75
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151222/c85d63ec/attachment.html>


More information about the vc mailing list