Hi,

I just found a way to speed up IrLPT! While printing to my HP LaserJet
2100TN, I noticed that the printing went really slow even if I had a 4Mbps
connection. The reason is as follows:

13:43:15.729396 (0000.39 ms) i:cmd  > ca=28 pf=1 nr=3 ns=6 LM slsap=10 dlsap=02 (2048) 
13:43:15.737624 (0008.23 ms) rr:rsp < ca=28 pf=1 nr=7 (2) 
13:43:15.738028 (0000.40 ms) i:cmd  > ca=28 pf=1 nr=3 ns=7 LM slsap=10 dlsap=02 (2048) 
13:43:15.744256 (0006.23 ms) rnr:rsp < ca=28 pf=1 nr=7 (2) 
13:43:16.234777 (0490.52 ms) rr:cmd > ca=28 pf=1 nr=3 (2) 
13:43:16.239471 (0004.69 ms) rr:rsp < ca=28 pf=1 nr=7 (2) 
13:43:16.239860 (0000.39 ms) i:cmd  > ca=28 pf=1 nr=3 ns=7 LM slsap=10 dlsap=02 (2048) 
13:43:16.247044 (0007.18 ms) rr:rsp < ca=28 pf=1 nr=0 (2) 
13:43:16.247515 (0000.47 ms) i:cmd  > ca=28 pf=1 nr=3 ns=0 LM slsap=10 dlsap=02 (71) 
13:43:16.249758 (0002.24 ms) rnr:rsp < ca=28 pf=1 nr=0 (2) 
13:43:16.744864 (0495.11 ms) rr:cmd > ca=28 pf=1 nr=3 (2) 
13:43:16.747100 (0002.24 ms) rr:rsp < ca=28 pf=1 nr=0 (2) 

Here you can see that the LaserJet sends me a RNR (receive not ready) frame
after it receives data. This means that it currently cannot receive more
data (IrLAP flow control in action). What I then do is to wait the maximum
turnaround time before polling it again. After a little bit of thinking, I
had to admit to myself, that it was not the LaserJet that was slow. In fact
is was me!

So how do we fix this. Linux-IrDA already have a feature called "fast
RR's", so fixed the code so that fast RR's are used if our own Tx queue is
empty, or if the remote device is busy. The change in speed was enormous:

13:53:20.090728 (0000.38 ms) i:cmd  > ca=86 pf=1 nr=3 ns=3 LM slsap=10 dlsap=02 (1460) 
13:53:20.095861 (0005.13 ms) rnr:rsp < ca=86 pf=1 nr=3 (2) 
13:53:20.096220 (0000.36 ms) rr:cmd > ca=86 pf=1 nr=3 (2) 
13:53:20.098974 (0002.75 ms) rr:rsp < ca=86 pf=1 nr=3 (2) 
13:53:20.099343 (0000.37 ms) i:cmd  > ca=86 pf=1 nr=3 ns=3 LM slsap=10 dlsap=02 (1460) 
13:53:20.106877 (0007.53 ms) rr:rsp < ca=86 pf=1 nr=4 (2) 
13:53:20.107261 (0000.38 ms) i:cmd  > ca=86 pf=1 nr=3 ns=4 LM slsap=10 dlsap=02 (2048) 
13:53:20.113337 (0006.08 ms) rnr:rsp < ca=86 pf=1 nr=4 (2) 
13:53:20.113696 (0000.36 ms) rr:cmd > ca=86 pf=1 nr=3 (2) 
13:53:20.118802 (0005.11 ms) rr:rsp < ca=86 pf=1 nr=4 (2) 
13:53:20.119156 (0000.35 ms) i:cmd  > ca=86 pf=1 nr=3 ns=4 LM slsap=10 dlsap=02 (2048) 

So now you can see that we poll the LaserJet as fast as possible, when it's 
busy, and it will give us permission to send more data just a few ms later
instead of over 500 ms later.

You might think that this is a bad thing because you will bounce the
"token" very fast back and forth and burning battery power, but Linux will
back off and eventually reach the maximum turn-around time. Here is an
example of backoff.

13:53:20.234193 (0000.40 ms) i:cmd  > ca=86 pf=1 nr=3 ns=3 LM slsap=10 dlsap=02 (2048) 
13:53:20.240613 (0006.42 ms) rnr:rsp < ca=86 pf=1 nr=3 (2) 
13:53:20.240973 (0000.36 ms) rr:cmd > ca=86 pf=1 nr=3 (2) 
13:53:20.243877 (0002.90 ms) rnr:rsp < ca=86 pf=1 nr=3 (2) 
13:53:20.284857 (0040.98 ms) rr:cmd > ca=86 pf=1 nr=3 (2) 
13:53:20.287448 (0002.59 ms) rnr:rsp < ca=86 pf=1 nr=3 (2) 
13:53:20.384858 (0097.41 ms) rr:cmd > ca=86 pf=1 nr=3 (2) 
13:53:20.388496 (0003.64 ms) rnr:rsp < ca=86 pf=1 nr=3 (2) 
13:53:20.534780 (0146.28 ms) rr:cmd > ca=86 pf=1 nr=3 (2) 
13:53:20.538320 (0003.54 ms) rnr:rsp < ca=86 pf=1 nr=3 (2) 
13:53:20.734781 (0196.46 ms) rr:cmd > ca=86 pf=1 nr=3 (2) 
13:53:20.738674 (0003.89 ms) rnr:rsp < ca=86 pf=1 nr=3 (2) 
13:53:20.984942 (0246.27 ms) rr:cmd > ca=86 pf=1 nr=3 (2) 
13:53:20.987817 (0002.88 ms) rnr:rsp < ca=86 pf=1 nr=3 (2) 
13:53:21.284860 (0297.04 ms) rr:cmd > ca=86 pf=1 nr=3 (2) 
13:53:21.289559 (0004.70 ms) rr:rsp < ca=86 pf=1 nr=3 (2) 
13:53:21.289948 (0000.39 ms) i:cmd  > ca=86 pf=1 nr=3 ns=3 LM slsap=10 dlsap=02 (2048) 

-- Dag

-- 
   / Dag Brattli                   | The Linux-IrDA Project               /
  // University of Tromsoe, Norway | Infrared communication for Linux    //
 /// http://www.cs.uit.no/~dagb    | http://www.cs.uit.no/linux-irda/   ///




_______________________________________________
Linux-IrDA mailing list  -  [EMAIL PROTECTED]
http://www.pasta.cs.UiT.No/mailman/listinfo/linux-irda

Reply via email to