Use of a circular buffer to assure in-order delivery of packets
First Claim
1. A method of placing an incoming packet into a circular buffer based on a sequence number for the incoming packet, the method comprising:
- Calculating a write pointer offset based on the sequence number of the incoming packet and a sequence number of the packet currently associated with a buffer tail pointer for the circular buffer.
11 Assignments
0 Petitions
Accused Products
Abstract
A circular buffer is used to receive packets transmitted to an application. Normally, incoming packets are placed at the “tail” of the buffer, which is indicated by the write pointer. Packets to be used by the application are read from the “head” of the buffer, which is indicated by the read pointer. In contrast, the present invention uses the sequence number to direct the packets to specific places in the circular buffer. This inventive use of sequence number allows the packets to be written at the proper place in the buffer, regardless of the location of the write pointer. Within certain limits, a packet that arrives out of sequence is not bound by the position of the write pointer to be placed into the buffer out of sequence. This abstract is provided as a tool for those searching for patents, and not as a limitation on the scope of the claims.
-
Citations
17 Claims
-
1. A method of placing an incoming packet into a circular buffer based on a sequence number for the incoming packet, the method comprising:
Calculating a write pointer offset based on the sequence number of the incoming packet and a sequence number of the packet currently associated with a buffer tail pointer for the circular buffer. - View Dependent Claims (2, 3, 4, 5, 6)
-
7. A method of storing an incoming packet and placing a control block into a circular buffer based on a sequence number for the incoming packet, the method comprising:
-
Calculating a write pointer offset based on the sequence number of the incoming packet and a sequence number of a packet currently associated with a buffer tail pointer for the circular buffer, Writing the control block containing both the sequence number for the incoming packet and a pointer to a memory storage location, the control block written into the circular buffer based on the write pointer offset; and
Storing the incoming packet in the memory storage location corresponding to the pointer in the control block. - View Dependent Claims (8, 9, 10, 11, 12)
-
-
13. A method of determining the next circular buffer address in a circular buffer to receive a current incoming packet based on the sequence number of the current incoming packet, the method comprising:
-
A) Storing the following state variables;
Count of Sequence Numbers;
Tail Pointer wherein the Tail Pointer is a pointer to a highest circular buffer address where a packet has been written (taking wrapping of circular buffer addresses into account);
Tail Sequence Number wherein the Tail Sequence Number is a sequence number for the packet in the circular buffer address corresponding to the Tail Pointer;
Buffer Size wherein the Buffer Size is the total number of addresses for the circular buffer; and
Current Read Pointer wherein the Current Read Pointer is the circular buffer address for a next packet that will be read from the circular buffer;
B) Receiving a current packet;
C) Setting the Current Sequence Number equal to the sequence number for the current incoming packet;
D) Setting the Write Pointer Offset=(Current Sequence Number−
Tail Sequence Number);
E) Adjusting Write Pointer Offset for sequence number wrapping;
IF (Write Pointer Offset<
0−
Buffer Size)THEN Write Pointer Offset=Write Pointer Offset+Count of Sequence Numbers;
F) Adjusting Write Point Offset for going backwards across the sequence number wrap due to an out-of-order delivery;
IF (Write Pointer Offset>
Buffer Size)THEN Write Pointer=Write Pointer−
Count of Sequence Numbers;
G) Setting Buffer Spaces Used=(1+Tail Pointer−
Current Read Pointer) modulus (Buffer Size);
H) Setting Buffer Spaces Available=Buffer Size−
Buffer Spaces UsedI) Writing in-range packet;
IF (Write Pointer Offset>
Buffer Spaces Available)THEN Discard ELSE IF (Write Pointer Offset<
(1−
Buffer Spaces Used))THEN Discard ELSE New Write Pointer=(Tail Pointer+Write Pointer Offset) modulus (Buffer Size); and
Write the current incoming packet to circular buffer address indicated by the New Write Pointer; and
J) Check for new buffer tail;
IF (Current Read Pointer<
Tail Pointer<
New Write Pointer) ORIF (New Write Pointer<
Current Read Pointer<
Tail Pointer) ORIF (Tail Pointer<
New Write Pointer<
Current Read Pointer)THEN Tail Pointer=New Write Pointer; and
Tail Sequence Number=Current Sequence Number.
-
-
14. A method of storing incoming packets that includes storing control blocks comprising pointers to the stored packets and sequence numbers for the stored packets, the method including a step of determining a next circular buffer address in a circular buffer to receive the control block related to a current incoming packet, the determination based on a sequence number of the current incoming packet, the step of determining the next circular buffer address comprising:
-
A) Storing the following state variables;
Count of Sequence Numbers;
Tail Pointer wherein the Tail Pointer is a pointer to a highest circular buffer address where a control block has been written (taking wrapping of circular buffer addresses into account);
Tail Sequence Number wherein the Tail Sequence Number is a sequence number for the control block in the circular buffer address corresponding to the Tail Pointer;
Buffer Size wherein the Buffer Size is the total number of addresses for the circular buffer; and
Current Read Pointer wherein the Current Read Pointer is the circular buffer address for a next control block that will be read from the circular buffer to trigger the reading of the stored packet associated with the control block;
B) Receiving a current incoming packet;
C) Setting the Current Sequence Number equal to the sequence number for the current incoming packet;
D) Setting the Write Pointer Offset=(Current Sequence Number−
Tail Sequence Number);
E) Adjusting Write Pointer Offset for sequence number wrapping;
IF (Write Pointer Offset<
0−
Buffer Size)THEN Write Pointer Offset=Write Pointer Offset+Count of Sequence Numbers;
F) Adjusting Write Point Offset for going backwards across the sequence number wrap due to an out-of-order delivery;
IF (Write Pointer Offset>
Buffer Size)THEN Write Pointer=Write Pointer−
Count of Sequence Numbers;
G) Setting Buffer Spaces Used=(1+Tail Pointer−
Current Read Pointer) modulus (Buffer Size);
H) Setting Buffer Spaces Available=Buffer Size−
Buffer Spaces UsedI) Writing the control block for an in-range packet;
IF (Write Pointer Offset>
Buffer Spaces Available)THEN discard incoming packet ELSE IF (Write Pointer Offset<
(1−
Buffer Spaces Used))THEN discard incoming packet ELSE New Write Pointer=(Tail Pointer+Write Pointer Offset) modulus (Buffer Size); and
Write the control block for the current incoming packet to circular buffer address indicated by the New Write Pointer; and
J) Check for new buffer tail;
IF (Current Read Pointer<
Tail Pointer<
New Write Pointer) ORIF (New Write Pointer<
Current Read Pointer<
Tail Pointer) ORIF (Tail Pointer<
New Write Pointer<
Current Read Pointer)THEN Tail Pointer=New Write Pointer; and
Tail Sequence Number=Current Sequence Number.
-
-
15. An apparatus for re-ordering mildly out-of-sequence incoming packets through the use of a circular buffer, the apparatus comprising:
-
The circular buffer with a set of circular buffer memory slots, each slot having a unique circular buffer address;
A means for reading stored packets asynchronously to the arrival of new incoming packets;
A means for maintaining a tail pointer; and
A means for calculating a write pointer offset from the tail pointer to determine the circular buffer memory address to be used in connection with an incoming packet;
the means for calculating the write pointer offset including a means for determining that the incoming packet is sufficiently out-of-sequence that the incoming packet must be discarded. - View Dependent Claims (16, 17)
-
Specification