如何在网络上检测iPhone? [英] How do I detect iPhone on network?

查看:68
本文介绍了如何在网络上检测iPhone?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图检测我的iPhone是否与Raspberry Pi在同一网络中.我想在家时执行脚本,并且我的iPhone在我的局域网中注册了.

I am trying to detect if my iPhone is in the same network as my Raspberry Pi. I would like to execute a script when I am at home and my iPhone's presence is registered in my LAN.

似乎在手机处于待机状态时,甚至找不到iphone同步端口(6207/tcp). "/usr/bin/nmap -n -sT -p62078 [我的手机的本地IP]"显示没有主机.我想知道我还能扫描什么.显然,电话处于联机状态,可以接受通话时间(通过3G的数据已停用).我可以在Raspberry Pi上使用avahi完成某些工作,还是有其他方法.

It seems that when the phone is in standby not even the iphone-sync port (6207/tcp) is found. "/usr/bin/nmap -n -sT -p62078 [my phone's local IP]" shows no host. I wonder what else I could scan for. Obviously the phone is online and ready to accept facetime calls (data via 3G is deactivated). Could I accomplish something with avahi which I am using on my Raspberry Pi, or are there other ways.

推荐答案

我刚刚花了一个星期的时间来解决这个问题,因此我可以避免在妻子上班时向其妻子发送SMS家庭警报.

I've just spent a week beating on this problem so I can refrain from sending SMS home alarms to my wife when she's at work.

Ping不起作用,因为iPhone睡眠时不会响应ICMP.读取ARP缓存不起作用,因为会休眠的iPhone会来回走动(每30秒检查一次,持续几分钟).

Pinging won't work because the iPhone won't respond to ICMP when asleep. Reading the ARP cache won't work because a sleeping iPhone will come and go (check it every 30 seconds for a few minutes).

我发现可靠地"确定两部iPhone何时在本地(家庭)网络上的唯一方法是使用PCAP dotnet库来查找源自任一电话的MAC地址的任何数据包.例如,如果您使用捕获过滤器运行Wireshark

The only way I have found to 'reliably' determine when my two iPhones are on my local (home) network is to use the PCAP dotnet library to look for any packets originating from either of the phones' MAC addresses. For example, if you run Wireshark with the capture filter

ether src <iphone-mac-address>

您会从电话中看到数量惊人的网络发现/通告流量.它仍然具有静止状态,但是到目前为止,我看到的捕获数据包之间的最长间隔大约是10分钟.您必须等到一段时间没有听到电话通知(我用15分钟),然后再声明不在家.

you will see a surprising amount of network discovery/announcement traffic from the phone. It still has quiescent states, but so far the longest interval I have seen between captured packets is around 10 minutes. You would have to wait until you have not heard from the phone for some interval (I use 15 minutes) before declaring it not-home.

使用此技术,假设您的电话配置为使用DHCP,您将在重新加入家庭网络时快速找到电话.我还在主以太网交换机上使用端口镜像,以包括来自无线访问点的流量.

With this technique you will find a phone quickly when it rejoins the home network, assuming your phone is configured for DHCP. I also use port mirroring on my main Ethernet switch to include traffic from my wireless access points.

我没有Raspberry Pi解决方案,因为我的Linux专业知识非常有限,但是其他人也许可以按照这些方针为您提供帮助.我有一个使用PCAP库的Windows服务,到目前为止,它可以可靠地运行,但要等15分钟才能决定iPhone离开网络.

I don't have a Raspberry Pi solution for this, because my linux expertise is very limited, but someone else may be able to help you along those lines. I have a Windows Service using the PCAP library and so far it works reliably, with the limitation of waiting 15 minutes before deciding an iPhone has left the network.

*更新2-3-2018 *

我将这种检测算法的使用时间降到了大约5分钟,使用了指向每部手机的ping/arp消息组合,大约每分钟一次.似乎工作很棒.

I have this detection algorithm down to about 5 minutes, using a combination of ping/arp messages directed to each phone, about once per minute. Seems to work great.

这篇关于如何在网络上检测iPhone?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