diff options
author | Arnaldo Carvalho de Melo <acme@mandriva.com> | 2005-08-24 00:51:59 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2005-08-29 19:05:01 -0400 |
commit | 4fded33b3e8177d1d2eec0ccc69af8dfe8b4c3c3 (patch) | |
tree | 4b1dd2fbcd56886c863e380c7a8ea85c8705eb8f /net/dccp | |
parent | d4b81ff70547b40c9b0742b163e8354560003cc0 (diff) |
[CCID3]: Calculate the RTT in the RX half connection
Using TIMESTAMP_ECHO and ELAPSED_TIME options received.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp')
-rw-r--r-- | net/dccp/ccids/ccid3.c | 67 |
1 files changed, 38 insertions, 29 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index ffd5b449f5f1..48c36afa4934 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c | |||
@@ -1010,7 +1010,6 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) | |||
1010 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 1010 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; |
1011 | struct timeval now; | 1011 | struct timeval now; |
1012 | 1012 | ||
1013 | // ccid3_pr_debug("%s, sk=%p, more=%d, len=%d\n", dccp_role(sk), sk, more, len); | ||
1014 | BUG_ON(hctx == NULL); | 1013 | BUG_ON(hctx == NULL); |
1015 | 1014 | ||
1016 | if (hctx->ccid3hctx_state == TFRC_SSTATE_TERM) { | 1015 | if (hctx->ccid3hctx_state == TFRC_SSTATE_TERM) { |
@@ -1562,23 +1561,27 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) | |||
1562 | static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) | 1561 | static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) |
1563 | { | 1562 | { |
1564 | const struct dccp_sock *dp = dccp_sk(sk); | 1563 | const struct dccp_sock *dp = dccp_sk(sk); |
1564 | u32 x_recv, pinv; | ||
1565 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | 1565 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; |
1566 | 1566 | ||
1567 | if (hcrx == NULL || !(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN)) | 1567 | if (hcrx == NULL || !(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN)) |
1568 | return; | 1568 | return; |
1569 | 1569 | ||
1570 | if (hcrx->ccid3hcrx_elapsed_time != 0 && !dccp_packet_without_ack(skb)) | ||
1571 | dccp_insert_option_elapsed_time(sk, skb, hcrx->ccid3hcrx_elapsed_time); | ||
1572 | |||
1573 | if (DCCP_SKB_CB(skb)->dccpd_type != DCCP_PKT_DATA) { | ||
1574 | const u32 x_recv = htonl(hcrx->ccid3hcrx_x_recv); | ||
1575 | const u32 pinv = htonl(hcrx->ccid3hcrx_pinv); | ||
1576 | |||
1577 | dccp_insert_option(sk, skb, TFRC_OPT_LOSS_EVENT_RATE, &pinv, sizeof(pinv)); | ||
1578 | dccp_insert_option(sk, skb, TFRC_OPT_RECEIVE_RATE, &x_recv, sizeof(x_recv)); | ||
1579 | } | ||
1580 | |||
1581 | DCCP_SKB_CB(skb)->dccpd_ccval = hcrx->ccid3hcrx_last_counter; | 1570 | DCCP_SKB_CB(skb)->dccpd_ccval = hcrx->ccid3hcrx_last_counter; |
1571 | |||
1572 | if (dccp_packet_without_ack(skb)) | ||
1573 | return; | ||
1574 | |||
1575 | if (hcrx->ccid3hcrx_elapsed_time != 0) | ||
1576 | dccp_insert_option_elapsed_time(sk, skb, | ||
1577 | hcrx->ccid3hcrx_elapsed_time); | ||
1578 | dccp_insert_option_timestamp(sk, skb); | ||
1579 | x_recv = htonl(hcrx->ccid3hcrx_x_recv); | ||
1580 | pinv = htonl(hcrx->ccid3hcrx_pinv); | ||
1581 | dccp_insert_option(sk, skb, TFRC_OPT_LOSS_EVENT_RATE, | ||
1582 | &pinv, sizeof(pinv)); | ||
1583 | dccp_insert_option(sk, skb, TFRC_OPT_RECEIVE_RATE, | ||
1584 | &x_recv, sizeof(x_recv)); | ||
1582 | } | 1585 | } |
1583 | 1586 | ||
1584 | /* Weights used to calculate loss event rate */ | 1587 | /* Weights used to calculate loss event rate */ |
@@ -1860,8 +1863,10 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1860 | { | 1863 | { |
1861 | struct dccp_sock *dp = dccp_sk(sk); | 1864 | struct dccp_sock *dp = dccp_sk(sk); |
1862 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | 1865 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; |
1866 | const struct dccp_options_received *opt_recv; | ||
1863 | struct dccp_rx_hist_entry *packet; | 1867 | struct dccp_rx_hist_entry *packet; |
1864 | struct timeval now; | 1868 | struct timeval now; |
1869 | u32 now_usecs; | ||
1865 | u8 win_count; | 1870 | u8 win_count; |
1866 | u32 p_prev; | 1871 | u32 p_prev; |
1867 | int ins; | 1872 | int ins; |
@@ -1876,24 +1881,25 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1876 | BUG_ON(!(hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA || | 1881 | BUG_ON(!(hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA || |
1877 | hcrx->ccid3hcrx_state == TFRC_RSTATE_DATA)); | 1882 | hcrx->ccid3hcrx_state == TFRC_RSTATE_DATA)); |
1878 | 1883 | ||
1884 | opt_recv = &dp->dccps_options_received; | ||
1885 | |||
1879 | switch (DCCP_SKB_CB(skb)->dccpd_type) { | 1886 | switch (DCCP_SKB_CB(skb)->dccpd_type) { |
1880 | case DCCP_PKT_ACK: | 1887 | case DCCP_PKT_ACK: |
1881 | if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA) | 1888 | if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA) |
1882 | return; | 1889 | return; |
1883 | case DCCP_PKT_DATAACK: | 1890 | case DCCP_PKT_DATAACK: |
1884 | if (dp->dccps_options_received.dccpor_timestamp_echo == 0) | 1891 | if (opt_recv->dccpor_timestamp_echo == 0) |
1885 | break; | 1892 | break; |
1886 | p_prev = hcrx->ccid3hcrx_rtt; | 1893 | p_prev = hcrx->ccid3hcrx_rtt; |
1887 | do_gettimeofday(&now); | 1894 | do_gettimeofday(&now); |
1888 | /* hcrx->ccid3hcrx_rtt = now - dp->dccps_options_received.dccpor_timestamp_echo - | 1895 | now_usecs = now.tv_sec * USEC_PER_SEC + now.tv_usec; |
1889 | usecs_to_jiffies(dp->dccps_options_received.dccpor_elapsed_time * 10); | 1896 | hcrx->ccid3hcrx_rtt = now_usecs - |
1890 | FIXME - I think above code is broken - have to look at options more, will also need | 1897 | (opt_recv->dccpor_timestamp_echo - |
1891 | to fix pr_debug below */ | 1898 | opt_recv->dccpor_elapsed_time) * 10; |
1892 | if (p_prev != hcrx->ccid3hcrx_rtt) | 1899 | if (p_prev != hcrx->ccid3hcrx_rtt) |
1893 | ccid3_pr_debug("%s, sk=%p, New RTT estimate=%lu jiffies, tstamp_echo=%u, elapsed time=%u\n", | 1900 | ccid3_pr_debug("%s, New RTT=%luus, elapsed time=%u\n", |
1894 | dccp_role(sk), sk, hcrx->ccid3hcrx_rtt, | 1901 | dccp_role(sk), hcrx->ccid3hcrx_rtt, |
1895 | dp->dccps_options_received.dccpor_timestamp_echo, | 1902 | opt_recv->dccpor_elapsed_time); |
1896 | dp->dccps_options_received.dccpor_elapsed_time); | ||
1897 | break; | 1903 | break; |
1898 | case DCCP_PKT_DATA: | 1904 | case DCCP_PKT_DATA: |
1899 | break; | 1905 | break; |
@@ -1904,8 +1910,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1904 | return; | 1910 | return; |
1905 | } | 1911 | } |
1906 | 1912 | ||
1907 | packet = dccp_rx_hist_entry_new(ccid3_rx_hist, | 1913 | packet = dccp_rx_hist_entry_new(ccid3_rx_hist, opt_recv->dccpor_ndp, |
1908 | dp->dccps_options_received.dccpor_ndp, | ||
1909 | skb, SLAB_ATOMIC); | 1914 | skb, SLAB_ATOMIC); |
1910 | if (packet == NULL) { | 1915 | if (packet == NULL) { |
1911 | ccid3_pr_debug("%s, sk=%p, Not enough mem to add rx packet to history (consider it lost)!", | 1916 | ccid3_pr_debug("%s, sk=%p, Not enough mem to add rx packet to history (consider it lost)!", |
@@ -1930,9 +1935,9 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1930 | case TFRC_RSTATE_DATA: | 1935 | case TFRC_RSTATE_DATA: |
1931 | hcrx->ccid3hcrx_bytes_recv += skb->len - dccp_hdr(skb)->dccph_doff * 4; | 1936 | hcrx->ccid3hcrx_bytes_recv += skb->len - dccp_hdr(skb)->dccph_doff * 4; |
1932 | if (ins == 0) { | 1937 | if (ins == 0) { |
1933 | do_gettimeofday(&now); | 1938 | if (now_delta(hcrx->ccid3hcrx_tstamp_last_ack) >= |
1934 | if ((now_delta(hcrx->ccid3hcrx_tstamp_last_ack)) >= hcrx->ccid3hcrx_rtt) { | 1939 | hcrx->ccid3hcrx_rtt) { |
1935 | hcrx->ccid3hcrx_tstamp_last_ack = now; | 1940 | do_gettimeofday(&hcrx->ccid3hcrx_tstamp_last_ack); |
1936 | ccid3_hc_rx_send_feedback(sk); | 1941 | ccid3_hc_rx_send_feedback(sk); |
1937 | } | 1942 | } |
1938 | return; | 1943 | return; |
@@ -1946,8 +1951,8 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1946 | } | 1951 | } |
1947 | 1952 | ||
1948 | /* Dealing with packet loss */ | 1953 | /* Dealing with packet loss */ |
1949 | ccid3_pr_debug("%s, sk=%p(%s), skb=%p, data loss! Reacting...\n", | 1954 | ccid3_pr_debug("%s, sk=%p(%s), data loss! Reacting...\n", |
1950 | dccp_role(sk), sk, dccp_state_name(sk->sk_state), skb); | 1955 | dccp_role(sk), sk, dccp_state_name(sk->sk_state)); |
1951 | 1956 | ||
1952 | ccid3_hc_rx_detect_loss(sk); | 1957 | ccid3_hc_rx_detect_loss(sk); |
1953 | p_prev = hcrx->ccid3hcrx_p; | 1958 | p_prev = hcrx->ccid3hcrx_p; |
@@ -1985,7 +1990,11 @@ static int ccid3_hc_rx_init(struct sock *sk) | |||
1985 | hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA; | 1990 | hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA; |
1986 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist); | 1991 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist); |
1987 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_loss_interval_hist); | 1992 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_loss_interval_hist); |
1988 | 1993 | /* | |
1994 | * XXX this seems to be paranoid, need to think more about this, for | ||
1995 | * now start with something different than zero. -acme | ||
1996 | */ | ||
1997 | hcrx->ccid3hcrx_rtt = USEC_PER_SEC / 5; | ||
1989 | return 0; | 1998 | return 0; |
1990 | } | 1999 | } |
1991 | 2000 | ||