bacpytes started 笔记
http://bacpypes.sourceforge.net/gettingstarted/gettingstarted001.html
Device Identifier
Every BACnet device will have a unique identifier, a 22-bit unsigned non-zero value. It is critical that this be unique for every device and most large customers will have someone or a group responsible for maintaining device identifiers across the site. Keep track of the device identifier for the test device, assume that it is 1000 and you are going to pick 1001 for your workstation.
Device Name
Every BACnet device on a BACnet network has a unique name which is a character string. There is nothing on a BACnet network that enforces this uniqueness, but it is a real headache for integrators when it isn’t followed. You will need to pick a name for your workstation. My collegues and I use star names so the sample congiuration files will have “Betelgeuse”.
At some point you will probably running both “client” and “server” applications on your workstation, so you will want separate configuration files for them. Keep in mind that BACnet devices communicate as peers, so it is not unusual for an application to act as both a client and a server at the same time.
UDP Communications Issues
There are two types of UDP messages;
unicast which is a message from one specific IP address and port to another one,
and broadcast which is received and processed by all devices that have the port open.
BACnet uses both types of messages and your workstation will need to receive both types.
unicast (单播):在客户端与媒体服务器之间需要建立一个单独的数据通道,从一台服务器送出的每个数据包只能传送给一个客户机,这种传送方式称为单播。指网络中从源向目的地转发单播流量的过程。单播流量地址唯一。
根据unicast.h中的官方注释理解如下:单播模块发送一个数据包到一个确定的单跳邻居节点。单播原语使用标识广播原语,并将单跳接收节点的地址属性添加到传出的数据包中。当接收节点收到数据包后,单播模块会检查单跳的接收地址属性,如果数据包中的接收地址属性与本节点地址不匹配则丢弃该数据包。
《unicast, multicast, broadcast的区别》
1
The BACpypes.ini file has an address parameter which is an IP address in CIDR notation and can be followed by a port number. For example, 192.168.0.11/16 specifies both the IP address and the number of bits in the network portion, which in turn implies a subnet mask, in this case 255.255.0.0. Unicast messages will be sent to the IP address, and broadcast messages will be sent to the broadcast address 192.168.255.255 which is the network portion of the configuration value will all 1’s in the host portion.
To receive both unicast and broadcast addresses, BACpypes will open two sockets, one for unicast traffic and one that only listens for broadcast messages. The operating system will typically not allow two applications to open the same socket at the same time so to run two BACnet applciations at the same time they need to be configured with different ports.
The BACnet protocol has port 47808 (hex 0xBAC0) assigned to it by the Internet Assigned Numbers Authority, and sequentially higher numbers are used in many applications. There are some BACnet routing and networking isseus with this, but that is for antoher tutorial.
Starting An Application
objectName
modelName
application-software-version
protocol-revision
protocol-revision
iAmDeviceIdentifier = (‘device’, 599)
objectIdentifier: 599
Now to confirm that the workstation can receive the messages that the test device sends out, generate a Who-Is request. This one will be “unconstrained” which means that every device will respond. Do not generate these types of unconstrained requests on a large network because it will create a lot of traffic that can cause conjestion
BACnet网络讲义.doc
(稍后补充)