9
\$\begingroup\$

Is there a method for finding the current global time (UTC or other) using an off the shelf WiFi module like the ESP8266, but without actually connecting to one of the available networks?

Basically i'd like to use this in a similar fashion to how the WWV broadcast can be used to guarantee the time keeping of a clock, but without the signal strength concerns of WWV.

Because this is just for a clock and the only purpose of the WiFi support would be to provide accurate time - having the interface necessary to select a network and password is undesirably complex.

\$\endgroup\$
5
  • \$\begingroup\$ Are you asking if (1) you can "sniff" encrypted packets for a time stamp (headers aren't encrypted); or, (2) there is an open protocol for limited communications with an encrypted router that is available even with encryption enabled where you could get the time? Or, what other options do you imagine might be possible? \$\endgroup\$
    – jonk
    Dec 28, 2016 at 20:49
  • \$\begingroup\$ Does wifi have any kind of UTC timestamp? I don't think it does. GPS and WWV are two wireless time references that come to mind... \$\endgroup\$
    – Phil Frost
    Dec 28, 2016 at 20:56
  • \$\begingroup\$ @PhilFrost I think (but I'm not an expert here) that all of the headers are in the clear, even on an encrypted system. So if I'm right and if one sees an IP packet, that header can be read. If that says it holds a TCP packet inside, you can drill down and read the TCP header, too. But I don't recall ever seeing a time stamp listed there (assuming the router even has the correct time, which I also doubt.) Or perhaps the TCP header is itself encrypted. Not sure. (IPv6 may allow encryption of TCP?) But like I said, I'm no expert. Perhaps someone very knowledgeable might have a trick to teach us. \$\endgroup\$
    – jonk
    Dec 28, 2016 at 21:03
  • \$\begingroup\$ Your best bet is to use GPS instead. I don't believe you can get time from headers, even if you can sniff them, and GPS works even when you're away from WiFi. \$\endgroup\$
    – uint128_t
    Dec 29, 2016 at 0:30
  • \$\begingroup\$ @jonk regarding your option (1), basically yes. I have very little knowledge of whats going on under the hood of WiFi communications, so i wanted to post to get some feedback from those more familiar with it. Your point though that the router time might be incorrect is valid, or you might have conflicting times from many APs that your bound to be in range of these days. As for getting GPS time, i'm looking for a time source that would be available in lets say a concrete building. For an indoor clock, I expect WiFi will be available more often than GPS \$\endgroup\$
    – T Grandahl
    Dec 29, 2016 at 23:01

2 Answers 2

6
\$\begingroup\$

802.11 frames don't have any global time information, since such data serves no purpose in the wireless network.

If you have a WiFi hotspot with high uptime, and you can synchronize to UTC time at least once, you could capture beacon frames, which are unencrypted and provide a mandatory timestamp field for synchronization purposes. You could then associate that timestamp with a known UTC value, and later estimate current UTC time using that initial value and the current timestamp. Needless to say, the timestamp is lost every time the hotspot restarts, plus you'll miss some subtle events like leap seconds (that's why I said estimate).

Whether ESP8266 can provide you access to raw beacon frames is another question.

\$\endgroup\$
1
0
\$\begingroup\$

Probably not. Firstly most networks are going to be encrypted. Those that are not encrypted could in theory be listened to, however there are a few problems.

It would involve listening to many packets that potentially had private information in it. In some areas this could be viewed as an illegal activity, you may want to check in on your local laws.

The ESP8266's promiscuous mode is difficult to use and only of limited effect. It will miss most packets and those you do catch will only have the first part of the packet.

In theory you might manage to find a packet that has the time, but this packet will be at the application level and could take several different forms. What is worse is that you would not know if it is the correct time.

A good way to passively get the time via radio would be to use a GPS module which will feed you the correct time and location.

\$\endgroup\$
5
  • \$\begingroup\$ The legality of "sniffing" network traffic is interesting. I've been mainly thinking of this from a perspective similar to that jonk mentioned. Observing time information that might be part of header or un-encrypted authentication communications. As for GPS, i'm looking for a method that would work well inside a concrete box or lets say in the basement of a modern home far from windows. This might be a bridge to a different topic, but are there very high gain GPS antennas / receivers that work indoors / underground? \$\endgroup\$
    – T Grandahl
    Dec 29, 2016 at 23:05
  • \$\begingroup\$ @TGrandahl No amount of gain will help if the signal is a couple of orders weaker than the noise. \$\endgroup\$ Jan 11, 2017 at 17:55
  • \$\begingroup\$ Sniffic packets will serve no purpose, since if the OP can access an open network, they can also connect to pool.ntp.org and get the time from there. \$\endgroup\$ Jan 11, 2017 at 18:02
  • \$\begingroup\$ Not all networks are on the internet \$\endgroup\$
    – HighInBC
    Jan 11, 2017 at 23:42
  • 1
    \$\begingroup\$ @HighInBC true, but the chances of sniffing correct time information in isolated WIFI networks are even slim no none. \$\endgroup\$ Jan 12, 2017 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.