1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791
|
/*
* Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
* 2002, 2003, 2004
* Ohio University.
*
* ---
*
* Starting with the release of tcptrace version 6 in 2001, tcptrace
* is licensed under the GNU General Public License (GPL). We believe
* that, among the available licenses, the GPL will do the best job of
* allowing tcptrace to continue to be a valuable, freely-available
* and well-maintained tool for the networking community.
*
* Previous versions of tcptrace were released under a license that
* was much less restrictive with respect to how tcptrace could be
* used in commercial products. Because of this, I am willing to
* consider alternate license arrangements as allowed in Section 10 of
* the GNU GPL. Before I would consider licensing tcptrace under an
* alternate agreement with a particular individual or company,
* however, I would have to be convinced that such an alternative
* would be to the greater benefit of the networking community.
*
* ---
*
* This file is part of Tcptrace.
*
* Tcptrace was originally written and continues to be maintained by
* Shawn Ostermann with the help of a group of devoted students and
* users (see the file 'THANKS'). The work on tcptrace has been made
* possible over the years through the generous support of NASA GRC,
* the National Science Foundation, and Sun Microsystems.
*
* Tcptrace is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Tcptrace is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tcptrace (in the file 'COPYING'); if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Author: Shawn Ostermann
* School of Electrical Engineering and Computer Science
* Ohio University
* Athens, OH
* ostermann@cs.ohiou.edu
* http://www.tcptrace.org/
*/
#include "tcptrace.h"
static char const GCC_UNUSED copyright[] =
"@(#)Copyright (c) 2004 -- Ohio University.\n";
static char const GCC_UNUSED rcsid[] =
"@(#)$Header: /usr/local/cvs/tcptrace/rexmit.c,v 5.14 2003/11/19 14:38:05 sdo Exp $";
/*
* rexmit.c -- Determine if a segment is a retransmit and perform RTT stats
*
* Author: Sita Menon
* Computer Science Department
* Ohio University
* Date: Tue Nov 1, 1994
*/
/*
This function rexmit() checks to see if a particular packet
is a retransmit. It returns 0 if it isn't a retransmit and
returns the number of bytes retransmitted if it is a retransmit -
considering the fact that it might be a partial retransmit.
It can also keep track of packets that come out of order.
*/
/* locally global variables*/
/* local routine definitions*/
static void insert_seg_between (quadrant *,
segment *,
segment *,
segment *);
static void collapse_quad (quadrant *);
static segment *create_seg (seqnum,
seglen);
static quadrant *whichquad (seqspace *,
seqnum);
static quadrant *create_quadrant (void);
static int addseg (tcb *,
quadrant *,
seqnum,
seglen,
Bool *);
static void rtt_retrans (tcb *,
segment *);
static enum t_ack rtt_ackin (tcb *,
segment *,
Bool rexmit);
static void dump_rtt_sample (tcb *,
segment *,
double);
static void graph_rtt_sample (tcb *,
segment *,
unsigned long);
/*
* rexmit: is the specified segment a retransmit?
* returns: number of retransmitted bytes in segment, 0 if not a rexmit
* *pout_order to to TRUE if segment is out of order
*/
int
rexmit (tcb * ptcb,
seqnum seq,
seglen len,
Bool * pout_order)
{
seqspace *sspace = ptcb->ss;
seqnum seq_last = seq + len - 1;
quadrant *pquad;
int rexlen = 0;
/* unless told otherwise, it's IN order */
*pout_order = FALSE;
/* see which quadrant it starts in */
pquad = whichquad (sspace, seq);
/* add the new segment into the segment database */
if (BOUNDARY (seq, seq_last)) {
/* lives in two different quadrants (can't be > 2) */
seqnum seq1, seq2;
u_long len1, len2;
/* in first quadrant */
seq1 = seq;
len1 = LAST_SEQ (QUADNUM (seq1)) - seq1 + 1;
rexlen = addseg (ptcb, pquad, seq1, len1, pout_order);
/* in second quadrant */
seq2 = FIRST_SEQ (QUADNUM (seq_last));
len2 = len - len1;
rexlen += addseg (ptcb, pquad->next, seq2, len2, pout_order);
} else {
rexlen = addseg (ptcb, pquad, seq, len, pout_order);
}
return (rexlen);
}
/********************************************************************/
static int
addseg (tcb * ptcb,
quadrant * pquad,
seqnum thisseg_firstbyte,
seglen len,
Bool * pout_order)
{
seqnum thisseg_lastbyte = thisseg_firstbyte + len - 1;
segment *pseg;
segment *pseg_new;
int rexlen = 0;
Bool split = FALSE;
/* check each segment in the segment list */
pseg = pquad->seglist_head;
/* (optimize expected case, it just goes at the end) */
if (pquad->seglist_tail &&
(thisseg_firstbyte > pquad->seglist_tail->seq_lastbyte))
pseg = NULL;
for (; pseg != NULL; pseg = pseg->next) {
if (thisseg_firstbyte > pseg->seq_lastbyte) {
/* goes beyond this one */
continue;
}
if (thisseg_firstbyte < pseg->seq_firstbyte) {
/* starts BEFORE this recorded segment */
/* if it also FINISHES before this segment, then it's */
/* out of order (otherwise it's a resend the collapsed */
/* multiple segments into one */
if (thisseg_lastbyte < pseg->seq_lastbyte)
*pout_order = TRUE;
/* make a new segment record for it */
pseg_new = create_seg (thisseg_firstbyte, len);
insert_seg_between (pquad, pseg_new, pseg->prev, pseg);
/* see if we overlap the next segment in the list */
if (thisseg_lastbyte < pseg->seq_firstbyte) {
/* we don't overlap, so we're done */
return (rexlen);
} else {
/* overlap him, split myself in 2 */
/* adjust new piece to mate with old piece */
pseg_new->seq_lastbyte = pseg->seq_firstbyte - 1;
/* pretend to be just the second half of this segment */
pseg_new->seq_lastbyte = pseg->seq_firstbyte - 1;
thisseg_firstbyte = pseg->seq_firstbyte;
len = thisseg_lastbyte - thisseg_firstbyte + 1;
/* fall through */
}
}
/* no ELSE, we might have fallen through */
if (thisseg_firstbyte >= pseg->seq_firstbyte) {
/* starts within this recorded sequence */
++pseg->retrans;
if (!split)
rtt_retrans (ptcb, pseg); /* must be a retransmission */
if (thisseg_lastbyte <= pseg->seq_lastbyte) {
/* entirely contained within this sequence */
rexlen += len;
return (rexlen);
}
/* else */
/* we extend beyond this sequence, split ourself in 2 */
/* (pretend to be just the second half of this segment) */
split = TRUE;
rexlen += pseg->seq_lastbyte - thisseg_firstbyte + 1;
thisseg_firstbyte = pseg->seq_lastbyte + 1;
len = thisseg_lastbyte - thisseg_firstbyte + 1;
}
}
/* if we got to the end, then it doesn't go BEFORE anybody, */
/* tack it onto the end */
pseg_new = create_seg (thisseg_firstbyte, len);
insert_seg_between (pquad, pseg_new, pquad->seglist_tail, NULL);
return (rexlen);
}
/**********************************************************************/
static segment *
create_seg (seqnum seq,
seglen len)
{
segment *pseg;
pseg = (segment *) MallocZ (sizeof (segment));
pseg->time = current_time;
pseg->seq_firstbyte = seq;
pseg->seq_lastbyte = seq + len - 1;
return (pseg);
}
/**********************************************************************/
static quadrant *
create_quadrant (void)
{
quadrant *pquad;
pquad = (quadrant *) MallocZ (sizeof (quadrant));
return (pquad);
}
/********************************************************************/
static quadrant *
whichquad (seqspace * sspace,
seqnum seq)
{
quadnum qid = QUADNUM (seq);
quadrant *pquad;
int qix;
int qix_next;
int qix_opposite;
int qix_prev;
/* optimize expected case, it's all set up correctly already */
qix = qid - 1;
if ((pquad = sspace->pquad[qix]) && pquad->next && pquad->prev)
return (pquad);
/* determine indices of "neighbor" quadrants */
qix_next = (qix + 1) % 4;
qix_opposite = (qix + 2) % 4;
qix_prev = (qix + 3) % 4;
/* make sure that THIS quadrant exists */
if (sspace->pquad[qix] == NULL) {
sspace->pquad[qix] = create_quadrant ();
}
/* make sure that the quadrant AFTER this one exists */
if (sspace->pquad[qix_next] == NULL) {
sspace->pquad[qix_next] = create_quadrant ();
}
/* make sure that the quadrant BEFORE this one exists */
if (sspace->pquad[qix_prev] == NULL) {
sspace->pquad[qix_prev] = create_quadrant ();
}
/* clear out the opposite side, we don't need it anymore */
if (sspace->pquad[qix_opposite] != NULL) {
freequad (&sspace->pquad[qix_opposite]);
sspace->pquad[qix_opposite] = NULL;
}
/* set all the pointers */
sspace->pquad[qix]->prev = sspace->pquad[qix_prev];
sspace->pquad[qix]->next = sspace->pquad[qix_next];
sspace->pquad[qix_next]->prev = sspace->pquad[qix];
sspace->pquad[qix_prev]->next = sspace->pquad[qix];
sspace->pquad[qix_next]->next = NULL;
sspace->pquad[qix_prev]->prev = NULL;
return (sspace->pquad[qix]);
}
/*********************************************************************/
static void
collapse_quad (quadrant * pquad)
{
Bool freed;
segment *pseg;
segment *tmpseg;
if ((pquad == NULL) || (pquad->seglist_head == NULL))
return;
pseg = pquad->seglist_head;
while (pseg != NULL) {
freed = FALSE;
if (pseg->next == NULL)
break;
/* if this segment has not been ACKed, then neither have the */
/* ones that follow, so no need to continue */
if (!pseg->acked)
break;
/* if this segment and the next one have both been ACKed and they */
/* "fit together", then collapse them into one (larger) segment */
if (pseg->acked && pseg->next->acked &&
(pseg->seq_lastbyte + 1 == pseg->next->seq_firstbyte)) {
pseg->seq_lastbyte = pseg->next->seq_lastbyte;
/* the new ACK count is the ACK count of the later segment */
pseg->acked = pseg->next->acked;
/* the new "transmit time" is the greater of the two */
if (tv_gt (pseg->next->time, pseg->time))
pseg->time = pseg->next->time;
tmpseg = pseg->next;
pseg->next = pseg->next->next;
if (pseg->next != NULL)
pseg->next->prev = pseg;
if (tmpseg == pquad->seglist_tail)
pquad->seglist_tail = pseg;
free (tmpseg);
freed = TRUE;
}
if (!freed)
pseg = pseg->next;
/* else, see if the next one also can be collapsed into me */
}
/* see if the quadrant is now "full" */
if ((pquad->seglist_head->seq_lastbyte -
pquad->seglist_head->seq_firstbyte + 1) == QUADSIZE) {
pquad->full = TRUE;
}
}
static void
insert_seg_between (quadrant * pquad,
segment * pseg_new,
segment * pseg_before,
segment * pseg_after)
{
/* fix forward pointers */
pseg_new->next = pseg_after;
if (pseg_after != NULL) {
pseg_after->prev = pseg_new;
} else {
/* I'm the tail of the list */
pquad->seglist_tail = pseg_new;
}
/* fix backward pointers */
pseg_new->prev = pseg_before;
if (pseg_before != NULL) {
pseg_before->next = pseg_new;
} else {
/* I'm the head of the list */
pquad->seglist_head = pseg_new;
}
}
static enum t_ack
rtt_ackin (tcb * ptcb,
segment * pseg,
Bool rexmit_prev)
{
double etime_rtt;
enum t_ack ret;
u_long current_size = 0;
/* how long did it take */
etime_rtt = elapsed (pseg->time, current_time);
if (rexmit_prev) {
/* first, check for the situation in which the segment being ACKed */
/* was sent a while ago, and we've been piddling around */
/* retransmitting lost segments that came before it */
ptcb->rtt_last = 0.0; /* don't use this sample, it's very long */
etime_rtt = 0.0;
++ptcb->rtt_nosample; /* no sample, even though not ambig */
ret = NOSAMP;
} else if (pseg->retrans == 0) {
ptcb->rtt_last = etime_rtt;
if ((ptcb->rtt_min == 0) || (ptcb->rtt_min > etime_rtt))
ptcb->rtt_min = etime_rtt;
if (ptcb->rtt_max < etime_rtt)
ptcb->rtt_max = etime_rtt;
ptcb->rtt_sum += etime_rtt;
ptcb->rtt_sum2 += etime_rtt * etime_rtt;
++ptcb->rtt_count;
/* Collecting stats for full size segments */
/* Calculate the current_size of the segment,
taking care of possible sequence space wrap around */
if (pseg->seq_lastbyte > pseg->seq_firstbyte)
current_size = pseg->seq_lastbyte - pseg->seq_firstbyte + 1;
else
/* MAX_32 is 0x1,0000,0000
So we don't need the "+ 1" while calculating the size here */
current_size =
(MAX_32 - pseg->seq_firstbyte) + pseg->seq_lastbyte;
if (!ptcb->rtt_full_size || (ptcb->rtt_full_size < current_size)) {
/* Found a bigger segment.. Reset all stats. */
ptcb->rtt_full_size = current_size;
ptcb->rtt_full_min = etime_rtt;
ptcb->rtt_full_max = etime_rtt;
ptcb->rtt_full_sum = etime_rtt;
ptcb->rtt_full_sum2 = (etime_rtt * etime_rtt);
ptcb->rtt_full_count = 1;
} else if (ptcb->rtt_full_size == current_size) {
++ptcb->rtt_full_count;
if ((ptcb->rtt_full_min == 0)
|| (ptcb->rtt_full_min > etime_rtt))
ptcb->rtt_full_min = etime_rtt;
if (ptcb->rtt_full_max < etime_rtt)
ptcb->rtt_full_max = etime_rtt;
ptcb->rtt_full_sum += etime_rtt;
ptcb->rtt_full_sum2 += (etime_rtt * etime_rtt);
}
ret = NORMAL;
} else {
/* retrans, can't use it */
if ((ptcb->rtt_min_last == 0) || (ptcb->rtt_min_last > etime_rtt))
ptcb->rtt_min_last = etime_rtt;
if (ptcb->rtt_max_last < etime_rtt)
ptcb->rtt_max_last = etime_rtt;
ptcb->rtt_sum_last += etime_rtt;
ptcb->rtt_sum2_last += etime_rtt * etime_rtt;
++ptcb->rtt_count_last;
++ptcb->rtt_amback; /* ambiguous ACK */
/* numbers not useful for plotting/dumping */
ptcb->rtt_last = 0.0;
etime_rtt = 0.0;
ret = AMBIG;
}
/* dump RTT samples, if asked */
if (dump_rtt && (etime_rtt != 0.0)) {
dump_rtt_sample (ptcb, pseg, etime_rtt);
}
/* plot RTT samples, if asked */
if (graph_rtt && (pseg->retrans == 0)) {
graph_rtt_sample (ptcb, pseg, etime_rtt);
}
return (ret);
}
static void
rtt_retrans (tcb * ptcb,
segment * pseg)
{
double etime;
if (!pseg->acked) {
/* if it was acked, then it's been collapsed and these */
/* are no longer meaningful */
etime = elapsed (pseg->time, current_time);
if (pseg->retrans > ptcb->retr_max)
ptcb->retr_max = pseg->retrans;
if (etime > ptcb->retr_max_tm)
ptcb->retr_max_tm = etime;
if ((ptcb->retr_min_tm == 0) || (etime < ptcb->retr_min_tm))
ptcb->retr_min_tm = etime;
ptcb->retr_tm_sum += etime;
ptcb->retr_tm_sum2 += etime * etime;
++ptcb->retr_tm_count;
}
pseg->time = current_time;
}
enum t_ack
ack_in (tcb * ptcb,
seqnum ack,
unsigned tcp_data_length,
u_long eff_win)
{
quadrant *pquad;
quadrant *pquad_prev;
segment *pseg;
Bool changed_one = FALSE;
Bool intervening_xmits = FALSE;
timeval last_xmit = { 0, 0 };
enum t_ack ret = 0;
enum dup_ack_handling { BSD_VERSION = 1, /* Handling of duplicate ack's
based on the specifications of
BSD code */
LEGACY_VERSION = 2 /* Handling of duplicate ack's according to the
old versions of "tcptrace" */
};
enum dup_ack_handling dup_ack_type; /* default type is the code based on
BSD specifications */
/* check each segment in the segment list for the PREVIOUS quadrant */
pquad = whichquad (ptcb->ss, ack);
pquad_prev = pquad->prev;
for (pseg = pquad_prev->seglist_head; pseg != NULL; pseg = pseg->next) {
if (!pseg->acked) {
++pseg->acked;
changed_one = TRUE;
++ptcb->rtt_cumack;
/* keep track of the newest transmission */
if (tv_gt (pseg->time, last_xmit))
last_xmit = pseg->time;
}
}
if (changed_one)
collapse_quad (pquad_prev);
/* check each segment in the segment list for the CURRENT quadrant */
changed_one = FALSE;
for (pseg = pquad->seglist_head; pseg != NULL; pseg = pseg->next) {
if (ack <= pseg->seq_firstbyte) {
/* doesn't cover anything else on the list */
break;
}
/* keep track of the newest transmission */
if (tv_gt (pseg->time, last_xmit))
last_xmit = pseg->time;
/* (ELSE) ACK covers this sequence */
if (pseg->acked) {
/* default will be the BSD version, it can be changed by giving
'--turn_off_BSD_dupack' switch */
dup_ack_type = (dup_ack_handling) ? BSD_VERSION : LEGACY_VERSION;
/* default type is the specifications based on BSD code */
switch (dup_ack_type) {
case LEGACY_VERSION:
if (ack == (pseg->seq_lastbyte + 1)) {
++pseg->acked; /* already acked this one */
++ptcb->rtt_dupack; /* one more duplicate ack */
ret = CUMUL;
if (pseg->acked == 4) {
/* some people say these CAN'T have data */
if ((tcp_data_length == 0)
|| triple_dupack_allows_data) {
++ptcb->rtt_triple_dupack;
ret = TRIPLE;
}
}
}
break;
case BSD_VERSION:
/* For an acknowledgement to be considered as duplicate ACK in
BSD version, following rules must be followed:
1) the received segment should contain the biggest ACK TCP
has seen,
2) the length of the segment containing dup ack should be 0,
3) advertised window in this segment should not change,
4) and there must be some outstanding data */
if ((ack == (pseg->seq_lastbyte + 1)) &&
(ack == ptcb->ptwin->ack) &&
(tcp_data_length == 0) &&
(eff_win == ptcb->ptwin->win_last) &&
(ptcb->owin_tot > 0)) {
++ptcb->rtt_dupack;
ret = CUMUL;
/* already acked this one */
++pseg->acked;
if (pseg->acked == 4) {
++ptcb->rtt_triple_dupack;
ret = TRIPLE;
}
} else
pseg->acked = 1; /* received segment is not pure
duplicate acknowledgement */
}
continue;
}
/* ELSE !acked */
++pseg->acked;
changed_one = TRUE;
if (ack == (pseg->seq_lastbyte + 1)) {
/* if ANY preceding segment was xmitted after this one,
the the RTT sample is invalid */
intervening_xmits = (tv_gt (last_xmit, pseg->time));
ret = rtt_ackin (ptcb, pseg, intervening_xmits);
} else {
/* cumulatively ACKed */
++ptcb->rtt_cumack;
ret = CUMUL;
}
}
if (changed_one)
collapse_quad (pquad);
return (ret);
}
void
freequad (quadrant ** ppquad)
{
segment *pseg;
segment *pseg_next;
pseg = (*ppquad)->seglist_head;
while (pseg && pseg->next) {
pseg_next = pseg->next;
free (pseg);
pseg = pseg_next;
}
if (pseg)
free (pseg);
free (*ppquad);
*ppquad = NULL;
}
/* dump RTT samples in milliseconds */
static void
dump_rtt_sample (tcb * ptcb,
segment * pseg,
double etime_rtt)
{
/* if the FILE is "-1", couldn't open file */
if (ptcb->rtt_dump_file == (MFILE *) - 1) {
return;
}
/* if the FILE is NULL, open file */
if (ptcb->rtt_dump_file == (MFILE *) NULL) {
MFILE *f;
static char filename[15];
snprintf (filename, sizeof (filename), "%s2%s%s",
ptcb->host_letter, ptcb->ptwin->host_letter,
RTT_DUMP_FILE_EXTENSION);
if ((f = Mfopen (filename, "w")) == NULL) {
perror (filename);
ptcb->rtt_dump_file = (MFILE *) - 1;
}
if (debug)
fprintf (stderr, "RTT Sample file is '%s'\n", filename);
ptcb->rtt_dump_file = f;
}
Mfprintf (ptcb->rtt_dump_file, "%lu %lu\n",
pseg->seq_firstbyte,
(int) (etime_rtt / 1000) /* convert from us to ms */ );
}
/* graph RTT samples in milliseconds */
static void
graph_rtt_sample (tcb * ptcb,
segment * pseg,
unsigned long etime_rtt)
{
char title[210];
/* if the FILE is NULL, open file */
if (ptcb->rtt_plotter == NO_PLOTTER) {
char *name_from, *name_to;
if (ptcb == &ptcb->ptp->a2b) {
name_from = ptcb->ptp->a_endpoint;
name_to = ptcb->ptp->b_endpoint;
} else {
name_from = ptcb->ptp->b_endpoint;
name_to = ptcb->ptp->a_endpoint;
}
snprintf (title, sizeof (title), "%s_==>_%s (rtt samples)",
name_from, name_to);
ptcb->rtt_plotter =
new_plotter (ptcb, NULL, title, "time", "rtt (ms)",
RTT_GRAPH_FILE_EXTENSION);
plotter_perm_color (ptcb->rtt_plotter, "red");
if (graph_time_zero) {
/* set graph zero points */
plotter_nothing (ptcb->rtt_plotter, current_time);
}
ptcb->rtt_line = new_line (ptcb->rtt_plotter, "rtt", "red");
}
if (etime_rtt <= 1)
return;
extend_line (ptcb->rtt_line, current_time, (int) (etime_rtt / 1000));
}
Bool IsRTO(tcb *ptcb, seqnum s) {
quadrant *pquad = whichquad(ptcb->ss,s);
segment *pseg;
for (pseg = pquad->seglist_head; pseg != NULL; pseg = pseg->next) {
if (s == (pseg->seq_lastbyte+1)) {
if (pseg->acked < 4) return TRUE;
else return FALSE;
}
}
return TRUE;
}
|