-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdemo.py
More file actions
executable file
·33 lines (27 loc) · 827 Bytes
/
demo.py
File metadata and controls
executable file
·33 lines (27 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/python3
import sntp
import sntp_server
### Demo on how to use class sntp_server.SNTPSocket ###
if __name__ == "__main__":
sock = sntp_server.SNTPSocket ()
while True:
msg = sock.recvSNTP ()
print (msg)
msg ["Mode"] = 4
msg ["Stratum"] = 15
msg ["LI"] = 0
msg ["RecieveTimestamp"] = msg ["TransmitTimestamp"]
msg ["OriginateTimestamp"] = msg ["TransmitTimestamp"]
sock.sendSNTP (msg)
exit ()
### Demo on how to use class sntp.SNTPMsg ###
if __name__ == "__main__":
# Constructing a message object
msg = sntp.SNTPMsg ()
# Assigning individual properties
msg ["Mode"] = 3
msg ["VN"] = 4
msg ["Stratum"] = 15
# Using the output
print (repr (msg)) # A byte-by-byte hex representation, for debugging
print (msg)