• AVR Freaks

AnsweredHot!PIC32mz NTP Client not recognizing responses from server

Author
ajones
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2017/02/21 17:33:01
  • Location: 0
  • Status: offline
2018/07/02 15:28:21 (permalink)
0

PIC32mz NTP Client not recognizing responses from server

I have pic32mz1024efm100 on custom pcb based off of the pic32mz ef starter kit running harmony 2.02b.
 
My NTP client always works fine for the first, sometimes second query. After that, my client no longer recognizes the responses that are received from the server. As a result the timestamp goes stale because of a SNTP_RES_NTP_SERVER_TMO. I can see the request from my client and the response from the server on wireshark but my client does not pick up the response from the server.
 
Thanks in advance for any ideas?
 
/*** SNTP Configuration ***/
#define TCPIP_STACK_USE_SNTP_CLIENT
#define TCPIP_NTP_DEFAULT_IF                        "PIC32INT"
#define TCPIP_NTP_VERSION                             4
#define TCPIP_NTP_DEFAULT_CONNECTION_TYPE           IP_ADDRESS_TYPE_IPV4
#define TCPIP_NTP_EPOCH                                2208988800ul
#define TCPIP_NTP_REPLY_TIMEOUT                        6
#define TCPIP_NTP_MAX_STRATUM                        15
#define TCPIP_NTP_TIME_STAMP_TMO                    66//0
#define TCPIP_NTP_SERVER                            "pool.ntp.org"
#define TCPIP_NTP_SERVER_MAX_LENGTH                 30
#define TCPIP_NTP_QUERY_INTERVAL                    60//0
#define TCPIP_NTP_FAST_QUERY_INTERVAL               14
#define TCPIP_NTP_TASK_TICK_RATE                    1100
#define TCPIP_NTP_RX_QUEUE_LIMIT                    3//2
#1
rainad
Moderator
  • Total Posts : 1176
  • Reward points : 0
  • Joined: 2009/05/01 13:39:25
  • Location: 0
  • Status: offline
Re: PIC32mz NTP Client not recognizing responses from server 2018/07/03 13:34:18 (permalink)
3 (1)
There is a symbol enabling the debug messages in the sntp.c module:
#define TCPIP_SNTP_DEBUG_LEVEL (0)
Please change that to turn on all the debug capabilities:
#define TCPIP_SNTP_DEBUG_LEVEL (0x1f)
and then, if you have a console connected to your board, we'll get some debug output from NTP module.
Please post here the log so we can take a look.
 
I'd also recommend an upgrade to the latest Harmony version, there's been some updates in the SNTP module since v2.02 and there is a chance that the issue, if there is one, was meanwhile resolved.
#2
ajones
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2017/02/21 17:33:01
  • Location: 0
  • Status: offline
Re: PIC32mz NTP Client not recognizing responses from server 2018/07/03 14:27:25 (permalink)
0
I just checked a test I had setup yesterday, and in the last 12 hours the NTP module received 5 successful updates in addition to the first two that succeeded. They happened randomly throughout my 12 hour test. I counted a success when the return from TCPIP_SNTP_TimeStampGet(NULL, NULL) transitions from SNTP_RES_TSTAMP_STALE to SNTP_RES_OK. So, it is not failing 100% of the time - only 99.8%.
 
Thanks rainad, I'll turn on debug, try to get console running, and let you know the results.
#3
ajones
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2017/02/21 17:33:01
  • Location: 0
  • Status: offline
Re: PIC32mz NTP Client not recognizing responses from server 2018/07/05 11:45:33 (permalink)
0
Got the console running with the SNTP debug set:
#define TCPIP_SNTP_DEBUG_LEVEL (0x1f)
 
