Has anyone used the Daytime protocol on an esp8266?

Discussion of issues related to writing ZBasic applications for targets other than ZX devices, i.e. generic targets.
Post Reply
JimG
Posts: 17
Joined: 24 March 2017, 6:15 AM

Has anyone used the Daytime protocol on an esp8266?

Post by JimG »

For my first ZBasic project, I wanted to get the date/time from the Daytime Protocol server from Nist. (RFC-867). It works using tcp/ip or udp/ip on port 13. So I thought I'd just change the server to "time.nist.gov" and the port to 13 in the ClientTCP.bas program in the Examples-ESP8266 folder. Everything seemed to be going well except no message was ever received.
Has anyone used the protocol successfully, and if so, could you share some code, or at least give some hints at what needs to be changed?
JimG
Posts: 17
Joined: 24 March 2017, 6:15 AM

Post by JimG »

After many hours of testing, it mysteriously started working. Went back to the original code, and it also worked. No idea what the problem was. It only works on tcp however. It should work on udp also, but just doesn't.
JimG
Posts: 17
Joined: 24 March 2017, 6:15 AM

Daytime Protocol

Post by JimG »

After several weeks of struggle, I'm still having problems getting this protocol to work consistently.

I've gotten it to work pretty good, but I would like a better success rate for attempts. I wrote the below program to help figure out the best way to code this, and these are typical results-

Code: Select all

------- stats -------   runtime=7562.40 seconds  3:06:02.40
 total successful attempts = 200 of 438 = 45%
 1  216.228.192.69   25 good of 25  trys, connect timeouts=0   read timeouts=0   disconnects=0  
 2  129.6.15.30      14 good of 16  trys, connect timeouts=1   read timeouts=1   disconnects=0  
 3  64.113.32.5      29 good of 30  trys, connect timeouts=0   read timeouts=0   disconnects=1  
 4  216.229.0.179    19 good of 236 trys, connect timeouts=105 read timeouts=0   disconnects=112
 5  129.6.15.28       3 good of 11  trys, connect timeouts=6   read timeouts=2   disconnects=0  
 6  128.138.141.172  90 good of 94  trys, connect timeouts=0   read timeouts=0   disconnects=4  
 7  129.6.15.29       4 good of 7   trys, connect timeouts=2   read timeouts=1   disconnects=0  
 8  129.6.15.27      16 good of 19  trys, connect timeouts=2   read timeouts=1   disconnects=0  
  Maximum connect time=1.71        Maximum wait data time=9.16
  Average connect time=0.1222166  Average wait data time=0.5689964
The ip addresses you see are the one given out by nist by accessing time.nist.gov, and they are supposedly given out in a manner to balance the load on the servers.

The real problem site seems to be 216.229.0.179, which you can see only succeeded 19 out of 236 tries. A pretty miserable success rate. Also, it is by far the most commonly served host by nist. After thinking about this a lot, I've come to the conclusion that this is probably their fastest, and therefore least busy server.

The majority of failures seem to be that we timed out before connection was made (I had to add a Net.SetTimeout command because if we don't get connected in 10 seconds, we never will and the program just dies) or we got a disconnect before we got the data. But looking at the timing when it works, it is very fast. Therefore, I think the problem is that we are too slow and missing the response from the server. Either the esp's aren't fast enough (I've tried 8 different esp's, both 1 and 4 meg units with similar results), or there is something going on that is bogging down the net.connect command to the point where it misses the connect and/or data sent.

If you get a chance, would you take a quick look to see if there is something odd on the ZBasic side? I've tried everything I can think of at my level.

I really appreciate the effort you put into making this available. I really can't stand curly braces.
Attachments
daytime.zip
(6.14 KiB) Downloaded 359 times
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Daytime Protocol

Post by dkinzer »

JimG wrote:If you get a chance, would you take a quick look to see if there is something odd on the ZBasic side?
I have a critical project underway but I should be able to take a look at this and the MAC address issue in the next few days.
- Don Kinzer
JimG
Posts: 17
Joined: 24 March 2017, 6:15 AM

Post by JimG »

Thank you very much. I understand that real life comes first, and am very appreciative of the efforts you have put into making ZBasic work with the esp.
Post Reply