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

查看:21
本文介绍了如何在网络上检测 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-sync 端口 (6207/tcp)./usr/bin/nmap -n -sT -p62078 [我手机的本地 IP]"显示没有主机.我想知道我还能扫描什么.显然,手机已在线并准备好接受 facetime 电话(通过 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.

推荐答案

我刚刚花了一个星期来解决这个问题,所以我可以避免在妻子上班时向她发送家庭警报短信.

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 服务,到目前为止它工作可靠,在决定 iPhone 离开网络之前等待 15 分钟的限制.

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天全站免登陆