--- iputils-s20071127/arping.c	2013-09-17 08:29:40.109976987 +0200
+++ iputils-s20071127-monotonic/arping.c	2013-09-17 08:28:55.000000000 +0200
@@ -14,7 +14,7 @@
 #include <sys/socket.h>
 #include <linux/sockios.h>
 #include <sys/file.h>
-#include <sys/time.h>
+#include <time.h>
 #include <sys/signal.h>
 #include <sys/ioctl.h>
 #include <linux/if.h>
@@ -58,7 +58,7 @@ int broadcast_only;
 struct sockaddr_ll me[2];
 struct sockaddr_ll he[2];
 
-struct timeval start, last;
+struct timespec start, last;
 
 int sent, brd_sent;
 int received=0, brd_recv, req_recv;
@@ -107,7 +107,7 @@ int send_pack(int s, struct in_addr src,
 	      struct sockaddr_ll *ME, struct sockaddr_ll *HE)
 {
 	int err;
-	struct timeval now;
+	struct timespec now;
 	unsigned char buf[256];
 	struct arphdr *ah = (struct arphdr*)buf;
 	unsigned char *p = (unsigned char *)(ah+1);
@@ -135,7 +135,7 @@ int send_pack(int s, struct in_addr src,
 	memcpy(p, &dst, 4);
 	p+=4;
 
-	gettimeofday(&now, NULL);
+	clock_gettime(CLOCK_MONOTONIC, &now);
 	err = sendto(s, buf, p-buf, 0, (struct sockaddr*)HE, (ah->ar_hln > 8) ?
 		     sizeof(*HE) + ah->ar_hln - 8 : sizeof(*HE));
 	if (err == p-buf) {
@@ -172,27 +172,50 @@ void finish(void)
 	exit(!received);
 }
 
+static void timespec_sub(struct timespec *a, struct timespec *b,
+			 struct timespec *res)
+{
+	res->tv_sec = a->tv_sec - b->tv_sec;
+	res->tv_nsec = a->tv_nsec - b->tv_nsec;
+	if (a->tv_nsec < b->tv_nsec) {
+		res->tv_sec--;
+		res->tv_nsec += 1000000000;
+	}
+}
+
+static int timespec_later(struct timespec *a, struct timespec *b)
+{
+	return (a->tv_sec > b->tv_sec) ||
+		((a->tv_sec == b->tv_sec) && (a->tv_nsec > b->tv_nsec));
+}
+
 void catcher(void)
 {
-	struct timeval tv;
+	struct timespec ts, ts_s, ts_o;
 
-	gettimeofday(&tv, NULL);
+	clock_gettime(CLOCK_MONOTONIC, &ts);
 
 	if (start.tv_sec==0)
-		start = tv;
+		start = ts;
+
+	timespec_sub(&ts, &start, &ts_s);
+	ts_o.tv_sec = timeout;
+	ts_o.tv_nsec = 500 * 1000000;
 
-	if ((timeout && MS_TDIFF(tv,start) > timeout*1000 + 500) ||
-		((count == 0) && (!timeout)))
+	if (count-- == 0 || (timeout && timespec_later(&ts_s, &ts_o)))
 		finish();
 
-	if (last.tv_sec == 0 || MS_TDIFF(tv, last) > 500) {
-		count--;
-		send_pack(s, src, dst, &me[0], &he[0]);
+	timespec_sub(&ts, &last, &ts_s);
+	ts_o.tv_sec = 0;
+
+	if (last.tv_sec==0 || timespec_later(&ts_s, &ts_o)) {
+		send_pack(s, src, dst,
+				  (struct sockaddr_ll *)&me, (struct sockaddr_ll *)&he);
 		if (count == 0 && unsolicited)
 			finish();
 	}
 	alarm(1);
-}
+} 
 
 void print_hex(unsigned char *p, int len)
 {
@@ -206,12 +229,12 @@ void print_hex(unsigned char *p, int len
 
 int recv_pack(unsigned char *buf, int len, struct sockaddr_ll *FROM)
 {
-	struct timeval tv;
+	struct timespec ts;
 	struct arphdr *ah = (struct arphdr*)buf;
 	unsigned char *p = (unsigned char *)(ah+1);
 	struct in_addr src_ip, dst_ip;
 
-	gettimeofday(&tv, NULL);
+	clock_gettime(CLOCK_MONOTONIC, &ts);
 
 	/* Filter out wild packets */
 	if (FROM->sll_pkttype != PACKET_HOST &&
@@ -287,8 +310,8 @@ int recv_pack(unsigned char *buf, int le
 			printf("]");
 		}
 		if (last.tv_sec) {
-			long usecs = (tv.tv_sec-last.tv_sec) * 1000000 +
-				tv.tv_usec-last.tv_usec;
+			long usecs = (ts.tv_sec-last.tv_sec) * 1000000 +
+				(ts.tv_nsec-last.tv_nsec+500) / 1000;
 			long msecs = (usecs+500)/1000;
 			usecs -= msecs*1000 - 500;
 			printf(" %ld.%03ldms\n", msecs, usecs);
--- iputils-s20071127.orig/Makefile	2013-08-30 12:22:17.417615128 +1000
+++ iputils-s20071127/Makefile	2013-08-30 12:22:40.790614283 +1000
@@ -4,7 +4,7 @@
 DEFINES= 
 
 #options if you have a bind>=4.9.4 libresolv (or, maybe, glibc)
-LDLIBS=-lresolv
+LDLIBS=-lresolv -lrt
 ADDLIB=
 
 #options if you compile with libc5, and without a bind>=4.9.4 libresolv
