Pages: [1]   Go Down
Author Topic: Broken & dangerous NTP tutorial code...  (Read 5304 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am actually talking about two different sets of code for retrieving time via NTP.  The first is the code at  This code does not work with the current version of the Arduino IDE (0022), and should be updated.  I would suggest updating to the example code included in the Arduino IDE, which does work, however...

The code included with the Arduino IDE does some dangerous things.  Most importantly, it polls a public server every 10 seconds!  To make matters worse, it a stratum 1 server, which are already overburdened1.  Now imagine a classroom of students with Arduinos all firing up NTP clients at the same time, or worse, the same code being embedded in a project and causing huge floods of traffic to the NTP servers for years to come2.  Now I know this is example code, and not meant to be used in production sans modification, but let's not have it use bad practices by default.  The last thing I want is an excuse for people to point a finger at such an open, lauded platform for development.

So, what would I recommend changing?  First and foremost, don't include a hard-coded public stratum 1 server in the code.  Instead, have no default server (, and include a link to a list of public stratum 2 time servers and guidelines3, and inform users how to look up the IP addresses (`nslookup` on windows; `host` on everything else) of the servers on the list to hard-code it into the example.  If you insist on the example working "out of the box" (aside from possibly IP, subnet, gateway, & MAC address changes), then someone at should set up a public time server for the purpose.

In addition, do not have the code synchronize every 10 seconds by default, unless the people at are running the time server, and even then make a note that when using with other public servers the delay should be increased.

I'm all for making things easy for people, and it can still be easy while at the same time not being problematic to others.  I also don't think many of the Arduino users want to a burden, and likely don't even know that they are.

2) Flawed Routers Flood University of Wisconsin Internet Time Server
3) Rules of Engagement
« Last Edit: February 12, 2011, 12:01:19 pm by Orum » Logged

Global Moderator
Online Online
Shannon Member
Karma: 227
Posts: 14019
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

FYI, I updated my playground article  - - with a reference to this thread.

So, who builds the first Arduino based NTP server ! smiley


Rob Tillaart

Nederlandse sectie -,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Karma: 0
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I endorse Orum's comment regarding contacting  upper stratum time servers including Stratum Two Time Servers.  including

Perhaps a random member of would be better shown in the source example:,, or to name a few.

Found by command:  dig +short which will return different addresses everytime.

Please omit
// find your local ntp server or
// byte timeServer[] = {192, 43, 244, 18}; // NTP server
byte timeServer[] = {193, 79, 237, 14};    // NTP server 

Thank you for you consideration and for providing this example.

Pages: [1]   Go Up
Jump to: