Changeset 4524
 Timestamp:
 10/22/09 00:19:40 (5 years ago)
 Location:
 vic/branches/cc/cc
 Files:

 2 modified
Legend:
 Unmodified
 Added
 Removed

vic/branches/cc/cc/tfwc_sndr.cpp
r4522 r4524 61 61 jacked_(0), 62 62 begins_(0), 63 ends_(0) 63 ends_(0), 64 num_elm_(1), 65 num_vec_(1) 64 66 { 65 67 // allocate tsvec_ in memory 66 68 tsvec_ = (double *)malloc(sizeof(double) * TSZ); 67 bzero(tsvec_,TSZ);69 clear_tsv(TSZ); 68 70 69 71 // allocate seqvec in memory 70 72 seqvec_ = (u_int32_t *)malloc(sizeof(u_int32_t) * SSZ); 71 bzero(seqvec_, SSZ); 73 clear_sqv(SSZ); 74 num_seqvec_ = 0; 72 75 73 76 // is TFWC running? … … 150 153 // get start/end seqno that this XR chunk reports 151 154 begins_ = begin; // lowest packet seqno 152 ends_ = end; // highest packet seqno 155 ends_ = end; // highest packet seqno plus one 153 156 154 157 // get the number of AckVec chunks … … 156 159 // (add one to num unless exactly divisible by BITLEN 157 160 //  so it is large enough to accomodate all the bits 158 int num_chunks = (ends_begins_)/BITLEN + ((ends_begins_)%BITLEN > 0); 161 num_elm_ = ends_  begins_; 162 num_vec_ = num_elm_/BITLEN + (num_elm_%BITLEN > 0); 159 163 160 164 // retrieve ackvec … … 165 169 166 170 // declared AckVec 167 ackv_ = (u_int16_t *) malloc (sizeof(u_int16_t) * num_ chunks);168 bzero(ackv_, num_chunks);171 ackv_ = (u_int16_t *) malloc (sizeof(u_int16_t) * num_vec_); 172 clear_ackv(num_vec_); 169 173 170 174 // clone AckVec from Vic 171 for (int i = 0; i < num_ chunks; i++)175 for (int i = 0; i < num_vec_; i++) 172 176 ackv_[i] = ntohs(chunk[i]); 173 177 … … 176 180 177 181 // generate seqno vector 182 clear_sqv(num_seqvec_); 178 183 gen_seqvec(ackv_); 179 184 … … 202 207 control(); 203 208 } 209 printf("\tnow: %f\tcwnd: %d\n", now_, cwnd_); 204 210 205 211 // set ackofack (real number) … … 218 224 ntep_++; // number of ts echo packet received 219 225 220 ts_echo_ = chunk[num_ chunks 1];226 ts_echo_ = chunk[num_vec_  1]; 221 227 printf(" [%s +%d] ts echo: %f\n", __FILE__,__LINE__, ts_echo_); 222 228 … … 231 237 * generate seqno vector 232 238 * (interpret the received AckVec to real sequence numbers) 233 * @num_chunks: number of AckVec chunks234 239 * @ackvec: received AckVec 235 240 */ 236 241 void TfwcSndr::gen_seqvec (u_int16_t *ackvec) { 237 // number of seqvec elements238 // (i.e., number of packets that this AckVec is representing)239 int num_elm = ends_  begins_;240 241 // number of AckVec chunks242 int x = num_elm%BITLEN;243 int num_chunks = num_elm/BITLEN + (x > 0);244 245 242 int i, j, k = 0; 243 int x = num_elm_%BITLEN; 246 244 247 245 // start of seqvec (lowest seqno) 248 246 int start = begins_; 249 247 250 for (i = 0; i < num_ chunks1; i++) {248 for (i = 0; i < num_vec_1; i++) { 251 249 for (j = BITLEN; j > 0; j) { 252 250 if( CHECK_BIT_AT(ackvec[i], j) ) 253 seqvec_[k %SSZ] = start;251 seqvec_[k++%SSZ] = start; 254 252 else num_loss_++; 255 k++;start++;253 start++; 256 254 } 257 255 } … … 259 257 int a = (x == 0) ? BITLEN : x; 260 258 for (i = a; i > 0; i) { 261 if( CHECK_BIT_AT(ackvec[num_ chunks1], i) )259 if( CHECK_BIT_AT(ackvec[num_vec_1], i) ) 262 260 seqvec_[k++%SSZ] = start; 263 261 else num_loss_++; … … 265 263 } 266 264 267 // therefore, the number of seqvec is:268 int num_seqvec = num_elm num_loss_;265 // therefore, the number of seqvec elements is: 266 num_seqvec_ = num_elm_  num_loss_; 269 267 // printing retrieved sequence numbers from received AckVec 270 print_seqvec(num_seqvec );268 print_seqvec(num_seqvec_); 271 269 } 272 270 … … 281 279 282 280 // number of tempvec element when no loss 283 int num_elm = ((end  begin + 1) < 0) ? 0 : (end  begin + 1); 284 u_int32_t tempvec[num_elm]; 281 //int num = ((end  begin + 1) < 0) ? 0 : (end  begin + 1); 282 int num = end  begin + 1; 283 printf("\tnum_tempvec: %d\n", num); 284 u_int32_t tempvec[num]; 285 285 286 286 // generate tempvec elements 287 287 printf("\tcomparing numbers: ("); 288 for (int i = 0; i < num _elm; i++) {288 for (int i = 0; i < num; i++) { 289 289 tempvec[i] = begin + i; 290 290 printf(" %d", tempvec[i]); 291 291 } printf(" )\n"); 292 292 293 // number of seqvec element294 int num_seqvec = num_elm  num_loss_;295 296 293 // compare tempvec and seqvec 297 for (int i = 0; i < num _elm; i++) {298 for (int j = num_seqvec 1; j >= 0; j) {294 for (int i = 0; i < num; i++) { 295 for (int j = num_seqvec_1; j >= 0; j) { 299 296 if (tempvec[i] == seqvec_[j]) { 300 297 is_there = true; … … 316 313 // store tempvec elements for updating loss history 317 314 first_elm_ = tempvec[0]; 318 last_elm_ = first_elm_ + num _elm;315 last_elm_ = first_elm_ + num; 319 316 320 317 return ret = (count > 0) ? true : false; 
vic/branches/cc/cc/tfwc_sndr.h
r4520 r4524 187 187 void dupack_action(); 188 188 189 // clear timestamp vector 190 inline void clear_tsv (int n) { 191 for (int i = 0; i < n; i++) 192 tsvec_[i] = 0; 193 } 194 195 // clear seqvec 196 inline void clear_sqv (int n) { 197 for (int i = 0; i < n; i++) 198 seqvec_[i] = 0; 199 } 200 201 // clear ackvec 202 inline void clear_ackv (int n) { 203 for (int i = 0; i < n; i++) 204 ackv_[i] = 0; 205 } 206 189 207 int ndtp_; // number of data packet sent 190 208 int nakp_; // number of ackvec packet received … … 198 216 199 217 u_int32_t *seqvec_; // generated seqno vec 218 int num_seqvec_; // number of seqvec elements 200 219 double *tsvec_; // timestamp vector 201 220 u_int16_t jacked_; // just acked seqno (head of ackvec) … … 241 260 u_int16_t begins_; // start seqno that this XR chunk reports 242 261 u_int16_t ends_; // end seqno + 1 that this XR chunk reports 262 int num_elm_; // number of ackvec elements 263 int num_vec_; // numver of ackvec chunks 243 264 }; 244 265