Multipeer Framework iOS reliable

243 Views Asked by At

Can someone steer me to documentation on how the Reliable option works for sendData using Apple's Multipeer Framework for iOS? From what I can learn, it guarantees delivery in the right order, but what happens when the connection between peers is unreliable? When the two devices reconnect, will they resume transmission? If the receiver goes away permanently, what's the mechanism to tell the sender's app that the message failed in order to start recovery? At what point does the sender's outbound queue get cleared? Thanks!

1

There are 1 best solutions below

0
On

Lacking any info, I implemented a numbered packet scheme whereby the sender sends to the receiver a sequential 'packet' number and a pre-assigned sender ID embedded in the data that remains constant thru crashes, reboots, etc. All transmissions are queued at the sender in the event resending is required. When the receiver gets the message, it pulls the 'packet' number out and performs one of three actions:

  • if it was the expected next packet (base on tracking the packets already received from the sender), it processes it and tells the sender to remove it from its transmission queue.
  • if a packet number was skipped, it ignores it and asks the sender to resend everything in the queue beginning with that packet.
  • if the packet number was already received, it discards it as a duplicate although it signals the sender that it can remove it from its transmission queue.

In normal operation, this scheme relies on the "reliable" setting to deliver the messages in sequence. However, the second and third options are critical in the event of a disconnect/reconnect since it prevents duplicate and lost messages.