Rollover Issue

R

raj

Hi,

I am dealing with the sequence number rollover issue.
I need to compare the incoming packet sequence number w/ the one in the
table. There is good possibility that the incoming packet sequence number
has rolledover. I am using Unsigned data type to store the sequence number.
I read somewhere that I 've to do Signed arithmetic to deal with it.

I would appreciate if you can help me out. (Pseudo code would be helpful)

Thanks.
 
N

Nick Austin

Hi,

I am dealing with the sequence number rollover issue.
I need to compare the incoming packet sequence number w/ the one in the
table. There is good possibility that the incoming packet sequence number
has rolledover. I am using Unsigned data type to store the sequence number.
I read somewhere that I 've to do Signed arithmetic to deal with it.

You mean something like this:

#define N 64

unsigned long difference( unsigned long seq1, unsigned long seq2 )
{
return ( seq2 + N - seq1 ) % N;
}

Nick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top