A question about HTTP2, TCP packets and wireshark

240 Views Asked by At

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

1

There are 1 best solutions below

2
sbordet On

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.