Skip to main content
DUrbano
Associate III
January 24, 2018
Question

NTP request problem on SPWF04

  • January 24, 2018
  • 8 replies
  • 2892 views
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
This topic has been closed for replies.

8 replies

Tesla DeLorean
Guru
January 24, 2018
Posted on January 24, 2018 at 15:44

Build you own port 123 listener on the network and confirm you can receive packets.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
DUrbano
DUrbanoAuthor
Associate III
January 24, 2018
Posted on January 24, 2018 at 15:46

Please, could you tell me how ?

Bogdan Golab
Lead
January 24, 2018
Posted on January 24, 2018 at 15:55

Is the NTP server connected through the LAN port to the network  - try to sniff the traffic (if linux - try tcp dump ) to see if the NTP request reaches the server.

The WiFi side: can you ping the NTP server  - just to check the routing.

Can other device (real host connect to this time server) - just to verify that the NTP service is up and working.

Sniffing is the best way to follow OR look at the NTP Server logs to see if the NTP Client was able to reach the Server.

Bogdan Golab
Lead
January 24, 2018
Posted on January 24, 2018 at 15:59

Wireshark is recommended if you do not use tcpdump.

Sorry I wasn't not able to edit the post.

DUrbano
DUrbanoAuthor
Associate III
January 24, 2018
Posted on January 24, 2018 at 16:02

NTP server is a public server (ntp.inrim.it) but I can see the ping to this server going well...is really really strange...I tested the server from my PC and is up and working well.

Elio Cometti
Visitor II
January 24, 2018
Posted on January 24, 2018 at 16:31

Is the ping going well from the SPWF04 too?

I have just done the following:

AT+S.PING=,,193.204.114.105

AT-S.Start:193.204.114.105

AT-S.Reply:56:52

AT-S.Stop:0:52

AT-S.OK

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

AT-S.On:193.204.114.105:0

AT-S.OK

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

AT-S.OK

+WIND:55:Pending Data::0:48:48

Bogdan Golab
Lead
January 24, 2018
Posted on January 24, 2018 at 16:34

Great idea to verify ping to check the routing. Also we want to see if the NTP packets are leaving the box since we have no response (it does not have to be the server if the packets do not leave the box)

Bogdan Golab
Lead
January 24, 2018
Posted on January 24, 2018 at 16:27

Can you see the NTP packets (UDP 123) from the board. I guess you can sniff them in the middle.

We need to know if the NTP packets from the boards are seen in the network.

DUrbano
DUrbanoAuthor
Associate III
January 24, 2018
Posted on January 24, 2018 at 16:44

Ping to the NTP server going well...now install Wireshark and check the packets...

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

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

Bogdan Golab
Lead
January 25, 2018
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
DUrbanoAuthor
Associate III
January 25, 2018
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 ?

Bogdan Golab
Lead
January 25, 2018
Posted on January 25, 2018 at 16:18

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

Bogdan Golab
Lead
January 25, 2018
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.

DUrbano
DUrbanoAuthor
Associate III
January 26, 2018
Posted on January 26, 2018 at 12:00

Thanks a lot Elio for your suggests; if I connect to my local network a PC configured as NTP server, all works perfectly. Even if I try to connect to the TCP port 37 of 

193.204.114.105, I get immediately the 4 bytes...so I'm thinking I have a problem to connect out of my network...