diff options
-rw-r--r-- | net/dccp/ccids/ccid3.c | 89 |
1 files changed, 52 insertions, 37 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 22a07248c240..bd353044c547 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c | |||
@@ -121,12 +121,15 @@ static inline void ccid3_update_send_time(struct ccid3_hc_tx_sock *hctx) | |||
121 | /* | 121 | /* |
122 | * Update X by | 122 | * Update X by |
123 | * If (p > 0) | 123 | * If (p > 0) |
124 | * x_calc = calcX(s, R, p); | 124 | * X_calc = calcX(s, R, p); |
125 | * X = max(min(X_calc, 2 * X_recv), s / t_mbi); | 125 | * X = max(min(X_calc, 2 * X_recv), s / t_mbi); |
126 | * Else | 126 | * Else |
127 | * If (now - tld >= R) | 127 | * If (now - tld >= R) |
128 | * X = max(min(2 * X, 2 * X_recv), s / R); | 128 | * X = max(min(2 * X, 2 * X_recv), s / R); |
129 | * tld = now; | 129 | * tld = now; |
130 | * | ||
131 | * If X has changed, we also update the scheduled send time t_now, | ||
132 | * the inter-packet interval t_ipi, and the delta value. | ||
130 | */ | 133 | */ |
131 | static void ccid3_hc_tx_update_x(struct sock *sk, struct timeval *now) | 134 | static void ccid3_hc_tx_update_x(struct sock *sk, struct timeval *now) |
132 | 135 | ||
@@ -413,10 +416,8 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
413 | struct dccp_tx_hist_entry *packet; | 416 | struct dccp_tx_hist_entry *packet; |
414 | struct timeval now; | 417 | struct timeval now; |
415 | unsigned long t_nfb; | 418 | unsigned long t_nfb; |
416 | u32 t_elapsed; | ||
417 | u32 pinv; | 419 | u32 pinv; |
418 | u32 x_recv; | 420 | long r_sample, t_elapsed; |
419 | u32 r_sample; | ||
420 | 421 | ||
421 | BUG_ON(hctx == NULL); | 422 | BUG_ON(hctx == NULL); |
422 | 423 | ||
@@ -427,31 +428,51 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
427 | 428 | ||
428 | opt_recv = &hctx->ccid3hctx_options_received; | 429 | opt_recv = &hctx->ccid3hctx_options_received; |
429 | 430 | ||
430 | t_elapsed = dp->dccps_options_received.dccpor_elapsed_time * 10; | ||
431 | x_recv = opt_recv->ccid3or_receive_rate; | ||
432 | pinv = opt_recv->ccid3or_loss_event_rate; | ||
433 | |||
434 | switch (hctx->ccid3hctx_state) { | 431 | switch (hctx->ccid3hctx_state) { |
435 | case TFRC_SSTATE_NO_FBACK: | 432 | case TFRC_SSTATE_NO_FBACK: |
436 | case TFRC_SSTATE_FBACK: | 433 | case TFRC_SSTATE_FBACK: |
437 | /* Calculate new round trip sample by | 434 | /* get packet from history to look up t_recvdata */ |
438 | * R_sample = (now - t_recvdata) - t_delay */ | ||
439 | /* get t_recvdata from history */ | ||
440 | packet = dccp_tx_hist_find_entry(&hctx->ccid3hctx_hist, | 435 | packet = dccp_tx_hist_find_entry(&hctx->ccid3hctx_hist, |
441 | DCCP_SKB_CB(skb)->dccpd_ack_seq); | 436 | DCCP_SKB_CB(skb)->dccpd_ack_seq); |
442 | if (unlikely(packet == NULL)) { | 437 | if (unlikely(packet == NULL)) { |
443 | DCCP_WARN("%s, sk=%p, seqno %llu(%s) does't exist " | 438 | DCCP_WARN("%s(%p), seqno %llu(%s) doesn't exist " |
444 | "in history!\n", dccp_role(sk), sk, | 439 | "in history!\n", dccp_role(sk), sk, |
445 | (unsigned long long)DCCP_SKB_CB(skb)->dccpd_ack_seq, | 440 | (unsigned long long)DCCP_SKB_CB(skb)->dccpd_ack_seq, |
446 | dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type)); | 441 | dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type)); |
447 | return; | 442 | return; |
448 | } | 443 | } |
449 | 444 | ||
450 | /* Update RTT */ | 445 | /* Update receive rate */ |
446 | hctx->ccid3hctx_x_recv = opt_recv->ccid3or_receive_rate; | ||
447 | |||
448 | /* Update loss event rate */ | ||
449 | pinv = opt_recv->ccid3or_loss_event_rate; | ||
450 | if (pinv == ~0U || pinv == 0) | ||
451 | hctx->ccid3hctx_p = 0; | ||
452 | else { | ||
453 | hctx->ccid3hctx_p = 1000000 / pinv; | ||
454 | |||
455 | if (hctx->ccid3hctx_p < TFRC_SMALLEST_P) { | ||
456 | hctx->ccid3hctx_p = TFRC_SMALLEST_P; | ||
457 | ccid3_pr_debug("%s, sk=%p, Smallest p used!\n", | ||
458 | dccp_role(sk), sk); | ||
459 | } | ||
460 | } | ||
461 | |||
451 | dccp_timestamp(sk, &now); | 462 | dccp_timestamp(sk, &now); |
452 | r_sample = timeval_delta(&now, &packet->dccphtx_tstamp); | 463 | |
453 | if (unlikely(r_sample <= t_elapsed)) | 464 | /* |
454 | DCCP_WARN("r_sample=%uus,t_elapsed=%uus\n", | 465 | * Calculate new round trip sample as per [RFC 3448, 4.3] by |
466 | * R_sample = (now - t_recvdata) - t_elapsed | ||
467 | */ | ||
468 | r_sample = timeval_delta(&now, &packet->dccphtx_tstamp); | ||
469 | t_elapsed = dp->dccps_options_received.dccpor_elapsed_time * 10; | ||
470 | |||
471 | if (unlikely(r_sample <= 0)) { | ||
472 | DCCP_WARN("WARNING: R_sample (%ld) <= 0!\n", r_sample); | ||
473 | r_sample = 0; | ||
474 | } else if (unlikely(r_sample <= t_elapsed)) | ||
475 | DCCP_WARN("WARNING: r_sample=%ldus <= t_elapsed=%ldus\n", | ||
455 | r_sample, t_elapsed); | 476 | r_sample, t_elapsed); |
456 | else | 477 | else |
457 | r_sample -= t_elapsed; | 478 | r_sample -= t_elapsed; |
@@ -474,31 +495,25 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
474 | hctx->ccid3hctx_t_ld = now; | 495 | hctx->ccid3hctx_t_ld = now; |
475 | 496 | ||
476 | ccid3_update_send_time(hctx); | 497 | ccid3_update_send_time(hctx); |
477 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK); | ||
478 | } else { | ||
479 | hctx->ccid3hctx_rtt = (hctx->ccid3hctx_rtt * 9) / 10 + | ||
480 | r_sample / 10; | ||
481 | ccid3_hc_tx_update_x(sk, &now); | ||
482 | } | ||
483 | 498 | ||
484 | ccid3_pr_debug("%s, sk=%p, New RTT estimate=%uus, " | 499 | ccid3_pr_debug("%s(%p), s=%u, w_init=%u, " |
485 | "r_sample=%us\n", dccp_role(sk), sk, | 500 | "R_sample=%ldus, X=%u\n", dccp_role(sk), |
486 | hctx->ccid3hctx_rtt, r_sample); | 501 | sk, hctx->ccid3hctx_s, w_init, r_sample, |
502 | hctx->ccid3hctx_x); | ||
487 | 503 | ||
488 | /* Update receive rate */ | 504 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK); |
489 | hctx->ccid3hctx_x_recv = x_recv;/* X_recv in bytes per sec */ | 505 | } else { |
506 | hctx->ccid3hctx_rtt = (9 * hctx->ccid3hctx_rtt + | ||
507 | (u32)r_sample ) / 10; | ||
490 | 508 | ||
491 | /* Update loss event rate */ | 509 | ccid3_hc_tx_update_x(sk, &now); |
492 | if (pinv == ~0 || pinv == 0) | ||
493 | hctx->ccid3hctx_p = 0; | ||
494 | else { | ||
495 | hctx->ccid3hctx_p = 1000000 / pinv; | ||
496 | 510 | ||
497 | if (hctx->ccid3hctx_p < TFRC_SMALLEST_P) { | 511 | ccid3_pr_debug("%s(%p), RTT=%uus (sample=%ldus), s=%u, " |
498 | hctx->ccid3hctx_p = TFRC_SMALLEST_P; | 512 | "p=%u, X_calc=%u, X=%u\n", dccp_role(sk), |
499 | ccid3_pr_debug("%s, sk=%p, Smallest p used!\n", | 513 | sk, hctx->ccid3hctx_rtt, r_sample, |
500 | dccp_role(sk), sk); | 514 | hctx->ccid3hctx_s, hctx->ccid3hctx_p, |
501 | } | 515 | hctx->ccid3hctx_x_calc, |
516 | hctx->ccid3hctx_x); | ||
502 | } | 517 | } |
503 | 518 | ||
504 | /* unschedule no feedback timer */ | 519 | /* unschedule no feedback timer */ |