iPhone GameKit Season 2 Episode 5: WiFi 3

Today was a very productive day. I was able to finish my WiFi implementation and test it thoroughly. And I made some amazing discoveries.
First of all, a while ago we ran some tests on the iPhone, iPod and G1 devices to determine the latency and throughput of the WiFi connection. The results were sobering. GameKit appeared to be the rescue, delivering about the same throughput (about 60KiB/s) and better latency (15-30ms). The drawback was that it only supported 3 devices, making it completely unusable for our purposes.
Now, with my new WiFi implementation, I’ve ran similar tests to those before, and I’m now getting an awesome 600KiB/s throughput over one or several TCP connections. Because it’s using my wrapper interface, we can easily switch to gamekit to perform some comparisons. We’re still getting at most 60KiB/s with the very same code when switching to the GameKit implementation (switching is just one line of code). So we’re seeing an almost tenfold increase of throughput here, and we’re absolutely amazed.
But what about the latency? As it turned out yesterday, the latency can be good with WiFi, too. You just have to be sending data constantly. We’re getting about 15-45ms, with a little more variance than the Bluetooth connection. But the difference is, we can even sustain this latency while pushing reliable data out at 500Kib/s and more. There may be a little more packet drop and variance in the latencies, but it’s still essentially very responsive.
We’ve also performed some tests with the total number of clients, and so far we had 4 iP* devices (2x Touch 2G, 1x iPhone 3G, 1x iPhone 3GS) and two MacBook Pros (in the simulator), in the same room via one (dedicated) WiFi router. So it was a total of 6 clients, and it was great. Low latencies, no reliability issues, high throughput (about 120KiB/s per client output, iPhone 3GS was the host). I’m curious to find out how this scales with more devices (at some point there must be WiFi interference, I guess).
I’m going to hang out and make pizza with some friends now, but I’m going to post more stuff tomorrow. There are some problems I ran into (SIGPIPEs, address reuses, weird UDP errors) that I want to write down.
BTW, thanks for the comments, it’s great to see people’s interest in this stuff, and motivates me to post more 🙂 Also, check out my good friends Sander’s blog, he got some great megatexturing results.

7 thoughts on “iPhone GameKit Season 2 Episode 5: WiFi 3

  1. Any more news on this? Is GameKit over bluetooth more or less unusable with more then two, max tree, devices? Even in the latest firmware version?

    Looks like I'll stick to a homebrew wifi implementation for my game.

  2. Hi, no, I do not believe that Bluetooth Gamekit is something you want to rely on, even for 2 player. To me it seems like it is extremely unreliable and will cause a bad user experience. While we need access points for the Wifi mode, it is so much more reliable, and fast.

Leave a Reply

Your email address will not be published. Required fields are marked *