Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: Bolt on October 25, 2018, 04:19:08 PM

Title: NETTIME and proper setup
Post by: Bolt on October 25, 2018, 04:19:08 PM
I've been using a NETTIME instruction for quite a while, and have always gotten allot of timeouts, failed updates.  It does work successfully sometimes, but not consistently.

I've tried different servers.  I get all my IP's from https://tf.nist.gov/tf-cgi/servers.cgi

I've changed timeout from 1000 ms to 2000 ms.

How does "proper" NETTIME logic look?  If failed, try again in 10 seconds?  If failed try different IP address?

Here's my attached logic.  Just trying to generate conversation for proper procedure.
Title: Re: NETTIME and proper setup
Post by: Mike Nash on October 25, 2018, 06:22:49 PM
My code does time out at times, but it doesn't seem excessive. I'm only using it to display the time on my desk on a device not remotely associated with being a timepiece or display - it was primarily to get comms working with that family just to see if I could. (And then I got to do it for real.)

You're not hitting the time server too frequently are you?
Quote
All users should ensure that their software NEVER queries a server more frequently than once every 4 seconds. Systems that exceed this rate will be refused service. In extreme cases, systems that exceed this limit may be considered as attempting a denial-of-service attack.
Title: Re: NETTIME and proper setup
Post by: BobO on October 26, 2018, 01:13:53 PM
It is and has always worked perfectly for me. Just set up a quick test, hitting a NIST server in Maryland every 6 seconds. It's close to 100 now with zero failures.

My guess is that you have more general issues with network stability. You might ping one of the servers recurrently and observe any bumps in ping responses.
Title: Re: NETTIME and proper setup
Post by: ATU on October 26, 2018, 01:56:19 PM
Do a little data collection.
When you have a a NETTIME  timeout, start pinging the server and then record in an array how long it takes before you get a response.
Title: Re: NETTIME and proper setup
Post by: Bolt on October 26, 2018, 02:07:45 PM
Regularly, I only attempt it once an hour.  So I'm not bombarding the server.

I can't even ping any of the NIST servers from the command prompt, so I didn't bother having the PLC ping the servers.  What am I missing there?  Are they port specific, don't reply to regular pings?

Title: Re: NETTIME and proper setup
Post by: BobO on October 26, 2018, 02:21:24 PM
The time.nist.gov domain gets round robin mapped to a range of servers. It appears that some of those servers are answering pings, but others are not. For my test I looked up one of the servers and just used that IP. That worked fine.

How are you resolving the address to the server?
Title: Re: NETTIME and proper setup
Post by: ADC Product Engineer on October 26, 2018, 04:10:20 PM
One other thing to note, not all of the NIST servers are public anymore.  Be sure you are picking from a current list.  As Bob said, time.nist.gov should typically be the proper access point.

Current list: https://tf.nist.gov/tf-cgi/servers.cgi
Title: Re: NETTIME and proper setup
Post by: Bolt on October 29, 2018, 02:04:23 PM
The time.nist.gov domain gets round robin mapped to a range of servers. It appears that some of those servers are answering pings, but others are not. For my test I looked up one of the servers and just used that IP. That worked fine.

How are you resolving the address to the server?

I am picking an IP address from the list that I and the ADC Product Engineer have linked to in this post,  the nist.gov servers.  I have tried several, and they all work occasionally, and occasionally not.  Since starting this post, running NETTIME just once an hour (and occasionally forcing it for troubleshooting) success rate is about 58%.

It's not a big deal, but I'm wondering what I'm doing wrong, or how I should be structuring my ladder logic.  Most of my logic has a success rate of well over 58%, haha.  I'm just trying to cut down on the warning errors every time I open DmD. 
Title: Re: NETTIME and proper setup
Post by: BobO on October 29, 2018, 02:55:00 PM
I am picking an IP address from the list that I and the ADC Product Engineer have linked to in this post,  the nist.gov servers.  I have tried several, and they all work occasionally, and occasionally not.  Since starting this post, running NETTIME just once an hour (and occasionally forcing it for troubleshooting) success rate is about 58%.

It's not a big deal, but I'm wondering what I'm doing wrong, or how I should be structuring my ladder logic.  Most of my logic has a success rate of well over 58%, haha.  I'm just trying to cut down on the warning errors every time I open DmD.

That's terrible. I have not seen anything that bad, but I haven't run it over night.

Maybe the servers coming and going is expected, and perhaps the global DNS function is accounting for servers being up or down. Add an additional step that does a DNSLOOKUP on time.nist.gov before calling NETTIME. I just set that up myself. It looks like the returned server is changing every 15 seconds or so.
Title: Re: NETTIME and proper setup
Post by: Mike Nash on October 29, 2018, 04:02:34 PM
No errors after 3 1/2+ days checking every 2 hours here.

The NETTIME errors I do get are quite possibly me screwing up the ethernet here in the office network, and our service can get iffy at times.
Title: Re: NETTIME and proper setup
Post by: Bolt on October 30, 2018, 01:10:20 AM
Strange.