This is about 15min of logging:
 
 
ÀTCP/IP Stack: Initialization Started
SNTP State: 0 - init
TCP/IP Stack: Initialization Ended - success
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP solving IPv4 DNS: pool.ntp.org
SNTP solving IPv4 DNS: pool.ntp.org
SNTP solving IPv4 DNS: pool.ntp.org
SNTP solving IPv4 DNS: pool.ntp.org
SNTP solving IPv4 DNS: pool.ntp.org
SNTP solving IPv4 DNS: pool.ntp.org
SNTP solving IPv4 DNS: pool.ntp.org
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 6 - s_wait
SNTP Error: 10 - dns_err
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 45.79.11.217
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP new TStamp: 1530814010
SNTP State: 7 - l_wait
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 45.79.11.217
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP new TStamp: 1530814075
SNTP State: 7 - l_wait
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 45.79.11.217
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP new TStamp: 1530814140
SNTP State: 7 - l_wait
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 69.10.161.7
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 69.10.161.7
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 138.236.128.36
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 138.236.128.36
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 204.9.54.119
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 204.9.54.119
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 204.9.54.119
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 204.9.54.119
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 204.9.54.119
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 107.175.144.206
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 107.175.144.206
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 107.175.144.206
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 107.175.144.206
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 107.175.144.206
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 107.175.144.206
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 23.239.26.89
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 23.239.26.89
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 23.239.26.89
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 23.239.26.89
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 23.239.26.89
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 23.239.26.89
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 12.167.151.1
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 12.167.151.1
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 12.167.151.1
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 12.167.151.1
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 12.167.151.1
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 184.105.182.15
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
SNTP State: 1 - home
SNTP State: 2 - wait_dns
SNTP solving IPv4 DNS: pool.ntp.org
SNTP State: 3 - dns_solved
SNTP solved DNS: pool.ntp.org, address: 184.105.182.15
SNTP State: 4 - send
SNTP State: 5 - recv
SNTP State: 6 - s_wait
SNTP Error: 5 - srv_tmo
 
Looks like I received three timestamps this time before it started failing.
Next, I'll try updating to the latest Harmony version.
 
Can I use the Harmony 2.06 sntp.c and sntp.h and keep the rest of my project at 2.02b?
#4
Jim Nickerson
User 452
  • Total Posts : 5949
  • Reward points : 0
  • Joined: 2003/11/07 12:35:10
  • Location: San Diego, CA
  • Status: online
Re: PIC32mz NTP Client not recognizing responses from server 2018/07/05 12:40:31 (permalink)
3 (1)
I wonder how frequently you are requesting the time ?
#5
rainad
Moderator
  • Total Posts : 1176
  • Reward points : 0
  • Joined: 2009/05/01 13:39:25
  • Location: 0
  • Status: offline
Re: PIC32mz NTP Client not recognizing responses from server 2018/07/05 15:17:02 (permalink) ☼ Best Answerby ajones 2018/07/05 15:47:14
5 (2)
The log shows that the SNTP runs into the server timeout condition once the DNS comes up with a different address for the NTP server (this is how the DNS for those servers is supposed to work).
This is a bug that has been fixed some time ago.
Probably best to upgrade. But you can either try to replace just the sntp.h and .c files and see how it goes.
 
 
Or try to add the fix to your version:
In TCPIP_SNTP_Process, case SM_DNS_RESOLVED, after:
bindRes = TCPIP_UDP_RemoteBind(sntpSocket, ntpConnection, TCPIP_NTP_SERVER_REMOTE_PORT, &ntpServerIP);
if(bindRes)
{
bindRes = TCPIP_UDP_SocketNetSet(sntpSocket, pSntpIf);
}
add:
 
if(bindRes)
{
bindRes = TCPIP_UDP_SocketNetSet(sntpSocket, pSntpIf);
TCPIP_UDP_OptionsSet(sntpSocket, UDP_OPTION_STRICT_ADDRESS, (void*)false);
}
The problem was that the setting of the network interface also enforced the STRICT ADDRESS mode and the socket won't receive messages from other servers/addresses.
 
Let us know if the problem is solved for you.
 
#6
ajones
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2017/02/21 17:33:01
  • Location: 0
  • Status: offline
Re: PIC32mz NTP Client not recognizing responses from server 2018/07/05 15:46:13 (permalink)
3 (1)
Yes, replacing the sntp.h and .c files with the latest version solved the problem. I should have done that in the first place. I just did a test and received 100 successful NTP updates in a row with zero failures.
 
Thanks very much!
#7
XorLor
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2009/10/23 00:17:05
  • Location: 0
  • Status: offline
Re: PIC32mz NTP Client not recognizing responses from server 2019/06/12 00:06:28 (permalink)
0
SNTP still seem to be broken with the web_net_server_nvm_mpfs project using the PIC32MZ EF Starter Kit.
 
