Changeset 1971 for features/performance/src/send_packets.c
- Timestamp:
- 04/09/08 15:37:35 (9 months ago)
- Files:
-
- 1 modified
-
features/performance/src/send_packets.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
features/performance/src/send_packets.c
r1970 r1971 327 327 static int adjuster_flipper = 0; 328 328 #ifdef HAVE_TCPREPLAY 329 struct time val adjuster = { 0, OPT_VALUE_SLEEP_ACCEL}329 struct timespec adjuster = { 0, OPT_VALUE_SLEEP_ACCEL * 1000 } 330 330 #else 331 struct time val adjuster = { 0, ADJUSTER_OFFSET};332 #endif 333 static struct time valnap = { 0, 0 };331 struct timespec adjuster = { 0, ADJUSTER_OFFSET * 1000 }; 332 #endif 333 static struct timespec nap = { 0, 0 }; 334 334 static u_int32_t double_up = 0; 335 struct timeval n ow, sleep_until, nap_this_time;336 struct timespec ignore, sleep ;335 struct timeval nap_for, now, sleep_until; 336 struct timespec ignore, sleep, nap_this_time; 337 337 float n; 338 338 static u_int32_t send = 0; /* accellerator. # of packets to send w/o sleeping */ 339 u_int 32_t ppusec; /* packets per usec */339 u_int64_t ppnsec; /* packets per usec */ 340 340 341 341 /* just return if topspeed */ … … 373 373 */ 374 374 if (timerisset(last) && timercmp(time, last, >)) { 375 timersub(time, last, &nap); 376 timerdiv(&nap, options.speed.speed); 375 timersub(time, last, &nap_for); 376 TIMEVAL_TO_TIMESPEC(&nap_for, &nap); 377 timesdiv(&nap, options.speed.speed); 377 378 } 378 379 else { … … 382 383 * last packet. 383 384 */ 384 time rclear(&nap);385 timesclear(&nap); 385 386 } 386 387 break; … … 394 395 n = (float)len / (options.speed.speed * 1024 * 1024 / 8); /* convert Mbps to bps */ 395 396 nap.tv_sec = n; 396 nap.tv_ usec = (n - nap.tv_sec) * 1000000;397 nap.tv_nsec = (n - nap.tv_sec) * 1000000000; 397 398 dbgx(3, "packet size %d\t\tequals %f bps\t\tnap " TIMEVAL_FORMAT, len, n, 398 nap.tv_sec, nap.tv_ usec);399 nap.tv_sec, nap.tv_nsec); 399 400 } 400 401 else { 401 402 /* don't sleep at all for the first packet */ 402 time rclear(&nap);403 timesclear(&nap); 403 404 } 404 405 break; … … 406 407 case SPEED_PACKETRATE: 407 408 /* only need to calculate this the first time */ 408 if (! time risset(&nap)) {409 if (! timesisset(&nap)) { 409 410 /* run in packets/sec */ 410 pp usec = 1000000 / options.speed.speed;411 MICROSEC_TO_TIMEVAL(ppusec, &nap);412 dbgx(1, "sending 1 packet per %lu usec", nap.tv_usec);411 ppnsec = 1000000000 / options.speed.speed; 412 NANOSEC_TO_TIMESPEC(ppnsec, &nap); 413 dbgx(1, "sending 1 packet per %lu nsec", nap.tv_nsec); 413 414 } 414 415 break; … … 439 440 */ 440 441 nap_this_time.tv_sec = nap.tv_sec; 441 nap_this_time.tv_ usec = nap.tv_usec;442 nap_this_time.tv_nsec = nap.tv_nsec; 442 443 443 444 /* apply the adjuster... */ 444 if (time risset(&adjuster)) {445 if (time rcmp(&nap_this_time, &adjuster, >)) {446 time rsub(&nap_this_time, &adjuster, &nap_this_time);447 dbgx(1, "adjusting nap_this_time by %lu usec", adjuster.tv_usec);445 if (timesisset(&adjuster)) { 446 if (timescmp(&nap_this_time, &adjuster, >)) { 447 timessub(&nap_this_time, &adjuster, &nap_this_time); 448 dbgx(1, "adjusting nap_this_time by %lu nsec", adjuster.tv_nsec); 448 449 } else { 449 450 dbg(1, "resetting nap_this_time to 0"); 450 time rclear(&nap_this_time);451 timesclear(&nap_this_time); 451 452 } 452 453 } 453 454 454 455 /* don't sleep if nap = { 0, 0} */ 455 if (!time risset(&nap_this_time))456 if (!timesisset(&nap_this_time)) 456 457 return; 457 458
