BACnet通讯分析文档格式.docx
《BACnet通讯分析文档格式.docx》由会员分享,可在线阅读,更多相关《BACnet通讯分析文档格式.docx(48页珍藏版)》请在冰豆网上搜索。
![BACnet通讯分析文档格式.docx](https://file1.bdocx.com/fileroot1/2023-1/23/e6cf0cc7-b700-4497-8117-46d21f1a4b2a/e6cf0cc7-b700-4497-8117-46d21f1a4b2a1.gif)
3、BACnetNPDU结构.
版本信息
1Byte
Version
控制字
Control
目标网络号
2Bytes
DNET
目标网络长度
DLEN
目标地址
可变长度
DADR
原网络号
SNET
原网络长度
SLEN
原地址
可变
路由数目
HopCount
消息类型
MessageType
卖方ID
VendorID
应用层信息
版本信息:
默认0x01
控制字:
BIT7:
1表示MessageType存在,为0时MessageType不存在
BIT6:
保存,为0
BIT5:
1表示DNETDLENHopCount存在,当DLEN为0时说明播送网络
DADR不存在;
0表示DNETDLENDADRHopCount不存在
BIT4:
BIT3:
1表示SNETSLEN存在,当SLEN为0时说明无效SADR不存在;
0表示SNETSLENSADRHopCount不存在
BIT2:
1表示为一个需确认的请求数据单元,一复杂ACK数据单元或一网络层
信息非reply的;
0表示除去上述情形的数据单元
BIT1、0:
网络优先级
11=LifeSafetymessage
10=CriticalEquipmentmessage
01=Urgentmessage
00=Normalmessage
目标网络号:
FFFF的时候表示播送
目标长度:
表示DADR的长度
目标地址:
目标网络MAC地址
原网络号:
同目标网络号
原网络长度:
表示SADR的长度
原地址:
原网络的MAC地址
路由数目:
数据需要经过的路由个数,当不存在DNET的时候,需设置为FF
消息类型:
X'
00'
:
Who-Is-Router-To-Network
X'
01'
I-Am-Router-To-Network
02'
I-Could-Be-Router-To-Network
03'
Reject-Message-To-Network
04'
Router-Busy-To-Network
05'
Router-Available-To-Network
06'
Initialize-Routing-Table
07'
Initialize-Routing-Table-Ack
08'
Establish-Connection-To-Network
09'
Disconnect-Connection-To-Network
0A'
toX'
7F'
ReservedforusebyASHRAE
80'
FF'
Availableforvendorproprietarymessages
卖方ID:
当控制字的BIT7为1并且消息类型为X'
的时候,才会存在
本次开发没有用到,不再解释
本次应用中控制字只用到0x20和0x04两种,前者为播送查询设备,后者微点对对取设备数据或属性。
4、BACnetAPDU结构:
〔应用层协议数据单元〕
BACnet网络层数据主要分为一下几种:
BACnetPDU:
=CHOICE
{
confirmed-request-PDU[0]BACnet-Confirmed-Request-PDU,
unconfirmed-request-PDU[1]BACnet-Unconfirmed-Request-PDU,
simpleACK-PDU[2]BACnet-SimpleACK-PDU,
complexACK-PDU[3]BACnet-ComplexACK-PDU,
segmentAck-PDU[4]BACnet-SegmentACK-PDU,
error-PDU[5]BACnet-Error-PDU,
reject-PDU[6]BACnet-Reject-PDU,
abort-PDU[7]BACnet-Abort-PDU
}
对于本次应用,主要用到了
BACnet-Confirmed-Request-PDU〔需确认的请求协议数据单元〕
BACnet-Unconfirmed-Request-PDU〔无需确认的请求协议数据单元〕
BACnet-ComplexACK-PDU〔复杂的ACK命令〕
BACnet-Error-PDU〔报错的协议数据单元〕
对于上述几种数据的分类主要根据pdutype〔下文进行讲解〕进行判定。
4.1.BACnet-Confirmed-Request-PDU的结构:
BACnet-Confirmed-Request-PDU:
=SEQUENCE
pdu-type[0]Unsigned(0..15),--0forthisPDUtype
segmented-message[1]BOOLEAN,
more-follows[2]BOOLEAN,
segmented-response-accepted[3]BOOLEAN,
reserved[4]Unsigned(0..3),--mustbesettozero
max-segments-accepted[5]Unsigned(0..7),--asper.4
max-APDU-length-accepted[6]Unsigned(0..15),--asper.5
invokeID[7]Unsigned(0..255),
sequence-number[8]Unsigned(0..255)OPTIONAL,--onlyifsegmentedmsg
proposed-window-size[9]Unsigned(1..127)OPTIONAL,--onlyifsegmentedmsg
service-choice[10]BACnetConfirmedServiceChoice,
service-request[11]BACnet-Confirmed-Service-RequestOPTIONAL
BIT7
BIT6
BIT5
BIT4
BIT3
BIT2
BIT1
BIT0
PDUTYPE
SEG
MOR
SA
MaxSegs
MaxResp
InvokeID
SequenceNumber(onlypresentbySEG==1)
ProposedWindowSize(onlypresentbySEG==1)
ServiceChioce
ServiceRequest……
PDUType0(BACnet-Confirmed-Service-Request-PDU)
SEG0(UnsegmentedRequest)
1(SegmentedRequest)
MOR0(NoMoreSegmentsFollow)
1(MoreSegmentsFollow)
SA0(SegmentedResponsenotaccepted)
1(SegmentedResponseaccepted)
MaxSegs(0..7)(Numberofresponsesegmentsacceptedper.4)
MaxResp(0..15)(SizeofMaximumAPDUacceptedper.5)
InvokeID(0..255)
SequenceNumber(0..255)OnlypresentifSEG=1
ProposedWindowSize(1..127)OnlypresentifSEG=1
ServiceChoiceBACnetConfirmedServiceChoice
ServiceRequestVariableEncoding
SEG:
指出当前的数据单元是否为完整的还是为一局部分段信息
MOR:
指出是否还有更多的分段信息
SA:
为1时指出将收到一个复杂的回应〔complexack〕
MaxSegs:
指出设备将要接收到多少分段信息
B'
000'
Unspecifiednumberofsegmentsaccepted.
B'
001'
2segmentsaccepted.
010'
4segmentsaccepted.
011'
8segmentsaccepted.
100'
16segmentsaccepted.
101'
32segmentsaccepted.
110'
64segmentsaccepted.
111'
Greaterthan64segmentsaccepted.
MaxResp:
指出将收到的〔APDU〕最大长度
0000'
UptoMinimumMessageSize(50octets)
0001'
Upto128octets
0010'
Upto206octets(fitsinaLonTalkframe)
0011'
Upto480octets(fitsinanARCNETframe)
0100'
Upto1024octets
0101'
Upto1476octets(fitsinanISO8802-3frame)
InvokeID:
调用者ID
ServiceChioce:
此处说明次报文的作用,详见BACnetConfirmedServiceChoice
ServiceRequest:
根据BACnetConfirmedServiceChoice不同而结构不同,详见
BACnet-Confirmed-Service-Request
BACnetConfirmedServiceChoice:
=枚举类型
--AlarmandEventServices
acknowledgeAlarm(0),
confirmedCOVNotification
(1),
confirmedEventNotification
(2),
getAlarmSummary(3),
getEnrollmentSummary(4),
getEventInformation(29),
subscribeCOV(5),
subscribeCOVProperty(28),
lifeSafetyOperation(27),
--FileAccessServices
atomicReadFile(6),
atomicWriteFile(7),
--ObjectAccessServices
addListElement(8),
removeListElement(9),
createObject(10),
deleteObject(11),
readProperty(12),
readPropertyConditional(13),
readPropertyMultiple(14),
readRange(26),
writeProperty(15),
writePropertyMultiple(16),
。
上述标记为红色的表示本次应用中所用到的,所以只对这些进行讲解。
可以根据BACnetConfirmedServiceChoice找到相对应的Request或者Ack的数据的结构
BACnet-Confirmed-Service-Request:
=CHOICE//对应上面的Choice
acknowledgeAlarm[0]AcknowledgeAlarm-Request,
confirmedCOVNotification[1]ConfirmedCOVNotification-Request,
confirmedEventNotification[2]ConfirmedEventNotification-Request,
--getAlarmSummaryconveysnoparameters
getEnrollmentSummary[4]GetEnrollmentSummary-Request,
getEventInformation[29]GetEventInformation-Request,
subscribeCOV[5]SubscribeCOV-Request,
subscribeCOVProperty[28]SubscribeCOVProperty-Request,
lifeSafetyOperation[27]LifeSafetyOperation-Request,
atomicReadFile[6]AtomicReadFile-Request,
atomicWriteFile[7]AtomicWriteFile-Request,
addListElement[8]AddListElement-Request,
removeListElement[9]RemoveListElement-Request,
createObject[10]CreateObject-Request,
deleteObject[11]DeleteObject-Request,
readProperty[12]ReadProperty-Request,
readPropertyConditional[13]ReadPropertyConditional-Request,
readPropertyMultiple[14]ReadPropertyMultiple-Request,
readRange[26]ReadRange-Request,
writeProperty[15]WriteProperty-Request,
writePropertyMultiple[16]WritePropertyMultiple-Request,
上述标记为红色的既是针对BACnetConfirmedServiceChoice所用到的数据结构。
ReadProperty-Request:
=SEQUENCE//读数据请求和读数据答复
objectIdentifier[0]BACnetObjectIdentifier,
propertyIdentifier[1]BACnetPropertyIdentifier,
propertyArrayIndex[2]UnsignedOPTIONAL--usedonlywitharraydatatype
ReadPropertyMultiple-Request:
listOfReadAccessSpecsSEQUENCEOFReadAccessSpecification
ReadAccessSpecification:
objectIdentifier[0]BACnetObjectIdentifier,
listOfPropertyReferences[1]SEQUENCEOFBACnetPropertyReference
BACnetPropertyReference:
propertyIdentifier[0]BACnetPropertyIdentifier,
propertyArrayIndex[1]UnsignedOPTIONAL--usedonlywitharraydatatype
--ifomittedwithanarraytheentirearrayisreferenced
BACnetPropertyIdentifier:
=ENUMERATED
accepted-modes(175),
acked-transitions(0),
ack-required
(1),
action
(2),
action-text(3),
active-text(4),
active-vt-sessions(5),
active-cov-subscriptions(152),
adjust-value(176),
alarm-value(6),
alarm-values(7),
all(8),
all-writes-successful(9),
apdu-segment-timeout(10),
apdu-timeout(11),
application-software-version(12),
firmware-revision(44),
archive(13),
attempted-samples(124),
list-of-group-members(53),
list-of-object-property-references(54),
list-of-session-keys(55),
local-date(56),
local-time(57),
location(58),
maintenance-required(158),
manipulated-variable-reference(60),
manual-slave-address-binding(170),
maximum-output(61),
maximum-value(135),
maximum-value-timestamp(149),
max-apdu-length-accepted(62),
max-info-frames(63),
max-master(64),
max-pres-value(65),
max-segments-accepted(167),
member-of(159),
minimum-off-time(66),
minimum-on-time(67),
minimum-output(68),
event-state(36),
model-name(70),
number-of-APDU-retries(73),
object-identifier(75),
object-list(76),
object-name(77),
object-property-reference(78),
object-type(79),
operation-expected(161),
optional(80),
out-of-service(81),
output-units(82),
--seeevent-parameters(83),
polarity(84),
prescale(185),
present-value(85),
priority(86),
pulse-rate(186),
priority-array(87),
priority-for-writing(88),
protocol-object-types-supported(96),
protocol-revision(139),
protocol-services-supported(97),
protoco