Harmony v2_06
MPLAB X v5.20
XC32 v2.20
 
It works once then fails every time after that. It seems to fail at:
SNTP solving IPv4 DNS: pool.ntp.org
 
Here is the console output:
 
>SNTP State: 1 - home, time: 1
PIC32INT IP Address: 192.168.100.115
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 3
SNTP State: 2 - wait_dns, time: 3
PIC32INT IP Address: 192.168.1.33
SNTP solving IPv4 DNS: pool.ntp.org, time: 4
SNTP solving IPv4 DNS: pool.ntp.org, time: 5
SNTP solving IPv4 DNS: pool.ntp.org, time: 6
SNTP solving IPv4 DNS: pool.ntp.org, time: 7
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 8
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 8
SNTP solving IPv4 DNS: pool.ntp.org, time: 8
SNTP State: 3 - dns_solved, time: 8
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 9
SNTP solved DNS: pool.ntp.org, address: 142.147.92.5, time: 9
SNTP State: 4 - send, time: 9
SNTP State: 5 - recv, time: 10
SNTP State: 6 - s_wait, time: 11
SNTP new TStamp: 1560321361, time: 11
SNTP State: 7 - l_wait, time: 11
SNTP State: 1 - home, time: 612
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 613
SNTP State: 2 - wait_dns, time: 613
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 613
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 614
SNTP solving IPv4 DNS: pool.ntp.org, time: 614
SNTP State: 6 - s_wait, time: 614
SNTP Error: 11 - if_err, time: 614


 
I added this to the TCPIP_SNTP_Process as explained in the previous post but it didn't help:
 
TCPIP_UDP_OptionsSet(sntpSocket, UDP_OPTION_STRICT_ADDRESS, (void*)false);
 

Any clues?
Thanks!
#8
rainad
Moderator
  • Total Posts : 1176
  • Reward points : 0
  • Joined: 2009/05/01 13:39:25
  • Location: 0
  • Status: offline
Re: PIC32mz NTP Client not recognizing responses from server 2019/06/12 09:57:59 (permalink)
0
The problem that I see in your log is the:
"SNTP Error: 11 - if_err, time: 614"
Which means that SNTP finds the network down at that moment.
Can you check the output of "netinfo" at that moment?
Also check if the board is alive, it can be pinged, etc.
Do you have multiple interfaces enabled in your application?
 
#9
XorLor
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2009/10/23 00:17:05
  • Location: 0
  • Status: offline
Re: PIC32mz NTP Client not recognizing responses from server 2019/06/12 13:09:14 (permalink)
0
rainad
The problem that I see in your log is the:
"SNTP Error: 11 - if_err, time: 614"
Which means that SNTP finds the network down at that moment.
Can you check the output of "netinfo" at that moment?
Also check if the board is alive, it can be pinged, etc.
Do you have multiple interfaces enabled in your application?



Thanks for the reply rainad. The board is alive and can be pinged.
 
It looks like there is a bug causing the wrong SNTP debug messages to be displayed. The _SNTP_DbgResError_Tbl table in sntp.c is missing the entry for SNTP_RES_TSTAMP_ERROR. I added it as seen bellow:
 

static const char* const _SNTP_DbgResError_Tbl[] =
{
"Unknown", // None
"busy", // SNTP_RES_BUSY
"ts_err", // SNTP_RES_TSTAMP_ERROR <- added by XorLor
"t_stale", // SNTP_RES_TSTAMP_STALE
"skt_err", // SNTP_RES_SKT_ERR
"skt_bind", // SNTP_RES_SKT_BIND_ERR
"srv_tmo", // SNTP_RES_NTP_SERVER_TMO
"v_err", // SNTP_RES_NTP_VERSION_ERR
"t_err", // SNTP_RES_NTP_TSTAMP_ERR
"sync_err", // SNTP_RES_NTP_SYNC_ERR
"kod_err", // SNTP_RES_NTP_KOD_ERR
"dns_err", // SNTP_RES_NTP_DNS_ERR
"if_err", // SNTP_RES_NTP_IF_ERR
"conn_err", // SNTP_RES_NTP_CONN_ERR
};

 
Console log:
 
