* [PATCH 4/7]: Provide function for RTT sampling
@ 2007-01-23 15:41 Gerrit Renker
2007-01-24 1:27 ` Ian McDonald
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Gerrit Renker @ 2007-01-23 15:41 UTC (permalink / raw)
To: dccp
[DCCP]: Provide function for RTT sampling
A recurring problem, in particular in the CCID code, is that RTT samples
from packets with timestamp echo and elapsed time options need to be taken.
This service is provided via a new function dccp_sample_rtt in this patch.
Furthermore, to protect against `insane' RTT samples, the sampled value
is bounded between 100 microseconds and 4 seconds - for which u32 is sufficient.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
---
net/dccp/dccp.h | 10 ++++++++--
net/dccp/input.c | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 2 deletions(-)
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -71,11 +71,15 @@ extern void dccp_time_wait(struct sock *
/* RFC 1122, 4.2.3.1 initial RTO value */
#define DCCP_TIMEOUT_INIT ((unsigned)(3 * HZ))
+#define DCCP_RTO_MAX ((unsigned)(120 * HZ)) /* FIXME: using TCP value */
+
+/* bounds for sampled RTT values from packet exchanges (in usec) */
+#define DCCP_SANE_RTT_MIN 100
+#define DCCP_SANE_RTT_MAX (4 * USEC_PER_SEC)
+
/* Maximal interval between probes for local resources. */
#define DCCP_RESOURCE_PROBE_INTERVAL ((unsigned)(HZ / 2U))
-#define DCCP_RTO_MAX ((unsigned)(120 * HZ)) /* FIXME: using TCP value */
-
/* sysctl variables for DCCP */
extern int sysctl_dccp_request_retries;
extern int sysctl_dccp_retries1;
@@ -293,6 +297,8 @@ extern int dccp_v4_connect(struct soc
extern int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code);
extern void dccp_send_close(struct sock *sk, const int active);
extern int dccp_invalid_packet(struct sk_buff *skb);
+extern u32 dccp_sample_rtt(struct sock *sk, struct timeval *t_recv,
+ struct timeval *t_history);
static inline int dccp_bad_service_code(const struct sock *sk,
const __be32 service)
--- a/net/dccp/input.c
+++ b/net/dccp/input.c
@@ -590,3 +590,43 @@ discard:
}
EXPORT_SYMBOL_GPL(dccp_rcv_state_process);
+
+/**
+ * dccp_sample_rtt - Sample RTT from packet exchange
+ *
+ * @sk: connected dccp_sock
+ * @t_recv: receive timestamp of packet with timestamp echo
+ * @t_hist: packet history timestamp or NULL
+ */
+u32 dccp_sample_rtt(struct sock *sk, struct timeval *t_recv,
+ struct timeval *t_hist)
+{
+ struct dccp_sock *dp = dccp_sk(sk);
+ struct dccp_options_received *or = &dp->dccps_options_received;
+ suseconds_t delta;
+
+ if (t_hist = NULL) {
+ if (!or->dccpor_timestamp_echo) {
+ DCCP_WARN("packet without timestamp echo\n");
+ return DCCP_SANE_RTT_MAX;
+ }
+ timeval_sub_usecs(t_recv, or->dccpor_timestamp_echo * 10);
+ delta = timeval_usecs(t_recv);
+ } else
+ delta = timeval_delta(t_recv, t_hist);
+
+ delta -= or->dccpor_elapsed_time * 10; /* either set or 0 */
+
+ if (unlikely(delta <= 0)) {
+ DCCP_WARN("unusable RTT sample %ld, using min\n", (long)delta);
+ return DCCP_SANE_RTT_MIN;
+ }
+ if (unlikely(delta - (suseconds_t)DCCP_SANE_RTT_MAX > 0)) {
+ DCCP_WARN("RTT sample %ld too large, using max\n", (long)delta);
+ return DCCP_SANE_RTT_MAX;
+ }
+
+ return delta;
+}
+
+EXPORT_SYMBOL_GPL(dccp_sample_rtt);
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 4/7]: Provide function for RTT sampling
2007-01-23 15:41 [PATCH 4/7]: Provide function for RTT sampling Gerrit Renker
@ 2007-01-24 1:27 ` Ian McDonald
2007-01-24 9:37 ` Gerrit Renker
2007-01-24 23:27 ` Ian McDonald
2 siblings, 0 replies; 4+ messages in thread
From: Ian McDonald @ 2007-01-24 1:27 UTC (permalink / raw)
To: dccp
Gerrit,
Is 100 microseconds a bit high perhaps? I'm seeing about 250
microseconds on a 100 Mbits LAN and therefore presumably on a 10 Gbits
LAN it could be as low as 2.5 microseconds??
Other than that:
Acked-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
On 24/01/07, Gerrit Renker <gerrit@erg.abdn.ac.uk> wrote:
> [DCCP]: Provide function for RTT sampling
>
--
Web: http://wand.net.nz/~iam4
Blog: http://iansblog.jandi.co.nz
WAND Network Research Group
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 4/7]: Provide function for RTT sampling
2007-01-23 15:41 [PATCH 4/7]: Provide function for RTT sampling Gerrit Renker
2007-01-24 1:27 ` Ian McDonald
@ 2007-01-24 9:37 ` Gerrit Renker
2007-01-24 23:27 ` Ian McDonald
2 siblings, 0 replies; 4+ messages in thread
From: Gerrit Renker @ 2007-01-24 9:37 UTC (permalink / raw)
To: dccp
| Is 100 microseconds a bit high perhaps? I'm seeing about 250
| microseconds on a 100 Mbits LAN and therefore presumably on a 10 Gbits
| LAN it could be as low as 2.5 microseconds??
This is correct, but these are not speeds that CCID 3 can handle. From my
calculations, the maximum speed is about 12 kilobits/second: the best possible
t_gran is 1 millisecond; whenever t_ipi < t_gran, then the speed of sending
packets is no longer controlled by the packet scheduling.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 4/7]: Provide function for RTT sampling
2007-01-23 15:41 [PATCH 4/7]: Provide function for RTT sampling Gerrit Renker
2007-01-24 1:27 ` Ian McDonald
2007-01-24 9:37 ` Gerrit Renker
@ 2007-01-24 23:27 ` Ian McDonald
2 siblings, 0 replies; 4+ messages in thread
From: Ian McDonald @ 2007-01-24 23:27 UTC (permalink / raw)
To: dccp
On 24/01/07, Gerrit Renker <gerrit@erg.abdn.ac.uk> wrote:
> | Is 100 microseconds a bit high perhaps? I'm seeing about 250
> | microseconds on a 100 Mbits LAN and therefore presumably on a 10 Gbits
> | LAN it could be as low as 2.5 microseconds??
> This is correct, but these are not speeds that CCID 3 can handle. From my
> calculations, the maximum speed is about 12 kilobits/second: the best possible
> t_gran is 1 millisecond; whenever t_ipi < t_gran, then the speed of sending
> packets is no longer controlled by the packet scheduling.
>
OK. I might wade into the debate about packet scheduling later but
won't for now.
--
Web: http://wand.net.nz/~iam4
Blog: http://iansblog.jandi.co.nz
WAND Network Research Group
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-01-24 23:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-23 15:41 [PATCH 4/7]: Provide function for RTT sampling Gerrit Renker
2007-01-24 1:27 ` Ian McDonald
2007-01-24 9:37 ` Gerrit Renker
2007-01-24 23:27 ` Ian McDonald
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.