That's a great idea. You should try it!udara wrote:Is it possible to start a NTP server in my PC and then add its IP address in raspberry pi ntp pool.
Thanks.
If you can get this working, let us all know. It could be useful.udara wrote: Mainly I'm try to start a NTP server in PC.
Thanks.
The problem is that all solutions are basically equivalent - they all require mucking about in Windows, and defeating all the lame-o "security" mis-features of Windows. I have no doubt that if you mucked with it long enough, you could get NTP working under Windows. But you would feel dirty for having done so.udara wrote:I enabled NTP server from windows registry and enabled time service from administrative tools - services and then I open TCP and UDP port 123 then I add my pc ip address to ntp.conf but it didn't work.
I would really appreciate if someone can give me some points or a different method to do this.
Thanks.
problem == opportunity to learn something newudara wrote:I enabled NTP server from windows registry and ...
Code: Select all
import socket
import time
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
while 1:
s.sendto(str(time.time()), ('255.255.255.255',55555))
time.sleep(10-(time.time() % 10))
Code: Select all
import socket
import time
import os
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(('',55555))
while 1:
l = s.recv(100)
t = float(l)
d = t - time.time()
if (abs(d) > 1):
os.system('echo sudo date %s' % time.strftime('%m%d%H%M%Y.%S', time.localtime(t)))
else:
print(l,t,d)udara wrote:I enabled NTP server from windows registry and enabled time service from administrative tools - services and then I open TCP and UDP port 123 then I add my pc ip address to ntp.conf but it didn't work.
I would really appreciate if someone can give me some points or a different method to do this.
Thanks.
Code: Select all
import ntplib
from time import ctime
c = ntplib.NTPClient()
response = c.request('192.168.1.100', version=3)
#response = c.request('europe.pool.ntp.org', version=3)
print response.offset
print response.version
print ctime(response.tx_time)
print ntplib.leap_to_text(response.leap)
print response.root_delay
print ntplib.ref_id_to_text(response.ref_id)Code: Select all
server 0.192.168.1.100Code: Select all
date -s <date string> Code: Select all
server 192.168.1.100 iburstIt may be running, but it's probably not serving the time, or it's being firewalled or something silly.udara wrote:Now I think NTP service is running on my pc,
Code: Select all
$ ntpq -np
remote refid st t when poll reach delay offset jitter
==============================================================================
+27.54.95.12 233.171.100.138 3 u 92 1024 377 85.189 -7.976 7.993Code: Select all
tcpdump -npi any udp port 123Code: Select all
$ sudo tcpdump -npi any udp port 123
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked), capture size 65535 bytes
14:53:33.794425 IP 192.168.1.93.123 > 27.54.95.12.123: NTPv4, Client, length 48
14:53:33.889467 IP 27.54.95.12.123 > 192.168.1.93.123: NTPv4, Server, length 48(text cut-and-paste will do fine, no need for a graphical screnshot).udara wrote:Thanks for the reply,
I ran those commands (in screen shot) and I think there is version mismatch if I'm right how can i resolve it or is it a different issue?
Thanks.
Code: Select all
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10The easiest way to do it is to get the well-known, standards-based programs working.Joe Schmoe wrote:Were you able to compile and use the rdate_server program?
That's clearly the easiest way to do this - instead of all this mucking with the guts of the ntp* programs.
Start with the PC's OS :-)ame wrote:The easiest way to do it is to get the well-known, standards-based programs working.Joe Schmoe wrote:Were you able to compile and use the rdate_server program?
That's clearly the easiest way to do this - instead of all this mucking with the guts of the ntp* programs.