>SNTP State: 1 - home, time: 1
PIC32INT IP Address: 192.168.1.33
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 4
SNTP State: 2 - wait_dns, time: 4
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 4
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 5
SNTP solving IPv4 DNS: pool.ntp.org, time: 5
SNTP State: 6 - s_wait, time: 5
SNTP Error: 11 - dns_err, time: 5
SNTP State: 1 - home, time: 19
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 20
SNTP State: 2 - wait_dns, time: 20
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 20
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 21
SNTP solving IPv4 DNS: pool.ntp.org, time: 21
SNTP State: 6 - s_wait, time: 21
SNTP Error: 11 - dns_err, time: 21
SNTP State: 1 - home, time: 36
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 37
SNTP State: 2 - wait_dns, time: 37
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 37
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 38
SNTP solving IPv4 DNS: pool.ntp.org, time: 38
SNTP State: 6 - s_wait, time: 38
SNTP Error: 11 - dns_err, time: 38
netinfo
---------- Interface <eth0/PIC32INT> ----------
Host Name: MCHPBOARD_E - NBNS enabled
IPv4 Address: 192.168.1.33
Mask: 255.255.255.0
Gateway: 192.168.1.11
DNS: 192.168.1.11
MAC Address: 80:1f:12:2b:39:3b
dhcp is ON
Link is UP
 
So the problem seems to be DNS related. I will do more debugging...
 
Thanks!
#10
rainad
Moderator
  • Total Posts : 1176
  • Reward points : 0
  • Joined: 2009/05/01 13:39:25
  • Location: 0
  • Status: offline
Re: PIC32mz NTP Client not recognizing responses from server 2019/06/12 15:54:40 (permalink)
0
Good catch, indeed that error was missing from the debug strings table.
If you could check to see what happens  if you try the same DNS lookup from the console, when this fails:
>dnsc lookup -a pool.ntp.org
Let's see if this one works.
 
#11
XorLor
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2009/10/23 00:17:05
  • Location: 0
  • Status: offline
Re: PIC32mz NTP Client not recognizing responses from server 2019/06/12 17:10:00 (permalink)
0
dnsc lookup works.
 
I added some additional debugging messages to show the return values of TCPIP_DNS_Resolve, TCPIP_DNS_IsResolved, and TCPIP_UDP_RemoteBind.
 
What's interesting is TCPIP_DNS_IsResolved returns -1 TCPIP_DNS_RES_NO_NAME_ENTRY - no such entry to be resolved exists
 
I'm not sure what that means exactly...
 

>SNTP State: 1 - home, time: 1
PIC32INT IP Address: 192.168.100.115
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 4
SNTP DNS_Resolve: 1 TCPIP_DNS_RES_PENDING
SNTP State: 2 - wait_dns, time: 4
PIC32INT IP Address: 192.168.1.33
SNTP solving IPv4 DNS: pool.ntp.org, time: 5
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
SNTP solving IPv4 DNS: pool.ntp.org, time: 6
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
SNTP solving IPv4 DNS: pool.ntp.org, time: 7
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
SNTP solving IPv4 DNS: pool.ntp.org, time: 8
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 9
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 9
SNTP solving IPv4 DNS: pool.ntp.org, time: 9
SNTP IsResolved: 0 TCPIP_DNS_RES_OK
SNTP State: 3 - dns_solved, time: 9
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 10
SNTP solved DNS: pool.ntp.org, address: 69.89.207.99, time: 10
SNTP bindRes: 1
SNTP State: 4 - send, time: 10
SNTP State: 5 - recv, time: 12
SNTP State: 6 - s_wait, time: 12
SNTP new TStamp: 1560382968, time: 12
SNTP State: 7 - l_wait, time: 12
SNTP State: 1 - home, time: 132
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 134
SNTP DNS_Resolve: 1 TCPIP_DNS_RES_PENDING
SNTP State: 2 - wait_dns, time: 134
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 134
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 135
SNTP solving IPv4 DNS: pool.ntp.org, time: 135
SNTP IsResolved: -1 TCPIP_DNS_RES_NO_NAME_ENTRY
SNTP State: 6 - s_wait, time: 135
SNTP Error: 11 - dns_err, time: 135
dnsc lookup a pool.ntp.org
dnsc lookup: resolving host: pool.ntp.org for type:a
>DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 153
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 153
Lookup Answer:
----------------------
[pool.ntp.org] A IPv4 Address : 47.190.36.230
[pool.ntp.org] A IPv4 Address : 72.5.72.15
[pool.ntp.org] A IPv4 Address : 50.205.244.107
[pool.ntp.org] A IPv4 Address : 45.76.244.193
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 154
post edited by XorLor - 2019/06/12 18:44:02
#12
rainad
Moderator
  • Total Posts : 1176
  • Reward points : 0
  • Joined: 2009/05/01 13:39:25
  • Location: 0
  • Status: offline
