seemoo-lab / owl

An open Apple Wireless Direct Link (AWDL) implementation written in C
https://owlink.org
GNU General Public License v3.0
1.21k stars 86 forks source link

Sporadic behavior despite active monitor mode #38

Open thomasst opened 3 years ago

thomasst commented 3 years ago

I opened this issue in the owl repository since I believe that the issue lies in the owl implementation and not in the opendrop tool itself, but I can't confirm. What can I do to get this to work or debug this further?

thomasst commented 3 years ago

I was able to maybe narrow the problem down a bit.

I have a MacBook running macOS Catalina 10.15.7 (fe80::fc77:26ff:febc:5a5d), iPhone running iOS 14.0 (fe80::1c0d:aaff:fe4d:5a79) and a Linux box running owl (fe80::523e:aaff:fe31:c062) on the AWDL network. ff02::fb is the broadcast address. The iPhone has a share sheet open and the Mac has a Finder Airdrop window open.

% ping6 ff02::fb%awdl0
PING6(56=40+8+8 bytes) fe80::fc77:26ff:febc:5a5d%awdl0 --> ff02::fb%awdl0
ping6: failed to get receiving hop limit
16 bytes from fe80::fc77:26ff:febc:5a5d%awdl0, icmp_seq=0 hlim=64 time=0.219 ms
16 bytes from fe80::1c0d:aaff:fe4d:5a79%awdl0, icmp_seq=0 hlim=64 time=531.305 ms
16 bytes from fe80::523e:aaff:fe31:c062%awdl0, icmp_seq=0 hlim=64 time=532.701 ms
16 bytes from fe80::523e:aaff:fe31:c062%awdl0, icmp_seq=0 hlim=64 time=925.133 ms
16 bytes from fe80::1c0d:aaff:fe4d:5a79%awdl0, icmp_seq=0 hlim=64 time=926.269 ms
16 bytes from fe80::fc77:26ff:febc:5a5d%awdl0, icmp_seq=1 hlim=64 time=0.228 ms
16 bytes from fe80::1c0d:aaff:fe4d:5a79%awdl0, icmp_seq=1 hlim=64 time=446.991 ms
16 bytes from fe80::1c0d:aaff:fe4d:5a79%awdl0, icmp_seq=1 hlim=64 time=575.425 ms
16 bytes from fe80::523e:aaff:fe31:c062%awdl0, icmp_seq=1 hlim=64 time=576.498 ms
16 bytes from fe80::523e:aaff:fe31:c062%awdl0, icmp_seq=1 hlim=64 time=968.384 ms
16 bytes from fe80::1c0d:aaff:fe4d:5a79%awdl0, icmp_seq=1 hlim=64 time=968.629 ms
...
PING fe80::1c0d:aaff:fe4d:5a79%awdl0(fe80::1c0d:aaff:fe4d:5a79%awdl0) 56 data bytes
64 bytes from fe80::1c0d:aaff:fe4d:5a79%awdl0: icmp_seq=1 ttl=64 time=163 ms
^C
--- fe80::1c0d:aaff:fe4d:5a79%awdl0 ping statistics ---
219 packets transmitted, 1 received, 99% packet loss, time 223191ms
rtt min/avg/max/mdev = 163.962/163.962/163.962/0.000 ms
% ping ff02::fb%awdl0
PING ff02::fb%awdl0(ff02::fb%awdl0) 56 data bytes
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=1 ttl=64 time=0.030 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=2 ttl=64 time=0.046 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=3 ttl=64 time=0.043 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=4 ttl=64 time=0.043 ms
64 bytes from fe80::fc77:26ff:febc:5a5d%awdl0: icmp_seq=1 ttl=64 time=3598 ms (DUP!)
64 bytes from fe80::fc77:26ff:febc:5a5d%awdl0: icmp_seq=2 ttl=64 time=2595 ms (DUP!)
64 bytes from fe80::fc77:26ff:febc:5a5d%awdl0: icmp_seq=3 ttl=64 time=1572 ms (DUP!)
64 bytes from fe80::fc77:26ff:febc:5a5d%awdl0: icmp_seq=4 ttl=64 time=916 ms (DUP!)
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=5 ttl=64 time=0.047 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=6 ttl=64 time=0.046 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=7 ttl=64 time=0.046 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=8 ttl=64 time=0.045 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=9 ttl=64 time=0.051 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=10 ttl=64 time=0.047 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=11 ttl=64 time=0.048 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=12 ttl=64 time=0.045 ms
64 bytes from fe80::fc77:26ff:febc:5a5d%awdl0: icmp_seq=5 ttl=64 time=7268 ms (DUP!)
64 bytes from fe80::fc77:26ff:febc:5a5d%awdl0: icmp_seq=10 ttl=64 time=2155 ms (DUP!)
64 bytes from fe80::fc77:26ff:febc:5a5d%awdl0: icmp_seq=11 ttl=64 time=1131 ms (DUP!)
64 bytes from fe80::fc77:26ff:febc:5a5d%awdl0: icmp_seq=12 ttl=64 time=107 ms (DUP!)
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=13 ttl=64 time=0.047 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=14 ttl=64 time=0.047 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=15 ttl=64 time=0.045 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=16 ttl=64 time=0.047 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=17 ttl=64 time=0.041 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=18 ttl=64 time=0.045 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=19 ttl=64 time=0.044 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=20 ttl=64 time=0.045 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=21 ttl=64 time=0.046 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=22 ttl=64 time=0.045 ms
64 bytes from fe80::fc77:26ff:febc:5a5d%awdl0: icmp_seq=13 ttl=64 time=9586 ms (DUP!)
64 bytes from fe80::fc77:26ff:febc:5a5d%awdl0: icmp_seq=14 ttl=64 time=8571 ms (DUP!)
64 bytes from fe80::fc77:26ff:febc:5a5d%awdl0: icmp_seq=15 ttl=64 time=7555 ms (DUP!)
64 bytes from fe80::fc77:26ff:febc:5a5d%awdl0: icmp_seq=16 ttl=64 time=6531 ms (DUP!)
64 bytes from fe80::fc77:26ff:febc:5a5d%awdl0: icmp_seq=17 ttl=64 time=5508 ms (DUP!)
64 bytes from fe80::fc77:26ff:febc:5a5d%awdl0: icmp_seq=18 ttl=64 time=4484 ms (DUP!)
64 bytes from fe80::fc77:26ff:febc:5a5d%awdl0: icmp_seq=19 ttl=64 time=3460 ms (DUP!)
64 bytes from fe80::fc77:26ff:febc:5a5d%awdl0: icmp_seq=20 ttl=64 time=2436 ms (DUP!)
64 bytes from fe80::fc77:26ff:febc:5a5d%awdl0: icmp_seq=21 ttl=64 time=1412 ms (DUP!)
64 bytes from fe80::fc77:26ff:febc:5a5d%awdl0: icmp_seq=22 ttl=64 time=395 ms (DUP!)
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=23 ttl=64 time=0.049 ms
64 bytes from fe80::523e:aaff:fe31:c062%awdl0: icmp_seq=24 ttl=64 time=0.048 ms

