NTP not syncing immediately on windows - ntp

I am trying to sync with NTP server, but server is responding with below messages.
Below are the wireshark captures.
Flags: 0x0c
11.. .... = Leap Indicator: unknown (clock unsynchronized) (3)
..00 1... = Version number: NTP Version 1 (1)
.... .100 = Mode: server (4)
Peer Clock Stratum: unspecified or invalid (0)
Peer Polling Interval: invalid (0)
Peer Clock Precision: 0.000008 sec
Root Delay: 0.0000 sec
Reference Timestamp: Jan 1, 1970 00:00:00.000000000 UTC
My ntp.conf file has below enteries:
server 127.127.1.0
fudge 127.127.1.0 stratum 0
restrict 127.127.1.0
After some 3 minutes the sync is happening properly.But its not happening immediately.
Can anybody help me in resolving.

The fudge 127.127.1.0 stratum 0 line is telling ntp that your local server has the accuracy of an atomic clock. I doubt this is the case...
My guess is that your local clock is being used as a time source because of this line.
I believe that 0 should be a 10, which will tell ntp that unless there is another server in your ntp.conf that has a better time source(a higher stratum), do not use your local clock as a time source. This line is typically added to be used as a last resort.
ntp typically takes around 3 to 5 minutes to sync by default. Two things that can speed this up:
Use the iburst option in your ntp.conf
Manually sync to a time source using ntpd -gq

Related

Stuck in infinite loop trying to sync to NTP server on ESP8266