Re: PIC32mz NTP Client not recognizing responses from server 2019/06/13 07:09:54 (permalink)
0
The TCPIP_DNS_RES_NO_NAME_ENTRY  result means just that: when SNTP asks for the pool.ntp.org resolution, DNS says that it doesn't have that name in its cache...And that seems to be because the timeout for this entry is just 1 second!
I can see in your log DNS events like:
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: x
...
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: x + 1
 
Basically meaning that if the SNTP runs frequently enough to get to DNS before this second expired, it will be OK - and sometimes it happens, but not very often.
 
I assume that the TCPIP_NTP_TASK_TICK_RATE in your configuration is >= 1 second.
Make it around 300 ms and give it a try.
Normally this shouldn't be a problem but not sure why the DNS server sends such a short time to live for that NTP entry. 1 second seems excessive to me, but anyway you can check it with wireshark, if you want to be absolutely sure that it's not something that the Harmony DNS resolver miss interprets.
 
Another thing that you can do is to force the DNS time out yourself:
instead of the default:
#define TCPIP_DNS_CLIENT_CACHE_ENTRY_TMO 0
use something like 10 seconds:
#define TCPIP_DNS_CLIENT_CACHE_ENTRY_TMO 10
but that's more like a test, because it affects all DNS, not only NTP.
 
One note: you mentioned in the 1st post that you've tried adding:
TCPIP_UDP_OptionsSet(sntpSocket, UDP_OPTION_STRICT_ADDRESS, (void*)false);
to your code and that didn't help.
Since you're running v2.06 that code should have been already there. Just to make sure.
 
#13
XorLor
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2009/10/23 00:17:05
  • Location: 0
  • Status: offline
Re: PIC32mz NTP Client not recognizing responses from server 2019/06/13 10:16:57 (permalink)
0
rainad
One note: you mentioned in the 1st post that you've tried adding:
TCPIP_UDP_OptionsSet(sntpSocket, UDP_OPTION_STRICT_ADDRESS, (void*)false);
to your code and that didn't help.
Since you're running v2.06 that code should have been already there. Just to make sure.



You are correct. That code was already there. I realized my mistake shortly after posting that.
 
 
rainad
I assume that the TCPIP_NTP_TASK_TICK_RATE in your configuration is >= 1 second.
Make it around 300 ms and give it a try.

 
I changed TCPIP_NTP_TASK_TICK_RATE from the default 1100 ms to 300 ms and it started working, but with only about a 70% success rate. This is a significant improvement.
 
 
rainad
Another thing that you can do is to force the DNS time out yourself:
instead of the default:
#define TCPIP_DNS_CLIENT_CACHE_ENTRY_TMO 0
use something like 10 seconds:
#define TCPIP_DNS_CLIENT_CACHE_ENTRY_TMO 10
but that's more like a test, because it affects all DNS, not only NTP.

 
I changed TCPIP_DNS_CLIENT_CACHE_ENTRY_TMO to 10 and am now seeing a 100% success rate with SNTP. Note: This is with TCPIP_NTP_TASK_TICK_RATE set to the default 1100 ms.
 
You mentioned this will affect all DNS but would it be in a negative way (SMTPC for example)?
 
 
#14
rainad
Moderator
  • Total Posts : 1176
  • Reward points : 0
  • Joined: 2009/05/01 13:39:25
  • Location: 0
  • Status: offline
Re: PIC32mz NTP Client not recognizing responses from server 2019/06/13 10:36:53 (permalink)
0
The value of 10 seconds was just to use a more reasonable value than the 1 second returned for the pool.ntp.org and to check that indeed this was the issue. For other domains, the TTL could be much higher, so forcing it to 10 seconds doesn't seem to be such a good idea, as it forces the DNS to do more queries than necessary.
If you use this approach, make it at least 100 seconds, this is probably better.
This should not have impact on SNTP because once a time stamp is obtained, the request for another one from the server is in the range of minutes.
 
