ip结构体中各个字段含义
来源:互联网 发布:ping网络 编辑:程序博客网 时间:2024/05/16 15:49
ip(struct)
ip is a struct (structure) in the C programming language. The ip struct is used as a template to form an IPv4 header in a raw socket. The structure can be found in the default include files of most Unix distributions. It is most commonly located in the <netinet/ip.h> header file.
Definition
struct ip { unsigned int ip_hl:4; /* both fields are 4 bits */ unsigned int ip_v:4; uint8_t ip_tos; uint16_t ip_len; uint16_t ip_id; uint16_t ip_off; uint8_t ip_ttl; uint8_t ip_p; uint16_t ip_sum; struct in_addr ip_src; struct in_addr ip_dst;};
[edit]Fields
unsigned int ip_hl:4
IP header length expressed as a multiple of 32-bit octets or DWORDS (i.e. header length in bytes = value set in ip_hl x 4 [each # counts for 4 octets]). From the hex dump of an IP header this can be read off the value of an unsigned character at offset 0. Typically it will read 45 where 5 is a common default for ip_hl and 4 is ip_v.
- Common Defaults: 5; sets header length to 20 bytes (header length without any routing options)
unsigned int ip_v:4
Internet Protocol version
- Common Defaults: usually 4 (IPv4) or 6 (IPv6)
unsigned char ip_tos;
Type of Service controls the priority of the packet. The first 3 bits stand for routing priority, the next 4 bits for the type of service (delay, throughput, reliability and cost).
- Common Defaults: 0x00 (normal)
unsigned short int ip_len;
Total length must contain the total length of the IP datagram. This includes IP, ICMP, TCP or UDP header and payload size in bytes.
unsigned short int ip_id;
The ID sequence number is mainly used for reassembly of fragmented IP datagrams.
- Common Defaults: Single datagrams - arbitrary ID, Multiple datagrams - sequential ID.
unsigned short int ip_off;
The fragment offset is used for reassembly of fragmented datagrams. The first 3 bits are the fragment flags, the first one always 0, the second the do-not-fragment bit (set by ip_off |= 0x4000) and the third the more-flag or more-fragments-following bit (ip_off |= 0x2000). The following 13 bits is the fragment offset, containing the number of 8-byte big packets already sent.
unsigned char ip_ttl;
Time to live is the amount of hops (routers to pass) before the packet is discarded, and an ICMP error message is returned. Can sometimes be used to reverse engineer the client distance from server (e.g. if ttl = 250 at server, client is probably 5 hops away)
- Common Defaults: 64, 255 (max)
unsigned char ip_p;
The transport layer protocol. Can be tcp (6), udp(17), icmp(1), or whatever protocol follows the IP header. Look in /etc/protocols for more.
unsigned short int ip_sum;
The header checksum. Every time anything in the header changes, it needs to be recalculated, or the packet will be discarded by the next router.
struct in_addr ip_src;
Source IP address - must be converted into binary format (suggested function is inet_pton())
struct in_addr ip_dst;
Destination IP address - must be converted into binary format (suggested function is inet_pton())
- ip结构体中各个字段含义
- HTTP各个字段含义
- HTTP请求报头中各个字段的含义
- /etc/fstab 各个字段含义
- eclipse中类结构中各个小图标的含义
- 11、IP报文的格式,格式的各个字段的含义要理解
- android editText inputType 各个字段的含义
- android dex文件中try块数据结构中各个字段的含义
- 执行计划中各个字段的含义描述及获取方法
- 执行计划中各个字段的含义描述及获取方法
- putty中各个颜色含义
- 屏幕字段结构SCREEN的字段含义
- LWIP中各个结构体汇总
- IP数据包格式每个字段的含义
- 结构体中冒号的含义
- Linux系统 /etc/fstab各个字段含义解释
- Android的DDMS中的Threads的各个字段的含义
- shell 命令产生的各个字段的含义
- BZOJ1010 [HNOI2008]玩具装箱toy
- 混乱的URL编码
- Or How I Learned to Stop Worrying and Love C++ Templates
- eclipse 插件挂载
- oracle随手笔记
- ip结构体中各个字段含义
- dwz日期控件日期控制
- LinkedList的线程安全处理
- Https于Http之间的差异
- 一脸懵逼学习基于CentOs的Hadoop集群安装与配置
- 制作一个简单的canvas动画
- Sql server对表中数据进行排序,并将序号更新至列
- 搭建安卓反编译环境(AndroidStudio)
- 在QT中画曲线图