Join 3,512 readers in helping fund MetaFilter (Hide)


How many iPhones/iPads can connect to each other through local wifi?
April 12, 2010 1:00 AM   Subscribe

A question for iPhone/iPad/iPod touch app developers: How many iDevices can connect to each other through a local wifi network? What is the maximum number of players you can have in a game at the same time locally?

I have an idea which requires a large number of LOCAL wifi connections to each other and was wondering if there's a limit to how many devices can relay information at once.

I found a couple of apps when searching for "MMO" and "massive multiplayer", so I think the iPhone/iPad is capable of unlimited connections (please correct me if I'm wrong). But the important part of this is if there's anything stopping unlimited LOCAL connections. I know that a couple of games out there can do at least six local connections at once (Shrek Kart racing I think is one).

I'm assuming that it shouldn't be any different for local wifi vs. online, that if there's at least a couple of massive multiplayer games out there, it shouldn't be a problem for a local wifi network either.

The reason I'm asking about local wifi is that this app cannot rely on an internet connection or a server; nothing outside of the app itself. Those would have to be optional.

Without going into too much detail, imagine a room set up with wifi and twenty kids sitting around. Nothing at all graphics intensive; in fact, what I'm imagining is more text-based than anything else. So, even if information is simultaneously being sent, the devices won't choke.

So, the only thing (unless you can tell me something I'm missing) that stops it is if there's some restriction on how many local connections can happen at once.

My understanding is that local wifi will do the trick, but just want to make sure Apple has no restrictions in the SDK about how many devices can connect to each other that way.

Is there anything else I'm missing? Can my dream of a massive multiplayer app that doesn't require a server be realized?

Thanks for your help.
posted by smersh to Computers & Internet (11 answers total)
 
Do you mean local WiFi in a sense of iPhone OS devices (iPhone/iPad/iPod Touch) that are connected directly to each other? I don't believe there is such a thing. They'd need either 3G or WiFi service to communicate in any way. I s'pose you could use bluetooth in some circumstances, but that wouldn't likely be very reliable for what you're trying to accomplish.

Maybe I'm misunderstanding your question - and I'm really only starting out in iPhone OS development myself, but I'm mostly asking for the benefit of anyone with more knowledge who posts after me - as they'd probably ask the same question.
posted by revmitcz at 1:10 AM on April 12, 2010


I think there is a limit of six or seven devices connecting over Bluetooth with the GameKit framework. There is no limit described for local WiFi-connected devices in the public documentation, although the conditions of your network will probably put an upper bound on how many can exchange messages reliably (or a lower bound on latency).

If you use the GameKit's "faster-but-less-reliable" messaging option you'll get lower latency at the cost of a higher error rate. Whether you want this option will likely depend on your game.

Also, the clients are not truly connecting peer-to-peer, but instead relay messages through intermediate devices that are designated servers for a given session. So whatever else the server device might be doing could affect latency and connectivity. Network conditions (e.g. your neighbor suddenly sets up a wireless network that interferes with yours) could also knock out a server.

I don't know what problems you'll run into but if your messages are small I don't foresee any major issues, other than the need for all your clients to be v3.1 firmware and up to do GameKit over WiFi, which could be an issue for some iPod Touch users who don't want to pay for the firmware upgrade.

Stack Overflow might also be a good resource for a question like this.
posted by Blazecock Pileon at 1:31 AM on April 12, 2010


revmitcz, sorry for being unclear. The devices wouldn't be connected to each other directly. They'd all be connected to the same wifi connection.

eg. At my house, my wifi connection might be called "smersh's wifi". All the devices would be connected to smersh's wifi. This is what I mean by local wifi, all devices on the same wifi network, not having to rely on the internet at all (if the cable company screws up at my house and I can't get online, my iPhones can still communicate with each other through my wifi network. Local wifi allows you not to have to rely on the internet).

I found that Apple's Texas Hold 'Em app supports 9 people in local wifi multiplayer. If you look at that app, that's exactly the implementation I'm talking about. Nine is a great start, but I'm hoping for 20-50 if it can be done.
posted by smersh at 1:45 AM on April 12, 2010


Blazecock Pileon,

I want to avoid Bluetooth entirely because I cannot control the size of the space that this app would be used in. Bluetooth has far greater range limitations; wifi can be extended more readily. Besides, if the limit is 6-7 devices, Bluetooth is definitely out.

Here's how it's playing out in my head. This app is primarily for me; selling it is really only a consideration if it turns out to be a good app that's useful to others. I just want to make sure it works within my parameters before subjecting anyone else to it.

So, assuming I have a great wifi network (say for example, I've made certain that every inch of my house is fully covered and spared no expense on extending my network properly), I should be okay with this implementation. I don't want to rely on GameKit's messaging option if it's less reliable.

And, when you say that "intermediate devices... are designated servers for a given session", do you mean my router is acting like a server? If that's what you meant, I'm cool with that.

Stack Overflow looks like a great resource. Thanks for that.
posted by smersh at 2:09 AM on April 12, 2010


And, when you say that "intermediate devices... are designated servers for a given session", do you mean my router is acting like a server? If that's what you meant, I'm cool with that.

No, I mean that, in a room of ten devices, for example, a message sent from Device 3 to Device 8 might go through Device 1 and Device 6, not directly from Device 3 to Device 8.

This is what I meant by "intermediate devices are designated servers" — Devices 1 and 6 are conduits for messages between peers; it's not a true "peer-to-peer" arrangement where 3 and 8 would talk to each other directly.
posted by Blazecock Pileon at 2:20 AM on April 12, 2010


Interesting. Intermediate devices act as servers until all devices eventually get the messages?

If there's 50 iDevices connected at once to an Apple Time Capsule wifi network (and assuming the network wasn't doing anything else but allowing these devices to communicate), how bad do you think the latency could get if I did NOT use GameKit messaging? Would it be in the milliseconds or seconds? Certainly not minutes, right?

I know you wouldn't have a definitive answer, but an educated guess is fine. For what I want, even 10 seconds delay would be fine.

I appreciate your answers for this.
posted by smersh at 3:00 AM on April 12, 2010


I don't think there's a limit, but I've not written iPhone code. It *should* be capable of having tens of concurrent connections and since it all goes through an 802.11 router in the middle, there isn't really any difference between n "local" connections (as you put it) and n "internet" connections - it's just n sockets and n entries in the ARP table.

However, you don't seem to have thought much about how to maintain coherency of state in your game, and that is the truly hard problem. You'll need to do some CS reading: look up coherency, consistency (particularly "release consistency") and related things. And "distributed termination detection", "atomic broadcast", "consistent cuts" and, well, a whole bunch of other things. What you're proposing to do is truly not an easy task at all and is subject to all sorts of nasty timing-related failures (race conditions) that are unbelievably hard to track down... but that's a question for another day.
posted by polyglot at 5:06 AM on April 12, 2010


polyglot, you're right. Not thought about it at all. I don't know much about making apps, and I'd be leaving it to professionals to create. Is it really an insurmountable problem?

I figure that if there are apps out there that are far more intensive than mine (graphics-based games like Shrek Kart can do six players, Apple's Texas Hold 'Em can do nine, and a few other Massive Multiplayer games like Pocket Legends can do even more than that), it's a solvable problem, right? If they can do, wouldn't it be significantly easier for a mostly text-based app?

Nevertheless, thank you. I'll be looking into it to see what I need to know.

Is there anything else I should be aware of?
posted by smersh at 6:12 AM on April 12, 2010


If they can do, wouldn't it be significantly easier for a mostly text-based app?

Not necessarily. Those graphical games [probably] aren't sending very much over the network. They're certainly not sending images over the network. Whatever your sort of game, minimizing network traffic is good. The less time your app has to spend interpreting this packet of information it just received, the more time it can spend drawing frames.

If anything, a purely text-based network game would probably have the luxury of being able to send more data between the clients, because the display processing wouldn't be as time-sensitive.

But, generally, nthing the "this-isn't-terribly-simple" sentiment.
posted by chazlarson at 2:13 PM on April 12, 2010


If the chunks of data are large but text-based, you might benefit from compressing the data before sending it along. If you're not taxing the device, you might not suffer too much latency from optimizing the data message.
posted by Blazecock Pileon at 4:11 PM on April 12, 2010


thank you all for your help.
posted by smersh at 12:28 AM on April 13, 2010


« Older What can I do/get for a couple...   |  What are some fun ongoing game... Newer »
This thread is closed to new comments.