![netty tcp bridge netty tcp bridge](https://files.speakerdeck.com/presentations/7f0c525b9c314f15b6f94cb488b562ba/slide_13.jpg)
flow control Can send WINDOW_UPDATE frame To reset window size.
![netty tcp bridge netty tcp bridge](https://programmer.group/images/article/e9c7e2cd6a91c54a06dc8290a9db1a46.jpg)
Next, let's look at his two implementation classes, What's different.
#Netty tcp bridge windows
Įstablish the initial windows size after, For the receiver, Every time the sender sends data frame Will reduce window The size of, And every time the receiver sends WINDOW_UPDATE frame Time will increase window Size, From achieving the purpose of dynamic control. The default value of the flow control window is set to 65,535 byte, But the receiver can modify it, The maximum value is 2^31-1 byte. The specific process is like this, When the client and server establish a connection, Will send Http2SettingsFrame, This settings frame It contains SETTINGS_INITIAL_WINDOW_SIZE, This is the window size of the sender, be used for Stream Level flow control. So in HTTP2 in, A more refined flow control mechanism is realized, It allows clients and servers to implement their own data flow and connection level flow control. So for http2 Come on TCP The flow control mechanism itself is too rough, Not enough fine.
![netty tcp bridge netty tcp bridge](https://img2018.cnblogs.com/blog/557082/201912/557082-20191218093905338-858378612.png)
because HTTP2 The multiplexing mechanism is used, One TCP There can be multiple connections http2 Connect. however TCP The flow of is controlled at HTTP2 It's not enough in. In the introduction, we also mentioned, Conventional HTTP1.1 It uses the flow control mechanism at the bottom of the system, To be specific TCP Flow control. This article will introduce netty Yes http2 Flow control support. HTTP2 The buffer size message is transmitted through client-side and server-side applications, By controlling the data flow at the application layer level, Therefore, each application end can control the size of traffic by itself, So as to achieve higher connection efficiency. If the receive window size is zero, The receiver buffer is full, Then the sender will no longer send data, Until the client clears its internal buffer, Then request to resume data transmission.
#Netty tcp bridge free
When data is communicating, Will tell the other party the size of its receiving window, This receive window is the free space remaining in the buffer. Stay HTTP1.1 in, Flow control depends on the bottom layer TCP agreement, When establishing a connection between the client and the server, The system default settings will be used to create the buffer. To avoid buffer overflow, each HTTP The agreements provide certain solutions. Why is there flow control ? This is because no matter what kind of agreement, When receiving data, both the client and server have a buffer to store temporarily unprocessed data, But the size of the buffer is limited, Therefore, buffer overflow may occur, For example, the client uploads a large picture to the server, It may cause the server-side buffer overflow, This leads to the loss of some additional packets. HTTP2 be relative to http1.1 An important improvement is flow control flowcontrol.