5

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:

  • a TCP packet may contain several frames, and they can belong to different streams.
  • a request or response is composed of one or more frames that belong to the same stream.
  • Physically there's no "stream", it's just a logical concept(Yeah I know each frame contains a stream ID).

Am I correct?

4
  • HTTP/2 is an application layer protocol while TCP is a transport layer streaming protocol. There is no specific relation between a TCP packet and specific parts of the application layer, i.e. there might be multiple application layer entities inside a single TCP packet, partial entities etc. Commented Sep 28, 2016 at 6:19
  • Looks about right. Commented Sep 29, 2016 at 6:25
  • Frames and streams are abstractions built on TCP. Consider that a single browser request is built on 7 layers of abstraction: en.wikipedia.org/wiki/OSI_model#Description_of_OSI_layers Commented Oct 26, 2016 at 18:31
  • @BSeven Yes, you're right. Commented Oct 27, 2016 at 3:49

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

2 Comments

The reason I'm asking about TCP packet is that I'm using WireShark to debug http2, and each "line" in Wireshark is a TCP packet (I guess?). I see each line contain multiple frames, that's why I'm asking. BTW I don't really understand what you mean by "TCP packets are reassembled into TCP streams by your TCP stack, and should have no bearing".
@laike9m: Each TCP "packet" contain just some part of the TCP stream. These packets have no relation to any kind of message - because TCP is a single stream and not a sequence of messages. Thus an application layer frame may be packet in multiple TCP packets, a single packet may contain multiple application layer frames etc. There simply is no defined mapping from application layer frames to TCP packets.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.