数据包解码说明 |
数据链路层 data link layer
如:设备驱动 |
网络层 network layer
如:ip,icmp,igmp等 |
传输层 transport layer
如:tcp,udp |
应用层 application layer
如:ftp,http,email等 |
下图是科来网络分析系统对数据包的解码图,其中对数据包中的每一层协议分别进行了解码分析:
这里面,我们可以看到协议由外向内封装,分别是:
下面我们就分别对这四层协议做详细解释。
ethernet ii的详细资料,可参见网页:
协议结构为:
7 | 1 | 6 | 6 | 2 | 46-1500bytes | 4 |
pre | sfd | da | sa | length type | data unit pad | fcs |
下图是科来网络分析系统5.0对ethernet ii协议解码后的内容,我们利用此实例进行说明:
目标mac地址 0位开始/6 bytes长
源mac地址 6位开始/6 bytes长
上层协议 12位开始/2 bytes长
字段 | 说明 |
destination address | da,目标mac地址6 字节 |
source addresses | sa,源mac地址6 字节 |
protocol | length type,承载的上层协议类型 |
data unit pad,数据字段(46-1500bytes) | |
fcs检验(4bytes) |
mac地址:
mac地址为16进制编码,在解码中可以将前3 bytes代表厂商的字段翻译出来,方便定位问题,如网络上有两台设备ip地址冲突,可以通过厂商信息方便的将故障设备找到,如00e04c为tp-link,000akb为迅捷,00a0c9为intel等等,此资料可参见科来软件提供的ethernet codes master page (ethernet.txt)。
上层协议:
ethernet ii 承载的上层协议主要包括0x800为ip协议和0x806为arp协议。
ip的详细资料,可参见网页:
ip头的结构如下:
4 | 8 | 16 | 19 | 32bits |
ver | ihl | type of service | total length | |
identification | flags | fragment offset | ||
time to live | protocol | header checksum | ||
source address | ||||
destination address | ||||
option padding | ||||
data |
下图是科来网络分析系统对ip层解码后的内容,我们利用此实例进行说明:
下面是ip协议解码的对应字段解释:
字段 | 说明 |
version: 4 | 版本号为4,即ipv4协议, |
header length: 5 | 头部长度20字节,5 bits |
type of service: 000 0000 | 服务提供类型,显示参数摘要。 |
precedence | 优先路由信息 |
delay | 迟延 |
throughput | 吞吐量 |
reliability | 可靠性 |
total length: 131 | 总长131(单位字节,最长为65535字节) |
identification: 10403 | 标识 |
fragmentation flags: 000. …. | 标志 |
reserved: | 保留 |
fragment: | 片断 |
more fragment: | 最后片断 |
fragment offset: 0 | 偏移量 |
time to live: | ttl, 科来网络分析系统5.0将丢弃ttl=0的数据包 |
protocol: 17 | 是哪种协议,1–icmp,6 – tcp, 17 – udp,89 – ospf |
check sum: 0xce73 | 对ip协议头的校验合,0xce73 为正确 |
source ip: 192.168.1.1 | 源ip地址 |
destination ip: 192.168.1.2 | 目标ip地址 |
arp的详细资料,可参见网页:
以下是arp协议结构:
8 | 16 | 32 bits |
hardware type | protocol type | |
hardware address length | protocol address length | opcode |
sender hardware address | ||
sender protocol address | ||
target hardware address | ||
target protocol address |
下图是科来网络分析系统对arp协议进行解码视图:
我们对上图中的arp字段进行详细说明:
字段 | 说明 |
hardware type:1 | (硬件类型) 占16 bits,用来定义运行arp的网络类型,每一个局域网基于其类型被指定一个整数,例如,以太网是类型1,arp可以使用在任何网络上。 |
protocol type: 0x0800 | (协议类型)占16 bits,用来定义协议的类型。如:0x0800代表ip协议,arp可用于任何高层协议。 |
hardware length: 6 | (硬件长度)占8 bits,用来定义物理地址和长度。以太网值为6。 |
protocol length: 4 | (协议长度)占8 bits,用来定义物理地址和长度。ipv4值为4。 |
type: 1 | (操作类型)占16 bits,用来定义操作类型,请求为1,回答为2。 |
source physics: 00:a0:c9:bb:21:2a |
源mac地址 |
source ip: source ip 192.168.1.3 |
源ip地址 |
destination physics: 00:00:00:00:00:00 |
目标mac地址,对于arp请求数据包,此值全为0,因为请求主机并不知道目标主机的mac地址 |
destination ip: 192.168.1.1 |
目标ip地址 |
arp的详细资料,可参见网页:
以下是dns协议的结构:
16 | 32 bits | |||||||
source port | destination port | |||||||
sequence number | ||||||||
acknowledgement number | ||||||||
offset | reserved | u | a | p | r | s | f | window |
checksum | urgent pointer | |||||||
option padding | ||||||||
data | ||||||||
下图是科来网络分析系统对tcp协议进行解码视图:
我们对上图中的tcp字段进行详细说明:
字段 | 说明 |
source port: 80 | 源端口,http为80端口 |
destination port: 3406 | 目标端口 |
sequence number: 4161759990 | 32 bits. the sequence number of the first data octet in this segment (except when syn is present). if syn is present, the sequence number is the initial sequence number (isn) and the first data octet is isn 1. |
ack number: 0 | 32 bits. if the ack control bit is set, this field contains the value of the next sequence number which the sender of the segment is expecting to receive. once a connection is established, this value is always sent. |
data offset: 80 header length: 80 |
4 bits. the number of 32-bit words in the tcp header. this indicates where the data begins. the length of the tcp header is always a multiple of 32 bits. |
reserved: 0 | 6 bits. reserved for future use. must be cleared to zero. |
urgent pointer: | urgent pointer field significant. |
acknowledgment number | acknowledgment field significant. |
push function: | push function. |
reset the connection: | reset the connection. |
synchronize sequence: | synchronize sequence numbers. |
end of data: | no more data from sender. |
window | 16 bits. it specifies the size of the sender’s receive window, that is, the buffer space available in octets for incoming data. |
check sum: | 16 bits. the checksum field is the 16 bit one¡¯s complement of the one¡¯s complement sum of all 16-bit words in the header and text. if a segment contains an odd number of header and text octets to be checksummed, the last octet is padded on the right with zeros to form a 16-bit word for checksum purposes. the pad is not transmitted as part of the segment. while computing the checksum, the checksum field itself is replaced with zeros. |
urgent pointer | 16 bits. this field communicates the current value of the urgent pointer as a positive offset from the sequence number in this segment. the urgent pointer points to the sequence number of the octet following the urgent data. this field can only be interpreted in segments for which the urg control bit has been set. |
arp的详细资料,可参见网页:
以下是http协议的结构:
arp的详细资料,可参见网页:
以下是dns协议的结构:
16 | 17 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 32 |
identification | qr | opcode | aa | tc | rd | ra | z | ad | cd | rcode |
question count | answer count | |||||||||
authority count | additional count |
下图是科来网络分析系统对dns协议进行解码视图:
我们对上图中的dns字段进行详细说明:
字段 | 说明 |
identification: 43 | 标识,占16 bits |
flags: | |
query/response: 1 | 用于定义是query还是response。0为query, 1为response。 |
operator code: 0 | 占 4 bits,其对应代码如下:
0 query, standard query. 1 iquery, inverse query. 2 status, server status request. 3 reserved. 4 notify. 5 update. 6-15 reserved. |
authoritative answer: 0 | 1-bit field. when set to 1, identifies the response as one made by an authoritative name server. 0 not authoritative. 1 is authoritative |
truncation: 0 | 1-bit field. when set to 1, indicates the message has been truncated. 0 not truncated. 1 message truncated |
recursion desired: 1 recursion desired: |
1-bit field. may be set in a query and is copied into the response. if set, the name server is directed to pursue the query recursively. recursive query support is optional. 0 recursion not desired. 1 recursion desired. |
approve recursion: 1 | 1 bit field. indicates if recursive query support is available in the name server. 0 recursive query support not available.1 recursive query support available. |
reserved: 0 | 1 bit field. indicates in a response that all data included in the answer and authority sections of the response have been authenticated by the server according to the policies of that server. it should be set only if all data in the response has been cryptographically verified or otherwise meets the server’s local security policy. |
respond code: 0 | 0 no error. the request completed successfully.
1 format error. the name server was unable to interpret the query. 2 server failure. 3 name error. 6 yxdomain. name exists when it should not. 7 yxrrset. rr set exists when it should not. 8 nxrrset. rr set that should exist does not. 9 notauth. server not authoritative for zone. 10 notzone. name not contained in zone. 11-15 reserved. 16 badvers. bad opt version.badsig. tsig signature failure. 17 badkey. key not recognized. 18 badtime. signature out of time window. 19 badmode. bad tkey mode. 20 badname.duplicate key name. 21 badalg.algorithm not supported. 22-3840 3841-4095 private use. 4096-65535 |
questions: 1 | 16-bit field that defines the number of entries in the question section. |
answers: 2 | 16-bit field that defines the number of resource records in the answer section. |
authority: 0 | 16-bit field that defines the number of name server resource records in the authority section. |
additional: 0 | 16-bit field that defines the number of resource records in the additional records section. |
question: 数据结构
1 16 | 17 32 |
query name | |
type | class |
我们对上图的question进行说明:
字段 | 说明 |
domain name: www.autofx.com. | 请求的域名。 |
type: 1 | 1为a, ipv4 address. |
class: 1 | 1为in, internet. |
answer: 数据结构
1 16 | 17 32 |
name | |
type | class |
ttl | |
rdata length |
我们对上图的answer进行说明:
字段 | 说明 |
domain name: autofx.com. | 解析的域名。 |
type: 1 | 1为a, ipv4 address. |
class: 1 | 1为in, internet. |
time to live: 1200 | 生存周期为1200秒 |
data length 4 | 数据长度为4 字节 |
ip address: 206.132.220.203 | ip地址为206.132.220.203 |