[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash sockets: printf \x0a does TCP fragmentation

From: Robert Elz
Subject: Re: bash sockets: printf \x0a does TCP fragmentation
Date: Sun, 23 Sep 2018 16:20:02 +0700

    Date:        Sat, 22 Sep 2018 23:51:08 -0600
    From:        Bob Proulx <address@hidden>
    Message-ID:  <address@hidden>

  | Using the same buffer size
  | for input and output is usually most efficient.

Yes, but as the objective seemed to be to make big packets, that is probably
not as important.

  |   $ printf -- "%s\n" one two | strace -o /tmp/out -e write,read dd 
status=none obs=1M ; cat /tmp/out
  |   one
  |   two
  |   ...
  |   read(0, "one\ntwo\n", 512)              = 8

What is relevant there is that you're getrting both lines from the printf in 
one read.  If that had happened, there would ne no need for any rebuffering.
The point of the original complaint was that  that was not ahppening, and
the reads were being broken at the \n ... here it might easily make a 
difference whether the output is a pipe or a socket (I have no idea.)

  | But even if ibs is much too small it still behaves okay with a small
  | input buffer size and a large output buffer size.

Yes, with separate buffers, that's how dd works (has always worked).
That is why using it that way could solve the problem.

  | It seems to me that using a large buffer size for both read and write
  | would be the most efficient.


  | It can then use the same buffer that data was read into for the output
  | buffer directly.

No, it can't, that's what bs= does - you're right, that is most effecient,
but there is no rebuffering, whatever is read, is written, and in that case
even more effecient is not to interpose dd at all.  The whole point was
to get the rebuffering.

Try tests more like

        { printf %s\\n aaa; sleep 1; printf %s\\n bbb ; } | dd ....

so there will be clearly 2 different writes, and small reads for dd
(however big the input buffer has) - with obs= (somethingbig enough)
there will be just 1 write, with bs= (anything big enough for the whole
output) there will still be two writes.


ps: this is not really the correct place to discuss dd.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]