
WiFried: iOS 8 WiFi Issue - ValentineC
https://medium.com/@mariociabarra/wifried-ios-8-wifi-performance-issues-3029a164ce94
======
conradev
I was curious as to how Apple implemented AirDrop discovery (particularly the
Contacts Only feature) because their documentation is helpful, but vague[1]. I
spent a night reverse engineering it, and this is the process:

1\. Alice opens the AirDrop sheet.

2\. Alice begins advertising her short "proximity"[2] hashes over BTLE.

3\. Bob, continually scanning in the background, sees Alice and her hashes.

4\. If Bob either a) has the "Everyone" setting enabled, or b) has a match to
one of Alice's proximity hashes in his contacts, Bob connects to Alice over
AWDL.

6\. Bob starts a HTTP server.

7\. Bob advertises a Bonjour service for his HTTP server.

8\. Alice sends a discovery request.

9\. If the request is valid, Bob sends a discovery response (including device
model, name and icon).

Also to note, the author, Mario Ciabarra is the (co?)-founder of Rock Your
Phone, the alternative to Cydia until the two merged in 2010[3].

[1]
[https://www.apple.com/privacy/docs/iOS_Security_Guide_Oct_20...](https://www.apple.com/privacy/docs/iOS_Security_Guide_Oct_2014.pdf)
(Page 23)

[2] Each device hashes every phone number and email in its address book with
SHA256 after normalizing them. These hashes are referred to as full hashes.
The "proximity" hashes are the first two bytes of the long hash. The full
hashes are not broadcasted, but they are verified later over AWDL.

[3] [http://www.tuaw.com/2010/09/11/alliance-of-the-
jailbreakers-...](http://www.tuaw.com/2010/09/11/alliance-of-the-jailbreakers-
cydia-acquires-rock/)

~~~
geekam
Very interesting. How did you go about reverse engineering it? Would you mind
sharing?

~~~
conradev
Sure! It's a combination of static and dynamic analysis. I have a jailbroken
phone, which allows me to access any file on the filesystem and decrypt any
App Store binaries[1]. The first step is to find in which binaries the
functionality lives. I know from searching that AirDrop lives in
Sharing.framework[2], which has a supporting daemon, sharingd. Then, I open
the binaries in a disassembler like IDA Pro[3] or Hopper[4] to determine how
they work. Running class-dump is also helpful[5]. If I need to inspect a
process like sharingd at runtime, I use Cycript[6], which gives me an
Objective-C REPL into the process, or LLDB[7].

[1]
[https://github.com/stefanesser/dumpdecrypted](https://github.com/stefanesser/dumpdecrypted)

[2] [https://github.com/JaviSoto/iOS8-Runtime-
Headers/tree/master...](https://github.com/JaviSoto/iOS8-Runtime-
Headers/tree/master/PrivateFrameworks/Sharing.framework)

[3] [https://www.hex-rays.com/products/ida/](https://www.hex-
rays.com/products/ida/)

[4] [http://www.hopperapp.com/](http://www.hopperapp.com/)

[5] [http://stevenygard.com/projects/class-
dump/](http://stevenygard.com/projects/class-dump/)

[6] [http://www.cycript.org/](http://www.cycript.org/)

[7]
[http://iphonedevwiki.net/index.php/Debugserver](http://iphonedevwiki.net/index.php/Debugserver)

~~~
coldpie
Oh crap, I didn't know IDA was free for non-commercial use. I thought it was
like Photoshop: prohibitively expensive for most users, so everyone pirates
it. I'm going to have to give that a shot.

~~~
edeion
Maybe you'd like Radare, which is free software.
[http://www.radare.org/y/](http://www.radare.org/y/)

~~~
coldpie
Thank you for the link.

------
PakG1
I gotta say that this is annoying. I currently work for a place where we're
all Macs and iOS. Many, many devices all over the place, all broadcasting for
AirDrop and AirPlay. We're a school, they are useful features. Everything
connects to a mesh wifi network. Neighbouring APs are of course on different
channels.

It's like we're the perfect environment to experience this problem on a
massive scale. We've tested and replicated OP's test results. So now we have a
choice between good wifi and AirDrop/AirPlay? This sucks.

~~~
jaxbot
I work for a university, and am a student at the same university. WiFi in
lecture halls has been complete garbage since 10.10.1 hit. Students love their
Macbooks, and in a room with 30+ of them, our wifi connection drops at least
every minute.

------
Osiris
I have been suffering some really bizarre WiFi issues on my rMBP since
upgrading to 10.10. I'll suddenly get latencies of a second or more. Switching
WiFi networks or even turning WiFi off and back on again will solve the
problem for a short period of time.

I just tested this fix to do _sudo ifconfig awdl0 down_ and my ping times are
consistently low.

~~~
craigching
> Switching WiFi networks or even turning WiFi off and back on again will
> solve the problem for a short period of time.

This is exactly the problem I'm having both with my 10.10 MBP and my
iPhones/iPads running iOS8. Glad to hear bringing down awdl0 fixes it, I'm
going to try it as well, but it seems there's no solution for non-jailbroken
iOS devices yet :(

Here's the weird thing, my devices (both i and MBP) are fine on the work
network, so I wonder why they're good there but not at home? I have a decent
router (LinkSys E4200) that worked fine pre-iOS8 and 10.10. I have fiddled
with the settings on the 2.4 Ghz and 5 Ghz to no avail (though admittedly I
haven't tried _everything_ ).

Does anyone have any idea why my devices work fine on our work network and not
at home? I'd hate to think I need a new router, I know it's not real gear, but
it's served it's purpose just fine until this. I know my company at work
doesn't allow Bonjour, is there a way to disallow it on my home router too?

~~~
JoshTheGeek
Unrelated: Don't factory reset your router. The software to set it up requires
you to downgrade to 10.7 or something. It'd be nice if linksys would update
their software, or at least remove the version cap.

~~~
danudey
I didn't have to use any special software to set up my Linksys E4200, either
when it was new or this year.

You can always use the web interface to set it up, it's just 'easier' for non-
technical consumers to use the software.

------
jlarocco
Seems Apple's quality control has really been screwing up the last few
releases. I haven't updated to iOS 8 or OSX 10.10, and the way things are
going I'm not going to any time soon.

If they keep this up, I'm switching back to Android and Linux.

~~~
jaxbot
I second this. I'm part of Appleseed because I figured my use cases of my
Macbook for development might bring out some less noticeable bugs.

In the latest pre-release before 10.10.1 came out, the iCloud settings broke
so that you could only access the system settings by agreeing to the iCloud
EULA, or clicking _very_ quickly and hoping you could press the back button
before the dialog reappeared. Very obvious, easy to reproduce bug.

Even after sending in multiple reports via Feedback assistant, it's still a
live bug in 10.10.1 production. I get it, bugs happen, but the lack of QA and
use of feedback assistant is really mindblowing to me.

Anyone have some light to shed on what's up?

------
rafeed
Neat. This is very helpful. Hopefully it actually fixes the WiFi performance
issues. I created an Alfred workflow for myself based on the terminal commands
listed in the article to quickly enable/disable WiFried on Yosemite. It
basically runs the terminal command after authenticating upon entering a
keyword to trigger. Quick and easy, just like the iOS tweak.

Edit: Here's a link to the Alfred workflows to disable/enable AirDrop if
you're interested.
[https://dl.dropboxusercontent.com/u/534072/WiFried.zip](https://dl.dropboxusercontent.com/u/534072/WiFried.zip)

------
canadev
In a related but different issue, my iPhone 4S has not been able to connect to
wifi since I upgraded to 8.0. 8.1 didn't fix it. It notified me of some patch
today; I hope it works.

I tried a few different tricks I found by Googling, like "Reset Network
Settings", but they didn't work. It's weird, after upgrading to 8.1, I had
Wifi for a short period, then the next time I came back to my phone it was
back to being completely gone. As in the Settings app won't even let me turn
it on.

Pretty frustrating.

~~~
petemc_
In my experience, the wifi icon being greyed out can often mean the hardware
on your device is no longer functioning. There are plenty of cases of this,
seemed to happen most to 4S phones on upgrade from ios6 to 7 but also to
iphone 5 as well. Not generally fixable despite people trying crazy things
like blowing hair dryer down the headphone socket etc.

~~~
canadev
I'm definitely hoping that's not the case... I did have this "no wifi"
experience happen once before with this phone on, I think, iOS 6, and I did
the "Reset Network Settings" trick and it worked again.

EDIT: After installing iOS 8.1.1, I have wifi back... for now. :)

EDIT 2: Gone again after a reboot, which I did because wifi died. I believe it
may have actually crashed my cable modem/router before I rebooted it.

------
gaza3g
I had this same issue on my 5S and a majority of my friends with that
particular model seems to be experiencing that as well.

In any case, after browsing the apple support forums, I decided to try a few
of the workarounds there and the only one which worked was by setting my
2.4ghz interface to b/g(legacy)-only mode.

It was an acceptable fix since all my other devices were on the 5ghz and I
don't really have any other option(7.1.2 was great for me, shouldn't have
upgraded).

------
danielhunt
Very interesting and detailed post

Since upgrading to Yosemite, I've effectively had to stop using Airdrop, as it
is now _completely_ unreliable.

The sooner this is sorted, the better.

------
cobralibre
I see many comments criticizing Apple's QA and wondering how this defect was
not discovered prior to release. The bulk of the comments seem to adopt a tone
of disbelief. I find _that_ hard to believe.

It would be illuminating to know more details about how development and
testing worked for the Yosemite project. Was this a late change? Were there
systematic blind spots in the test environments and test processes that made
defects like this difficult to discover internally? Are we even sure that this
issue was _not_ identified internally? Etc.

------
72deluxe
I have noticed since iOS8 on an iPad3 and my 2012 MBP (non-retina) that Safari
is insanely slow to resolve sites. It gets to about 15% of the progress bar
and will just sit there.

Has anyone else noticed this?

~~~
getsat
Safari is borderline unusable for me on 10.9 and 10.10. It will literally take
30 seconds to load facebook.com. If I open Chrome or Firefox and try it, it
loads instantly.

I've tried different DNS servers to no avail. I don't use Safari that often so
I never bothered digging deeper.

~~~
caw
Happens to me as well on a rMBP. There's also significant lag opening new
tabs.

I've had wifi issues on my phone since upgrading, where the iPhone will switch
to LTE even though there's wifi available, from a network it remembers.
Rebooting the phone will cause it to reconnect, so I'm trying this airdrop
disable tip to see if it helps my connection problems.

~~~
getsat
I disabled AirDrop using the "defaults write" command, and now Safari loads
things instantly! Holy crap!

------
mike-cardwell
I thought one of the benefits of the Apple ecosystem was that they controlled
both the software _and_ the hardware, so they should be able to catch these
things...

------
twsted
The 'sudo ifconfig awdl0 down' trick does not seem to solve the issues I have
on Yosemite (described here BTW
[http://markmaunder.com/2014/11/13/os-x-10-10-yosemite-
wifi-p...](http://markmaunder.com/2014/11/13/os-x-10-10-yosemite-wifi-
problems-analyzed/)): TCP Retransmissions and TCP Dup ACK.

------
mrgordon
Yeah when are they going to fix these issues? Everything was great until iOS 8
& Yosemite. My Mac with Yosemite can no longer use Airplay and my Airport
Express no longer shows up as a supported Apple device in Airport Utility
(despite the wifi still working)

~~~
toyg
IMHO everything was not "great" since Mavericks came about. My wifi (2012 MBP)
started having issues connecting on wake, which were fixed and unfixed with
each patch released. Now Yosemite will reconnect on wake, but DNS resolution
will be broken, so when that happens i have to go in TCP/IP settings, make any
change and "Apply" to get back to a working state.

It's 2014 and these _were_ solved problems, I really don't know why they
couldn't leave it well alone.

~~~
_asummers
I've been experiencing the wake issues on 10.9, as well. Bouncing wifi seems
to fix it, but it's very annoying. It seems to be when I close lid on one
network and open it on a different network that it gets confused what to do.

------
dennish00a
I've had WiFi problems for many moons on 10.9: long latencies when pinging the
router and complete dropouts for periods of 2-10 seconds every 3 minutes or
so. The problem seems only to happen with certain routers. I was hopeful that
my problems could be explained by the AirDrop issue (i.e., maybe I was only
having problems when in proximity to certain computers using those troublesome
routers).

Sadly, I don't even have the awdl0 interface. I tried taking down p2p0 but
that didn't help either. Any other ideas?

I am really desperate!!!

------
tdicola
I'm surprised this issue wasn't caught at Apple. You would think they must
have a huge network of Macs and iPhones--surely someone should have noticed
the poor WiFi performance.

~~~
Kudos
I tested on my 802.11ac network with an iPhone 6 and couldn't replicate using
the steps provided. A speed test sustained 193Mb/s. Maybe 802.11ac networks
don't have the same problem? I would think Apple are running 802.11ac on
campus.

~~~
TazeTSchnitzel
Perhaps 802.11ac, since it uses 5GHz, is less congested and thus has less
problems?

------
apenwarr
Here's my tool for measuring latency glitches in real time on any device with
a javascript-capable web browser. Maybe it will help some people narrow down
the nature of their wifi slowness problems. In short, if the latency is always
high, that's one thing. If it is usually low but then jumps, that's a
different thing. [http://gfblip.appspot.com/](http://gfblip.appspot.com/)

------
pkaye
What is the impact on Yosemite if I don't actively use AirDrop. Does it still
cause WiFi issues? I'm not clear on the severity of the issue.

~~~
ralucam
The amount of usage doesn't seem to matter in my testing. I didn't share
anything (and I also set the discoverable setting to 'no one'), and I see a
big difference in the throughput: 38 Mbps (awdl0 interface up) vs ~80 Mbps
(awdl0 interface down). Yikes. This was a TCP test using iperf, between the
laptop and another machine on the lan.

Turning off bluetooth didn't help, so it looks like it's easy to be affected
by the performance hit.

~~~
tuacker
Ouch, I just ran iperf on mine (rMBP wifi to LAN server). I get ~30 Mbits/sec
with awdl0 down, and ~9 Mbits/sec with the interface up. This explains why
I've been having some problems streaming movies over wifi for a while now,
probably since upgrading to Yosemite.

------
fit2rule
Bonjour over Wifi is used for more than Airdrop - its also used for
virtualized CoreMIDI endpoints, and Audio too .. maybe there's something to be
said about paring down the Bonjour refresh interval or something, but then
we'd all be complaining about how long it takes to connect our studio gear to
the fancy set of iPads whose soul purpose is to rock and roll ..

~~~
danudey
Bonjour advertisements have an exponential back-off. They'll advertise
themselves, then again 1s later, then 3s, then 9s, 27s, etc.

The same is true of bonjour probes; they'll request, then again 1s later, then
3s, then 9s, and so on.

Source:
[https://developer.apple.com/library/ios/documentation/Cocoa/...](https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/NetServices/Articles/about.html)

~~~
fit2rule
Ah, that explains everything, thanks ..

------
b2themax
On a related note, I believe there is also a hardware problem on the iPhone 6
plus' 4G LTE radio for ATT. Same network, but my old nokia 1020 had a much
faster network connection. This is annecdotal, but there are reports in other
forums also.

------
newman314
Ever since I upgraded to iOS 8.1, I've seen random wifi drops where wifi just
disappears completely and I've got to go back into Settings to reactivate
wifi.

As you can imagine, it's exceedingly annoying when trying to watch a video.

------
acdha
At least in previous releases, you could disable AirDrop on OS X:

defaults write com.apple.NetworkBrowser DisableAirDrop -boolean YES

I don't have any Bluetooth-LE hardware to confirm whether this affects the
newer-style AirDrop reported as the problem.

------
lyinsteve
Did he file a bug report?

~~~
robmcm
It doesn't seem like a bug, it seems like a trade off. In order to work over
wifi it needs to flick between channels, reducing the uptime on the current
channel you are using.

~~~
mscman
Except my phone will get itself in a state where that latency stays high, and
bandwidth drops for a long time. Only solution is to turn wifi off/on. That
definitely seems like a bug.

I'm fine with lower throughput while discovery is going on, but when nothing's
changed on the network I've been on for days, and my phone can't use wifi
anymore, that's a bug.

------
yalogin
Airdrop uses Bluethooth for discovery (and may be even transfer?). Why does
the author say it uses Wifi for discovery?

~~~
donatj
Yes it does in Yosemite, not sure why you've been down voted .

------
slothbury
great article! Hope Apple takes the hint for this call to action.

------
ape4
Must be a real problem since its got an icon.

