Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Overview
Basic Message Structure
What is a MAC layer?
NPDU Structure
MAC Layer
messages
Message Frames
Start of Message
End of Message
Destination
Data
Source
Length
Error Detection/Correction
MPDUs
Destination: 112233445566
Length: 12
Data: 00112233445566778899AABB
headers
MPDU
Version
Control
DNET
DLEN
DADR
SNET
SLEN
SADR
Hop Count
Message Type
Vendor ID
NPDU or APDU
1996-2009 PolarSoft Inc., All Rights Reserved
1 octet
1 octet
2 octets
1 octet
M octets
2 octets
1octet
L octets
1 octet
1 octet
1 octet
N octets
Network Layer
Message
Structure
Local APDUs
Version
1 octet
Control
1 octet
APDU
N octets
Version
1 octet
Control
1 octet
Message Type
1 octet
NPDU
2 octets
1 octet
Control
1 octet
DNET
2 octets
DLEN
1 octet
DADR
M octets
Hop Count
APDU
1996-2009 PolarSoft Inc., All Rights Reserved
1 octet
N octets
SADR
Hop Count
1 octet
1 octet
2 octets
1 octet
M octets
2 octets
1octet
L octets
1 octet
APDU
N octets
Version
Control
DNET
DLEN
DADR
SNET
SLEN
Version
1 octet
Control
1 octet
SNET
2 octets
SLEN
1 octet
SADR
M octets
APDU
N octets
NPCI
7
6
0
Version
Control
0
0
0
1
1
0
1
0
1
Normal
Urgent
Critical Equipment
Life Safety
1 = Reply expected
DNET
DLEN
DADR
SNET
SLEN
SADR
Hop Count
0 = AL Message
1 = NL Message
APDU
Questions
Overview
ASN.1 Bootcamp
What is ASN.1
Encoding Approaches
Tags
Detailed look at encoding ReadProperty
ASN.1
[0] Datatype1,
[1] Datatype2,
[N-1] DatatypeN
ASN.1
BACnet defines 13 primitive or
application datatypes.
0 Null
1 Boolean
2 Unsigned Integer
3 Signed Integer
4 Real
5 Double
6 Octet String
7
8
9
10
11
12
Character String
Bit String
Enumerated
Date
Time
BACnetObjectIdentifier
ASN.1
ProductionName ::= SEQUENCE {
item1
item2
item3
.
.
.
itemN
}
[0] Datatype1,
[1] Datatype2 OPTIONAL,
[2] Datatype3,
[N-1] DatatypeN
ASN.1
BACnetDayOfWeek ::= BIT STRING {
monday
tuesday
wednesday
thursday
friday
saturday
sunday
}
(0),
(1),
(2),
(3),
(4),
(5),
(6)
ASN.1
BACnetEventState ::= ENUMERATED
{
normal
(0),
fault
(1),
offnormal
(2),
high-limit
(3),
low-limit
(4)
}
Encoding Approaches
Fixed position encoding
A map is made that indicates exactly
where each piece of the message is to
appear. There is no variation.
Variable position encoding
The pieces of the message can vary. A
special marker called a tag is used to
indicate which piece comes next and how
big it is.
1996-2009 PolarSoft Inc., All Rights Reserved
7
6
5
4
3
2
1
0
|---|---|---|---|---|---|---|---|
|
PDU Type
|SEG|MOR| SA| 0 |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 |
Max Resp
|
|---|---|---|---|---|---|---|---|
|
Invoke ID
|
|---|---|---|---|---|---|---|---|
|
Sequence Number
| Only present if SEG = 1
|---|---|---|---|---|---|---|---|
|
Proposed Window Size
| Only present if SEG = 1
|---|---|---|---|---|---|---|---|
|
Service Choice
|
|---|---|---|---|---|---|---|---|
|
Service Request
|
|
.
|
.
|
.
|
|---|---|---|---|---|---|---|---|
Tags
Bit Number:
7
6
5
4
3
2
1
0
|-----|-----|-----|-----|-----|-----|-----|-----|
|
Tag Number
|Class|Length/Value/Type|
|-----|-----|-----|-----|-----|-----|-----|-----|
where
Tag Number = the tag number within the class
Class
= application or context specific
Length/Value/Type = whether the data following the tag
is primitive or constructed and specifies the length
or value of primitive data.
ReadProperty
client
server
ReadProperty(msg#123
objectid=AnalogInput 5
propertyid=Present_Value)
72
Req
Ind
M
M
M
U
M(=)
M(=)
M(=)
U(=)
Rsp
Cnf
Result (+)
Object Identifier
Property Identifier
Property Array Index
Property Value
S
M
M
U
M
S(=)
M(=)
M(=)
U(=)
M(=)
Result (-)
Error Type
S
M
S(=)
M(=)
M
U
S
mandatory
user option
selection
BACnetPDU
::= CHOICE {
confirmed-requestPDU
[0] BACnetConfirmed-RequestPDU,
unconfirmed-request-PDU [1] BACnet-Unconfirmed-RequestPDU,
simpleACKPDU
[2] BACnetSimpleACKPDU,
complexACKPDU
[3] BACnetComplexACKPDU,
segmentAck-PDU
[4] BACnet-SegmentACK-PDU,
errorPDU
[5] BACnetErrorPDU,
reject-PDU
[6] BACnet-Reject-PDU,
abort-PDU
[7] BACnet-Abort-PDU
}
--
BACnet-Confirmed-Request-PDU
pdu-type
segmented-message
more-follows
segmented-response-accepted
reserved
max-APDU-length-accepted
invokeID
sequence-number
proposed-window-size
service-choice
service-request
}
::= SEQUENCE {
[0] Unsigned (0..15), -0 for this PDU type
[1] BOOLEAN,
[2] BOOLEAN,
[3] BOOLEAN,
[4] Unsigned (0..31),
[5] Unsigned (0..15),
[6] Unsigned (0..255),
[7] Unsigned (0..255) OPTIONAL,
[8] Unsigned (1..127) OPTIONAL,
[9] BACnetConfirmedServiceChoice,
[10] BACnet-Confirmed-Service-Request
OPTIONAL
.
.
.
--
.
.
.
BACnetObjectIdentifier,
BACnetPropertyIdentifier,
Unsigned OPTIONAL
used only with array datatype
if omitted with an array then
the entire array is referenced
X`00'
Fixed
Variable
X`00'
X`01'
X`0C'
X`0C'
X`00000005'
X`19'
X`55'
7
6
5
4
3
2
1
0
|-----|-----|-----|-----|-----|-----|-----|-----|
|
Tag Number=0
|Class|Length/Value/Type|
| 0
0
0
0
1
1
0
0 |
|-----|-----|-----|-----|-----|-----|-----|-----|
Context Tag
objectIdentifier
1996-2009 PolarSoft Inc., All Rights Reserved
[0]
ObjectIdentifiers are
length = 4 octets
BACnetObjectIdentifier,
7
6
5
4
3
2
1
0
|-----|-----|-----|-----|-----|-----|-----|-----|
|
Tag Number=1
|Class|Length/Value/Type|
| 0
0
0
1
1
0
0
1 |
|-----|-----|-----|-----|-----|-----|-----|-----|
Context Tag
propertyIdentifier
1996-2009 PolarSoft Inc., All Rights Reserved
[1]
PropertyIdentifiers
are Unsigned, min
length = 1 octet
BACnetPropertyIdentifier,
Questions
Overview
Encoding NULL
Tag Number
Class Length/Value/Type
7
6
5
4
3
2
1
0
|-----|-----|-----|-----|-----|-----|-----|-----|
| 0
0
0
0
0
0
0
0 |
|-----|-----|-----|-----|-----|-----|-----|-----|
NULL = 0
Encoding BOOLEAN
Tag Number
Class Length/Value/Type
7
6
5
4
3
2
1
0
|-----|-----|-----|-----|-----|-----|-----|-----|
| 0
0
0
1
0
0
0
0/1 |
|-----|-----|-----|-----|-----|-----|-----|-----|
BOOLEAN = 1
Value is 0 or 1
|-----|-----|-----|-----|-----|-----|-----|-----|
| ?
?
?
?
1
0
0
1 |
|-----|-----|-----|-----|-----|-----|-----|-----|
| 0
0
0
0
0
0
0
0/1 |
|-----|-----|-----|-----|-----|-----|-----|-----|
Encoding Unsigned
Tag Number
Class Length/Value/Type
7
6
5
4
3
2
1
0
|-----|-----|-----|-----|-----|-----|-----|-----|
| 0
0
1
0
0
001..100
|
|-----|-----|-----|-----|-----|-----|-----|-----|
|
1, 2, 3 or 4 octets of big-endian value
|
|-----|-----|-----|-----|-----|-----|-----|-----|
Encoding Signed
Tag Number
Class Length/Value/Type
7
6
5
4
3
2
1
0
|-----|-----|-----|-----|-----|-----|-----|-----|
| 0
0
1
1
0
001..100
|
|-----|-----|-----|-----|-----|-----|-----|-----|
|
1, 2, 3 or 4 octets of big-endian value
|
|-----|-----|-----|-----|-----|-----|-----|-----|
Encoding REAL
Tag Number
Class Length/Value/Type
7
6
5
4
3
2
1
0
|-----|-----|-----|-----|-----|-----|-----|-----|
| 0
1
0
0
0
1
0
0 |
|-----|-----|-----|-----|-----|-----|-----|-----|
|
4 octets of IEEE real value
|
|
|
|
|
|
|
|-----|-----|-----|-----|-----|-----|-----|-----|
Encoding Double
Tag Number
Class Length/Value/Type
7
6
5
4
3
2
1
0
|-----|-----|-----|-----|-----|-----|-----|-----|
| 0
1
0
1
0
1
0
1 |
|-----|-----|-----|-----|-----|-----|-----|-----|
| 0
0
0
0
1
0
0
0 |
|-----|-----|-----|-----|-----|-----|-----|-----|
|
8 octets of IEEE double value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|-----|-----|-----|-----|-----|-----|-----|-----|
5 = extended length
extended length = 8
X`75'
X`06'
X`00'
X`4142434445'
X`82'
X`03'
X`A8'
Encoding Enumerations
Tag Number
Class Length/Value/Type
7
6
5
4
3
2
1
0
|-----|-----|-----|-----|-----|-----|-----|-----|
| 1
0
0
1
0
001..100
|
|-----|-----|-----|-----|-----|-----|-----|-----|
|
1, 2, 3 or 4 octets of big-endian value
|
|-----|-----|-----|-----|-----|-----|-----|-----|
Encoding Dates
Tag Number
Class Length/Value/Type
7
6
5
4
3
2
1
0
|-----|-----|-----|-----|-----|-----|-----|-----|
| 1
0
1
0
0
1
0
0 |
|-----|-----|-----|-----|-----|-----|-----|-----|
|
year 1900, e.g. 103 = 2003
|
|-----|-----|-----|-----|-----|-----|-----|-----|
|
month, 1=January
|
|-----|-----|-----|-----|-----|-----|-----|-----|
|
day, e.g. 1..31
|
|-----|-----|-----|-----|-----|-----|-----|-----|
|
day of week, 1=Monday, 7=Sunday
|
|-----|-----|-----|-----|-----|-----|-----|-----|
0xFF = wildcard
Encoding Times
Tag Number
Class Length/Value/Type
7
6
5
4
3
2
1
0
|-----|-----|-----|-----|-----|-----|-----|-----|
| 1
0
1
1
0
1
0
0 |
|-----|-----|-----|-----|-----|-----|-----|-----|
|
hours 00..23
|
|-----|-----|-----|-----|-----|-----|-----|-----|
|
minutes 00..59
|
|-----|-----|-----|-----|-----|-----|-----|-----|
|
seconds 00..59
|
|-----|-----|-----|-----|-----|-----|-----|-----|
|
hundredths 00..99
|
|-----|-----|-----|-----|-----|-----|-----|-----|
0xFF = wildcard
Encoding ObjectIdentifier
Tag Number
Class Length/Value/Type
7
6
5
4
3
2
1
0
|-----|-----|-----|-----|-----|-----|-----|-----|
| 1
1
0
0
0
1
0
0 |
|-----|-----|-----|-----|-----|-----|-----|-----|
|
object type 0..1023
|
|-----|-----|-----|-----|-----|-----|-----|-----|
|
object instance 0.. 4194303
|
|-----|-----|-----|-----|-----|-----|-----|-----|
|
|
|-----|-----|-----|-----|-----|-----|-----|-----|
|
|
|-----|-----|-----|-----|-----|-----|-----|-----|
Paired Delimiters
ReadProperty-ACK ::= SEQUENCE {
objectIdentifier
[0]
propertyIdentifier
[1]
propertyArrayIndex [2]
propertyValue
[3]
}
X`0C'
X`00000005'
X`19'
X`55'
X`3E'
X`44'
X`4290999A'
X`3F'
BACnetObjectIdentifier,
BACnetPropertyIdentifier,
Unsigned OPTIONAL,
ABSTRACT-SYNTAX.&Type
Overview
Detailed look at PDUs
Unconfirmed
Confirmed
Simple ACK
Complex ACK
Error
Reject
Abort
1996-2009 PolarSoft Inc., All Rights Reserved
BACnet-Unconfirmed-Request-PDU
Bit Number:
7
6
5
4
3
2
1
0
|---|---|---|---|---|---|---|---|
| PDU Type = 1 | 0 | 0 | 0 | 0 |
|---|---|---|---|---|---|---|---|
|
Service Choice
|
|---|---|---|---|---|---|---|---|
|
Service Request
|
|
.
|
.
|
.
|
|---|---|---|---|---|---|---|---|
BACnet-Confirmed-Request-PDU
Bit Number:
7
6
5
4
3
2
1
0
|---|---|---|---|---|---|---|---|
| PDU Type = 0 |SEG|MOR| SA| 0 |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 |
Max Resp
|
|---|---|---|---|---|---|---|---|
|
Invoke ID
|
|---|---|---|---|---|---|---|---|
|
Sequence Number
| Only present if SEG = 1
|---|---|---|---|---|---|---|---|
|
Proposed Window Size
| Only present if SEG = 1
|---|---|---|---|---|---|---|---|
|
Service Choice
|
|---|---|---|---|---|---|---|---|
|
Service Request
|
|
.
|
.
|
.
|
|---|---|---|---|---|---|---|---|
BACnet-SimpleACK-PDU
Bit Number:
7
6
5
4
3
2
1
0
|---|---|---|---|---|---|---|---|
| PDU Type = 2 | 0 | 0 | 0 | 0 |
|---|---|---|---|---|---|---|---|
|
Original InvokeID
|
|---|---|---|---|---|---|---|---|
|
Service Ack Choice
|
|---|---|---|---|---|---|---|---|
BACnet-ComplexACK-PDU
Bit Number:
7
6
5
4
3
2
1
0
|---|---|---|---|---|---|---|---|
| PDU Type = 3 |SEG|MOR| 0 | 0 |
|---|---|---|---|---|---|---|---|
|
Original Invoke ID
|
|---|---|---|---|---|---|---|---|
|
Sequence Number
| Only present if SEG = 1
|---|---|---|---|---|---|---|---|
|
Proposed Window Size
| Only present if SEG = 1
|---|---|---|---|---|---|---|---|
|
Service-ACK Choice
|
|---|---|---|---|---|---|---|---|
|
Service ACK
|
|
.
|
.
|
.
|
|---|---|---|---|---|---|---|---|
BACnet-Error-PDU
Bit Number:
7
6
5
4
3
2
1
0
|---|---|---|---|---|---|---|---|
| PDU Type = 5 | 0 | 0 | 0 | 0 |
|---|---|---|---|---|---|---|---|
|
Original Invoke ID
|
|---|---|---|---|---|---|---|---|
|
Error Choice
|
|---|---|---|---|---|---|---|---|
|
Error
|
|
.
|
.
|
.
|
|---|---|---|---|---|---|---|---|
BACnet-Reject-PDU
Bit Number:
7
6
5
4
3
2
1
0
|---|---|---|---|---|---|---|---|
| PDU Type = 6 | 0 | 0 | 0 | 0 |
|---|---|---|---|---|---|---|---|
|
Original Invoke ID
|
|---|---|---|---|---|---|---|---|
|
Reject Reason
|
|---|---|---|---|---|---|---|---|
BACnet-Abort-PDU
Bit Number:
7
6
5
4
3
2
1
0
|---|---|---|---|---|---|---|---|
| PDU Type = 7 | 0 | 0 | 0 | 0 |
|---|---|---|---|---|---|---|---|
|
Original Invoke ID
|
|---|---|---|---|---|---|---|---|
|
Abort Reason
|
|---|---|---|---|---|---|---|---|
ReadProperty
client
server
ReadProperty(msg#123
objectid=AnalogInput 29
propertyid=Present_Value)
72
ReadPropertyAck(msg#123
objectid=AnalogInput 29
propertyid=Present_Value
value=72.0)
or
Error(msg#123
class=object
code=NoSuchObject)
ReadProperty
client
server
ReadProperty Confirmed
Service Request
72
ReadProperty ComplexACK
or
Error
Questions