Identifying the SOM (Start of Message) is critically important in decoding the correct data. For some applications, e.g. Order Entry Protocols, we can find the start of message but these protocols tend to use the same “message type” in both directions, inbound or outbound. We need to validate these protocols more thoroughly to identify which direction the messages are coming from, and then we can decode the correct messages for the stream we’re decoding.

The example below is a section taken from the ouch5 decoder (the full example is in acd_lib : ouch5.combined.json).

The key difference to note is that there is a “streams” section under Validation. Each key is a unique name for the stream being identified, the direction it represents, and the set of fields to validate from the message. The direction is a unique name specific to each protocol. Once a stream is validated and decoded, the field “acd.Direction” contains this string.

Multiple streams validations can be specified. ACD tests each one and the first to validate will be the selected stream name used in “acd.Direction”.

The “StreamMessages” is a specific set of messages per “direction” name given. So in this example, there is a set of messages defined for “inbound” and another for “outbound”.

The reason we need to identify the direction for ouch5 is that some message types are re-used in both directions of traffic, and ACD would not be able to choose the correct set of message definitions to decode the message data from, unless it was validated and set in this way.

Multiple Streams example

"Validation": {
"data":"stream",
"minimum_size":1,
streams" : {
 
"inbound_unique": {
"direction": "inbound",
"fields": [
{
"name": "MessageType",
"type": "MESSAGE_TYPE",
"offset": 0,
"validate": [ "O", "X" ]
}
]
},
 
"outbound_unique": {
"direction": "outbound",
"fields": [
{
"name": "MessageType",
"type": "MESSAGE_TYPE",
"offset": 0,
"validate":
["S", "A", "C", "D", "E", "B", "F", "J", "P", "I", "T", "R" ]
}
]
},
....
"StreamMessages": {
"inbound": {
 
"O": {
"name": "EnterOrder",
"fields": [
{
"name": "UserRefNum",
"type": "USER_REF_NUM"
},
{
"name": "Side",
"type": "SIDE"
},
...
"outbound": {
 
"S": {
"name": "SystemEvent",
"fields": [
{
"name": "Timestamp",
"type": "TIMESTAMP"
},
{
"name": "EventCode",
"type": "CHAR"
}
]
},
"A": {
"name": "OrderAccepted",
"fields": [
{
"name": "Timestamp",
"type": "TIMESTAMP"
},
...

Validation streams object:

Each JSON key for this object is the name of the stream to validate.

The value of each key is an object containing the following keys:

JSON key: "direction" - required
JSON value: A string containing the name of the identified stream. The name is used to match the “StreamMessages” to decode for this message. The name can be re-used in multiple validation stream objects.

JSON key: "fields" - required
The validation rules to apply for this stream.

StreamMessages object:

Each JSON key for this object is the name for this “set” of messages. The name must match a name used in “direction” from the Validation streams object so that the validation name and messages can be related to each other and then the correct set of messages will be decoded.

The value of this object is a set of messages that may appear on this stream. The format of these definitions is the same as for the “Messages” object.