分类: C/C++
2007-09-17 09:37:21
IP header structure:
4 | 8 | 16 | 32bit | |
Version | IHL | Type of service | Total length | |
Identification | Flags | Fragment offset | ||
Time to live | Protocol | Header checksum | ||
Source address | ||||
Destination address | ||||
Option + Padding | ||||
Data |
|
16 | 32 bit | |||||||
Source port | Destination port | |||||||
Sequence number | ||||||||
Acknowledgement number | ||||||||
Offset | Reserved | U | A | P | R | S | F | Window |
Checksum | Urgent pointer | |||||||
Option + Padding | ||||||||
Data |
|
U (URG) | Urgent pointer field significant. |
A (ACK) | Acknowledgment field significant. |
P (PSH) | Push function. |
R (RST) | Reset the connection. |
S (SYN) | Synchronize sequence numbers. |
F (FIN) | No more data from sender. |
|
UDP HEAD
16 |
32bit |
source port |
Destination port |
length |
checksum |
data |
UDP长字段的值是UDP报文头的长度(8字节)与UDP所携带数据长度的总和。确定UDP长字段值的快速方法是将IP长字段的值减去20个字节。因为IP报文头的长度始终是20字节,所以结果就总是取决于UDP报文头及UDP数据的长度。例如,如果IP所带数据为1480字节,则可以知道UDP所带的数据是1452字节(1480-20(IP)-8(UDP报头)=UDP数据)。当然,您可以查看UDP长字段,不过有时进行减法运算更容易。
UDP校验和字段是对整个UDP报文头和UDP所带的数据的校验和。UDP报文头的校验和是可选的,应用程序可以不使用该校验和。取消UDP校验和计算有时可以加快运行缓慢的主机上的报文处理。如果没有使用校验和,则发送方传输的校验和必须是全1。当接收方站点在校验和字段发现都是1时,就不会试图重新计算校验和。
ICMP HEAD
8 |
16 |
32bit |
Type |
Code |
Checksum |
Identifier |
Sequence number | |
Address mask |
|
16 | 21 | 28 | 32 bit | ||||||
ID | Q | Query | A | T | R | V | B | Rcode | |
Question count |
Answer count | ||||||||
Authority count | Additional count |
|