[Live-devel] Out of order packets

Ross Finlayson finlayson at live555.com
Fri Sep 15 16:29:39 PDT 2006


>Assume the server is sending the stream starting with sequence number 65000.
>Assume there is a out of order packet for the sequence number 65500. When
>the sequence number is wrapped around, the sequence number starts with zero.
>In the client side, in the noteIncomingPacket() function, the variable
>"newSeqNum" becomes 65536. At this point of time, if the client receives out
>of order packet with sequence number 65500, then the variable "newSeqNum"
>becomes 131036, which we feel is a wrong number.

OK, thanks for the explanation.

You can fix this problem by replacing the following code (in "RTPSource.cpp"):

   // Check whether the sequence number has wrapped around:
   unsigned seqNumCycle = (fHighestExtSeqNumReceived&0xFFFF0000);
   unsigned oldSeqNum = (fHighestExtSeqNumReceived&0xFFFF);
   unsigned seqNumDifference = (unsigned)((int)seqNum-(int)oldSeqNum);
   if (seqNumDifference >= 0x8000
       && seqNumLT((u_int16_t)oldSeqNum, seqNum)) {
     // sequence number wrapped around => start a new cycle:
     seqNumCycle += 0x10000;
   }

   unsigned newSeqNum = seqNumCycle|seqNum;
   if (newSeqNum > fHighestExtSeqNumReceived) {
     fHighestExtSeqNumReceived = newSeqNum;
   }

with

   // Check whether the new sequence number is the highest yet seen:
   unsigned oldSeqNum = (fHighestExtSeqNumReceived&0xFFFF);
   if (seqNumLT((u_int16_t)oldSeqNum, seqNum)) {
     // This packet was not an old packet received out of order, so check it:
     unsigned seqNumCycle = (fHighestExtSeqNumReceived&0xFFFF0000);
     unsigned seqNumDifference = (unsigned)((int)seqNum-(int)oldSeqNum);
     if (seqNumDifference >= 0x8000) {
       // The sequence number wrapped around, so start a new cycle:
       seqNumCycle += 0x10000;
     }

     unsigned newSeqNum = seqNumCycle|seqNum;
     if (newSeqNum > fHighestExtSeqNumReceived) {
       fHighestExtSeqNumReceived = newSeqNum;
     }
   }

This change will be included in the next release of the software.
-- 

Ross Finlayson
Live Networks, Inc.
http://www.live555.com/


More information about the live-devel mailing list