What's new

Set the router clock with a GPS receiver for under $70

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

I was more implying that my math education is not even high-school level (and the current time is past midnight). I didn't really mean to criticize him.

Transients = other possible factors?

I don't think anyone took your comments as criticism...

Transients - not urban campers, but time deltas - the SV's are in low earth orbit, so the GPS chipset averages the time streams across all the SV's, so there's a little bit of output jitter depending on integration time - longer integration, the better the time resolution reported... but longer integration time means longer time before we get a good fix - it's always a trade-off...
 
And without getting all relativistic - if I recall, Einstein said that the man who has two watches doesn't know what time it is...

GPS is at least 24 time sources, lol...

(GPS works because of Einstein's equations...)
 
Anyways - I think this is one of the more fun projects that we've seen on the board - really appreciate everyone's inputs...
 
I found that it helps to redirect the DNS lookups for NTP server names, to the router's NTP server. It is for when your Internet connection is unstable or your upstream DNS server is flaky.

/jffs/configs/dnsmasq.conf.add
Code:
address=/.pool.ntp.org/192.168.1.1
address=/ntp.ubuntu.com/192.168.1.1
address=/time.nist.gov/192.168.1.1
address=/time-nw.nist.gov/192.168.1.1
address=/time-a.nist.gov/192.168.1.1
address=/time-b.nist.gov/192.168.1.1
address=/time.windows.com/192.168.1.1


AND, here's how to intercept those NTP synchronization requests on the LAN and redirect them to the router's NTP server.

/jffs/scripts/nat-start
Code:
#!/bin/sh
/usr/sbin/iptables -t nat PREROUTING -i br0 -s 192.168.1.0/24 -p tcp --dport 123 -j DNAT --to-destination 192.168.1.1
/usr/sbin/iptables -t nat PREROUTING -i br0 -s 192.168.1.0/24 -p udp --dport 123 -j DNAT --to-destination 192.168.1.1
 
Last edited:
lol

barbara = ASAT...?

/usr/sbin/iptables -t nat PREROUTING -i br0 -s 192.168.1.0/24 -p udp --dport 123 -j DNAT --to-destination 192.168.1.1[/CODE]

This alone is sufficient. No need to add entries to dnsmasq..
 
Last edited:
Just looking at my ntp.conf file, saw this at the tail end... ubuntu 16.04LTS...

Code:
#Changes recquired to use pps synchonisation as explained in documentation:
#http://www.ntp.org/ntpfaq/NTP-s-config-adv.htm#AEN3918

#server 127.127.8.1 mode 135 prefer    # Meinberg GPS167 with PPS
#fudge 127.127.8.1 time1 0.0042        # relative to PPS for my hardware

#server 127.127.22.1                   # ATOM(PPS)
#fudge 127.127.22.1 flag3 1            # enable PPS API
 
Code:
sfx@raspy:~$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 0.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 1.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 2.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 3.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 ntp.ubuntu.com  .POOL.          16 p    -   64    0    0.000    0.000   0.000
-207.196.240.30  207.171.7.152    3 u  228 1024  377   59.238   -1.082   2.353
 utcnist2.colora .ACTS.           1 u  291 1024  374   60.316   -1.274   0.936
+time.tritn.com  216.218.192.202  2 u 1031 1024  377   14.847   -4.709   0.785
+216.152.240.220 216.218.254.202  2 u  167 1024  367   16.235   -4.699   0.820
*ntp1.digitalwes .GPS.            1 u  290 1024  377   28.310    0.867   0.878
 
No need to add entries to dnsmasq?
Test it by turning off your cable modem. Then see if your LAN clients can sync their clocks. If there is no DNS to resolve "time.nist.gov", for example, to an IP address, then the LAN client will never try to make the NTP synchronization request in the first place.
 
Test it by turning off your cable modem. Then see if your LAN clients can sync their clocks. If there is no DNS to resolve "time.nist.gov", for example, to an IP address, then the LAN client will never try to make the NTP synchronization request in the first place.

Okay...you have a point..

I use router.asus.com as time server on my LAN clients.
 
Code:
sfx@raspy:~$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
0.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
1.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
2.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
3.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
ntp.ubuntu.com  .POOL.          16 p    -   64    0    0.000    0.000   0.000
-207.196.240.30  207.171.7.152    3 u  228 1024  377   59.238   -1.082   2.353
utcnist2.colora .ACTS.           1 u  291 1024  374   60.316   -1.274   0.936
+time.tritn.com  216.218.192.202  2 u 1031 1024  377   14.847   -4.709   0.785
+216.152.240.220 216.218.254.202  2 u  167 1024  367   16.235   -4.699   0.820
*ntp1.digitalwes .GPS.            1 u  290 1024  377   28.310    0.867   0.878

On my RT-AC56U:

pic.png


Current system clock offset is -0.27 ms with a jitter 0.67 ms. I won't ask for more without GPS.
 
I use router.asus.com as time server on my LAN clients
I discovered this when testing Ubuntu Mate with a Banana Pi M3, without an Internet connection on the router. For some reason, the Pi was ignoring my changes to /etc/ntp.conf. So this would fix the issue when I can't set the NTP server name on the LAN client.
 
I discovered this when testing Ubuntu Mate with a Banana Pi M3, without an Internet connection on the router. For some reason, the Pi was ignoring my changes to /etc/ntp.conf. So this would fix the issue when I can't set the NTP server name on the LAN client.

You did a kill -HUP after editing the ntp.conf file right?
 
Pulling this thread out of the attic... as while it might not be fully useful on AsusWRT, there's a lot of good notes here that can be used with something like RPi Model B, which can be powered from the Router directly as an adjunct processor...
 
I found that it helps to redirect the DNS lookups for NTP server names, to the router's NTP server. It is for when your Internet connection is unstable or your upstream DNS server is flaky.

So funny - ran into this the other day, and came to same conclusion to solve a similar problem

Just using 192.168.0.1 as an example... myrouter.lan is 192.168.0.1

iptables -t nat -A PREROUTING -i br-lan -p udp --dport 123 -j DNAT --to 192.168.0.1

edit /etc/dnsmasq.conf - assuming that hostname is myrouter.lan

cname=time.nist.gov,myrouter.lan
cname=time-a.nist.gov,myrouter.lan
cname=time-b.nist.gov,myrouter.lan
cname=time-nw.nist.gov,myrouter.lan
cname=pool.ntp.org,myrouter.lan
cname=android.pool.ntp.org,myrouter.lan


Add/Ensure to slash etc slash hosts # cloudflare stuff

192.168.0.1 myrouter.lan

Bonus Points

Add/Edit ntp configs... below is for openwrt

/etc/config/system as it runs busybox for ntp

config timeserver 'ntp'
option enabled '1'
option enable_server '1'
list server 'time1.google.com'
list server 'time2.google.com'
list server 'time3.google.com'
list server 'time4.google.com'


For real NTP - just add those as servers to slash etc slash ntp.conf

Some folks worry about google time* - and that's ok, just change it out for the pools for local regions.

Google public NTP servers work well with Google public DNS - short hops, lower latency

* google public NTP smear time to cover for things like leap seconds - when one has 100,000 plus servers synced up globally, doing a gentle smudge over 20 hours prior to the leap second jump makes sense.​

for ntp.conf is really running gps/pps - as mentioned - add the stanza for PPS and NMEA - there's an appropriate REFID for those services...

@kvic - seems good enough for gobernent work... the ASCII codes for REFID are fun ;)

