Chinaunix首页 | 论坛 | 博客
  • 博客访问: 93392
  • 博文数量: 14
  • 博客积分: 188
  • 博客等级: 入伍新兵
  • 技术积分: 142
  • 用 户 组: 普通用户
  • 注册时间: 2011-10-11 09:59
文章分类

全部博文(14)

文章存档

2012年(14)

分类: LINUX

2012-05-17 16:16:19

转于:%CE%ED%B6%BC%D6%AE%D1%C5/blog/item/d9d456e3753329cfcf1b3e83.htmlIP、TCP、UDP Header StructIP头视图


IP头结构体

typedef struct _IPHeader                    // 20字节的IP头
{
    UCHAR     iphVerLen;          // 4位首部长度+4位IP版本号            | Version (4 bits) + Internet header length (4 bits)
    UCHAR     ipTOS;                 // 8位服务类型                                    | TOS Type of service
    USHORT    ipLength;             // 16位封包总长度,即整个IP报的长度   | Total length
    USHORT    ipID;                    // 16位封包标识,惟一标识发送的每一个数据报      | Identification
    USHORT    ipFlags;              // 3位标志位+13报片偏移                 | Flags (3 bits) + Fragment offset (13 bits)
    UCHAR     ipTTL;                 // 8位生存时间,就是TTL                 | Time to live
    UCHAR     ipProtocol;            // 8位协议,TCP、UDP、ICMP等          | Protocol
    USHORT    ipChecksum;    // 16位IP首部校验和                   | Header checksum
    ULONG     ipSource;          // 32位源IP地址                       | Source address
    ULONG     ipDestination;            // 32位目标IP地址                     | Destination address
} IPHeader, *PIPHeader;      

 


TCP头视图


TCP头结构体

typedef struct _TCPHeader          // 20字节的TCP头
{
       USHORT sourcePort;           // 16位源端口号    | Source port
       USHORT destinationPort;      // 16位目的端口号 | Destination port
       ULONG sequenceNumber;       // 32位序列号      | Sequence Number
       ULONG acknowledgeNumber;    // 32位确认号      | Acknowledgement number
       UCHAR   dataoffset;                        // 高4位表示数据偏移,低6位保留字 | Header length
       UCHAR   flags;                  // 6位标志位       | packet flags
       USHORT windows;                    // 16位窗口大小    | Window size
       USHORT checksum;                  // 16位校验和      | Header Checksum
       USHORT urgentPointer;        // 16位紧急数据偏移量   | Urgent pointer...still don't know what this is...
} TCPHeader, *PTCPHeader;      

                                              

UDP头视图

UDP头结构体

typedef struct _UDPHeader
{
       USHORT               sourcePort;           // 16位源端口号   | Source port
       USHORT               destinationPort;      // 16位目的端口号 | Destination port     
       USHORT               len;                  // 16位封包长度   | Sequence Number
       USHORT               checksum;             // 16位校验和     | Acknowledgement number
} UDPHeader, *PUDPHeader;                   


阅读(5747) | 评论(0) | 转发(0) |
0

上一篇:Linux Pthread 深入解析

下一篇:没有了

给主人留下些什么吧!~~