InternetTime example - always fails on first attempt to read time, 2nd try works
briggsm opened this issue · 2 comments
Hi,
I'm running the InternetTime example from the Adafruit_CC3000_Library. If I only change my wifi router ssid & password, and upload the script, after connecting to my router, it always fails to connect to the NTP server the 1st time, but the 2nd time (after the 15 second delay) it works. I also changed the 15 sec. delay to 1ms, and still works the 2nd time (but not the 1st). Here's the output from the Serial Monitor:
Hello, CC3000!
RX Buffer : 341 bytes
TX Buffer : 341 bytes
Initialising the CC3000 ...
Firmware V. : 1.24
MAC Address : 0x08 0x00 0x28 0x57 0x98 0x75
Deleting old connection profiles
Attempting to connect to Kuzu
Connected!
Request DHCP
IP Addr: 192.168.1.100
Netmask: 255.255.255.0
Gateway: 192.168.1.1
DHCPsrv: 192.168.1.50
DNSserv: 8.8.8.8
Locating time server...
Attempting connection...
connected!
Issuing request...
Awaiting response...error
Current UNIX time: 64 (seconds since 1/1/1970 UTC)
Locating time server...
Attempting connection...
connected!
Issuing request...
Awaiting response...OK
Current UNIX time: 1407163100 (seconds since 1/1/1970 UTC)
I have an Apple Time Capsule (192.168.1.50) running as the DHCP server. The CC3000 is connecting to the Time Capsule (Kuzu) The Time Capsule is connected to the router/modem (192.168.1.1) (of which I disabled the DHCP server and turned off the wifi). The router/modem is ADSL connected to the internet.
The responseTimeout
is 15 seconds. But even if I decrease it to 1 second, same thing happens (error on 1st try, success on 2nd)
(If I connect directly to the model/router (with WiFi turned back on and DHCP server enabled), it connects to the NTP server on the 1st try.)
Any ideas why I always get an error on the first try (when going through the Apple Time Capsule)? Am I missing something obvious? Any ideas, help, tips, experiments would be greatly appreciated!
Thanks!
I don't work for Adafruit, but I do work in networking, and this sounds
like a 1st-packet-causes-ARP-and-gets-dropped situation. Some routers do
this in order not to hold onto the ARP-causing IP packet while waiting for
the ARP reply. Then the ARP reply arrives, the device makes an entry it its
ARP cache (table), and the 2nd IP packet find the entry and goes on. The
thing is this behavior is usually done on large routers where there is no
RAM to hold packets a long time, not home equipment. Anyway a packet
capture at each hop would show where the NTP packet arrives or doesn't
arrive and tell you where to concentrate next.
Also the other obvious Q: does this same behavior happen with a different
wireless device.
-Nicolas
On Mon, Aug 4, 2014 at 8:02 AM, Mark Briggs notifications@github.com
wrote:
Hi,
I'm running the InternetTime example from the Adafruit_CC3000_Library. If
I only change my wifi router ssid & password, and upload the script, after
connecting to my router, it always fails to connect to the NTP server the
1st time, but the 2nd time (after the 15 second delay) it works. I also
changed the 15 sec. delay to 1ms, and still works the 2nd time (but not the
1st). Here's the output from the Serial Monitor:Hello, CC3000!
RX Buffer : 341 bytes
TX Buffer : 341 bytesInitialising the CC3000 ...
Firmware V. : 1.24
MAC Address : 0x08 0x00 0x28 0x57 0x98 0x75Deleting old connection profiles
Attempting to connect to Kuzu
Connected!
Request DHCPIP Addr: 192.168.1.100
Netmask: 255.255.255.0
Gateway: 192.168.1.1
DHCPsrv: 192.168.1.50
DNSserv: 8.8.8.8
Locating time server...
Attempting connection...
connected!
Issuing request...
Awaiting response...error
Current UNIX time: 64 (seconds since 1/1/1970 UTC)
Locating time server...
Attempting connection...
connected!
Issuing request...
Awaiting response...OK
Current UNIX time: 1407163100 (seconds since 1/1/1970 UTC)I have an Apple Time Capsule (192.168.1.50) running as the DHCP server.
The CC3000 is connecting to the Time Capsule (Kuzu) The Time Capsule is
connected to the router/modem (192.168.1.1) (of which I disabled the DHCP
server and turned off the wifi). The router/modem is ADSL connected to the
internet.The responseTimeout is 15 seconds. But even if I decrease it to 1 second,
same thing happens (error on 1st try, success on 2nd)(If I connect directly to the model/router (with WiFi turned back on and
DHCP server enabled), it connects to the NTP server on the 1st try.)Any ideas why I always get an error on the first try (when going through
the Apple Time Capsule)? Am I missing something obvious? Any ideas, help,
tips, experiments would be greatly appreciated!Thanks!
—
Reply to this email directly or view it on GitHub
#95.
Thanks for the tips nsd20463! I'll close this since it looks like it's an issue with the Time Capsule as a router. Like NSD mentioned you might need to get some packet captures to really investigate what's going on, unfortunately there isn't much to tell from just the code.