• BACnet协议


    BACNET MS/TP , 其中MS/TP全称是Master Slave/ Token Pass, 是无主从协议,靠令牌传递进行实现

    参考链接: https://www.daoshengshu.com/html/bacnet%20mstp%20%E5%8D%8F%E8%AE%AE/

     系统实现基于BACnet/IP(又称B/IP)网络进行通讯。BACnet虚拟链路层(BVLL)提供了BACnet网络层和某指定的通讯子系统的接口,本文指定了BACnet虚拟链路控制(BVLC)要求支持的定向和广播信息。本实现关于BACnet协议定义主要可分为三层:B/IP网络虚拟层,BACnet网络层和BACnet应用层。B/IP提供了TCP/IP一样的通讯结构,采用UDP的通讯方式。本文接下来将对此三层结构进行详细的讲解。

    其文本协议的大致格式如下:

     通过wireshark捕获包确实是在UDP基础上加上BVLC、NPDU、APDU
     
     

    BACnet的对象、服务和功能组

    BACnet采用面向对象技术,借此提供一种表示楼宇自控设备的标准。在BACnet中,对象就是在网络设备之间传输的一组数据结构,网络设备通过读取、修改封装在应用层APDU中的对象数据结构,实现互操作。BACnet目前定义了18个对象,如图3所示,每个对象都必须有三个属性:对象标志符(Object_Identifier)、对象名称(Object_Name)和对象类型(Object_Type)。其中,对象标志符用来唯一标识对象;BACnet设备可以通过广播自身包含的某个对象的对象名称,与包含相关对象的设备建立联系。BACnet协议要求每个设备都要包含“设备对象”,通过对其属性的读取可以让网络获得设备的全部信息。
     

    在BACnet中,把对象的方法称为服务,对象及其属性提供了对一个楼宇自控设备“网络可见信息”的抽象描述,而服务提供了如何访问和操作这些信息的命令和方法。BACnet设备通过在网络中传递服务请求和服务应答报文实现服务。BACnet定义了35种服务,并将其划分为6个类别:
    (1)报警与事件服务(Alarm and Event Services)包含8种服务处理环境状态的变化,提供了BACnet设备预设的请求值改变通告、请求报警或事件状态摘要、发送报警或事件通知、收到报警通知确认等方法;
    (2)文件访问服务(File Access Services)包含2种服务,提供读写文件的方法,包括上/下载控制程序和数据库的能力;
    (3)对象访问服务(Object Access Services)包含9种服务,提供了读、修改和写属性值以及增删对象的方法;
    (4)远程设备管理服务(Remote Device Management Services)包含11种服务,提供对BACnet设备进行维护和故障检测的工具、方法;
    (5)虚拟终端服务(Virtual Terminal Services)包含3种服务,提供了一种面向字符的数据双向交换机制,使其他具有专有特性的楼宇自控设备成为一个BACnet虚拟终端并使BACnet网络能对其进行重构;
    (6)网络安全服务(Network Security Services)包含2种服务,提供对等实体验证、数据源验证、操作者验证和数据加密等功能。

    BACnet功能组规定了实现特定控制功能所需的对象和服务的组合。BACnet已定义了13个功能组,包括时钟功能组、事件响应功能组、文件功能组、虚拟终端功能组、设备通信功能组等。

     

     

     

     bacnet源码下载:https://sourceforge.net/projects/bacnet/  

    每个文件基本含义:

    * abort.c - BACnet Abort service encode/decode

    * bacerror.c - BACnet Error service encode/decode

    * reject.c - BACnet Reject service encode/decode

    * arf.c - AtomicReadFile service encode/decode

    * awf.c - AtomicWriteFile service encode/decode

    * rp.c - BACnet ReadProperty service encode/decode

    * rpm.c - ReadPropertyMultiple service encode/decode

    * iam.c - I-Am service encode/decode

    * whois.c - WhoIs service encode/decode

    * wp.c - WriteProperty service encode/decode

    * wpm.c - WritePropertyMultiple service encode/decode

    * dcc.c - DeviceCommunicationControl service encode/decode

    * ihave.c - I-Have service encode/decode

    * rd.c - ReinitializedDevice service encode/decode

    * timesync.c - TimeSynchronization service encode/decode

    * whohas.c - WhoHas service encode/decode

    * event.c - EventNotification service encode/decode

    * get_alarm_sum.c - GetAlarmSummary service encode/decode

    * getevent.c - GetEventInformation service encode/decode

    * lso.c - LifeSafetyOperation service encode/decode

    * ptransfer.c - PrivateTransfer service encode/deco

    * readrange.c - ReadRange service encode/decode

    2、各种服务处理(handler)

    * demo/handler/h_alarm_ack.c - Alarm ACK service handler example

    * demo/handler/h_arf.c - AtomicReadFile service handler example

    * demo/handler/h_arf_a.c - AtomicReadFile ACK service handler example

    * demo/handler/h_awf.c - AtomicWriteFile service handler example

    * demo/handler/h_ccov.c - ConfirmedCOVNotification service handler example

    * demo/handler/h_cov.c - SubscribeCOV service handler example

    * demo/handler/h_dcc.c - DeviceCommuncationControl service handler example

    * demo/handler/h_get_alarm_sum.c - GetAlarmSummary service handler example

    * demo/handler/h_get_event.c - GetEventInformation service handler example

    * demo/handler/h_iam.c - I-Am service handler example

    * demo/handler/h_ihave.c - I-Have service handler example

    * demo/handler/h_lso.c - LifeSafetyOperation service handler example

    * demo/handler/h_pt.c - PrivateTransfer service handler example

    * demo/handler/h_pt_a.c - PrivateTransfer ACK service handler example

    * demo/handler/h_rp.c - ReadProperty service handler example

    * demo/handler/h_rp_a.c - ReadProperty ACK service handler example

    * demo/handler/h_rpm.c - ReadPropertyMultiple service handler example

    * demo/handler/h_rpm_a.c - ReadPropertyMultiple ACK service handler example

    * demo/handler/h_rr.c - ReadRange service handler example

    * demo/handler/h_rr_a.c - ReadRange ACK service handler example

    * demo/handler/h_ts.c - TimeSynchronization service handler example

    * demo/handler/h_ucov.c - UnconfirmedCOV service handler example

    * demo/handler/h_upt.c - UnconfirmedPrivateTransfer service handler example

    * demo/handler/h_whohas.c - WhoHas service handler example

    * demo/handler/h_whois.c - Who-Is service handler example

    * demo/handler/h_wp.c - WriteProperty ACK service handler example

    * demo/handler/h_wpm.c - WritePropertyMultiple service handler example

    * demo/handler/h_noserv.c - unrecognized service handler example

    2、地址绑定和交换状态机

    * address.c - This module is used to handle the address binding that occurs

    in BACnet. A device id is bound to a MAC address. The normal method is using

    Who-Is, and binding with the data from I-Am. This is needed for client

    functionality.

    * tsm.c - Transaction State Machine handles resending messages if a timeout

    occurs, and is needed for client functionality. The transaction state machine is

    used for Confirmed messages and segmentation. For confirmed messages, it

    automatically (via tsm_timer_milliseconds) handles the retries and the timeout.

    It uses the InvokeID as the unique key (although officially it should be the

    combination of InvokeID, DeviceID, and service). So if you tried to send a

    confirmed request to a device that was taken offline, you would see the retry go

    out after every apdu_timeout until apdu retries had completed. Then the

    transaction would self-delete (free). The stack as it is written (and most

    stacks are written this way) has a limited amount of transactions, and if you

    are sending alot of confirmed data, it can be a bottleneck if they are not freed

    in a timely manner.

    4、 对象文件

    * demo/object/ai.c - analog input object demo

    * demo/object/ao.c - analog output object demo

    * demo/object/av.c - analog value object demo

    * demo/object/bacfile.c - File object demo

    * demo/object/device.c - device object demo

    * demo/object/bi.c - binary input object demo

    * demo/object/bo.c - binary output object demo

    * demo/object/bv.c - binary value object demo

    * demo/object/lc.c - load control object demo

    * demo/object/lsp.c - life safety point object demo

    * demo/object/mso.c - multi-step output object demo

    5、数据链路层的数据包服务:

    * apdu.c - handles dispatching the services to the proper handlers

    * bacdcode.c - primitive BACnet datatype encoding and decoding

    * bacint.c - primitive BACnet integer datatype encoding and decoding

    * bacreal.c - primitive BACnet REAL datatype encoding and decoding

    * bacstr.c - primative BACnet string datatype encoding and decoding

    * bacapp.c - application data encoding and decoding

    * npdu.c - encoding and decoding of the NPDU layer data

    * demo/handler/h_npdu.c - handles dispatching of the network message

    to the apdu dispatcher.

    6、数据链路层控制访问物理介质

    * bip.c - BACnet/IP functionality - depends on bip_init.c in port/xx

    * dllmstp.c - MS/TP datalink layer, also in port/xx

    * mstp.c - MS/TP master and receive state machine

    * crc.c - computes CRC checksum for MS/TP

    * ringbuf.c - MS/TP ring buffer used for testing

    * arcnet.c - ARCNET datalink layer functionality, in port/xx

    * ethernet.c - BACnet Ethernet datalink layer functionality, in port/xx

    There are a dozen demonstration applications in the demo directory,

    along with many demonstation objects and handlers. All the demos accept

    command line options and have been tested under Win32 and Linux.

    There is a makefile in the respective demo directory for Linux and

    for Borland C++ compilers, and a master makefile at the root level

    (Makefile=Linux, makefile.b32=Borland).

    The simplest demonstration is to run demo/server/bacserv on one PC (or

    virtual PC), and run the other client demonstration applications one

    at time on another PC (or virtual PC). Monitor the network communcations

    using Wireshark protocol analyzer, or test the BACnet server using

    BACnet Visual Test Shell VTS3.
    ————————————————
    版权声明:本文为CSDN博主「yuesichiu」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/yuesichiu/article/details/9067551

    参考链接:

    https://blog.csdn.net/yuesichiu/article/details/9067559

     https://blog.csdn.net/yuesichiu/article/details/9067551

    https://blog.51cto.com/u_7034817/2785532

  • 相关阅读:
    Java内存模型(JMM)是什么?JMM 通过控制主内存与每个线程的本地内存之间的交互,来提供内存可见性保证
    【普及组_在线赛】班级聚会(reuntion)
    面试官:你对Redis缓存了解吗?面对这11道面试题是否有很多问号?
    【华为云技术分享】浅谈产品模型(Profile)在程序设计中的作用
    【华为云技术分享】LiteAI四大绝招,解锁物联网智能设备AI开发难关
    【华为云技术分享】漫谈Huawei LiteOS五大内核模块
    科技感满满,华为云DevCloud推出网页暗黑模式
    赶在520之前,程序员如何用Python送上最特别的“我爱你”表白
    【华为云技术分享】从部署和运维说说DLI(1)
    【2017.11.25普及组模拟】The Farthest House题解
  • 原文地址:https://www.cnblogs.com/hzijone/p/16404148.html
Copyright © 2020-2023  润新知