diff options
author | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2007-03-20 14:24:37 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:27:01 -0400 |
commit | 7dfee1a9c07f80a82aa5fbad340146f2b5c794b4 (patch) | |
tree | e59036f22f10b1fa8527537158a435d86f82f048 /net/dccp/ccids | |
parent | 4712a792ee661921374c163eb6a4d06e33fd305f (diff) |
[CCID3]: Use function for RTT sampling
This replaces the existing occurrences of RTT sampling with
the use of the new function dccp_sample_rtt.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Signed-off-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp/ccids')
-rw-r--r-- | net/dccp/ccids/ccid3.c | 42 | ||||
-rw-r--r-- | net/dccp/ccids/ccid3.h | 10 |
2 files changed, 11 insertions, 41 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 35123c19a08f..f4097ddf2504 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c | |||
@@ -414,8 +414,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
414 | struct dccp_tx_hist_entry *packet; | 414 | struct dccp_tx_hist_entry *packet; |
415 | struct timeval now; | 415 | struct timeval now; |
416 | unsigned long t_nfb; | 416 | unsigned long t_nfb; |
417 | u32 pinv; | 417 | u32 pinv, r_sample; |
418 | suseconds_t r_sample, t_elapsed; | ||
419 | 418 | ||
420 | BUG_ON(hctx == NULL); | 419 | BUG_ON(hctx == NULL); |
421 | 420 | ||
@@ -457,18 +456,10 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
457 | * Calculate new round trip sample as per [RFC 3448, 4.3] by | 456 | * Calculate new round trip sample as per [RFC 3448, 4.3] by |
458 | * R_sample = (now - t_recvdata) - t_elapsed | 457 | * R_sample = (now - t_recvdata) - t_elapsed |
459 | */ | 458 | */ |
460 | r_sample = timeval_delta(&now, &packet->dccphtx_tstamp); | 459 | r_sample = dccp_sample_rtt(sk, &now, &packet->dccphtx_tstamp); |
461 | t_elapsed = dp->dccps_options_received.dccpor_elapsed_time * 10; | ||
462 | 460 | ||
463 | DCCP_BUG_ON(r_sample < 0); | 461 | /* |
464 | if (unlikely(r_sample <= t_elapsed)) | 462 | * Update RTT estimate by |
465 | DCCP_WARN("WARNING: r_sample=%dus <= t_elapsed=%dus\n", | ||
466 | (int)r_sample, (int)t_elapsed); | ||
467 | else | ||
468 | r_sample -= t_elapsed; | ||
469 | CCID3_RTT_SANITY_CHECK(r_sample); | ||
470 | |||
471 | /* Update RTT estimate by | ||
472 | * If (No feedback recv) | 463 | * If (No feedback recv) |
473 | * R = R_sample; | 464 | * R = R_sample; |
474 | * Else | 465 | * Else |
@@ -487,15 +478,15 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
487 | ccid3_update_send_interval(hctx); | 478 | ccid3_update_send_interval(hctx); |
488 | 479 | ||
489 | ccid3_pr_debug("%s(%p), s=%u, MSS=%u, " | 480 | ccid3_pr_debug("%s(%p), s=%u, MSS=%u, " |
490 | "R_sample=%dus, X=%u\n", dccp_role(sk), | 481 | "R_sample=%uus, X=%u\n", dccp_role(sk), |
491 | sk, hctx->ccid3hctx_s, | 482 | sk, hctx->ccid3hctx_s, |
492 | dp->dccps_mss_cache, (int)r_sample, | 483 | dp->dccps_mss_cache, r_sample, |
493 | (unsigned)(hctx->ccid3hctx_x >> 6)); | 484 | (unsigned)(hctx->ccid3hctx_x >> 6)); |
494 | 485 | ||
495 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK); | 486 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK); |
496 | } else { | 487 | } else { |
497 | hctx->ccid3hctx_rtt = (9 * hctx->ccid3hctx_rtt + | 488 | hctx->ccid3hctx_rtt = (9 * hctx->ccid3hctx_rtt + |
498 | (u32)r_sample) / 10; | 489 | r_sample) / 10; |
499 | 490 | ||
500 | /* Update sending rate (step 4 of [RFC 3448, 4.3]) */ | 491 | /* Update sending rate (step 4 of [RFC 3448, 4.3]) */ |
501 | if (hctx->ccid3hctx_p > 0) | 492 | if (hctx->ccid3hctx_p > 0) |
@@ -505,10 +496,10 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
505 | hctx->ccid3hctx_p); | 496 | hctx->ccid3hctx_p); |
506 | ccid3_hc_tx_update_x(sk, &now); | 497 | ccid3_hc_tx_update_x(sk, &now); |
507 | 498 | ||
508 | ccid3_pr_debug("%s(%p), RTT=%uus (sample=%dus), s=%u, " | 499 | ccid3_pr_debug("%s(%p), RTT=%uus (sample=%uus), s=%u, " |
509 | "p=%u, X_calc=%u, X_recv=%u, X=%u\n", | 500 | "p=%u, X_calc=%u, X_recv=%u, X=%u\n", |
510 | dccp_role(sk), | 501 | dccp_role(sk), |
511 | sk, hctx->ccid3hctx_rtt, (int)r_sample, | 502 | sk, hctx->ccid3hctx_rtt, r_sample, |
512 | hctx->ccid3hctx_s, hctx->ccid3hctx_p, | 503 | hctx->ccid3hctx_s, hctx->ccid3hctx_p, |
513 | hctx->ccid3hctx_x_calc, | 504 | hctx->ccid3hctx_x_calc, |
514 | (unsigned)(hctx->ccid3hctx_x_recv >> 6), | 505 | (unsigned)(hctx->ccid3hctx_x_recv >> 6), |
@@ -1025,8 +1016,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1025 | const struct dccp_options_received *opt_recv; | 1016 | const struct dccp_options_received *opt_recv; |
1026 | struct dccp_rx_hist_entry *packet; | 1017 | struct dccp_rx_hist_entry *packet; |
1027 | struct timeval now; | 1018 | struct timeval now; |
1028 | u32 p_prev, rtt_prev; | 1019 | u32 p_prev, r_sample, rtt_prev; |
1029 | suseconds_t r_sample, t_elapsed; | ||
1030 | int loss, payload_size; | 1020 | int loss, payload_size; |
1031 | 1021 | ||
1032 | BUG_ON(hcrx == NULL); | 1022 | BUG_ON(hcrx == NULL); |
@@ -1042,17 +1032,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1042 | break; | 1032 | break; |
1043 | rtt_prev = hcrx->ccid3hcrx_rtt; | 1033 | rtt_prev = hcrx->ccid3hcrx_rtt; |
1044 | dccp_timestamp(sk, &now); | 1034 | dccp_timestamp(sk, &now); |
1045 | timeval_sub_usecs(&now, opt_recv->dccpor_timestamp_echo * 10); | 1035 | r_sample = dccp_sample_rtt(sk, &now, NULL); |
1046 | r_sample = timeval_usecs(&now); | ||
1047 | t_elapsed = opt_recv->dccpor_elapsed_time * 10; | ||
1048 | |||
1049 | DCCP_BUG_ON(r_sample < 0); | ||
1050 | if (unlikely(r_sample <= t_elapsed)) | ||
1051 | DCCP_WARN("r_sample=%ldus, t_elapsed=%ldus\n", | ||
1052 | (long)r_sample, (long)t_elapsed); | ||
1053 | else | ||
1054 | r_sample -= t_elapsed; | ||
1055 | CCID3_RTT_SANITY_CHECK(r_sample); | ||
1056 | 1036 | ||
1057 | if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA) | 1037 | if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA) |
1058 | hcrx->ccid3hcrx_rtt = r_sample; | 1038 | hcrx->ccid3hcrx_rtt = r_sample; |
diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h index 15776a88c090..8d31b389c19c 100644 --- a/net/dccp/ccids/ccid3.h +++ b/net/dccp/ccids/ccid3.h | |||
@@ -51,16 +51,6 @@ | |||
51 | /* Parameter t_mbi from [RFC 3448, 4.3]: backoff interval in seconds */ | 51 | /* Parameter t_mbi from [RFC 3448, 4.3]: backoff interval in seconds */ |
52 | #define TFRC_T_MBI 64 | 52 | #define TFRC_T_MBI 64 |
53 | 53 | ||
54 | /* What we think is a reasonable upper limit on RTT values */ | ||
55 | #define CCID3_SANE_RTT_MAX ((suseconds_t)(4 * USEC_PER_SEC)) | ||
56 | |||
57 | #define CCID3_RTT_SANITY_CHECK(rtt) do { \ | ||
58 | if (rtt > CCID3_SANE_RTT_MAX) { \ | ||
59 | DCCP_CRIT("RTT (%d) too large, substituting %d", \ | ||
60 | (int)rtt, (int)CCID3_SANE_RTT_MAX); \ | ||
61 | rtt = CCID3_SANE_RTT_MAX; \ | ||
62 | } } while (0) | ||
63 | |||
64 | enum ccid3_options { | 54 | enum ccid3_options { |
65 | TFRC_OPT_LOSS_EVENT_RATE = 192, | 55 | TFRC_OPT_LOSS_EVENT_RATE = 192, |
66 | TFRC_OPT_LOSS_INTERVALS = 193, | 56 | TFRC_OPT_LOSS_INTERVALS = 193, |