iPhone Presence Detection with hping3 and ARP

@smhgit Can you confirm that the iputils arping works not as good for iphone detection than thomas arping? That would answer @muelli1967’s question.

Was just coming to write it :slight_smile:

Yes, with iputils when iphone is off, no ping from arping:

 [15:19:06] openhabian@openHABianPi:~$ arping -c 1 -I eth0
ARPING from eth0
Sent 1 probes (1 broadcast(s))
Received 0 response(s)

I do recall that arping with thomas was better but I have removed the version :frowning: so I cannot confirm it now (and not sure spo better to check it again).

Thanks! i will give it a try with thomas arping and let you know.

I have been following along your conversation and with my current (brand new) system set up, I am also on the old verson 2.14 of Thomas’ arping. How can I update arping to the latest supported version 2.19? If the answer is “compiling yourself”, I would need some instructions since I did not set up my pi other than installing OpenHAB (the Pi’s sole purpose).

Here are my specs (running on Raspbian Stretch Lite):

##   Release = Raspbian GNU/Linux 9 (stretch)
##   Kernel = Linux 4.9.41-v7+

$ which arping
> /usr/sbin/arping

$ arping
> ARPing 2.14, by Thomas Habets <thomas@habets.se>

I have installed arping and hping3 through

$ sudo apt-get install arping hping3

Thanks for your help!

1 Like

I have tested thomas arping as well, but the iphone detection is not great here as well. same issue. The iphone gets detected, but goes to status OFFLINE quite quickly after the iphone goes to sleep modus.

I am back now to the 2.1.0 network binding and here the detection of the iphone works perfectly fine as it was before. It stays ONLINE as long as in range of the network, even in sleep modus. The enhancements in SNAPSHOT 2.2.0 are unfortunately not working for me right now. I will continue to follow the conversation for further development and happy to test at a later stage.

Thanks to all for your time and effort to work on the projects. Much appreciated.

Download for your platform here.
(I download on my Win & copied it to openHAB2-userdata samba share)
Example for my Ubuntu server 16.04 LTS:

omr@shs2:~$ sudo dpkg -i /var/lib/openhab2/arping_2.19-1_amd64.deb
[sudo] password for omr:
(Reading database ... 68239 files and directories currently installed.)
Preparing to unpack .../arping_2.19-1_amd64.deb ...
Unpacking arping (2.19-1) over (2.14-1) ...
Setting up arping (2.19-1) ...
Removing obsolete conffile /etc/default/arping ...
Removing obsolete conffile /etc/network/if-up.d/arping ...
Processing triggers for man-db (2.7.5-1) ...

omr@shs2:~$ sudo arping -v
ARPing 2.19, by Thomas Habets <thomas@habets.se>
usage: arping [ -0aAbdDeFpPqrRuUv ] [ -w <sec> ] [ -W <sec> ] [ -S <host/ip> ]
              [ -T <host/ip ] [ -s <MAC> ] [ -t <MAC> ] [ -c <count> ]
              [ -C <count> ] [ -i <interface> ] [ -m <type> ] [ -g <group> ]
              [ -V <vlan> ] [ -Q <priority> ] <host/ip/MAC | -B>
For complete usage info, use --help or check the manpage.
1 Like

Took the arping 2.19 (by Thomas Habets) for a spin pinging a sleeping iPhone 6S.

omr@shs2:/var/lib/openhab2/etc$ sudo arping -vv
arping: clock_getres() = 0s 1ns
arping: libnet_init(<null>)
arping: Autodetected interface enp3s0
arping: libnet_init(enp3s0)
Timestamp types:
  Name               Description
  host               Host
arping: Successfully chrooted to /var/run/sshd
arping: Successfully dropped uid/gid to 65534/65534.
arping: pcap_get_selectable_fd(): 5
This box:   Interface: enp3s0  IP:   MAC address: 78:24:af:04:e6:94
arping: sending packet at time 1664524.533523928
 - removed timeouts -