I am working on a project with an ESP8266 and trying to use a setClock function that, to my understanding, should configure the time based off of the NTP server defined in the 'TIMEZONE' variable. However, when I upload the program it gets stuck in the while loop because 'now' is getting set at 0 every iteration through the loop and gets incremented by 1 for every two iterations.
I'm assuming this means I am either defining TIMEZONE as the wrong NTP server (though I'm not sure how that would cause this issue) or the device isn't connecting to the NTP server properly.
This is where TIMEZONE is defined
// Pick a timezone from https://github.com/esp8266/Arduino/blob/master/cores/esp8266/TZ.h
#define TIMEZONE TZ_America_Kentucky_Louisville
and this is the setClock function
void setClock() {
// General C time functions: https://en.wikipedia.org/wiki/C_date_and_time_functions
configTime(TIMEZONE, "pool.ntp.org");
Serial.print("Waiting for NTP time sync: ");
time_t now = time(nullptr);
// 1546300800 = 01/01/2019 # 12:00am (UTC)
while (now < 1546300800) {
delay(500);
//Serial.print(".");
Serial.print(now);
Serial.print(\n);
now = time(nullptr);
}
Output
Attaching servo...done.
Initializing display...done.
Connecting to WiFi 'test'............done. IP 192.168.137.3
Waiting for NTP time sync: 4
4
5
5
6
6
7
I have verified that the ESP8266 is connected to the internet properly and the program also verifies it in the output.
I also tried commenting out the for loop to see if it would run anyway but the program says local time is 0:00 Jan 1 1970 which I know is just because the time is 0 seconds. This, however, causes the next part of my program to fail because it is using the time for x.509 validation.

ALSA ignores configuration

I have an audio box that can be connected via USB to my laptop.
I've written a C application that uses the ALSA API to open a communication channel with this audio box.
The communication should be established at 8kHz, running with a 10ms period size (that is 80 samples).
If I'm connecting the audio box to my laptop and then start the app, it seems that the min period size supported is 170 (e.g. snd_pcm_hw_params_get_period_size_min sets min period size to 170), while snd_pcm_hw_params_set_period_size_near sets the period size to 170.
Looking to /proc/asound/name-of-the-card/stream0, I can see Momentary freq = 48000 Hz (0x30.0000), but the sampling rate requested by me is 8kHz.
Also, snd_pcm_hw_params_set_rate_near call, is not changing the value that I've passed.
By starting the app first and then connecting the audio box to my laptop, snd_pcm_hw_params_get_period_size_min sets the min period size to 16 and when calling snd_pcm_hw_params_set_period_size_near, the period size is set to 80 (which represents what I want to achieve).
Checking again /proc/asound/name-of-the-card/stream0, I can see Momentary freq = 8000 Hz (0x8.0000), that is correct.
I have to mention that my app is trying to open the card associated with the audio box and if the operation doesn't succeed, is retrying the open it every 200ms until succeeds.
My feeling is that in the second case when the period size is set accordingly, my application sets the configuration before the system does (I'm not sure if the system does this).
I've tried to modify defaults.pcm.dmix.rate to 8000 in /usr/share/alsa/alsa.conf, but in this case the period size that is returned by acting as in the first scenario is 1024.
Below are some configurations from /usr/share/alsa/alsa.conf if this helps.
defaults.pcm.minperiodtime 5000 # in us
defaults.pcm.ipc_key 5678293
defaults.pcm.ipc_gid audio
defaults.pcm.ipc_perm 0666
defaults.pcm.dmix.max_periods 0
defaults.pcm.dmix.channels 2
defaults.pcm.dmix.rate 48000
Is there a config file that has a higher priority than what I want to configure via the API?

Cannot sync with the NTP server

I am using lubuntu Linux 18.04 Bionic. When I print ntpq -pn I cannot see that my computer is synced with my desired NTP server.
I have tried several tutorials like here: LINK. I took the NTP servers from Google HERE and included the all 4 servers to my config file.
Then, I did the following things in order to sync with one of the Google NTP servers:
sudo service stop
sudo service ntpdate time1.google.com and received a log ntpdate[2671]: adjust time server 216.239.35.0 offset -0.000330 sec
sudo service start
Here is my /etc/ntp.conf file:
driftfile /var/lib/ntp/ntp.drift
leapfile /usr/share/zoneinfo/leap-seconds.list
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited
restrict 127.0.0.1
restrict ::1
restrict source notrap nomodify noquery
server time1.google.com iburst
server time2.google.com iburst
server time3.google.com iburst
server time4.google.com iburst
After doing the steps above, I got this result from ntpq -pn:
remote refid st t when poll reach delay offset jitter
+216.239.35.0 .GOOG. 1 u 33 64 1 36.992 0.519 0.550
+216.239.35.4 .GOOG. 1 u 32 64 1 20.692 0.688 0.612
*216.239.35.8 .GOOG. 1 u 36 64 1 22.233 0.088 1.091
-216.239.35.12 .GOOG. 1 u 32 64 1 33.480 -0.218 1.378
Why my computer is not synced?
EDIT:
Here is my log output after sudo systemctl status ntp.service:
ntp.service - Network Time Service
Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2019-01-17 11:37:33 CET; 17min ago
Docs: man:ntpd(8)
Process: 2704 ExecStart=/usr/lib/ntp/ntp-systemd-wrapper (code=exited, status=0/SUCCESS)
Main PID: 2712 (ntpd)
CGroup: /system.slice/ntp.service
└─2712 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 105:108
Jan 17 11:37:33 ELAR-Systems ntpd[2712]: proto: precision = 1.750 usec (-19)
Jan 17 11:37:33 ELAR-Systems ntpd[2712]: leapsecond file ('/usr/share/zoneinfo/leap-seconds.list'): good hash
Jan 17 11:37:33 ELAR-Systems ntpd[2712]: leapsecond file ('/usr/share/zoneinfo/leap-seconds.list'): loaded, e
Jan 17 11:37:33 ELAR-Systems ntpd[2712]: Listen and drop on 0 v6wildcard [::]:123
Jan 17 11:37:33 ELAR-Systems ntpd[2712]: Listen and drop on 1 v4wildcard 0.0.0.0:123
Jan 17 11:37:33 ELAR-Systems ntpd[2712]: Listen normally on 2 lo 127.0.0.1:123
Jan 17 11:37:33 ELAR-Systems ntpd[2712]: Listen normally on 3 wlan0 192.168.86.26:123
Jan 17 11:37:33 ELAR-Systems ntpd[2712]: Listen normally on 4 lo [::1]:123
Jan 17 11:37:33 ELAR-Systems ntpd[2712]: Listen normally on 5 wlan0 [fe80::71d6:ec6e:fa92:b53%4]:123
Jan 17 11:37:33 ELAR-Systems ntpd[2712]: Listening on routing socket on fd #22 for interface updates
Your system time actually is getting synced but is running off very quick.
The Raspberry Pi, Arduino, Asus Tinker and the other PCB single-board computers have no onboard RTC (real time clock) and no battery to keep it up constantly. It has nothing to do with RAM or current, but simply the fact that there is no hardware clock on the computer.
On my raspberry pi, the time went off several minutes within an hour.
The "software clock" on the computer is impacted by system load and is very unstable.
An RTC extension (for RPI) looks like this:
(Source: www.robotshop.com)

ntpdate - no server suitable for synchronization found

I am working on ntp. I have to connect to some external NTP server to get my system date updated. The issue is that ntpd Daemon is always using my local clock (127.127.1.0) and it is not using the NTP server that I have provided in ntp.conf. I am using 123.108.225.6 as NTP server and I am able to ping this IP. For the purpose of testing i executed ntpdate but i got the following result.
[root#commander_a ~]# sudo ntpdate -dv 123.108.225.6
18 Nov 06:11:47 ntpdate[4781]: ntpdate 4.2.6p3#1.2290 Fri Aug 28 07:43:22 UTC 2015 (1)
Looking for host 123.108.225.6 and service ntp
host found : 123.108.225.6
transmit(123.108.225.6)
transmit(123.108.225.6)
transmit(123.108.225.6)
transmit(123.108.225.6)
transmit(123.108.225.6)
123.108.225.6: Server dropped: no data
server 123.108.225.6, port 123
stratum 0, precision 0, leap 00, trust 000
refid [123.108.225.6], delay 0.00000, dispersion 64.00000
transmitted 4, in filter 4
reference time: 00000000.00000000 Sun, Dec 31 1899 18:00:00.000
originate timestamp: 00000000.00000000 Sun, Dec 31 1899 18:00:00.000
transmit timestamp: d9f6e989.bbb84d5f Wed, Nov 18 2015 6:11:53.733
filter delay: 0.00000 0.00000 0.00000 0.00000
0.00000 0.00000 0.00000 0.00000
filter offset: 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000
delay 0.00000, dispersion 64.00000
offset 0.000000
18 Nov 06:11:55 ntpdate[4781]: no server suitable for synchronization found
[root#commander_a ~]# ^C
I find it strange that "originate timestamp" it is taking some old time. It is not my local system time.
originate timestamp: 00000000.00000000 Sun, Dec 31 1899 18:00:00.000
ntp.conf
disable stats
server 123.108.225.6
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
driftfile /etc/ntp/drift
I have spent lot of time finding the solution, But i didnt succeeded.
Please help me !!
This website maybe helpful to you
ntpdate: no server suitable for synchronization found
I use this command to modify the date
sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
It looks as if your internet service provider is blocking port 123.
Make sure there isn't an external firewall between the machine and the rest of the internet. If there is, request that the people administering the firewall open port 123.
You must use a UDP port (not TCP)
I had the same issue. I opened TCP port 123 bi-direction and it did NOT work. Turns out you specifically need a UDP port, as NTP does not run on TCP by default.
Hope this helps someone, I lost over an hour because of this subtlety.
For me same issue, we found firewall blocking the traffic. We modified rules and started working.
Cheers !!

bumblebee + wine + directx9 not working

I'm trying to run dxdiag or any other DX9 game from bumblebee+wine and no luck. These games works well without bumblebee in integrated graphic card. And no wine soft works well with bumblebee.
primusrun
$ primusrun bash
$ wine dxdiag
primus: warning: recreating incompatible pbuffer
primus: warning: recreating incompatible pbuffer
$
syslog output:
rtkit-daemon[2489]: Successfully made thread 23036 of process 23036 (n/a) owned by '1000' RT at priority 3.
rtkit-daemon[2489]: Supervising 1 threads of 1 processes of 1 users.
kernel: [147774.078061] bbswitch: enabling discrete graphics
kernel: [147774.221739] pci 0000:01:00.0: power state changed by ACPI to D0
kernel: [147774.245670] vgaarb: device changed decodes: PCI:0000:01:00.0,olddecodes=none,decodes=none:owns=none
kernel: [147774.245900] NVRM: loading NVIDIA UNIX x86_64 Kernel Module 304.88 Wed Mar 27 14:26:46 PDT 2013
acpid: client 23009[0:1002] has disconnected
acpid: client 23009[0:1002] has disconnected
acpid: client connected from 23066[0:1002]
acpid: 1 client rule loaded
acpid: client connected from 23066[0:1002]
acpid: 1 client rule loaded
bumblebeed[11391]: [XORG] (WW) NVIDIA(0): Unable to get display device for DPI computation.
rtkit-daemon[2489]: Successfully made thread 23071 of process 23033 (n/a) owned by '1000' RT at priority 2.
rtkit-daemon[2489]: Supervising 2 threads of 2 processes of 1 users.
kernel: [147778.018119] bbswitch: disabling discrete graphics
kernel: [147778.030858] pci 0000:01:00.0: Refused to change power state, currently in D0
kernel: [147778.030896] pci 0000:01:00.0: power state changed by ACPI to D3cold
optirun has similar result:
$ optirun bash
$ wine dxdiag
[VGL] NOTICE: Pixel format of 2D X server does not match pixel format of
[VGL] Pbuffer. Disabling PBO readback.
$
The syslog has the same error with optirun:
bumblebeed[11391]: [XORG] (WW) NVIDIA(0): Unable to get display device for DPI computation.
Any help? thank you!
This may or may not help, but try installing the primus-libs-ia32 package, it may be a 32 bit application you're trying to run (if you're on a 64 bit system, this could be the problem).

Resources