代码之家  ›  专栏  ›  技术社区  ›  Chris

帮助理解linux/tcp.h

  •  1
  • Chris  · 技术社区  · 16 年前

    我正在学习使用原始套接字,并尝试使用tcp头数据,但我似乎不知道res1、ece和cwr是什么。通过我的网络书和谷歌我知道其余的代表什么,但似乎找不到任何关于这三个。 下面是我的includes区域中的tcphdr结构。当我弄清楚这些部分代表什么的时候,我对它们作了一些评论。

    struct tcphdr {
            __be16  source;
            __be16  dest;
            __be32  seq;
            __be32  ack_seq;
    \#if defined(__LITTLE_ENDIAN_BITFIELD)
            __u16   res1:4,
                    doff:4,//tcp header length
                    fin:1,//final
                    syn:1,//synchronization
                    rst:1,//reset
                    psh:1,//push
                    ack:1,//ack
                    urg:1,// urge
                    ece:1,
                    cwr:1;
    \#elif defined(__BIG_ENDIAN_BITFIELD)
            __u16   doff:4,//tcp header length
                    res1:4,
                    cwr:1,
                    ece:1,
                    urg:1,//urge
                    ack:1,//ack
                    psh:1,//push
                    rst:1,//reset
                    syn:1,//synchronization
                    fin:1;//final
    \#else
    \#error  "Adjust your <asm/byteorder.h> defines"
    \#endif
            __be16  window;
            __sum16 check;
            __be16  urg_ptr;
    };
    
    1 回复  |  直到 15 年前
        1
  •  3
  •   evilpie    16 年前

    http://en.wikipedia.org/wiki/Transmission_Control_Protocol#TCP_segment_structure

    res1在那里被称为reserved。其他的名字都一样。

    CWR(1位)拥塞窗口减少(CWR)
    ECE(1位)ECN回波指示