Skip to contentSkip to conversation

: New RX History Step 4 - Receiver RTT sampling (part 1 of 3)

PATCH In review Gerrit Renker 2 participants 2 messages Jun 15, 2007 – Jun 25, 2007 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 5/9 : New RX History Step 4 - Receiver RTT sampling (part 1 of 3)

[TFRC]: New RX History Step 4 - Receiver RTT sampling (part 1 of 3)

The CCID 3 receiver needs an RTT estimate, for instance to compute the initial loss interval (RFC 3448, 6.3.1).

A function to realise this is provided by this patch.

It uses a much-optimised variant of the algorithm from [RFC 4342, 8.1]; relying on timestamps and CCVal counters. If RTT estimation fails (e.g. due to early loss), the fall-back value from [RFC 4340, 3.4] is used. For algorithm details see section 5 of
http://www.erg.abdn.ac.uk/users/gerrit/dccp/notes/ccid3_packet_reception/

Note: The complete realisation requires two more steps --
(a) a utility function to identify data packets [next patch] and
(b) the integration of this TFRC-function into CCID3 [next+1 patch].

---
 net/dccp/ccids/ccid3.c              |   67 +++---------------------------------
 net/dccp/ccids/lib/packet_history.c |   42 ++++++++++++++++++++++
 net/dccp/ccids/lib/packet_history.h |    4 +-
 3 files changed, 52 insertions(+), 61 deletions(-)
net/dccp/ccids/lib/packet_history.c +42 -0
@@ -268,6 +268,48 @@ void tfrc_rx_hist_cleanup(struct tfrc_rx
 }
 EXPORT_SYMBOL_GPL(tfrc_rx_hist_cleanup);
 
+/**
+ * tfrc_rx_sample_rtt  -  Sample RTT from timestamp / CCVal
+ * Based on ideas presented in RFC 4342, 8.1. Returns 0 if it was not able
+ * to compute a sample with given data - calling function should check this.
+ */
+u32 tfrc_rx_sample_rtt(struct tfrc_rx_hist *h, struct sk_buff *skb)
+{
+	u32 sample = 0,
+	    delta_v = SUB16(dccp_hdr(skb)->dccph_ccval, rtt_last_s(h)->ccval);
+
+	if (delta_v < 1 || delta_v > 4) {	/* unsuitable CCVal delta */
+
+		if (h->rtt_sample_prev = 2) {	/* previous candidate stored */
+			sample = ktime_delta(rtt_prev_s(h)->stamp,
+					     rtt_last_s(h)->stamp);
+			sample *= 4 / SUB16(rtt_prev_s(h)->ccval,
+					    rtt_last_s(h)->ccval);
+		} else if (delta_v < 1) {
+			h->rtt_sample_prev = 1;
+			goto keep_ref_for_next_time;
+		}
+
+	} else if (delta_v = 4) {     /* optimal match */
+		sample = ktime_to_us(net_timedelta(rtt_last_s(h)->stamp));
+
+	} else	{		       /* suboptimal match */
+		h->rtt_sample_prev = 2;
+		goto keep_ref_for_next_time;
+	}
+
+	if (unlikely(sample > DCCP_SANE_RTT_MAX)) {
+		DCCP_WARN("RTT sample %u too large, using max\n", sample);
+		sample = DCCP_SANE_RTT_MAX;
+	}
+
+	h->rtt_sample_prev = 0;	       /* use current entry as next reference */
+keep_ref_for_next_time:
+
+	return sample;
+}
+EXPORT_SYMBOL_GPL(tfrc_rx_sample_rtt);
+
 /* Module initialisation and cleanup routines */
 int __init packet_history_init(void)
 {
net/dccp/ccids/ccid3.c +7 -60

94 lines not on this page · raw message

net/dccp/ccids/lib/packet_history.h +3 -1
@@ -46,7 +46,8 @@
 #define NDUPACK 3
 
 #define TFRC_WIN_COUNT_PER_RTT	 4
-#define TFRC_WIN_COUNT_LIMIT	16
+/* Subtraction a-b modulo-16, respects circular wrap-around */
+#define SUB16(a,b)		(((a) + 16 - (b)) & 0xF)
 
 /*
  * 	Transmitter History data structures and declarations
@@ -223,6 +224,7 @@ static inline void tfrc_rx_hist_update(s
 	tfrc_rx_hist_entry_from_skb(last_rcv(h), skb, ndp);
 }
 
+extern u32  tfrc_rx_sample_rtt(struct tfrc_rx_hist *, struct sk_buff *);
 extern int  tfrc_rx_hist_init(struct tfrc_rx_hist *);
 extern void tfrc_rx_hist_cleanup(struct tfrc_rx_hist *);