Rev 2930 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2930 | Rev 2937 | ||
---|---|---|---|
Line 12... | Line 12... | ||
12 | ;; GNU GENERAL PUBLIC LICENSE ;; |
12 | ;; GNU GENERAL PUBLIC LICENSE ;; |
13 | ;; Version 2, June 1991 ;; |
13 | ;; Version 2, June 1991 ;; |
14 | ;; ;; |
14 | ;; ;; |
15 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
15 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 16... | Line 16... | ||
16 | 16 | ||
Line 17... | Line 17... | ||
17 | $Revision: 2930 $ |
17 | $Revision: 2937 $ |
Line 18... | Line 18... | ||
18 | 18 | ||
19 | macro TCP_checksum IP1, IP2 { |
19 | macro TCP_checksum IP1, IP2 { |
Line 468... | Line 468... | ||
468 | 468 | ||
Line -... | Line 469... | ||
- | 469 | ||
- | 470 | ||
469 | 471 | macro TCP_set_persist socket { |
|
- | 472 | ||
470 | 473 | ; First, check if retransmit timer is not set, retransmit and persist are mutually exclusive |
|
- | 474 | ||
- | 475 | ; cmp [socket + TCP_socket.timer_retransmission] |
|
- | 476 | ||
- | 477 | ; calculate RTO |
|
- | 478 | ||
471 | macro TCP_set_persist socket { |
479 | ; mov ecx, [socket + TCP_socket.t_srtt] |
472 | 480 | ; shr ecx, 2 |
|
473 | ;int t = ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1; |
481 | ; add ecx, [socket + TCP_socket.t_rttvar] |
474 | ;int tt; |
482 | ; shr ecx, 1 |
475 | ; |
483 | |
476 | ;tp->t_flags &= ~TF_PREVVALID; |
484 | ; and [socket + TCP_socket.t_flags], not TF_PREVVALID |
477 | ; |
485 | |
478 | ;if (tcp_timer_active(tp, TT_REXMT)) |
486 | ;if (tcp_timer_active(tp, TT_REXMT)) |
479 | ; panic("tcp_setpersist: retransmit pending"); |
487 | ; panic("tcp_setpersist: retransmit pending"); |
480 | ; |
488 | |
481 | ;; Start/restart persistance timer. |
489 | ; Start/restart persistance timer. |
482 | ; |
490 | |
483 | ;TCPT_RANGESET(tt, t * tcp_backoff[tp->t_rxtshift], TCPTV_PERSMIN, TCPTV_PERSMAX); |
491 | ;TCPT_RANGESET(tt, t * tcp_backoff[tp->t_rxtshift], TCPTV_PERSMIN, TCPTV_PERSMAX); |
- | 492 | ;tcp_timer_activate(tp, TT_PERSIST, tt); |
|
- | 493 | ||
Line 484... | Line 494... | ||
484 | ;tcp_timer_activate(tp, TT_PERSIST, tt); |
494 | ; cmp [socket + TCP_socket.t_rxtshift], TCP_MAXRXTSHIFT |
Line -... | Line 495... | ||
- | 495 | ; jae @f |
|
- | 496 | ; inc [socket + TCP_socket.t_rxtshift] |
|
485 | ; |
497 | ; @@: |
486 | ;if (tp->t_rxtshift < TCP_MAXRXTSHIFT) |
498 | |
Line 487... | Line 499... | ||
487 | ; tp->t_rxtshift++; |
499 | } |
488 | 500 | ||
Line 489... | Line 501... | ||
489 | } |
501 | |
- | 502 | ||
- | 503 | ; eax = rtt |
|
- | 504 | ; ebx = socket ptr |
|
- | 505 | ||
- | 506 | align 4 |
|
- | 507 | TCP_xmit_timer: |
|
- | 508 | ||
- | 509 | ;TODO: update stats |
|
- | 510 | ||
- | 511 | cmp [ebx + TCP_SOCKET.t_rtt], 0 |
|
- | 512 | je .no_rtt_yet |
|
- | 513 | ||
- | 514 | ; srtt is stored as a fixed point with 3 bits after the binary point. |
|
- | 515 | ; The following magic is equivalent of the smoothing algorithm in rfc793 with an alpha of .875 |
|
- | 516 | ; (srtt = rtt/8 + srtt*7/8 in fixed point) |
|
- | 517 | ; Adjust rtt to origin 0. |
|
- | 518 | ||
- | 519 | push ecx |
|
- | 520 | mov ecx, [ebx + TCP_SOCKET.t_srtt] |
|
- | 521 | shr ecx, TCP_RTT_SHIFT |
|
- | 522 | sub eax, ecx |
|
- | 523 | dec eax |
|
- | 524 | pop ecx |
|
- | 525 | ||
- | 526 | add [ebx + TCP_SOCKET.t_srtt], eax |
|
- | 527 | ja @f |
|
- | 528 | mov [ebx + TCP_SOCKET.t_srtt], 1 |
|
- | 529 | @@: |
|
- | 530 | ||
- | 531 | ; We accumulate a smoothed rtt variance (actually, a smoothed mean difference), |
|
- | 532 | ; then set the retransmit timer to smoothed rtt + 4 times the smoothed variance. |
|
- | 533 | ; rttvar is stored as fixed point with 2 bits after the binary point. |
|
- | 534 | ; The following is equivalent to rfc793 smoothing with an alpha of .75 |
|
- | 535 | ; (rttvar = rttvar*3/4 + delta/4) (delta = eax) |
|
- | 536 | ||
- | 537 | ; get abs(eax) |
|
- | 538 | push edx |
|
- | 539 | cdq |
|
- | 540 | xor eax, edx |
|
- | 541 | sub eax, edx |
|
- | 542 | ||
- | 543 | mov edx, [ebx + TCP_SOCKET.t_rttvar] |
|
- | 544 | shr edx, TCP_RTTVAR_SHIFT |
|
- | 545 | sub eax, edx |
|
- | 546 | pop edx |
|
- | 547 | ||
- | 548 | add [ebx + TCP_SOCKET.t_rttvar], eax |
|
- | 549 | ja @f |
|
- | 550 | mov [ebx + TCP_SOCKET.t_rttvar], 1 |
|
- | 551 | @@: |
|
- | 552 | ret |
|
- | 553 | ||
- | 554 | ||
- | 555 | .no_rtt_yet: |
|
- | 556 | ||
Line 490... | Line 557... | ||
490 | 557 | push ecx |