| OLD | NEW |
| (Empty) |
| 1 /***************************************************************************** | |
| 2 Copyright (c) 2001 - 2011, The Board of Trustees of the University of Illinois. | |
| 3 All rights reserved. | |
| 4 | |
| 5 Redistribution and use in source and binary forms, with or without | |
| 6 modification, are permitted provided that the following conditions are | |
| 7 met: | |
| 8 | |
| 9 * Redistributions of source code must retain the above | |
| 10 copyright notice, this list of conditions and the | |
| 11 following disclaimer. | |
| 12 | |
| 13 * Redistributions in binary form must reproduce the | |
| 14 above copyright notice, this list of conditions | |
| 15 and the following disclaimer in the documentation | |
| 16 and/or other materials provided with the distribution. | |
| 17 | |
| 18 * Neither the name of the University of Illinois | |
| 19 nor the names of its contributors may be used to | |
| 20 endorse or promote products derived from this | |
| 21 software without specific prior written permission. | |
| 22 | |
| 23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | |
| 24 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
| 25 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 26 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
| 27 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 28 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 29 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 30 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| 31 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| 32 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| 33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 34 *****************************************************************************/ | |
| 35 | |
| 36 /***************************************************************************** | |
| 37 written by | |
| 38 Yunhong Gu, last updated 01/22/2011 | |
| 39 *****************************************************************************/ | |
| 40 | |
| 41 #ifndef __UDT_LIST_H__ | |
| 42 #define __UDT_LIST_H__ | |
| 43 | |
| 44 | |
| 45 #include "udt.h" | |
| 46 #include "common.h" | |
| 47 | |
| 48 | |
| 49 class CSndLossList | |
| 50 { | |
| 51 public: | |
| 52 CSndLossList(const int& size = 1024); | |
| 53 ~CSndLossList(); | |
| 54 | |
| 55 // Functionality: | |
| 56 // Insert a seq. no. into the sender loss list. | |
| 57 // Parameters: | |
| 58 // 0) [in] seqno1: sequence number starts. | |
| 59 // 1) [in] seqno2: sequence number ends. | |
| 60 // Returned value: | |
| 61 // number of packets that are not in the list previously. | |
| 62 | |
| 63 int insert(const int32_t& seqno1, const int32_t& seqno2); | |
| 64 | |
| 65 // Functionality: | |
| 66 // Remove ALL the seq. no. that are not greater than the parameter. | |
| 67 // Parameters: | |
| 68 // 0) [in] seqno: sequence number. | |
| 69 // Returned value: | |
| 70 // None. | |
| 71 | |
| 72 void remove(const int32_t& seqno); | |
| 73 | |
| 74 // Functionality: | |
| 75 // Read the loss length. | |
| 76 // Parameters: | |
| 77 // None. | |
| 78 // Returned value: | |
| 79 // The length of the list. | |
| 80 | |
| 81 int getLossLength(); | |
| 82 | |
| 83 // Functionality: | |
| 84 // Read the first (smallest) loss seq. no. in the list and remove it. | |
| 85 // Parameters: | |
| 86 // None. | |
| 87 // Returned value: | |
| 88 // The seq. no. or -1 if the list is empty. | |
| 89 | |
| 90 int32_t getLostSeq(); | |
| 91 | |
| 92 private: | |
| 93 int32_t* m_piData1; // sequence number starts | |
| 94 int32_t* m_piData2; // seqnence number ends | |
| 95 int* m_piNext; // next node in the list | |
| 96 | |
| 97 int m_iHead; // first node | |
| 98 int m_iLength; // loss length | |
| 99 int m_iSize; // size of the static array | |
| 100 int m_iLastInsertPos; // position of last insert node | |
| 101 | |
| 102 pthread_mutex_t m_ListLock; // used to synchronize list operation | |
| 103 | |
| 104 private: | |
| 105 CSndLossList(const CSndLossList&); | |
| 106 CSndLossList& operator=(const CSndLossList&); | |
| 107 }; | |
| 108 | |
| 109 //////////////////////////////////////////////////////////////////////////////// | |
| 110 | |
| 111 class CRcvLossList | |
| 112 { | |
| 113 public: | |
| 114 CRcvLossList(const int& size = 1024); | |
| 115 ~CRcvLossList(); | |
| 116 | |
| 117 // Functionality: | |
| 118 // Insert a series of loss seq. no. between "seqno1" and "seqno2" into
the receiver's loss list. | |
| 119 // Parameters: | |
| 120 // 0) [in] seqno1: sequence number starts. | |
| 121 // 1) [in] seqno2: seqeunce number ends. | |
| 122 // Returned value: | |
| 123 // None. | |
| 124 | |
| 125 void insert(const int32_t& seqno1, const int32_t& seqno2); | |
| 126 | |
| 127 // Functionality: | |
| 128 // Remove a loss seq. no. from the receiver's loss list. | |
| 129 // Parameters: | |
| 130 // 0) [in] seqno: sequence number. | |
| 131 // Returned value: | |
| 132 // if the packet is removed (true) or no such lost packet is found (fal
se). | |
| 133 | |
| 134 bool remove(const int32_t& seqno); | |
| 135 | |
| 136 // Functionality: | |
| 137 // Remove all packets between seqno1 and seqno2. | |
| 138 // Parameters: | |
| 139 // 0) [in] seqno1: start sequence number. | |
| 140 // 1) [in] seqno2: end sequence number. | |
| 141 // Returned value: | |
| 142 // if the packet is removed (true) or no such lost packet is found (fal
se). | |
| 143 | |
| 144 bool remove(const int32_t& seqno1, const int32_t& seqno2); | |
| 145 | |
| 146 // Functionality: | |
| 147 // Find if there is any lost packets whose sequence number falling seqn
o1 and seqno2. | |
| 148 // Parameters: | |
| 149 // 0) [in] seqno1: start sequence number. | |
| 150 // 1) [in] seqno2: end sequence number. | |
| 151 // Returned value: | |
| 152 // True if found; otherwise false. | |
| 153 | |
| 154 bool find(const int32_t& seqno1, const int32_t& seqno2) const; | |
| 155 | |
| 156 // Functionality: | |
| 157 // Read the loss length. | |
| 158 // Parameters: | |
| 159 // None. | |
| 160 // Returned value: | |
| 161 // the length of the list. | |
| 162 | |
| 163 int getLossLength() const; | |
| 164 | |
| 165 // Functionality: | |
| 166 // Read the first (smallest) seq. no. in the list. | |
| 167 // Parameters: | |
| 168 // None. | |
| 169 // Returned value: | |
| 170 // the sequence number or -1 if the list is empty. | |
| 171 | |
| 172 int getFirstLostSeq() const; | |
| 173 | |
| 174 // Functionality: | |
| 175 // Get a encoded loss array for NAK report. | |
| 176 // Parameters: | |
| 177 // 0) [out] array: the result list of seq. no. to be included in NAK. | |
| 178 // 1) [out] physical length of the result array. | |
| 179 // 2) [in] limit: maximum length of the array. | |
| 180 // Returned value: | |
| 181 // None. | |
| 182 | |
| 183 void getLossArray(int32_t* array, int& len, const int& limit); | |
| 184 | |
| 185 private: | |
| 186 int32_t* m_piData1; // sequence number starts | |
| 187 int32_t* m_piData2; // sequence number ends | |
| 188 int* m_piNext; // next node in the list | |
| 189 int* m_piPrior; // prior node in the list; | |
| 190 | |
| 191 int m_iHead; // first node in the list | |
| 192 int m_iTail; // last node in the list; | |
| 193 int m_iLength; // loss length | |
| 194 int m_iSize; // size of the static array | |
| 195 | |
| 196 private: | |
| 197 CRcvLossList(const CRcvLossList&); | |
| 198 CRcvLossList& operator=(const CRcvLossList&); | |
| 199 }; | |
| 200 | |
| 201 | |
| 202 #endif | |
| OLD | NEW |