The LonWorks® Protocol
The LonWorks® protocol provides services at each layer of the OSI seven layer reference model.
The protocol is open for anyone to implement, and a reference implementation in the C programming language can be obtained from CEA. Since its invention, the protocol has become an ANSI standard, an IEC standard, a Chinese national standard, and recently has achieved ISO standardization.
Layer 1: Physical Layer
At Layer 1, multiple physical links are supported such as RS-485; our free-topology (FT) and power line (PLC) transceivers; and third-party wired, wireless, and fiber transceivers.
Layer 2: Link Layer – MAC Algorithm
At the Link Layer, Layer 2 of the OSI model, the LonWorks protocol provides an innovative independent media access control (MAC) layer based on improvements made to the Carrier Sense Multiple Access (CSMA) family after Ethernet was standardized. The MAC layer combines two concepts: p-persistent CSMA and non-persistent CSMA.
P-Persistent CSMA. In P-persistent CSMA, access to the link is slotted, and the transmitting station accesses the link with probability P, so for example, in a 0.1 persistent CSMA link, there would be 10 slots and access to the link would be randomized such that the probability of transmitting through any one of those slots is 10 percent.
Thus, the smaller the number P, the more slots there are for a station to randomize link access. Having a very large number of slots reduces the probability of collision because the chance that any two stations would pick the same slot to transmit is reduced. The drawback in having many slots is, in an idle network, the average delay to send a message is the number of slots divided by two. Ideally, randomized access to the link would be over a small number of slots when there are only a few stations waiting to transmit, and when many stations have a message to send, they would randomize access over many slots. P-persistent CSMA doesn't solve the delay problem by itself.
Non-persistent CSMA. With non-persistent CSMA, whenever a station has a message to send, it randomizes its access rather than immediately transmitting. This technique prevents multiple stations that respond to a single event from causing packet collisions.
Non-persistent CSMA is very useful for networks that have bursts of packet traffic, and many control networks have this characteristic. Other characteristics of networked control systems are that, often, when a station sends a message, it must receive a response or an acknowledgment, and this multicasting of information is often used. For example, a node with a temperature reading may need to share it with multiple nodes simultaneously. Multicasting is the most efficient way to do this. If multicasts need a response or are unacknowledged, more than half the packets on the link are predictable because each packet generates at least one and sometimes more responses.
Predictive p-persistent CSMA. To support prioritized access to the link when the network is congested, some number of randomizing slots may be assigned to individual stations for their exclusive use. In this way, a station with the MAC priority privilege may use the dedicated slot and avoid all link access contention. Figure 1 shows the slotted access protocol. Figure 2 shows the use of dedicated priority slots after each packet to ensure that critical stations have access to the link without packet contention.
Using Predictive CSMA, when a station sends a message, the number of response packets the message will generate is encoded in the packet’s Layer 2 header. This is called the link backlog increment. The number of packets that will be sent in response to an initial message is known by the sender because it must keep track of responses so it knows when to stop retransmitting. All the nodes on the link receive all the packets and examine the Layer 2 header to see what the increment of the link backlog is. They use this running backlog to adjust the number of slots they randomize for their own link access. So the backlog is dynamically increased when there is more traffic, and it decays over time as traffic recedes.
In this way, the LonWorks protocol dynamically adjusts the number of randomizing slots based on the known future. The protocol’s MAC algorithm for a peer-to-peer network has been shown empirically to use link bandwidth up to 80 percent of its theoretical maximum with the collision rate of fewer than 4 percent. It is very efficient and requires minimal state, no knowledge of the number of stations on the link, and no collision detection hardware.
Traffic versus delay illustrating the power of Predictive P-Persistent CSMA to avoid collisions even during network overload.
Layer 2: Link Layer – Bit Encoding
Beside the MAC algorithm, Layer 2 provides bit encoding and a 16-bit cyclic redundancy check (CRC). The CRC is the CCITT CRC-16 standard. Bit encoding is bi-phase space encoding. This is a variant of differential Manchester encoding that provides polarity insensitivity when communicating on twisted-pair wires. An installer need not be concerned about which of the two wires to connect to which of the two terminals.
Layer 3: Network Layer
Layer 3, the Network Layer, provides addressing. In the LonWorks protocol, addressing is hierarchical, starting with the node’s domain and followed by its subnet and identification number, each expressed in eight bits. Alternatively, a node may have membership in multiple multicast groups, with each group address encoded as a single byte. A domain can include up to 256 multicast groups, as well as 255 subnets, each having a maximum of 127 nodes. To save bandwidth, a domain’s address may be encoded as zero in length, as a single byte, three bytes, or to ensure uniqueness, six bytes. This simple addressing design permits very simple routing of packets across multiple links. The routing tables are quite small, with, for example, an array of 256 bits determining whether a message should pass across the router to a given subnet, or whether a member of a particular group is on the other side of the router.
Layer 4: Transport Layer
Layer 4, the Transport product protocol layer, is where packet retransmission and duplicate detection is handled. When the station sends a packet, it specifies whether the packet is sent using unreliable or reliable services. Unreliable services include unacknowledged services, and unacknowledged but repeated services. Reliable services are confirmed with an acknowledgment or response. The protocol supports reliable unicast as well as multicast, making it transparent to the application whether its information is being sent to one or more stations. For every packet, the number of retries, the time between retries, and the total transaction time on the receiver’s side are configurable. This allows transactions to either fail or succeed within a bounded time, meeting the application response time requirements.
Layer 5: Session Layer
Layer 5, the Session Layer, is where request response services are handled. Besides sending a response, the protocol saves it, so that if a retry comes along, the response can be resent without the application needing to re-compute and retransmit.
Layer 6: Presentation Layer
Layer 6, the Presentation Layer, is used with Echelon’s publisher-subscriber data model. The Presentation Layer header encodes the semantics of data passed in the Application Layer. It also carries the identifier of data items.
Layer 7: Application Layer
Layer 7, the Application Layer, provides data called network variables. Network variables are application specific data types that contain semantics beyond float, integer, and Boolean. Examples might be a temperature in degrees Celsius with high and low limits defined as well as a value defined as valid or not. Network