As indicated by David Martin there's a problem with the difference calculation in index_guess().
That is not the only problem with this code. It is incomplete in its ability to track the local sequence number sliding window across the sequence number range boundaries, in case the local sequence number is below halfway the range. This is the same area where David spotted his problem.
The attached patch tries to addresses both issues.
Logged In: YES
user_id=568867
Originator: NO
This patch has been superseded by patch 1867664.