ntpclient icon indicating copy to clipboard operation
ntpclient copied to clipboard

Ntp server is not responding at read function call in ntpclient/main.c

Open PravallikaKG opened this issue 7 years ago • 5 comments

In ntpclient/main.c program, at read function call the program is hanging and not coming out. Looks like it is not getting response from ntp server.

Same case at recievefrom function call in python script as well.

Could someone give me a hint, for what reason it is hanging?

PravallikaKG avatar Jan 07 '19 05:01 PravallikaKG

Also i had changed the li_vn_mode value to 0x23 i.e., *( ( char * ) &packet + 0 ) = 0x23; because current version number is 4.

but still i am not getting response from server. Do i need to any more changes to make it to work>

PravallikaKG avatar Jan 07 '19 11:01 PravallikaKG

Hello @PravallikaKG,

I pulled and compiled main.c and it works as expected.

Are you able to reach the server specified?

ping -c4 us.pool.ntp.org

You should see something like the following.

PING us.pool.ntp.org

--- us.pool.ntp.org ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 7ms
rtt min/avg/max/mdev = 66.001/66.107/66.221/0.197 ms

:+1:

lettier avatar Jan 08 '19 00:01 lettier

Hi lettier,

yes us.pool.ntp.org ntp server is reachable. yes when i pinged to server following is the output:

ping -c4 us.pool.ntp.org PING us.pool.ntp.org (199.38.183.232) 56(84) bytes of data. 64 bytes from iad1.m-d.net (199.38.183.232): icmp_req=1 ttl=47 time=253 ms 64 bytes from iad1.m-d.net (199.38.183.232): icmp_req=2 ttl=47 time=254 ms 64 bytes from iad1.m-d.net (199.38.183.232): icmp_req=3 ttl=47 time=253 ms 64 bytes from iad1.m-d.net (199.38.183.232): icmp_req=4 ttl=47 time=256 ms

--- us.pool.ntp.org ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3004ms rtt min/avg/max/mdev = 253.217/254.194/256.025/1.211 ms

And also i added logs in main.c after connect, write and read function calls. Connection success, write success logs are printed, but program hanged in read call. Because read logs after read call are not printed.

Also which ntp protocol version you have tried? 3 or 4 in code? i tried with different ntp servers like asia.pool.ntp.org, ntp.pool.org but problem remains same.

Is there any alternate to check why server is not responding to my request from my computer?

PravallikaKG avatar Jan 08 '19 05:01 PravallikaKG

Problem got resolved. it is because of firewall in my network. Thank you lettier :)

PravallikaKG avatar Jan 08 '19 06:01 PravallikaKG

Try #1 :Got server address, read sucessful, Try #2: some few seconds later, got same server address, hung waiting for read.

DG12 avatar Jan 10 '19 02:01 DG12