ntpq_recnet.png


This alone is sufficient. No need to add entries to dnsmasq..

The DNSmasq entries do keep things local... it's complicated with real ntp in this setup...

From a cold startup - it's good, but over time, ntp sorts itself - but the initial DNS lookups come into play - host thinks it's talking to a remote, but the real data is coming from the local timeserver
 
Last edited:
I'll have to go back to ntp.org's FAQs, but there are different strata of timeserver - implementing a GPS PPS receiver into your home network makes you effectively a Stratum 1 timesource if I'm not mistaken.

Given Merlin's 384.11 firmware and @JackYaz 's ntpMerlin scripts, accurate timing seems to be of import to people round about in these parts (this makes me very happy). have all y'all who get their time from space (SPACE!) considered forming a pool?
 
I'll have to go back to ntp.org's FAQs, but there are different strata of timeserver - implementing a GPS PPS receiver into your home network makes you effectively a Stratum 1 timesource if I'm not mistaken.

That's right - and there's a couple of GPS solutions that work out of the box with RPi...
 
That's right - and there's a couple of GPS solutions that work out of the box with RPi...
I am happy with this GPS NTP server. No assembly, no operating system, just plug and play.
https://v3.airspy.us/product/upu-leontp/
I set the IP address in DHCP. With IP instead of a name, DNS is not required for Asuswrt-Merlin to sync quickly as the router boots. These are the results with 8 second polling. I bet you can tell what time I began to watch a Twitch video stream.
NTP_Leo.png
 
I am happy with this GPS NTP server. No assembly, no operating system, just plug and play.
https://v3.airspy.us/product/upu-leontp/
I set the IP address in DHCP. With IP instead of a name, DNS is not required for Asuswrt-Merlin to sync quickly as the router boots. These are the results with 8 second polling. I bet you can tell what time I began to watch a Twitch video stream.

Can get the same performance with a Pi and the GPS hat...

https://v3.airspy.us/product/upu-rpigps/

Alt depending on market/location...

https://www.adafruit.com/product/2324
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top