• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


ping
#21
@chief-wiggem: I also had problems with phone detection until I added the poll-interval. I don't see it in your config, maybe if you add it detection will work.
 
Reply
#22
I have done some more intensive testing, i think the machine and the programmer do not agree, thus it would be helpfull if some comments are added to libs/pilight/ping.c in order to clearify the intentions of the code.

I have renumbered the return -1 exits of function ping in pilight/ping.c and called them Exit 1 to 6 (from top to bottom).
I can ping my router in the network, but pilight/ping.c uses Exit 6.
I can ping my own machine, but pilight/ping.c uses Exit 6.
For non existing devices pilight/ping.c uses Exit 5.

Line 93 of protocols/ping.c
I do not under stand the logic of } else if { statement.
as this would imply to set the state to DISCONNECT independent of the ping function call.

I assume that the logic is
Code:
} else {
    if (state == CONNECTED) {
     ....
    }
Please add the closing } at the end.
 
Reply
#23
Exits:
1 = Cannot create socket.
2 = Cannot construct IP header.
3 = Cannot set timeout to prevent us from waiting too long for a ping answer.
4 = Failed to send our ICMP package. Failure is on the server side.
5 = Didn't receive a ICMP respons within our timeout. Failure is on the client side.
6 = The received reply didn't match what we expected to receive or the respons address didn't match the device we were pinging.

Ping protocol:
This checks for changes in the ping device state. It makes sure we only broadcast when the state changes from CONNECTED -> DISCONNECTED or the reverse. The ping command only return 0 on successfull ping. So every other return code can be considered a disconnected state. However, we only broadcast this once.
 
Reply
#24
Exit 5:
Could the problem be caused by the WLAN nature of that link ?
What is the Timeout criteria ?
Code:
root@md:/home/wolfgang/pilight# ifconfig
eth0      Link encap:Ethernet  Hardware Adresse b8:27:eb:xx:xx:xx
          UP BROADCAST MULTICAST  MTU:1500  Metrik:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          Kollisionen:0 Sendewarteschlangenlänge:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Lokale Schleife
          inet Adresse:127.0.0.1  Maske:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metrik:1
          RX packets:482122 errors:0 dropped:0 overruns:0 frame:0
          TX packets:482122 errors:0 dropped:0 overruns:0 carrier:0
          Kollisionen:0 Sendewarteschlangenlänge:0
          RX bytes:55875536 (53.2 MiB)  TX bytes:55875536 (53.2 MiB)

tun0      Link encap:UNSPEC  Hardware Adresse 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet Adresse:10.xx.xx.xx  P-z-P:10.xx.xx.xx  Maske:255.255.255.255
          UP PUNKTZUPUNKT RUNNING NOARP MULTICAST  MTU:1492  Metrik:1
          RX packets:76342 errors:0 dropped:0 overruns:0 frame:0
          TX packets:382499 errors:0 dropped:305612 overruns:0 carrier:0
          Kollisionen:0 Sendewarteschlangenlänge:100
          RX bytes:5365161 (5.1 MiB)  TX bytes:495110265 (472.1 MiB)

wlan0     Link encap:Ethernet  Hardware Adresse 80:3f:5d:xx:xx:xx
          inet Adresse:192.168.43.100  Bcast:192.168.255.255  Maske:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metrik:1
          RX packets:133981 errors:0 dropped:0 overruns:0 frame:0
          TX packets:152392 errors:0 dropped:0 overruns:0 carrier:0
          Kollisionen:0 Sendewarteschlangenlänge:1000
          RX bytes:16379126 (15.6 MiB)  TX bytes:42964605 (40.9 MiB)

root@md:/home/wolfgang/pilight# ping 192.168.43.1
PING 192.168.43.1 (192.168.43.1) 56(84) bytes of data.
64 bytes from 192.168.43.1: icmp_req=1 ttl=255 time=2.32 ms
64 bytes from 192.168.43.1: icmp_req=2 ttl=255 time=5.88 ms
64 bytes from 192.168.43.1: icmp_req=3 ttl=255 time=7.81 ms
64 bytes from 192.168.43.1: icmp_req=4 ttl=255 time=5.95 ms
64 bytes from 192.168.43.1: icmp_req=5 ttl=255 time=6.31 ms
64 bytes from 192.168.43.1: icmp_req=6 ttl=255 time=6.62 ms
64 bytes from 192.168.43.1: icmp_req=7 ttl=255 time=5.99 ms
64 bytes from 192.168.43.1: icmp_req=8 ttl=255 time=6.02 ms
^C
--- 192.168.43.1 ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 7010ms
rtt min/avg/max/mdev = 2.322/5.866/7.810/1.467 ms
root@md:/home/wolfgang/pilight# ping 192.168.43.100
PING 192.168.43.100 (192.168.43.100) 56(84) bytes of data.
64 bytes from 192.168.43.100: icmp_req=1 ttl=64 time=0.293 ms
64 bytes from 192.168.43.100: icmp_req=2 ttl=64 time=0.214 ms
64 bytes from 192.168.43.100: icmp_req=3 ttl=64 time=0.205 ms
64 bytes from 192.168.43.100: icmp_req=4 ttl=64 time=0.212 ms
64 bytes from 192.168.43.100: icmp_req=5 ttl=64 time=0.208 ms
64 bytes from 192.168.43.100: icmp_req=6 ttl=64 time=0.221 ms
^C
--- 192.168.43.100 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5003ms
rtt min/avg/max/mdev = 0.205/0.225/0.293/0.034 ms
Exit 6:
Could it be that it has an impact that both devices in question are WiFi devices ?
I do not think that the tun adapter interface is causing the problem here.
 
Reply
#25
You can of course remove the timeout to test. It's currently 1 second. It are these lines:
Code:
    tv.tv_sec = 1;
    tv.tv_usec = 0;
    if(setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct timeval)) < 0) {
        perror("SO_RCVTIMEO");
        close(sockfd);
        return -1;
    }

I have not clue. You could add the values in the strcmp into a printf to see what they are on return.
 
Reply
#26
As you can see from the roundtrip time that is typically less then 10mS between Pi and AP, and less than 500µS on the Pi, i do feel comportablewith 1000mS.

I will get more detailled info on the status-bits.
 
Reply
#27
There are two implementation issues with the usage of the raw sockets. I found a solution for the first one and I am chasing the second.
send from tapatalk
 
Reply
#28
Nice! Thanks for investigating.
 
Reply
#29
I will test the 2nd issue tonight
----
I had the following 2 issues:
1. I was unable to ping my own machine.
2. My TP-LINK router does not reply to ICMP timestamp requests but to ECHO requests only.

regarding issue 1: i added the additional flag checking to the code
regarding issue 2: i replaced ICMP_TSTAMP with ICMP-ECHO

errno of some system calls was checked with perror, i changed that to logperror(LOG_DEBUG, ....);

I have uploaded a test version here..
 
Reply
#30
Running:

Code:
pilight-daemon: INFO: version 5.0, commit v5.0-275-g68d8927

I get this error below, where 137.120 is the IP address of the rpi running pilight.

Code:
pilight-daemon: DEBUG: unexpected status reply 3 from addr: 192.168.137.120

Besides the above, is it possible to specify poll-interval a bit more? Is it defined in ms, sec or?
 
Reply
  


Forum Jump:


Browsing: 1 Guest(s)