ccid3.c (20cbd3e120a0c20bebe420e1fed0e816730bb988) ccid3.c (d2c726309d88df3c5568486e4b5b9e4c3150903f)
1/*
2 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK
3 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand.
4 * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz>
5 *
6 * An implementation of the DCCP protocol
7 *
8 * This code has been developed by the University of Waikato WAND

--- 356 unchanged lines hidden (view full) ---

365 if (tfrc_tx_hist_add(&hc->tx_hist, dccp_sk(sk)->dccps_gss))
366 DCCP_CRIT("packet history - out of memory!");
367}
368
369static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
370{
371 struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk);
372 struct ccid3_options_received *opt_recv = &hc->tx_options_received;
1/*
2 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK
3 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand.
4 * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz>
5 *
6 * An implementation of the DCCP protocol
7 *
8 * This code has been developed by the University of Waikato WAND

--- 356 unchanged lines hidden (view full) ---

365 if (tfrc_tx_hist_add(&hc->tx_hist, dccp_sk(sk)->dccps_gss))
366 DCCP_CRIT("packet history - out of memory!");
367}
368
369static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
370{
371 struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk);
372 struct ccid3_options_received *opt_recv = &hc->tx_options_received;
373 struct tfrc_tx_hist_entry *acked;
373 ktime_t now;
374 unsigned long t_nfb;
375 u32 pinv, r_sample;
376
377 /* we are only interested in ACKs */
378 if (!(DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_ACK ||
379 DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_DATAACK))
380 return;
381 /* ... and only in the established state */
382 if (hc->tx_state != TFRC_SSTATE_FBACK &&
383 hc->tx_state != TFRC_SSTATE_NO_FBACK)
384 return;
385
374 ktime_t now;
375 unsigned long t_nfb;
376 u32 pinv, r_sample;
377
378 /* we are only interested in ACKs */
379 if (!(DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_ACK ||
380 DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_DATAACK))
381 return;
382 /* ... and only in the established state */
383 if (hc->tx_state != TFRC_SSTATE_FBACK &&
384 hc->tx_state != TFRC_SSTATE_NO_FBACK)
385 return;
386
386 now = ktime_get_real();
387
388 /* Estimate RTT from history if ACK number is valid */
389 r_sample = tfrc_tx_hist_rtt(hc->tx_hist,
390 DCCP_SKB_CB(skb)->dccpd_ack_seq, now);
391 if (r_sample == 0) {
392 DCCP_WARN("%s(%p): %s with bogus ACK-%llu\n", dccp_role(sk), sk,
393 dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type),
394 (unsigned long long)DCCP_SKB_CB(skb)->dccpd_ack_seq);
387 /*
388 * Locate the acknowledged packet in the TX history.
389 *
390 * Returning "entry not found" here can for instance happen when
391 * - the host has not sent out anything (e.g. a passive server),
392 * - the Ack is outdated (packet with higher Ack number was received),
393 * - it is a bogus Ack (for a packet not sent on this connection).
394 */
395 acked = tfrc_tx_hist_find_entry(hc->tx_hist, dccp_hdr_ack_seq(skb));
396 if (acked == NULL)
395 return;
397 return;
396 }
398 /* For the sake of RTT sampling, ignore/remove all older entries */
399 tfrc_tx_hist_purge(&acked->next);
397
400
401 /* Update the moving average for the RTT estimate (RFC 3448, 4.3) */
402 now = ktime_get_real();
403 r_sample = dccp_sample_rtt(sk, ktime_us_delta(now, acked->stamp));
404 hc->tx_rtt = tfrc_ewma(hc->tx_rtt, r_sample, 9);
405
398 /* Update receive rate in units of 64 * bytes/second */
399 hc->tx_x_recv = opt_recv->ccid3or_receive_rate;
400 hc->tx_x_recv <<= 6;
401
402 /* Update loss event rate (which is scaled by 1e6) */
403 pinv = opt_recv->ccid3or_loss_event_rate;
404 if (pinv == ~0U || pinv == 0) /* see RFC 4342, 8.5 */
405 hc->tx_p = 0;
406 else /* can not exceed 100% */
407 hc->tx_p = scaled_div(1, pinv);
406 /* Update receive rate in units of 64 * bytes/second */
407 hc->tx_x_recv = opt_recv->ccid3or_receive_rate;
408 hc->tx_x_recv <<= 6;
409
410 /* Update loss event rate (which is scaled by 1e6) */
411 pinv = opt_recv->ccid3or_loss_event_rate;
412 if (pinv == ~0U || pinv == 0) /* see RFC 4342, 8.5 */
413 hc->tx_p = 0;
414 else /* can not exceed 100% */
415 hc->tx_p = scaled_div(1, pinv);
416
408 /*
417 /*
409 * Validate new RTT sample and update moving average
410 */
411 r_sample = dccp_sample_rtt(sk, r_sample);
412 hc->tx_rtt = tfrc_ewma(hc->tx_rtt, r_sample, 9);
413 /*
414 * Update allowed sending rate X as per draft rfc3448bis-00, 4.2/3
415 */
416 if (hc->tx_state == TFRC_SSTATE_NO_FBACK) {
417 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK);
418
419 if (hc->tx_t_rto == 0) {
420 /*
421 * Initial feedback packet: Larger Initial Windows (4.2)

--- 497 unchanged lines hidden ---
418 * Update allowed sending rate X as per draft rfc3448bis-00, 4.2/3
419 */
420 if (hc->tx_state == TFRC_SSTATE_NO_FBACK) {
421 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK);
422
423 if (hc->tx_t_rto == 0) {
424 /*
425 * Initial feedback packet: Larger Initial Windows (4.2)

--- 497 unchanged lines hidden ---