cancel
Showing results for 
Search instead for 
Did you mean: 

NTP request problem on SPWF04

DUrbano
Associate III
Posted on January 24, 2018 at 14:43

Hi,

I'm working on SPWF04 linked by UART with a NUCLEO F411RE board; I'm facing with a strange problem: I'm trying to connect with an NTP server to synchronize the NUCLEO RTC, so after create a wifi connection, I open the socket, send the data, but the server not answer even if the request going well. This is what I send and what I receive:

TX:  AT+S.SOCKON=193.204.114.105,123,,u

RX: AT-S.On:193.204.114.105:0

RX: AT-S.OK

TX: AT+S.SOCKW=0,48<CR><ESC><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL>

RX: AT-S.OK

but after if I try to check any answer, I read:

TX: AT+S.SOCKQ=0

RX: AT-S.Query:0

RX: AT-S.OK

Please, could anyone tell me what's wrong ? Where's the problem ?

Regards

Davide Urbano

#spwf04 #ntp
22 REPLIES 22
Posted on January 24, 2018 at 17:49

Simple Berkeley Sockets implementation where you open a socket and listen. In Windows with libraries like WINSOCK. When developing TCP based server/client applications it helps to be able to emulate and test what you're doing, and sanity check things.

Also pool.ntp.org or time.windows.com

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 24, 2018 at 18:34

d.urbano said that NTP server is working (another PC was used for the purpose of NTP Client). Also the routing was verified from the board using ping test.

So we need to see real NTP request from the board to prove it is correctly configured as the NTP client.

Posted on January 24, 2018 at 19:04

My point more generally is that when debugging protocols and interactions it is often helpful to be able to debug and diagnose locally rather that via a large black box where you have no control or visibility into.

Given the level of abuse NTP servers see they might also blacklist specific clients, or limit DoS attacks (errant client banging on server repetitively)

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 24, 2018 at 19:11

Yes, agree. But writing socket server is not so simple if you not experience in C programming. But frankly node.js or other scripting languages make thing easier.

Posted on January 24, 2018 at 19:11

Of course you can always start local ntp service using linux...

DUrbano
Associate III
Posted on January 25, 2018 at 12:46

After many attempts, no one data there is on WireShark...

Posted on January 25, 2018 at 13:01

If you could check if use see ICMP packets during the ping tests.

This way we can verify that Wireshark is setup correctly i.e. it sniffs right interfaces and the traffic can be captured.

We want to avoid situation when the Wireshark cannot capture the traffic and conclude that the NTP packest are NOT sent.

Why the Wireshark can miss the traffic:

-when you use switches in the network the link between switch port is somewhat virtual - the other not involved porta cannot see the traffic. You need to have mirror-port functionality i.e. you need to configure traffci replication to the port where the sniffer is connected to.

So it is interesting where the Wireshark is ran and how the traffic you want to sniff is delivered to the Wireshark interface (host port) you ar elitening on.

DUrbano
Associate III
Posted on January 25, 2018 at 15:02

Yes I can see the ICMP packets; and I can get a web page with command AT+S.HTTPGET. One question: is correct the request I send to NTP server ?

AT+S.SOCKW=0,48<CR><ESC><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL>

Is there any error in this command ?

Posted on January 25, 2018 at 16:18

NTP uses UDP so HTTPGET is not for this purpose because it is TCP based request.

Posted on January 25, 2018 at 16:22

I am not familiar with this module - have you implemented own UDP Client?

NTP is not about requesting time using UDP/123 - it's quite complex protocol which takes into account network delays, etc.