Anyway, I'd use the NTP_RATE == 300 ms approach. Why do you say it's working only 70% of the cases, what is the reported failure in this case?
 
#15
XorLor
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2009/10/23 00:17:05
  • Location: 0
  • Status: offline
Re: PIC32mz NTP Client not recognizing responses from server 2019/06/13 15:23:07 (permalink)
0
 
rainad
Anyway, I'd use the NTP_RATE == 300 ms approach. Why do you say it's working only 70% of the cases, what is the reported failure in this case?



Ok, thanks for the advice. I will use the 300 ms approach. It works fine 5 times in a row, then fails every other time. The reported failure is the same: TCPIP_DNS_RES_NO_NAME_ENTRY and SNTP Error: 11 - dns_err
 

>SNTP State: 1 - home, time: 0
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 4
SNTP DNS_Resolve: 1 TCPIP_DNS_RES_PENDING
SNTP State: 2 - wait_dns, time: 4
PIC32INT IP Address: 192.168.100.115
SNTP solving IPv4 DNS: pool.ntp.org, time: 4
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
SNTP solving IPv4 DNS: pool.ntp.org, time: 4
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
SNTP solving IPv4 DNS: pool.ntp.org, time: 5
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
PIC32INT IP Address: 192.168.1.22
SNTP solving IPv4 DNS: pool.ntp.org, time: 5
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
SNTP solving IPv4 DNS: pool.ntp.org, time: 5
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
SNTP solving IPv4 DNS: pool.ntp.org, time: 5
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
SNTP solving IPv4 DNS: pool.ntp.org, time: 6
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
SNTP solving IPv4 DNS: pool.ntp.org, time: 6
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
SNTP solving IPv4 DNS: pool.ntp.org, time: 6
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
SNTP solving IPv4 DNS: pool.ntp.org, time: 7
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
SNTP solving IPv4 DNS: pool.ntp.org, time: 7
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
SNTP solving IPv4 DNS: pool.ntp.org, time: 7
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
SNTP solving IPv4 DNS: pool.ntp.org, time: 8
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
SNTP solving IPv4 DNS: pool.ntp.org, time: 8
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
SNTP solving IPv4 DNS: pool.ntp.org, time: 8
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
SNTP solving IPv4 DNS: pool.ntp.org, time: 8
SNTP IsResolved: 1 TCPIP_DNS_RES_PENDING
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 9
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 9
SNTP solving IPv4 DNS: pool.ntp.org, time: 9
SNTP IsResolved: 0 TCPIP_DNS_RES_OK
SNTP State: 3 - dns_solved, time: 9
SNTP solved DNS: pool.ntp.org, address: 204.2.134.162, time: 9
SNTP bindRes: 1
SNTP State: 4 - send, time: 9
SNTP State: 5 - recv, time: 9
SNTP State: 6 - s_wait, time: 9
SNTP new TStamp: 1560462587, time: 9
SNTP State: 7 - l_wait, time: 9
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 10
SNTP State: 1 - home, time: 130
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 130
SNTP DNS_Resolve: 1 TCPIP_DNS_RES_PENDING
SNTP State: 2 - wait_dns, time: 130
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 130
SNTP solving IPv4 DNS: pool.ntp.org, time: 130
SNTP IsResolved: 0 TCPIP_DNS_RES_OK
SNTP State: 3 - dns_solved, time: 130
SNTP solved DNS: pool.ntp.org, address: 204.11.201.10, time: 130
SNTP bindRes: 1
SNTP State: 4 - send, time: 130
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 131
SNTP State: 5 - recv, time: 131
SNTP State: 6 - s_wait, time: 131
SNTP new TStamp: 1560462708, time: 131
SNTP State: 7 - l_wait, time: 131
SNTP State: 1 - home, time: 251
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 251
SNTP DNS_Resolve: 1 TCPIP_DNS_RES_PENDING
SNTP State: 2 - wait_dns, time: 251
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 251
SNTP solving IPv4 DNS: pool.ntp.org, time: 252
SNTP IsResolved: 0 TCPIP_DNS_RES_OK
SNTP State: 3 - dns_solved, time: 252
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 252
SNTP solved DNS: pool.ntp.org, address: 69.10.161.7, time: 252
SNTP bindRes: 1
SNTP State: 4 - send, time: 252
SNTP State: 5 - recv, time: 252
SNTP State: 6 - s_wait, time: 252
SNTP new TStamp: 1560462829, time: 252
SNTP State: 7 - l_wait, time: 252
SNTP State: 1 - home, time: 372
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 373
SNTP DNS_Resolve: 1 TCPIP_DNS_RES_PENDING
SNTP State: 2 - wait_dns, time: 373
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 373
SNTP solving IPv4 DNS: pool.ntp.org, time: 373
SNTP IsResolved: 0 TCPIP_DNS_RES_OK
SNTP State: 3 - dns_solved, time: 373
SNTP solved DNS: pool.ntp.org, address: 162.248.241.94, time: 373
SNTP bindRes: 1
SNTP State: 4 - send, time: 373
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 374
SNTP State: 5 - recv, time: 374
SNTP State: 6 - s_wait, time: 374
SNTP new TStamp: 1560462950, time: 374
SNTP State: 7 - l_wait, time: 374
SNTP State: 1 - home, time: 494
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 494
SNTP DNS_Resolve: 1 TCPIP_DNS_RES_PENDING
SNTP State: 2 - wait_dns, time: 494
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 494
SNTP solving IPv4 DNS: pool.ntp.org, time: 494
SNTP IsResolved: 0 TCPIP_DNS_RES_OK
SNTP State: 3 - dns_solved, time: 494
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 495
SNTP solved DNS: pool.ntp.org, address: 72.5.72.15, time: 495
SNTP bindRes: 1
SNTP State: 4 - send, time: 495
SNTP State: 5 - recv, time: 495
SNTP State: 6 - s_wait, time: 495
SNTP new TStamp: 1560463071, time: 495
SNTP State: 7 - l_wait, time: 495
SNTP State: 1 - home, time: 615
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 615
SNTP DNS_Resolve: 1 TCPIP_DNS_RES_PENDING
SNTP State: 2 - wait_dns, time: 615
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 615
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 616
SNTP solving IPv4 DNS: pool.ntp.org, time: 616
SNTP IsResolved: -1 TCPIP_DNS_RES_NO_NAME_ENTRY
SNTP State: 6 - s_wait, time: 616
SNTP Error: 11 - dns_err, time: 616
SNTP State: 1 - home, time: 630
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 630
SNTP DNS_Resolve: 1 TCPIP_DNS_RES_PENDING
SNTP State: 2 - wait_dns, time: 630
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 630
SNTP solving IPv4 DNS: pool.ntp.org, time: 630
SNTP IsResolved: 0 TCPIP_DNS_RES_OK
SNTP State: 3 - dns_solved, time: 630
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 631
SNTP solved DNS: pool.ntp.org, address: 108.61.73.244, time: 631
SNTP bindRes: 1
SNTP State: 4 - send, time: 631
SNTP State: 5 - recv, time: 631
SNTP State: 6 - s_wait, time: 631
SNTP new TStamp: 1560463206, time: 631
SNTP State: 7 - l_wait, time: 631
SNTP State: 1 - home, time: 751
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 751
SNTP DNS_Resolve: 1 TCPIP_DNS_RES_PENDING
SNTP State: 2 - wait_dns, time: 751
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 751
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 752
SNTP solving IPv4 DNS: pool.ntp.org, time: 752
SNTP IsResolved: -1 TCPIP_DNS_RES_NO_NAME_ENTRY
SNTP State: 6 - s_wait, time: 752
SNTP Error: 11 - dns_err, time: 752
SNTP State: 1 - home, time: 766
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 766
SNTP DNS_Resolve: 1 TCPIP_DNS_RES_PENDING
SNTP State: 2 - wait_dns, time: 766
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 766
SNTP solving IPv4 DNS: pool.ntp.org, time: 766
SNTP IsResolved: 0 TCPIP_DNS_RES_OK
SNTP State: 3 - dns_solved, time: 766
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 767
SNTP solved DNS: pool.ntp.org, address: 142.147.92.5, time: 767
SNTP bindRes: 1
SNTP State: 4 - send, time: 767
SNTP State: 5 - recv, time: 767
SNTP State: 6 - s_wait, time: 767
SNTP new TStamp: 1560463342, time: 767
SNTP State: 7 - l_wait, time: 767
SNTP State: 1 - home, time: 887
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 887
SNTP DNS_Resolve: 1 TCPIP_DNS_RES_PENDING
SNTP State: 2 - wait_dns, time: 888
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 887
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 888
SNTP solving IPv4 DNS: pool.ntp.org, time: 888
SNTP IsResolved: -1 TCPIP_DNS_RES_NO_NAME_ENTRY
SNTP State: 6 - s_wait, time: 888
SNTP Error: 11 - dns_err, time: 888
SNTP State: 1 - home, time: 902
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 902
SNTP DNS_Resolve: 1 TCPIP_DNS_RES_PENDING
SNTP State: 2 - wait_dns, time: 902
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 902
SNTP solving IPv4 DNS: pool.ntp.org, time: 902
SNTP IsResolved: 0 TCPIP_DNS_RES_OK
SNTP State: 3 - dns_solved, time: 902
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 903
SNTP solved DNS: pool.ntp.org, address: 208.115.126.70, time: 903
SNTP bindRes: 1
SNTP State: 4 - send, time: 903
SNTP State: 5 - recv, time: 903
SNTP State: 6 - s_wait, time: 903
SNTP new TStamp: 1560463477, time: 903
SNTP State: 7 - l_wait, time: 903
SNTP State: 1 - home, time: 1023
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 1023
SNTP DNS_Resolve: 1 TCPIP_DNS_RES_PENDING
SNTP State: 2 - wait_dns, time: 1024
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 1023
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 1024
SNTP solving IPv4 DNS: pool.ntp.org, time: 1024
SNTP IsResolved: -1 TCPIP_DNS_RES_NO_NAME_ENTRY
SNTP State: 6 - s_wait, time: 1024
SNTP Error: 11 - dns_err, time: 1024
SNTP State: 1 - home, time: 1038
DNS Event: query, IF: PIC32INT, host: pool.ntp.org, time: 1038
SNTP DNS_Resolve: 1 TCPIP_DNS_RES_PENDING
SNTP State: 2 - wait_dns, time: 1038
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 1038
SNTP solving IPv4 DNS: pool.ntp.org, time: 1039
SNTP IsResolved: 0 TCPIP_DNS_RES_OK
SNTP State: 3 - dns_solved, time: 1039
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 1039
SNTP solved DNS: pool.ntp.org, address: 4.53.160.75, time: 1039
SNTP bindRes: 1
SNTP State: 4 - send, time: 1039
SNTP State: 5 - recv, time: 1039
SNTP State: 6 - s_wait, time: 1039
SNTP new TStamp: 1560463613, time: 1039
SNTP State: 7 - l_wait, time: 1039

