laike9m
laike9m

Reputation: 19348

In HTTP/2, What's the relationship between req/resp, frame and TCP packet?

enter image description here

Image is from https://hpbn.co/http2/#streams-messages-and-frames.

I want to make sure I really understand what's going on, so here's my understanding:

Am I correct?

Upvotes: 5

Views: 1449

Answers (1)

e.dan
e.dan

Reputation: 7487

I believe everything you said is correct, but I'd clarify:

  • The main point is that a single TCP connection may contain frames from many different HTTP/2 streams, interleaved. The relationship to TCP packets is not important here - TCP packets are reassembled into TCP streams by your TCP stack, and should have no bearing on your understanding of HTTP/2.
  • The reason why that first point is important is that it is a huge step forward from HTTP/1, in which the TCP stream is "blocked" by any given request/response pair, since the response to the current request must be sent before any other ones. This is the multiplexing feature that unblocks a huge bottleneck of HTTP/1.
  • A request or response is called a message and yes, it's composed of one or more frames.
  • There is no physical HTTP/2 stream just like there is no physical TCP stream - it's a higher level concept/abstraction that is handled by the layer in question, which reassembles individual packets or frames into a stream, which makes it infinitely easier to deal with.

Hope that helps.

Upvotes: 5

Related Questions