IETF-SSH archive

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

Re: data overflowing the window



On Sun, Dec 14, 2003 at 11:59:32PM -0500, der Mouse wrote:
> I note that data flowing over channels is flow-controlled with a window
> mechanism somewhat similar to TCP's (connect-18, section 5.2 et al).
> However, since (unlike TCP) there are no sequence numbers, I think I
> see a problem.
> 
> connect-18 excerpt:
> 
>    Data transfer is done with messages of the following type.
> 
>      byte      SSH_MSG_CHANNEL_DATA
>      uint32    recipient channel
>      string    data
> 
>    The maximum amount of data allowed is the current window size.  The
>    window size is decremented by the amount of data sent. Both parties
>    MAY ignore all extra data sent after the allowed window is empty.
> 
> But I think I see a race.  If a CHANNEL_DATA and a WINDOW_ADJUST cross
> in transit, the two ends' idea of how much window space is available
> can get permanently out of sync.  For example:
> 
> A                                                                B
> 
> Suppose the connection is idle and B's receive window is 1000 bytes.
> 
> --> CHANNEL_DATA, 1500 bytes -->

Why would A do this?

> A now thinks B's receive window is zero, with the last 500 bytes of
> data being possibly ignored.
> 
>                                 <-- WINDOW_ADJUST, 1000 bytes <--
> 
> B now thinks its receive window is 2000 bytes.

Er, why?  B first thought it was 1000, then zero (because A consumed
1000 bytes of the window), then 1000 (because the sink on B's side for
that channel consumed the 1000 bytes that A sent, so B grew the window
back to 1000) -- not 2000.

And A first thought the windows was 1000 octets (though it stubbornly
sent 1500 octets), then it knew it would fall to zero (because its
CHANNEL_DATA consumed the window), then it learned that the window went
back to 1000 octets when B sent the WINDOW_ADJUST message.

>                                 --> CHANNEL_DATA, 1500 bytes -->
> 
> B now thinks its receive window is 500 bytes.

See above -- B would now think its window is 0 and would discard the
last 500 bytes that A sent.

> <-- WINDOW_ADJUST, 1000 bytes <--
> 
> A now thinks B's receive window is 1000 bytes.

As does B.

What's the problem?

> At this point, the two ends are 500 bytes out of sync, and A could (for
> example) send 750 bytes thinking B won't ignore any of it whereas B is
> actually likely to ignore the last 250 bytes of it.

See above

Cheers,

Nico
-- 



Home | Main Index | Thread Index | Old Index