Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Network.Control
Description
Common parts to control network protocols.
This library assumes that Int
is 64bit.
Synopsis
- defaultMaxStreams :: Int
- defaultMaxStreamData :: Int
- defaultMaxData :: Int
- data TxFlow = TxFlow {}
- newTxFlow :: WindowSize -> TxFlow
- txWindowSize :: TxFlow -> WindowSize
- type WindowSize = Int
- data RxFlow = RxFlow {
- rxfBufSize :: Int
- rxfConsumed :: Int
- rxfReceived :: Int
- rxfLimit :: Int
- newRxFlow :: WindowSize -> RxFlow
- data FlowControlType
- maybeOpenRxWindow :: Int -> FlowControlType -> RxFlow -> (RxFlow, Maybe Int)
- checkRxLimit :: Int -> RxFlow -> (RxFlow, Bool)
- data LRUCache k v
- empty :: Int -> LRUCache k v
- insert :: Ord k => k -> v -> LRUCache k v -> LRUCache k v
- delete :: Ord k => k -> LRUCache k v -> LRUCache k v
- lookup :: Ord k => k -> LRUCache k v -> Maybe v
- data Rate
- newRate :: IO Rate
- getRate :: Rate -> IO Int
- addRate :: Rate -> Int -> IO Int
Flow control
This is based on the total approach of QUIC rather than the difference approach of HTTP/2 because QUIC'one is considered safer. Please refer to Using HTTP/3 Stream Limits in HTTP/2 to understand that QUIC's approaches are better though its topic is about stream concurrency.
Constants for flow control.
defaultMaxStreams :: Int Source #
Default max streams. (64)
defaultMaxStreamData :: Int Source #
Default max data of a stream. (256K bytes)
defaultMaxData :: Int Source #
Default max data of a connection. (1M bytes)
Flow control for sending
Flow for sending
--------------------------------------> ^ ^ txfSent txfLimit |-----------| The size which this node can send txWindowSize
Constructors
TxFlow | |
newTxFlow :: WindowSize -> TxFlow Source #
Creating TX flow with a receive buffer size.
txWindowSize :: TxFlow -> WindowSize Source #
type WindowSize = Int Source #
Window size.
Flow control for receiving
Flow for receiving.
rxfBufSize |------------------------| --------------------------------------> ^ ^ ^ rxfConsumed rxfReceived rxfLimit |-----------| The size which the peer can send Window
Constructors
RxFlow | |
Fields
|
newRxFlow :: WindowSize -> RxFlow Source #
Creating RX flow with an initial window size.
data FlowControlType Source #
The representation of window size update.
Constructors
FCTWindowUpdate | HTTP/2 style |
FCTMaxData | QUIC style |
Arguments
:: Int | The consumed size. |
-> FlowControlType | |
-> RxFlow | |
-> (RxFlow, Maybe Int) |
|
When an application consumed received data, this function should
be called to update rxfConsumed
. If the available buffer size
is less than the half of the total buffer size.
the representation of window size update is returned.
Example: rxfBufSize |------------------------| --------------------------------------> ^ ^ ^ rxfConsumed rxfReceived rxfLimit |01234567890| In the case where the window update should be informed to the peer,rxfConsumed
andrxfLimit
move to the right. The difference of old and newrxfLimit
is window update. rxfBufSize |------------------------| --------------------------------------> ^ ^ ^ rxfConsumed rxfReceived rxfLimit |0123456789012| : window glows Otherwise, onlyrxfConsumed
moves to the right. rxfBufSize |------------------------| --------------------------------------> ^ ^ ^ rxfConsumed rxfReceived rxfLimit |01234567890| : window stays
Checking if received data is acceptable against the current window.