常见协议解码详解.docx
- 文档编号:28815558
- 上传时间:2023-07-19
- 格式:DOCX
- 页数:14
- 大小:142.89KB
常见协议解码详解.docx
《常见协议解码详解.docx》由会员分享,可在线阅读,更多相关《常见协议解码详解.docx(14页珍藏版)》请在冰豆网上搜索。
常见协议解码详解
常见协议解码详解
●数据包封包分层
数据包解码说明
数据链路层DataLinkLayer
如:
设备驱动
网络层NetworkLayer
如:
IP,ICMP,IGMP等
传输层TransportLayer
如:
TCP,UDP
应用层ApplicationLayer
如:
FTP,HTTP,Email等
下图是对数据包的解码图,其中对数据包中的每一层协议分别进行了解码分析:
这里面,我们可以看到协议由外向内封装,分别是:
1.数据链路层对应“EthernetII”协议;
2.网络层对应“IP”协议;
3.传输层对应“UDP”协议;
4.应用层对应“DNS”协议。
下面我们就分别对这四层协议做详细解释。
●以太网数据包结构
协议结构为:
7
1
6
6
2
46-1500bytes
4
Pre
SFD
DA
SA
LengthType
Dataunit+pad
FCS
下图是EthernetII协议解码后的内容,利用此实例进行说明:
上层协议
0x0800(IP协议)
目标MAC
地址
源MAC
地址
目标MAC地址0位开始/6bytes长
源MAC地址6位开始/6bytes长
上层协议12位开始/2bytes长
字段
说明
Destinationaddress
DA,目标MAC地址6字节
Sourceaddresses
SA,源MAC地址6字节
Protocol
LengthType,承载的上层协议类型
Dataunit+pad,数据字段(46-1500bytes)
FCS检验(4bytes)
MAC地址:
MAC地址为16进制编码,在解码中可以将前3bytes代表厂商的字段翻译出来,方便定位问题,如网络上有两台设备IP地址冲突,可以通过厂商信息方便的将故障设备找到,如00e04C为TP-LINK,000AKB为迅捷,00A0C9为Intel等等,
上层协议:
EthernetII承载的上层协议主要包括0x800为IP协议和0x806为ARP协议。
●IP协议结构
IP头的结构如下:
4
8
16
19
32bits
Ver
IHL
Typeofservice
Totallength
Identification
Flags
Fragmentoffset
Timetolive
Protocol
Headerchecksum
Sourceaddress
Destinationaddress
Option+Padding
Data
下图是IP层解码后的内容,利用此实例进行说明:
下面是IP协议解码的对应字段解释:
字段
说明
Version:
4
版本号为4,即IPv4协议,
HeaderLength:
5
头部长度20字节,5bits
Typeofservice:
0000000
服务提供类型,显示参数摘要。
Precedence
优先路由信息
Delay
迟延
Throughput
吞吐量
Reliability
可靠性
TotalLength:
131
总长131(单位字节,最长为65535字节)
Identification:
10403
标识
FragmentationFlags:
000.....
标志
Reserved:
保留
Fragment:
片断
MoreFragment:
最后片断
FragmentOffset:
0
偏移量
TimetoLive:
TTL,科来网络分析系统5.0将丢弃TTL=0的数据包
Protocol:
17
是哪种协议,1–ICMP,6–TCP,17–UDP,89–OSPF
CheckSum:
0xCE73
对IP协议头的校验合,0xCE73为正确
SourceIP:
192.168.1.1
源IP地址
DestinationIP:
192.168.1.2
目标IP地址
●ARP协议结构
以下是ARP协议结构:
8
16
32bits
HardwareType
ProtocolType
Hardwareaddresslength
Protocoladdresslength
Opcode
SenderHardwareAddress
SenderProtocolAddress
TargetHardwareAddress
TargetProtocolAddress
下图是对ARP协议进行解码视图:
我们对上图中的ARP字段进行详细说明:
字段
说明
HardwareType:
1
(硬件类型)占16bits,用来定义运行ARP的网络类型,每一个局域网基于其类型被指定一个整数,例如,以太网是类型1,ARP可以使用在任何网络上。
ProtocolType:
0x0800
(协议类型)占16bits,用来定义协议的类型。
如:
0x0800代表IP协议,ARP可用于任何高层协议。
HardwareLength:
6
(硬件长度)占8bits,用来定义物理地址和长度。
以太网值为6。
ProtocolLength:
4
(协议长度)占8bits,用来定义物理地址和长度。
IPv4值为4。
Type:
1
(操作类型)占16bits,用来定义操作类型,请求为1,回答为2。
SourcePhysics:
00:
A0:
C9:
BB:
21:
2A
源MAC地址
SourceIP:
SourceIp
192.168.1.3
源IP地址
DestinationPhysics:
00:
00:
00:
00:
00:
00
目标MAC地址,对于ARP请求数据包,此值全为0,因为请求主机并不知道目标主机的MAC地址
DestinationIP:
192.168.1.1
目标IP地址
●TCP协议结构
以下是TCP协议的结构:
16
32bits
Sourceport
Destinationport
Sequencenumber
Acknowledgementnumber
Offset
Reserved
U
A
P
R
S
F
Window
Checksum
Urgentpointer
Option+Padding
Data
下图是对TCP协议进行解码视图:
我们对上图中的TCP字段进行详细说明:
字段
说明
SourcePort:
80
源端口,HTTP为80端口
DestinationPort:
3406
目标端口
SequenceNumber:
4161759990
32bits.Thesequencenumberofthefirstdataoctetinthissegment(exceptwhenSYNispresent).IfSYNispresent,thesequencenumberistheinitialsequencenumber(ISN)andthefirstdataoctetisISN+1.
AckNumber:
0
32bits.IftheACKcontrolbitisset,thisfieldcontainsthevalueofthenextsequencenumberwhichthesenderofthesegmentisexpectingtoreceive.Onceaconnectionisestablished,thisvalueisalwayssent.
DataOffset:
80
HeaderLength:
80
4bits.Thenumberof32-bitwordsintheTCPheader.Thisindicateswherethedatabegins.ThelengthoftheTCPheaderisalwaysamultipleof32bits.
Reserved:
0
6bits.Reservedforfutureuse.Mustbeclearedtozero.
Urgentpointer:
Urgentpointerfieldsignificant.
Acknowledgmentnumber
Acknowledgmentfieldsignificant.
PushFunction:
Pushfunction.
Resettheconnection:
Resettheconnection.
Synchronizesequence:
Synchronizesequencenumbers.
Endofdata:
Nomoredatafromsender.
Window
16bits.Itspecifiesthesizeofthesender'sreceivewindow,thatis,thebufferspaceavailableinoctetsforincomingdata.
CheckSum:
16bits.Thechecksumfieldisthe16bitone¡¯scomplementoftheone¡¯scomplementsumofall16-bitwordsintheheaderandtext.Ifasegmentcontainsanoddnumberofheaderandtextoctetstobechecksummed,thelastoctetispaddedontherightwithzerostoforma16-bitwordforchecksumpurposes.Thepadisnottransmittedaspartofthesegment.Whilecomputingthechecksum,thechecksumfielditselfisreplacedwithzeros.
UrgentPointer
16bits.Thisfieldcommunicatesthecurrentvalueoftheurgentpointerasapositiveoffsetfromthesequencenumberinthissegment.Theurgentpointerpointstothesequencenumberoftheoctetfollowingtheurgentdata.ThisfieldcanonlybeinterpretedinsegmentsforwhichtheURGcontrolbithasbeenset.
●DNS协议结构
以下是DNS协议的结构:
16
17
21
22
23
24
25
26
27
28
32
Identification
QR
Opcode
AA
TC
RD
RA
Z
AD
CD
Rcode
Questioncount
Answercount
Authoritycount
Additionalcount
下图是对DNS协议进行解码视图:
我们对上图中的DNS字段进行详细说明:
字段
说明
Identification:
43
标识,占16bits
Flags:
Query/Response:
1
用于定义是Query还是Response。
0为Query,1为Response。
OperatorCode:
0
占4bits,其对应代码如下:
0QUERY,Standardquery.
1IQUERY,Inversequery.
2STATUS,Serverstatusrequest.
3Reserved.
4Notify.
5Update.
6-15Reserved.
AuthoritativeAnswer:
0
1-bitfield.Whensetto1,identifiestheresponseasonemadebyanauthoritativenameserver.
0Notauthoritative.
1Isauthoritative
Truncation:
0
1-bitfield.Whensetto1,indicatesthemessagehasbeentruncated.
0Nottruncated.
1Messagetruncated
RecursionDesired:
1
Recursiondesired:
1-bitfield.Maybesetinaqueryandiscopiedintotheresponse.Ifset,thenameserverisdirectedtopursuethequeryrecursively.Recursivequerysupportisoptional.
0Recursionnotdesired.
1Recursiondesired.
ApproveRecursion:
1
1bitfield.Indicatesifrecursivequerysupportisavailableinthenameserver.
0Recursivequerysupportnotavailable.
1Recursivequerysupportavailable.
Reserved:
0
1bitfield.Indicatesinaresponsethatalldataincludedintheanswerandauthoritysectionsoftheresponsehavebeenauthenticatedbytheserveraccordingtothepoliciesofthatserver.Itshouldbesetonlyifalldataintheresponsehasbeencryptographicallyverifiedorotherwisemeetstheserver'slocalsecuritypolicy.
Respondcode:
0
0Noerror.Therequestcompletedsuccessfully.
1Formaterror.Thenameserverwasunabletointerpretthequery.
2Serverfailure.
3NameError.
4NotImplemented.
5Refused.
6YXDomain.NameExistswhenitshouldnot.
7YXRRSet.RRSetExistswhenitshouldnot.
8NXRRSet.RRSetthatshouldexistdoesnot.
9NotAuth.ServerNotAuthoritativeforzone.
10NotZone.Namenotcontainedinzone.
11-15Reserved.
16BADVERS.BadOPTVersion.BADSIG.TSIGSignatureFailure.
17BADKEY.Keynotrecognized.
18BADTIME.Signatureoutoftimewindow.
19BADMODE.BadTKEYMode.
20BADNAME.Duplicatekeyname.
21BADALG.Algorithmnotsupported.
22-3840
3841-4095Privateuse.
4096-65535
Questions:
1
16-bitfieldthatdefinesthenumberofentriesinthequestionsection.
Answers:
2
16-bitfieldthatdefinesthenumberofresourcerecordsintheanswersection.
Authority:
0
16-bitfieldthatdefinesthenumberofnameserverresourcerecordsintheauthoritysection.
Additional:
0
16-bitfieldthatdefinesthenumberofresourcerecordsintheadditionalrecordssection.
Question:
数据结构
116
1732
QueryName
Type
Class
我们对上图的Question进行说明:
字段
说明
DomainName:
.
请求的域名。
Type:
1
1为A,IPv4address.
Class:
1
1为IN,Internet.
Answer:
数据结构
116
1732
Name
Type
Class
TTL
RdataLength
我们对上图的Answer进行说明:
字段
说明
DomainName:
.
解析的域名。
Type:
1
1为A,IPv4address.
Class:
1
1为IN,Internet.
TimetoLive:
1200
生存周期为1200秒
DataLength4
数据长度为4字节
IPAddress:
206.132.220.203
IP地址为206.132.220.203
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 常见 协议 解码 详解