NTP time conversion, Baidu has long been no results. I have tried it for myself.
The time the packet is sent on the device is NTP format, and the raw data in the Wireshark is:
DA E5 D0 E5
1, through the struct.unpack, into the integral type:
S4=struct.unpack (' 4 B ', buf[0][102:106])
The results are as follows: 218 229 208 229
2. Each integer is converted to a 16 string, and the result is as follows:
T1=str (Hex (s4[0))
temp= ' 0xda0xe50xd00xe5 '
by Temp=temp.replace (' 0x ', '), delete ' 0x ', the result is as follows:
' Dae5d0e5 '
3, conversion to 10 data,
Timestamp = Int (temp,16)
Results: 3672494309
4, through the function of datetime, converted to datetime
Datearray = Datetime.datetime.utcfromtimestamp (timestamp)
5, the above time, the year also need to subtract (NTP time from 1900/1/1 00:00:00 start counting, and UTC time starting from 1970)
Con_time =datetime.datetime (Datearray-70,datearray.month,datearray.day,
Datearray.hour,datearray.minute,datearray.second)
Last available equipment time: 2016.5.17 17:18:29