#16
rainad
Moderator
  • Total Posts : 1176
  • Reward points : 0
  • Joined: 2009/05/01 13:39:25
  • Location: 0
  • Status: offline
Re: PIC32mz NTP Client not recognizing responses from server 2019/06/14 06:25:04 (permalink)
0
Well, it's the same thing as before. An example sequence from your log:
DNS Event: solved, IF: PIC32INT, host: pool.ntp.org, time: 615
DNS Event: expired, IF: PIC32INT, host: pool.ntp.org, time: 616
SNTP solving IPv4 DNS: pool.ntp.org, time: 616
SNTP IsResolved: -1 TCPIP_DNS_RES_NO_NAME_ENTRY
SNTP State: 6 - s_wait, time: 616
SNTP Error: 11 - dns_err, time: 616
 
You can see that the DNS resolves the entry at time 615, expires at time 616 and only after that the SNTP queries about it, when it's too late, the entry is already gone.
With the rate set to 300 ms, the SNTP should make 3 queries in that second that passes, but it doesn't seem to be the case. Not sure why, I'll have to check.
You could add some instrumentation to your code and count how many times the TCPIP_SNTP_Process() is called per second.
Or maybe your application is doing some lengthy processing somewhere else and the SNTP doesn't get a chance to run?
 
Anyway, you have a workaround, just increase the DNS timeout manually, and you can use that for now.
Bu it's also important to get to the root cause of this.
 
 
 
#17
Jump to:
© 2019 APG vNext Commercial Version 4.5