ben-wpan: pings between atben and atusb

Werner Almesberger werner at
Thu Jul 7 23:59:51 EDT 2011

Some news from the ben-wpan driver front: Stefan Schmidt did some
great work on the atusb driver, based on Richard Sharpe's skeleton
driver. I then killed a few remaining bugs.

All the kernel code is in the ben-wpan branch of

Now I got some clean pings between a Ben equipped with atben and a
PC equipped with atusb, both running dirtpan:

  100 packets transmitted, 100 received, 0% packet loss, time 99524ms
  rtt min/avg/max/mdev = 152.010/158.962/176.015/5.154 ms

The round-trip-time is quite long. This it at least in part
because it seems that I can get only one USB control transfer per
1 ms frame, which means that the very best-case timing for a
send-receive turnaround (on one end) is 23 ms. Sometimes, a control
transfer also takes longer.

A ping over dirtpan exchanges a total of four frames: the Echo
Request, an ACK generated by dirtpan, the Echo Reply, and finally
an ACK for the Echo Reply.

I don't see anything in the USB specification that would require
control transfers to be so slow, but I haven't been able to find
any mechanism in the kernel to make them faster either. Ideas
welcome :-)

dirtpan has relatively short timeouts. To make it work in this
scenario, the timeouts have to be enlarged, see the patch below.

One additional complication is that atben turns around faster
than atusb, so the ACK for a frame sent from atusb to atben is
usually lost, and it takes the two a while to resolve the problem.
As a dirty work-around, I just make dirtpan's send_ack wait until
we can be reasonably sure the peer has turned around.

The long turn-around time also effectively breaks any serious use
of TCP (SSH or such), probably because of TCP ACK loss.

If there's no easy solution for getting control transfers handled
more quickly, then it will be necessary to move more of the
send/receive logic from the kernel driver into the firmware.

- Werner

---------------------------------- cut here -----------------------------------

diff --git a/tools/dirtpan/dirtpan.c b/tools/dirtpan/dirtpan.c
index 5e6d200..22a20fa 100644
--- a/tools/dirtpan/dirtpan.c
+++ b/tools/dirtpan/dirtpan.c
@@ -61,8 +61,8 @@ enum packet_type {
 #define	MAX_FRAG	(127-11-2-1)	/* MHDR, FCS, control byte */
 #define	MAX_PACKET	2000
 #define	MAX_TRIES	5
-#define	T_REASS_MS	200
-#define	T_ACK_MS	50
+#define	T_REASS_MS	500
+#define	T_ACK_MS	100
 static struct {
@@ -323,6 +323,7 @@ static void send_ack(int seq)
 	uint8_t ack = pt_ack | (seq ? SEQ : 0);
 	send_frame(&ack, 1);

More information about the discussion mailing list