9

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.

T Grandahl
  • 93
  • 1
  • 4
  • 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? – jonk Dec 28 '16 at 20:49
  • 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... – Phil Frost Dec 28 '16 at 20:56
  • @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. – jonk Dec 28 '16 at 21:03
  • 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. – uint128_t Dec 29 '16 at 00:30
  • @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 – T Grandahl Dec 29 '16 at 23:01

2 Answers2

5

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.

Dmitry Grigoryev
  • 25,576
  • 5
  • 45
  • 106
  • timestamp is in the beacon frame's frame body: http://www.rfwireless-world.com/Terminology/WLAN-beacon-frame.html – Ben Mar 15 '19 at 06:54
0

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.

HighInBC
  • 925
  • 1
  • 7
  • 26
  • 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? – T Grandahl Dec 29 '16 at 23:05
  • @TGrandahl No amount of gain will help if the signal is a couple of orders weaker than the noise. – Dmitry Grigoryev Jan 11 '17 at 17:55
  • 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. – Dmitry Grigoryev Jan 11 '17 at 18:02
  • Not all networks are on the internet – HighInBC Jan 11 '17 at 23:42
  • 1
    @HighInBC true, but the chances of sniffing correct time information in isolated WIFI networks are even slim no none. – Dmitry Grigoryev Jan 12 '17 at 08:01