arping: sending packet at time 1664545.544827499
60 bytes from f4:31:c3:4e:34:bf ( index=0 time=171.203 msec
arping: sending packet at time 1664546.545722459
 - removed timeouts -
Time since last reply 639-545=94s
arping: sending packet at time 1664639.599271890
60 bytes from f4:31:c3:4e:34:bf ( index=1 time=124.669 msec
arping: sending packet at time 1664640.599523014
 - removed timeouts -
time since last reply 710-639=71s
arping: sending packet at time 1664710.637140904
60 bytes from f4:31:c3:4e:34:bf ( index=2 time=972.041 msec
60 bytes from f4:31:c3:4e:34:bf ( index=3 time=972.073 msec
arping: sending packet at time 1664711.637252153

These are my properties:

  • The uses_ios_wakeup is On

So is the arping reply interval of up to 94s as expected?
I also did the port 67 forwarding described in the binding doc, but uses_dhcp_listen is still a: no

Just updated to new snapshot with @David_Graeff’s fix.

 openhab> bundle:list | grep -i netw
186 â Active   â  80 â     â Network Binding

Properties are now:

When I check top (-V) I can see ping being run regularly, but never arping.
My toolpath is set to /usr/sbin/arping and the openhab user given privilege in sudoers:

openhab@shs2:~$ /usr/sbin/arping
ARPing 2.19, by Thomas Habets <thomas@habets.se>
usage: arping [ -0aAbdDeFpPqrRuUv ] [ -w <sec> ] [ -W <sec> ] [ -S <host/ip> ]
              [ -T <host/ip ] [ -s <MAC> ] [ -t <MAC> ] [ -c <count> ]
              [ -C <count> ] [ -i <interface> ] [ -m <type> ] [ -g <group> ]
              [ -V <vlan> ] [ -Q <priority> ] <host/ip/MAC | -B>
For complete usage info, use --help or check the manpage.


Why is my arping never called?

Try arping -c 1 -I eth0, adapt the IP.

edit: showing now after one additional restart of openhab
however i still have the same problem as @OMR in regards to the DHCP_state. all settings in regards to port forwarding are done as mentioned in the binding doc, but still getting the “No Access …” message.


Got it working and it seems to work really reliable for my P10plus.
however i noticed that in the config nothing is showing for the “Presence _detection_type”
is there a reason for that? (runninh lates bundel

There’s another way: grant your java binary full network access. How to do that is described in the Openhab setup documentation.

The port forwarding section of the binding docu need to be reworked. It doesn’t work in all conditions the documented way.


Thanks a lot, looks better, lets see how its working now with this settings and the latest snapshot.


HI David,

I am using RPI-3B with openhabian-jessie lite version,
I have installed ARPing with 2.19 version,

I have use sudo visudo and add below line,

openhab ALL=NOPASSWD: /usr/sbin/arping

but openhab still don’t have access right,

I set a rule for test purpose, run command as below

var String arping = executeCommandLine("arping -c 1 -I eth0 192.168.xxx.xx", 120*1000)

17:58:45.908 [INFO ] [clipse.smarthome.model.script.AirCon] - result:arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root

do you know why? and what should I do now?

Perhaps you should use the openhabian user instead?

I’m pretty sure the openhab user is the right user in this case. OH runs as openhab, not openhabian, so openhab is the one that needs the permission to run arping.

1 Like

actually I did both, result is when use sudo, I don’t require password, but arping still require sudo,

I was fooled by this fact:

When testing the arping command from root@shs2:/home/omr# su -l openhab -s /bin/bash running just the /usr/sbin/arping command seems to work, but providing actual parameters it will tell you you need to be root.

After fiddeling with visudo and entries in /etc/sudoers for hours, I ended up running root@shs2:/home/omr# chmod u+s /usr/sbin/arping. Then it worked!

I can even see in top (-V) that arping is called regularly. But, my Android phone is not seen, even though manual arping detects it. I suspect that is because on Ubuntu, my lan port is not named eth0, but enp3s0:

openhab@shs2:~$ /usr/sbin/arping -c 1 -i enp3s0
60 bytes from 60:f1:89:47:b9:b7 ( index=0 time=190.029 msec

Could this make the arping call from the binding fail do you think @David_Graeff?

Will try out DHCP tip next :slight_smile:

Could you please share how you did this?

I tried chmod u+s /usr/sbin/arping. but result still the same
it’s even getting worse, I got same warning even use sudo,

Hmm, I also, in the heat of the battle, issued a chmod 777 /usr/sbin/arping command. Maybe the combo is golden?