[sane-devel] Network protocol packet sizes
Oliver Rauch
oliver.rauch at rauch-domain.de
Fri Mar 15 00:50:50 GMT 2002
Dave Close wrote:
> Consider a hypothetical frontend which displays a scanned image on the
> screen in real time. It needs a full scan line before it can display
> the line and is written to display only full lines. In general, a scan
> line is not a multiple of the Ethernet MTU. So the frontend requests
> a length equal to a scan line, gets less, and repeats the request for
> the difference. It doesn't request another full scan line on the second
> call because it doesn't double-buffer the data and isn't prepared to do
> anything with data beyond a complete scan line.
>
Hi Dave.
The frontend does not need to double buffer the full image in this case.
It only has to buffer one scan line. And in this point there is no
difference if the frontend or the backend does buffer this line.
> So if a scan line (L) is greater than the data in one network packet
> (P), the frontend will call sane_read N times:
>
> N = int ( ( L + P - 1 ) / P )
>
> My test data involves scan lines of 7000 bytes. With the observed packet
> load of 1488 bytes, for this hypothetical example I would need 5 calls
> to sane_read for each scan line. That's a lot of overhead.
>
Please tell me where there is a lot of overhead?
When the frontend calls sane_read then it does call a library function with 4 parameters:
3 pointers and 1 SANE_Int. When the frontend is linked to sane_dll then the call has
to be done twice. And this is 90% of the necessary overhead, there is no process switching
necessary and nothing that takes a lot of time.
> All of the other backends I've examined always return the maximum size
> specified by the frontend, if they can. Why should net be an exception?
Then you did not ask for large blocks or your system does work totally different
than mine. Most (all?) backends use a reader process to do asyncronous IO between scanner
and sane interface. The data transfer between the reader process and the backend is done
with
a pipe. The size of the pipe on linux is 4096 bytes, so sane_read can not return more
than 4096 bytes (on linux).
If you have any performence problems than I think the reason for your problem is
the network and not the sane_read call.
If you want to do a test: change a local backend so that sane_read never returns
more than 1000 bytes.
Bye
Oliver
--
Homepage: http://www.rauch-domain.de
sane-umax: http://www.rauch-domain.de/sane-umax
xsane: http://www.xsane.org
E-Mail: mailto:Oliver.Rauch at rauch-domain.de
More information about the sane-devel
mailing list