3

My question is that is it possible to send and receive data between multiple android devices via broadcasting over wifi without establishing p2p connection?

Our professor asked us to design a wireless network system in which you broadcast a message within your android phone, and the other android phones nearby receive it and broadcast it again so that the other phones can receive it and it continues like that. In this way, for example, when someone writes a message in a classroom or café everyone will be able to receive it and broadcast it again. (like an adhoc network system). And although my professor believes it can be achievable, I didn't find anything online like this kind of android network system. So my question is again is it possible to do something like that?

Any helpful leads and references will be appreciated.

Edit: I had to change the title of the question.

I couldn't find a proper solution so I tried the following method so far: I set up a UDP messaging app using Wifi hotspot (it works perfectly for multi clients). The phone who turns on the hotspot is the server and others who connect to it are the clients. Then, I decided to turn this system into an adhoc-like system where there would be more than one hotspot and the clients would connect to them in cycling order and serve as a bridge among these servers.(every second, they will switch to other hotspot and vice versa.) So, they will carry the messages from one network to another. (I know it is very inefficient and prone to time delays; but it is the only idea I have come up with so far.)

When I told this system to my professor, he said that it is too complicated and I just need to broadcast a message from a device to a common channel(without setting up a network connection), and other devices will listen to this broadcast channel(without connecting to a network system), receive the message and broadcast their own messages along with received ones to this channel again as I described in the question body. (he never mentions hotspot, Wifi direct, and etc.) He even told me that the only thing I need to do was to think simpler and use the properties of 802.11. But, I do not think it is that easy to set up such a wireless system, at least for Android where ad hoc systems are not supported yet. So any help will be greatly appreciated. Thanks!

Umit
  • 33
  • 1
  • 5
  • You can broadcast datagrams quite easily using UDP, which is a connectionless protocol. All you will have to do is parse the datagrams on the device side. Here is a simple UDP example in Android: https://code.google.com/p/boxeeremote/wiki/AndroidUDP – Willis Mar 02 '15 at 22:09
  • Thanks for the quick reply! Sorry if I misunderstood, but UDP does require internet connection, right? We are required to design a wireless network without any internet connection using wifi technology only. – Umit Mar 02 '15 at 22:26
  • Although you do need an existing Wi-Fi network, you do not need an active internet connection. There has been some experimentation with using UDP to broadcast datagrams over Wi-Fi direct, although I do not know how successful this was. You can find more information here: http://stackoverflow.com/questions/15524593/broadcasting-over-wi-fi-direct – Willis Mar 02 '15 at 22:43
  • Thanks for the suggestion! And sorry for the late response. I edited my previous message. – Umit Apr 04 '15 at 13:45
  • @umit: Do you have new solution for this question ? – hoang8f May 22 '15 at 08:49
  • @hoang8f Sorry for the late response. No, I haven't come up with a new solution, but I did implement the solution that I explained above. And it worked just fine. Not a good or efficient solution by all means but still a working one. – Umit May 27 '15 at 17:24
  • @Umit: I have an answer here about connectionless data exchange on wifi: http://android.stackexchange.com/questions/77569/how-to-do-connectionless-udp-broadcast-using-wi-fi/126284#126284 – Riceball LEE Oct 19 '15 at 00:32

2 Answers2

5

The Nearby Connections API in Google Play Services released last week uses WiFi multicast: https://developers.google.com/games/services/android/nearby

It works for devices already on the same WiFi network. However, it uses a host/clients model, and doesn't work with WiFi direct or a tethered hotspot connection.

You could also use the WiFi direct APIs from ICS: https://developer.android.com/guide/topics/connectivity/wifip2p.html You can have multiple devices connected together via WiFi direct, so firing UDP packets as @willis suggests would seem the way to go

rockgecko
  • 4,127
  • 2
  • 18
  • 31
  • 1
    Thanks for the answer. The nearby connections seems promising but what I want is a messaging app without a wireless network. (No hotspot, no Wifi direct). The android phones in the system can broadcast a message to the common channel and they will also be able to listen to this channel for incoming messages. Is is it possible to create a such a hard coded channel where phones can send and receive messages from? As I said, my professor still insists on the possibility of such system. – Umit Apr 03 '15 at 14:01
0

It is implementable. Do you know the aircrack? similarly, you can receive all packets even not sent to you, and you can send any kinds of packets even not sent by you.

jackiszhp
  • 767
  • 1
  • 5
  • 11
  • Yes, this way can only broadcast to receivers. The data field in data frame is encrypted, u can used the exposed length filed as encoded data. The answer url see the main comment. – Riceball LEE Oct 19 '15 at 00:39
  • @RiceballLEE you mentioned the encryption, the one wants to broadcast, can it use open system, not to use encrypt? or is it possible for everyone participates to use a prefixed key? – jackiszhp Oct 11 '17 at 06:48
  • see my answer here: https://android.stackexchange.com/questions/77569/how-to-do-connectionless-udp-broadcast-using-wi-fi/126284 – Riceball LEE Oct 16 '17 at 08:29