Note that this is on channel 149 with the regulatory domain set to US. If the regulatory domain isn't set, none of the packets go out (consistent with https://github.com/seemoo-lab/owl/issues/10#issuecomment-532151769).

Maybe @Kulawik @neilalexander have any insights on this since it appears you have the same card?

schmittner commented 3 years ago

@thomasst which part of your issue was resolved with #39?

thomasst commented 3 years ago

@schmittner Thanks for checking in. #39 fixed queueing up the packets and responding in bulk in the scenario where I ping the broadcast. In my last comment above you can see that fe80::fc77:26ff:febc:5a5d%awdl0 was responding in batches to the pings, since they were previously queued up in the circular buffer -- this is now fixed.

However, there is still packet when sending packets via owl, on both TP-Link Archer T1U V1.0 as well as the Alfa AWUS036NHA. Overall, the Alfa card is performing better than the TP-Link. I suspect it might have to do with the timing of when the packets are sent out, but I'm not familiar enough with AWDL to figure it out. On the machine running owl, I can see all packets going out in wireshark on both awdl0 as well as the physical wi-fi interface, but I can't see it in Wireshark coming in on the Mac, so it appears the packet somehow gets lost "in the air".

With the Alfa card, there is frequent and sporadic packet loss without a specific pattern that I could figure out. On the Archer, certain devices, like my iPhone, barely receive any packets. The issue described above ("Sometimes none of the pings go through, sometimes just the first one (icmp_seq=1).") is still happening.

Do you have any ideas why this might be? If you have time to help out, I'm happy to do any more debugging and provide more details. Thanks!

schmittner commented 3 years ago

I see, thanks for clarifying. Can you assert that packets actually arrive at the Mac and not get lost over the air? To do this, set your Mac to monitor mode and record packets on channel 149 (in your case).

deanward81 commented 2 years ago

I can readily reproduce this here. I have an iPhone running iOS 15.1 and a MacBook Pro running Catalina 10.15.7 with OWL on a Raspberry Pi running kernel 5.10. I'm using a TP-Link Archer T1U V1.0 using the mt76 driver. MBP can send and receive to OWL just fine but the iPhone shows the sporadic traffic patterns described by @thomasst.

Running tcpdump on the Pi, while executing a ping to the link-local address of the iPhone, ICMPv6 echo request packets are being sent over the awdl0 interface and physical WLAN interfaces. Monitoring the rvi0 interface (which is a virtual interface representing all traffic sent to/from the iPhone, exposed on the MacBook as described here) shows that the iPhone is happily responding with an ICMPv6 echo reply, but those are only received sporadically by the Pi - tcpdump on either the awdl0 or physical interface shows that the majority of replies are somehow lost.

When monitoring awdl0 on the Pi I can see other traffic (e.g. mDNS multicast traffic) being received from the iPhone but any unicast traffic seems to be sporadic. When I run tcpdump on the physical WLAN interface while the ping is running I can see the occasional sporadic ping reply being received and plenty of radiotap traffic being received from the iPhone, as well as multicast packets. That seems to indicate that the IPv6 ping reply sent from the iPhone is dropped somewhere along the way.

When pinging the iPhone's link-local address via my MacBook's awdl0 interface then it pings consistently.

Additionally all of this just works if I do the same things from the MBP (rather than the iPhone).

I'm unsure how to go about debugging this further - any pointers really appreciated! I'm really confused as to why the MBP works fine but the iPhone does not.