I have changed my logic to DNSLOOKUP, NETTIME, and if success, repeat in 5 minutes.  if fail, repeat in 10 seconds.  So far I'm at about 75% success (about 160 attempts).  Overall my internet connection doesn't have that many issues, so not sure what gives.  I guess I'll just live with it, it's still quite accurate.
Title: Re: NETTIME and proper setup
Post by: BobO on October 30, 2018, 08:03:07 AM
I'm really quite curious. SNTP is a very simple UDP based protocol...packet out and back. There is really nothing to go wrong unless packet delivery is unreliable. It appears that some of the servers don't answer ping, but several do. I would still like to know what ping looks to a server that supports it.
Title: Re: NETTIME and proper setup
Post by: Bolt on October 30, 2018, 10:04:59 AM
I have actually yet to ping a NIST server that replies.  From PC, not PLC.
Title: Re: NETTIME and proper setup
Post by: Evilbeard on October 30, 2018, 10:37:10 AM
I have actually yet to ping a NIST server that replies.  From PC, not PLC.

Seems to me like you have some sort of firewall/traffic restriction. I know that here at work, I can't ping those servers, but my internet access works allowing me to ping things like google, etc. You might look at what kind of restrictions your network has in regards to network traffic. Corporate IT is my nemesis.
Title: Re: NETTIME and proper setup
Post by: BobO on October 30, 2018, 11:59:46 AM
I have actually yet to ping a NIST server that replies.  From PC, not PLC.

This one worked for me: utcnist.colorado.edu
Title: Re: NETTIME and proper setup
Post by: Bolt on October 30, 2018, 02:27:16 PM
Seems to me like you have some sort of firewall/traffic restriction. I know that here at work, I can't ping those servers, but my internet access works allowing me to ping things like google, etc. You might look at what kind of restrictions your network has in regards to network traffic. Corporate IT is my nemesis.

I don't think that's the issue, either.  I am my own IT guy, and have very few restrictions on traffic.

This one worked for me: utcnist.colorado.edu

I can also ping that one from command prompt in Windows.  With slightly better performance than a ping to google.com.
Title: Re: NETTIME and proper setup
Post by: BobO on October 30, 2018, 02:44:06 PM
This one worked for me: utcnist.colorado.edu

I can also ping that one from command prompt in Windows.  With slightly better performance than a ping to google.com.

If you hardcode NETTIME to that server, and then attempt to ping from the PLC when it fails, what happens?
Title: Re: NETTIME and proper setup
Post by: Bolt on October 31, 2018, 09:40:05 AM
This one worked for me: utcnist.colorado.edu

I can also ping that one from command prompt in Windows.  With slightly better performance than a ping to google.com.

If you hardcode NETTIME to that server, and then attempt to ping from the PLC when it fails, what happens?

I get about a 70% success rate getting a time from that server too. When it fails, a ping also fails 100% of the time. A ping does work from DmD when manually triggered however.
Title: Re: NETTIME and proper setup
Post by: BobO on October 31, 2018, 09:52:49 AM
I get about a 70% success rate getting a time from that server too. When it fails, a ping also fails 100% of the time. A ping does work from DmD when manually triggered however.

Everything you are describing points to some kind of general network instability.

Host's primary internet connection is fiber, but we have a backup copper line that works great...and then doesn't. Never could figure out exactly why it would go wobbly. From our desks it still appeared to work, but the packet losses would shoot way up for a bit and then it would be fine.
Title: Re: NETTIME and proper setup
Post by: Bolt on October 31, 2018, 04:16:48 PM
I spoke too soon.  I changed my logic up via remote desktop, and didn't enable the alternate bit to force everything over to the colorado IP address.  It has run 100% over the last 50+ attempts.  So it was also pinging the non-pingable IP address in the mean time.  Doh!
Title: Re: NETTIME and proper setup
Post by: Dean on November 01, 2018, 08:51:57 AM
After two systems with a hard coded IP, changing the addresses a few times, and having inconsistent results, I went with Bob's suggestion of using DNSLOOKUP on time.nist.gov and feeding it into NETTIME, (Which couldn't be simpler by the way, thanks guys.) Haven't had a failure since.
Title: Re: NETTIME and proper setup
Post by: Bolt on November 01, 2018, 10:04:00 AM
Strange.  I can go 100% on 260+ attempts with utcnist.colorado.edu, then go back to time.nist.gov, get 1 failure right away, it won't ping, and go back to utcnist.colorado.edu, and it succeeds again. 
Title: Re: NETTIME and proper setup
Post by: Controls Guy on November 01, 2018, 02:17:23 PM
Maybe the DNS server in use by your provider has a messed-up entry for time.nist.gov.   Can you ping it from the desktop while getting interwebs from the same network?  And, if you resolve the IP address elsewhere, can you ping it from that network with the explicit IP?
Title: Re: NETTIME and proper setup
Post by: Dean on November 02, 2018, 08:44:35 AM
Another option is pool.ntp.org. These servers don't get as much traffic as the NIST servers, have a higher service capacity, and automatically route your request to your nearest server.