Protocol Backgrounder


This backgrounder introduces the concepts on communication as relevant to this program. I'm not going to re-explain the modbus protocol, because it's pretty well explained in the Open-mbus spec revision J. Rather than re-explain things I aim to tell the whole story from a different angle in this backgrounder.

What is a communications protocol? The meaning of the word 'protocol' in person-to-person interface is very similar to that used for computers. In both cases it revolves around a set of previously agreed rules about how parties meet, start a conversation, and then how the exchange of ideas (data in the computer's case) goes on. Lastly a protocol also has rules covering how a 'meeting' ends. For humans, a protocol will cover how we punctuate our speech to separate ideas, while computers use special codes to denote data separation into telegrams and fields. We should also be careful not to confuse protocols with media.

Data Types

 Modbus Addresses  Data size  Description
 0..9999  1 bit
 Output (coils)
 10000..19999  1 bit
 Inputs (relays)
 16bit  Analog inputs
 40000..49999  16bit  Holding registers
 Extended Registers (added to spec for larger machines only)

Actual data used in clone implementations varies, for example it is possible to present 8-bit data objects by combining 8 Inputs together, alternately 32-bit integers can be constituted by combining 2 holding registers. At this point endian-ness becomes more relevant, for 16-bit values it is simple to swap the HI and LO byte for Intel platforms to convert to native integer (signed or unsigned). Because the modbus devices were originally built on small endian devices (A Motorola chip I believe?), they use Large Endian for all protocol packing.

Media Types

Media types relate to the physical layers used for any communication process. An example media type could be a telephone line. Humans popularly use air as a media type; whales use sea-water. Computing devices typically use a various copper conductor configurations as a media, some use air. Just in the same way that the amount of air (distance) between two participants affects the kind of communication that can take place, a physical media type must be clearly defined.

Device manufacturers typically will refer to a copper conductor of a certain maximum length and thickness, and then go on to describe other electrical properties of it. So the kind of wire used is important, but the colour is not directly important.
Even though 2 media (wires) look the same, they are not always, Ethernet 10 base-T is a good example of this kind of case. It defines transmission rates of 10 million and 100 million bits per second or even 1G bits, differing only in the amount of twist in the pairs. In addition, because Ethernet is so well defined as a media type of it's own, converters to other physical media such as fibre or radio are popular, and elevate it to the status of a protocol. To be true Ethernet is a protocol, but still referred to as a general media type, because many media converters are readily available. The 'protocol' component to Ethernet, exists because it defines a low-level protocol or IP layer, upon which other protocols can piggyback without regard for the underlying network.

OSI Model

Data unit Layer Function
Data 7. Application Network process to application
6. Presentation Data representation and encryption
5. Session Interhost communication
Segment 4. Transport End-to-end connections and reliability
Packet 3. Network Path determination and logical addressing
Frame 2. Data Link Physical addressing
Bit 1. Physical Media, signal and binary transmission

The simulator supports 2 media types: Serial and TCP/IP-Ethernet.

PDU - Protocol Data Unit

A protocol data unit is that part of a protocol message or frame that contains the data. In the case of modbus, a PDU and a telegram are the same thing, I'll explain how latter.

Data in 99% of protocols is not simply send without at least some kind of mechanism to format the data, explain what data it is, and ensure data integrity and/or security. In total these mechanisms make up a message frame.S ince a message frame cannot be of infinite length, so too, the data in it is restricted. The restriction thus becomes the maximum amount of data transmittable in one packet, and will differ as the maximum message or frame length changes. For modbus, the limit is 265 bytes; this is a resource limitation although partly historical plenty of space for most jobs.

DF1 specifies a PDU of 234 , (223 bytes if over IP) for the SLC5/03 or 5/04.
For the SLC 5/01 or 5/02 it's only only 82 bytes (equivalent to 41 words).

Alright, so we have telegrams, one station or partner will be designated the master, this designation is part of the protocol. The other station is thus the slave, and serves the master. As such the messages (telegrams) the slave sends will differ from those the master sends, moreover the master is always the one to start a conversation. The conversation starter is called the requesting station.

(TODO: narrative for the image above showing a TCP/IP - TCP frame)

(TODO: image here showing master/slave)