Changeset 4502 for vic/branches/cc/cc/tfwc_rcvr.cpp
 Timestamp:
 08/04/09 20:34:42 (7 years ago)
 Files:

 1 modified
Legend:
 Unmodified
 Added
 Removed

vic/branches/cc/cc/tfwc_rcvr.cpp
r4500 r4502 80 80 currNumElm_ = currseq_  ackofack_; 81 81 diffNumElm = currNumElm_  prevNumElm_; 82 int x = currNumElm_%BITLEN; 83 int y = prevNumElm_%BITLEN; 82 84 83 85 // number of chunks for building tfwcAV … … 95 97 // there is no packet loss (or reordering) 96 98 if (currseq_ == prevseq_ + 1) { 97 // set next bit to 1 98 if (diffNumElm > 0  currseq_ == 1) { 99 // we just need the same number of AckVec elements, 100 // hence just left shift by one and clear the top bit 101 if (diffNumElm == 0) { 102 // set next bit to 1 99 103 SET_BIT_VEC(tfwcAV[currNumVec_1], 1); 100 } 101 // free unnecessary bits 104 105 // and clear the top bit which we don't need it anymore 106 if (x != 0) 107 CLR_BIT_AT(tfwcAV[currNumVec_1], x+1); 108 } 109 // we just need less number of AckVec elements, 110 // hence first free unnecessary AckVec chunk(s) and set bit. 102 111 else if (diffNumElm < 0) { 103 // f reeing unnecessary AcvVec chunk(s)112 // firstly, freeing unnecessary AcvVec chunk(s) 104 113 if (currNumVec_ != prevNumVec_) { 105 114 for (int i = prevNumVec_; i > currNumVec_; i) { 106 for (int j = 1; j <= 16; j++)115 for (int j = 1; j <= BITLEN; j++) 107 116 SET_BIT_VEC(tfwcAV[i1], 0); 108 117 } 109 118 } 110 111 119 // set next bit to 1 112 120 SET_BIT_VEC(tfwcAV[currNumVec_1], 1); 113 114 121 // and clear the bit(s) that we don't need it anymore 115 int k = ( currNumElm_%16 == 0) ? 16: (currNumElm_%16);116 for (int i = 16; i > k; i)122 int k = (x == 0) ? BITLEN: x; 123 for (int i = BITLEN; i > k; i) 117 124 CLR_BIT_AT(tfwcAV[currNumVec_1], i); 118 125 } 119 // we just need the same number of AckVec element 120 // (i.e., diffNumElm==0), 121 // hence just left shift by one and clear the top bit 122 else { 123 // set next bit to 1 126 // otherwise, just set next bit to 1 127 // (i.e., we need more AckVec elements) 128 else 124 129 SET_BIT_VEC(tfwcAV[currNumVec_1], 1); 125 126 // and clear the bit which we don't need it anymore127 CLR_BIT_AT(tfwcAV[currNumVec_1], currNumElm_+1);128 }129 130 } 130 131 // we have one or more packet losses (or reordering) … … 132 133 // number of packet loss 133 134 numLoss = currseq_  prevseq_  1; 135 int z = numLoss%BITLEN; 134 136 135 137 // we need more AckVec chunks (maybe one or more) 136 138 if (currNumVec_ != prevNumVec_) { 137 139 // currently available spaces in the previous tfwcAV array 138 int numAvail = 16  prevNumElm_%16;140 int numAvail = BITLEN  y; 139 141 140 142 // first, fill up zeros into those available spaces … … 149 151 // fill up zeros accordingly if addiNumVec is greater than 1 150 152 for (int i = 0; i < (addiNumVec  1); i++) { 151 for (int j = 0; j < 16; j++) {152 SET_BIT_VEC(tfwcAV[prevNumVec_ +i], 0);153 for (int j = 0; j < BITLEN; j++) { 154 SET_BIT_VEC(tfwcAV[prevNumVec_+i], 0); 153 155 numLoss; 154 156 } … … 156 158 157 159 // finally, fill up zeros at the latest AckVec chunk 158 for (int i = 0; i < (numLoss%16); i++) {159 SET_BIT_VEC(tfwcAV[prevNumVec_ + addiNumVec 1], 0);160 for (int i = 0; i < z; i++) { 161 SET_BIT_VEC(tfwcAV[prevNumVec_+addiNumVec1], 0); 160 162 } 161 163 } … … 173 175 // (because we have pushed '0' and '1' at the end of this AckVec) 174 176 // it doesn't really matter if diffNumElm is greater than 0. 175 if ( diffNumElm <= 0) {176 int b = abs(diffNumElm) + currNumElm_ + numLoss;177 for (int i = currNumElm_+1; i <= b; i++)177 if ( (diffNumElm <= 0) && (x != 0) ) { 178 int b = abs(diffNumElm) + x + z; 179 for (int i = x + 1; i <= b; i++) 178 180 CLR_BIT_AT(tfwcAV[currNumVec_1], i); 179 181 } … … 206 208 // start sequence number 207 209 int seqno = ackofack_+1; 210 int x = currNumElm_%BITLEN; 208 211 209 212 // printing... … … 211 214 for (int i = 0; i < currNumVec_1; i++) { 212 215 printf("[%d] ( ", ackv[i]); 213 for (int j = 0; j < 16; j++) {216 for (int j = 0; j < BITLEN; j++) { 214 217 if ( CHECK_BIT_AT(ackv[i], (j+1)) ) 215 218 printf("%d ", seqno); … … 218 221 } printf (") "); 219 222 220 int k = ( currNumElm_%16 == 0) ? 16: currNumElm_%16;223 int k = (x == 0) ? BITLEN: x; 221 224 printf("[%d] ( ", ackv[currNumVec_1]); 222 225 for (int i = k; i > 0; i) {