wireshark - 为什么这个 SPDY SYN_STREAM 样本的 header 显然未压缩?

标签 wireshark zlib spdy

我正在试验 SPDY 协议(protocol),我偶然发现了 a sample of SPDY protocol (可以使用“attachment”链接下载)。

这是我的看法:

  • 在 Wireshark 1.12.2(或更新版本)
  • 中打开 pcapng 文件
  • 右键单击任何 SSL/TLS 帧,然后转到 Protocol Preferences -> RSA keys list...
  • 点击新建,输入IP地址0.0.0.0,端口443,协议(protocol)spdy和this key file的路径,
  • 右键单击任何 SPDY 帧,转到 Protocol Preferences -> Uncompress SPDY headers 以禁用 SPDY header decompression
  • 转到第 45 帧,观察“SPDY: SYN_STREAM”层中,突出显示“Header Block”后,下面的十六进制转储是可读的

  • 根据 SPDY 规范,this should be compressed .为什么我可以看到这个?有没有办法在 SPDY 协议(protocol)中禁用 header 压缩?我是否以错误的方式使用 Wireshark?

    最佳答案

    关于规范

    您链接的草案指出:

    The entire contents of the name/value header block is compressed using zlib. There is a single zlib stream for all name value pairs in one direction on a connection. SPDY uses a SYNC_FLUSH between each compressed frame.

    Implementation notes: the compression engine can be tuned to favor speed or size. Optimizing for size increases memory use and CPU consumption. Because header blocks are generally small, implementors may want to reduce the window-size of the compression engine from the default 15bits (a 32KB window) to more like 11bits (a 2KB window). The exact setting is chosen by the compressor, the decompressor will work with any setting.



    它不强制执行任何压缩级别。事实上,你可以使用 zlib 完全不压缩,这是 zlib 格式支持的:

    Level 0 actually does no compression at all, and in fact expands the data slightly to produce the zlib format (it is not a byte-for-byte copy of the input).



    关于 sample

    我联系了样本的作者。原来他正在使用 nginx 进行实验。在他提供的文档中,nginx的配置是这样的:
     # SPDY
     server {
         listen       443 ssl spdy;
         server_name  localhost;
         ssl_certificate      cert.pem;
         ssl_certificate_key  key.pem;
         ssl_session_cache    shared:SSL:1m;
         ssl_session_timeout  5m;
         ssl_ciphers  DES-CBC3-SHA;
         ssl_prefer_server_ciphers  on;
         location / {
             root   html;
             index  index.html index.htm;
         }
    

    但是,nginx 文档指出必须明确指定 header 压缩:

    Syntax: spdy_headers_comp level;
    Default : spdy_headers_comp 0;
    

    Sets the header compression level. [...] The special value 0 turns off the header compression.



    这意味着很可能没有为实验启用 header 压缩。

    我的结论
  • 是的,您可以在 SPDY 中禁用 header 压缩,但您必须保持 zlib 格式的压缩级别为 0
  • 您正在正确使用 Wireshark。您使用的示例是使用压缩级别 0
  • 创建的

    关于wireshark - 为什么这个 SPDY SYN_STREAM 样本的 header 显然未压缩?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27454189/

    相关文章:

    在没有运行 Wireshark 的情况下无法在 C 中嗅探 UDP 数据包

    c - 使用 zlib 编译 c 代码的正确标志是什么

    Python 和 zlib : Terribly slow decompressing concatenated streams

    c++ - Wireshark 插件 : Is There a non-ntoh Version of tvb_get_ntoh64?

    sockets - UDP 正在向数据报的末尾添加字节?

    macos - macOS 上的 Wireshark 不解析 HTTP 数据包

    c# - zlib 的 gzip 压缩和 .NET 的 GZipStream 使用的压缩有什么区别?

    android - Android 浏览器是否支持 SPDY 协议(protocol)?

    browser - 当支持 SPDY 的浏览器收到 HTTP2 (H2) 响应时会发生什么?

    Node.js 和 SPDY ...不工作?