-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
packet: add IsSynced i/o helper and reduce false positive rate of Sync #97
Conversation
ping |
Why is this necessary? |
Also, please provide a summary of what this change does |
This is necessary because the function claims correctness that it cannot provide, with significant amounts of work. The sync byte is a poor mark of packet boundaries, but it is what we have. Howevere, it's not intended to be used in a multiple testing scenario. Under correct use, you have a p=1/256 probability of getting an incorrectly positive claim that a stream offset is the start of a packet given a uniform probability of each byte in a stream. This significantly degrades when an arbitrary scan forward for sync bytes is done; if a false positive rate of 10p (ten times worse than the correct usage) is allowed, you will expect a false positive within 11 bytes. This degradation of the false positive rate is presumably why the double byte check with a 188 byte offset is done in the current code, this however only increased the expected distance between false positives to just over 2.5kB, with a systematic false positive introduced when the next packet's sync byte cannot be read (e.g. at the last packet). The way the work is currently done in The change to The addition of |
While we can all agree the current approach is flawed, I'm not sure decreasing our confidence of being synced with a stream by an order of magnitude and then passing the onus of being synced onto the user's plate is really the correct course of action here. I'm going to push back on the assertion that "the sync byte is all we have." What we really have is a 32 bit MPEG2-TS header, with 8 bits that must be a fixed value (0x47), 13 bits that cannot be 0x0004-0x000F (reserved range of PID values), and 2 bits that cannot be 00 (reserved I do agree with the decision to include the |
To be clear, my preferred option would be to delete However, with 15 of 32 bits with the pattern you point out, constrained we can scan 341B without an expected false positive with single packet checks (as expected better than the current situation and without false negatives at the ends of streams). I can make that change, but I think a warning on the function is worthwhile as well. |
Sorry, that estimate is optimistic. I'll fix it momentarily. |
ping |
kortschak, It sounded to me like you were going to make the change to use other header info to help sync the stream with greater reliability. That's what I would like to see. I think that while the original change may be technically correct, we have to weigh the practicalities of such a change. |
@BlakeOrth's comment indicated more discussion was necessary. I didn't get a reply to my assessment, so I didn't proceed with potentially futile work. |
ping |
ping |
78f02e2
to
b310632
Compare
Hi Dan, sorry for the delay, I've been focused on other things. The reality of the situation is that we need to strike some balance between practical and "technically correct". Unfortunately I believe the removing I would also like to reiterate that including the |
Please take a look at the code. |
Note also that the change here fixes #110. |
In implementing the additional parts of the Despite all this, with #110, the issue is now not just about technical correctness versus practicality, but actually broken code. Under go1.12 the current code fails tests. go1.12 is planned to be released in three week. It would be very nice if we could get something merged that will stop this code being broken. |
ping |
This looks good to me. I'm going to give @guygrigsby a little time to respond if he feels the need, otherwise I'll merge this in tomorrow. Thanks for the contribution! Also note this Fixes #110 |
For the sake of the bug tracker. Fixes #110. |
@kortschak Sorry, but could you quickly rebase this onto the most recent commit in master? |
The change to Sync significantly decreases the chance of a false positive but the approach of walking to a header is still statistically flawed.
Done Contributing here has been not the most frictionless work I've done. |
Feedback noted, sorry about that. |
Thanks |
Comcast#97) The change to Sync significantly decreases the chance of a false positive but the approach of walking to a header is still statistically flawed.
Please take a look.
The change to Sync here increases the false positive rate for finding packet starts, but the approach to walking to a sync byte is statistically flawed (it's a multiple testing issue) and I'd recommend that the function actually just gets removed (I'm happy to do that here).
Updates #87.