Sunday, 7 June 2020

3 Flow Controls in Streamed Networking Application

Introduction 

Suppose we develop a network application using reactive stream implementation. And we use HTTP/2 as a base application layer protocol. Reactive streams provide a flow control for stream processing, called back-pressure. A subscriber in reactive stream controls the size of streamed data by requesting its availability to connected publisher.
However, there also exists flow controls at computer networking protocol at application layer and transport layer each. So it means that 3-level flow controls are operating when we try to send streamed data to an end system.

TCP Layer 

It is well known that TCP provides a flow control. It provides client-side a way to control how many TCP segments it can receive at a time. A client notices its available window (size) in TCP header to a connected end system.
=> tunes each TCP segment size at live.
TCP is full-duplex communication, so each end system maintains variables as trasmitter and receiver both.
sender:
a sender can be ensured it is sending less data than of size of rwnd.
```
var = (LastByteSent - LastByteAcked) < rwnd
```
receiver:
a receiver continuously sends 'rwnd' of 'window size' in the TCP header and tells its available buffer size.
```
rwnd = RcvBuffer - (LastByteRcvd - LastByteRead)
```
misc.
if a sender receives rwnd = 0, it may stop transmitting data. However TCP specify its action to repetitively send a signal with 1 byte data.

HTTP/2 

Note that HTTP/1.1 and less does not support any flow control.



> ...
> Do the above requiremsents remind you of TCP flow control? They should, as the problem is effectively identical (see Flow Control). However, because the HTTP/2 streams are multiplexed within a single TCP connection, TCP flow control is both not granular enough, and does not provide the necessary application-level APIs to regulate the delivery of individual streams. To address this, HTTP/2 provides a set of simple building blocks that allow the client and server to implement their own stream- and connection-level flow control:

 HTTP/2 suppports multiplexed streams on a single TCP connection. It exchanges data within DATA, HEADERS frames, while providing for flow control through use of the WINDOW_UPDATE frame. A hop in HTTP/2 connected network controls how many frames it can accept from a counter hop.




  • Flow control is directional. Each receiver may choose to set any window size that it desires for each stream and the entire connection.
  • Flow control is credit-based. Each receiver advertises its initial connection and stream flow control window (in bytes), which is reduced whenever the sender emits a DATA frame and incremented via a WINDOW_UPDATE frame sent by the receiver.
  • Flow control cannot be disabled. When the HTTP/2 connection is established the client and server exchange SETTINGS frames, which set the flow control window sizes in both directions. The default value of the flow control window is set to 65,535 bytes, but the receiver can set a large maximum window size (2^31-1 bytes) and maintain it by sending a WINDOW_UPDATE frame whenever any data is received.
  • Flow control is hop-by-hop, not end-to-end. That is, an intermediary can use it to control resource use and implement resource allocation mechanisms based on own criteria and heuristics.
  •  

    Reactive Stream 

    Back-pressure is a mechaism subscriber controls its acceptance of published data from publisher. If a subscriber and a publisher are seperated on the network, their throughput must be differed from each other. If the subscriber processes the accepted data with throughput at lower rate than the publisher, then remaining data on subscriber-side is being stacked over and over. This results in some storage overflow(this may lead fatal hardware failures!). The subscriber controls its acceptance rate by requesting a size for next published data in its callback.
    Implementations of reactive stream supports many kinds of back-pressure strategies. There is no absolute strategy on various network conditions, and your application can handle back-pressure'd situation by how you want it to work :)

    BUFFER
    DROP

    References




    2 comments: