Closed mafradan closed 1 year ago
Hello, please see my app which makes use of this repository as an example. Happy to answer any questions.
Hello, thank you very much. I'm giving a look at it. Not completely clear because I can't build a stable version of Airly (the receiver crashes on my iPads/iPhones) but I think I'll get something useful out of it anyway. What I haven't understood so far is how you calculate the network latency - my big problem at the moment. My approach is more... say 'empirical', yours looks like a more 'scientific' one ;) Thank you again!
Hi Daniele,
Sorry about that, that project has been archived and not updated for a while. The function that calculates the offset between peer and host is here. Essentially it sends a packet to the host, asks the host to add the time it received it and send it immediately back. Then the peer notes the time it received the packet back, and can calculate the one-way time. Do that many times and take a rolling average, until the average stabilizes. That gets you a good approximation.
This is essentially an implementation of the Precision Time Protocol. Though surprisingly I learned of PTP after I wrote this library, so there may be some minor differences.
Thank you for focusing the function: I start understanding your code :) My point is this: I need a single synched event a few tenths of a second after the user taps a button (I need a precision of ~1/30 of a second, or 30 milliseconds). The problem is that I've seen that the latency is not constant: it varies based on... don't know what, but it differs from call to call. But if I send a number of calls at regular intervals (say every 1/2 of a second), the latency (apparently) tends to assume a cyclic behavior. So, what I was trying to do is to predict the next latency value based on the previous one(s): first I analyze the cycle, if it exists, then (with some regression algorithm or something like that) I predict the next one. This way I could possibly-hopefully-joining-hands-in-prayer try to sync my event. Of course this procedure is performed on all the peers linked to the host, because each peer has a different latency.
Thank you for your time and for the link to PTP! I'll deep dive into it.
Modeling latency can be very tough, there is quite a bit of research out there regarding this. But in the case of a phone, it sufficient for the user to walk around for it to drastically change. Your best best would be to calibrate a few moments before you expect the user to tap the button, then once tapped send the execution request. 30ms is plenty of leeway and should be easily achievable with this library which I used for sub ms precision.
Modeling latency can be very tough, there is quite a bit of research out there regarding this. But in the case of a phone, it sufficient for the user to walk around for it to drastically change. Your best best would be to calibrate a few moments before you expect the user to tap the button, then once tapped send the execution request. 30ms is plenty of leeway and should be easily achievable with this library which I used for sub ms precision.
Thank you!
Hi, I'd like to understand more about your Synaction library: I'm developing a new feature for my app ('DSLR Clapperboard' on the app store) and it requires the synchronization of two or more iOS devices to work.
Can you help me understanding how to use your library?
My app already uses the Multipeer Connectivity (for specific features), but if I'm not wrong your library uses a custom setup through 'ASyncSocket'. So I imported the pod in my project, and I added the files for both the connectivity and the synaction itself. It throws no errors and if I try to establish a connection I can see it's all right in the Log. How can I show the browser to actually connect the devices? And, once done with the network part, how am I intended to sync the devices to perform a single action at the same time? Thank you for you help, Daniele