2
votes

I am currently working on using multicast on a network to send a message (from one Android Device) on the network to all other Android devices including itself.

It works as required when both phones are connected via the local WiFi network. I.e Phone A send message and both Phone A and phone B receive the message. However, the ultimate goal is to have the phones connected via WiFi-Direct.

Therefore I connected both devices together and tried the same process again but this time only the phone that sends the packet that I'm broadcasting receives it. I.e. Phone A sends the message and receives it but phone B does not receive the message from phone A.

My ultimate question therefore is does Multicast work when using WiFi-Direct between Android devices or not? Has anyone else experienced problems with WiFi-Direct and Multicast on the Android platform?

1
Thanks for your response. So my aim is to have the message received at the same time (give or take a few milliseconds) on each device. Is it possible to send the message at exactly the same time to each device or would the message have to be sent one after another in a loop?Richard Lewin
If you peruse the linked documentation, it should be pretty clear how you need to handle it. Yes, if multicast isn't available, you'll need to handle distribution yourself. I would not worry about loop-induced jitter, if you are tolerant within "a few milliseconds" -- that's an eternity in terms of socket communication.323go
@323go I do not understand. You don't need a router for multicast within a subnet. You need a router to multicast into other subnets.user207421

1 Answers

3
votes

A similar question has been asked, please see my answer there: Android Wi-Fi Direct Network

To sum up: Multicast should work on Wi-Fi Direct in theory, but some Android devices block incoming non-unicast traffic on the stack level. Since you already have it working on the devices when using normal Wi-Fi, it seems to be another issue. Do make sure that you acquire a MulticastLock. I provided an alternative solution using unicast in the linked answer.