IETF-SSH archive

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

Re: Speaking of implementation quirks...



der Mouse <mouse%Rodents.Montreal.QC.CA@localhost> writes:

> > The first is possible confusion with the definition in 5.1 Opening a
> > Channel in -connect.  I recently found an implementation that thinks
> > that "maximum packet size" is the maximum payload size (not the
> > packet size), [...]
> 
> But it _is_ the packet size, just of different packets.  There are so
> many layers to ssh that "packet size" is an unclear concept unless it's
> disambiguated by reference to what layer it's at.

My reading is that the maximum packet size in SSH_MSG_CHANNEL_OPEN and
SSH_MSG_CHANNEL_OPEN_CONFIRMATION refers to the length of the data
field in SSH_MSG_CHANNEL_DATA and SSH_MSG_CHANNEL_EXTENDED_DATA. I.e.
an amount of application data. That's the _same_unit_of_measurement_
as for the window size, and I think that's what makes most sense in
the context.

When I decide how much application data I can send on a channel, I
simply take the minimum of the current window size and the channel's
max packet size ("read" below refers to reading from the data source,
e.g. stdin or a socket that's being forwarded):

  /* There are three numbers that limit the amount of data we can read:
   *
   *   1 The current send_window_size.
   *   2 The send_max_packet size for the channel.
   *   3 (The maximum size for a complete packet SSH_MAX_PACKET)
   *
   * We don't enforce (3) here, but assume that if the remote end has
   * given us a huge send_max_packet, it will also handle huge ssh
   * packets.
   *
   * For channels that are forwarded via a gateway, we do need to care
   * about (3), but that is done by the gatewaying code adjusting the
   * send_max_packet. */

  return MIN(self->channel->send_window_size, self->channel->send_max_packet);

Having send_max_packet use a different unit than the window size would
just make the flow control code more complex for no good reason.

My implementation also enforces the 32K limit on received ssh packets.
But that's no problem, I just make sure that I never advertize a
channel maximum packet size larger than

  #define SSH_MAX_DATA_SIZE (SSH_MAX_PACKET - SSH_CHANNEL_MAX_PACKET_FUZZ)

which happens to be 30536 bytes (a little conservative, but I don't
think it matters very much).

Regards,
/Niels



Home | Main Index | Thread Index | Old Index