-1

In last several days I always worked at a project about HTTP2, now I want to be clear about if a TCP packet can contain several HEADERS frames whose function are to create a new stream. As I just saw on the reference, several requests can be compressed into one packet, why I can not find multiple requests in a packet in wireshark?

The HEADERS frame I mentioned above is: associates with a request, has :method: GET or other segments

Please help me!!! Thank you

I can not find multiple requests in a packet in wireshark

  • SO is a programming Q&A platform and this question is not about programming. Questions about operating systems, their utilities, networking and hardware, are off topic here. [What topics can I ask about here?](https://stackoverflow.com/help/on-topic). Please delete this – Rob Jul 08 '23 at 19:39

1 Answers1

0

Yes, a TCP packet can contain multiple HEADERS frames.

Typically a TCP packet has an MTU of about 1500 bytes, while a typical HEADERS frame containing an HTTP request could be around 200-500 bytes so a TCP packet can contain about 2-8 HEADERS frames.

However, it is typical for clients to issue a TCP write per HTTP request, which is why you see just one HEADERS frame in each TCP packet.

To have the client send multiple HEADERS frames in a single TCP packet, you would need the following:

  • The client to support the gathering of many HEADERS frames into single TCP writes.
  • To cause the client to accumulate HEADERS frames, which typically means to send HTTP requests concurrently at a rate that is higher than the rate of TCP writes.

In summary, the case of multiple HEADERS frames in a single TCP packet depends heavily on the client implementation and the HTTP request send rate.

Disclaimer, I am the implementer of HTTP/2 in the Jetty Project

Jetty's HttpClient supports HEADERS frame gathering, so in the right conditions it may issue multiple HEADERS frames in a single TCP packet.

sbordet
  • 16,856
  • 1
  • 50
  • 45
  • Thank you very much, your answer solves my problem! – Ricardo Chiang Jul 10 '23 at 03:47
  • I want to ask another question: can a frame span two packets? For example, the former part of one frame exists in the first TCP packet while the latter part in the second packet – Ricardo Chiang Jul 10 '23 at 05:53
  • Yes, an HTTP/2 frame may span two TCP packets. The conditions where this happens are probably rare and difficult to reproduce, but in general TCP frame may be split/assembled along the way from client to server by any intermediary as they see fit, so you must not assume that if a peer wrote an HTTP/2 frame in a single TCP write, it will arrive so at the remote peer. – sbordet Jul 10 '23 at 06:35