[sane-standard] more network protocol proposals

Johannes Berg johannes@sipsolutions.net
Fri, 15 Oct 2004 16:03:36 +0200


--=-uJreBg2hZIlAPDePNyx8
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

After having worked through the network protocol here are a few more
suggestions:

* make the handle only one byte long (this will suffice for 255
   simultaneous scans, I don't think that could reasonably be called a
   limitation)
* make the procedure code only one byte long
* prepend the request procedure code to the answer
   (that is, an answer that would previously have been
    |status (1 word)| would now be
    |code (1b)|status (1w)|
   and it would be allowed for the server to send other packets before
   the answer.

These both assist in data reduction with the following:

* transfer scan data in the same connection as control data

This can be achieved by adding two new reserved procedure codes for
answers only, scan_data and scan_data_eof.
When scan_data is returned, the data record looks like this:
| scan_data code (1b) | handle (1b) | length (2b) | data... |
for scan_data_eof, only scan_data_eof code and handle are present.

I have deliberately made the length field only 2 bytes long because more
would hurt the case of small packets more, and less is obviously bad
too, a maximum of 64k data per packet seems reasonable. At 64k / packet
the overhead of this would be negligible, at 1k packets it is still less
than 4 percent. The server could of course locally cache data to fill
the packets to 64k (this shouldn't hurt).

I'd say this is worth it for the reasons that it very much simplifies
the code (no more extra sockets etc), makes saned easier to work with
through firewalls and allows for encrypting the transport much easier.

As an extra bonus, this allows the server to instruct callbacks on the
client side (these need to be defined as procedure codes, and also in
the SANE API).

johannes

--=-uJreBg2hZIlAPDePNyx8
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Comment: Johannes Berg (SIP Solutions)

iQIVAwUAQW/YtKVg1VMiehFYAQKWJg//VD+ul6VY/zRvOhYfvTWJvxJ/V2/FuEnH
P7d8+3vS2i3y+eG6njw9KPLXyHeXRbgbIjdOvkuhaXU3g+6lnbTJ25Qe2M3DZZbe
ZSTYD8e5ZhL+v15YdWBl+jdKHy1DbknsgNazk4Wpu22whtYxaZEPxgmkrt1Nm7o4
5FI/nqRxjdN5/1He4Gh3ccwfamr1W8e6sW3Q/5V/2PuTylAedm3PXYbeJCN6OsUN
aMY4hAz6UJQTLJbwAnlT4fIrIlCXZ42SoUmWy+Hr7l8vVSJGo42Oa9ylpO3mgZ0N
1Pdkb9VOQg9NhkvvI2sKFHjl6Z33wt9K8Y+97o4/Q8C0ccspfWYQVzUBxi6t1k5G
jlnuKacfibdH+EWM67NbxB8g5+m6+H1oEOW8sedWpH2FOjJZc2KKBkVVPdM7Dp79
o8Mk6jZ/D3KJzY08IK93L8mF4r+zLwZI5cSRXjjNck9K1irmwGC8xeL4NeIVce+S
Xik0reZ/J//DZJ3P2mGmVr897ZsPsTzybhPad+5jVnaZUiLLzPCF3nkZrGnWgEFv
bgC3ApDzHKcDgsu+7iMxoeJRca/bZoFhh64Fhc9PDs8tjCObK0xVk/SleY1wCoLN
5tEHHGSxtQI7ESyTlM/Ggz28fY1Qw/1d45sYXvUaO1FFDLRZYysVBwtcYoS2vj9n
kSXRATF0N9k=
=1esm
-----END PGP SIGNATURE-----

--=-uJreBg2hZIlAPDePNyx8--