I don’t think we should label such a device inheritance and I think it should be sliced in another way if we in the end decide that the added complexity is worth the effort.
First, let’s summarize a few scenarios:
-
Fully Dynamic - The most generic way of solving template evolution is to use non mutating TID and SCP Level 3 (i.e, dynamic template exchange). The base for this is already defined, but additional work is required for multicast applications.
-
Non Mutating TID and Accessible Extension - You want to add new data without modifying or sending out a new template. You also want all receivers to be able to discover and use the new data. To solve this you’d have to tack on an explicit extension field. It could look something like
The benefits of this soultion is that it is already available. The downside is that it is not particular flexible, it is intrusive, and it requires explicit processing at the application level.
- Mutating TID and Opaque Extension - You have different versions of the same template (same identifier). The versions are compatible. Receivers only knowing of V1 will simply ignore content available to those receivers that use V2.
Scenario 3 is what I beleive you tried to solve with your inheritance proposal. This is an outline of how I’d do it:
Add a new template construct named ‘extension’:
The semantics of this would be that messages of all these three templates would be fully interchangable (with a few constraints, see below). That is, the templates are both backward and forward compatible. V1 - V3 decoders can decode any message encoded with V1 - V3.
The fine print:
The wire representation would need a new predefined template identifier in the reserved range. Let’s use 121 for now. The definition of 121 would look something like this.
The predefined template is assumed to be known in advanced by any decoder supporting the feature.
When an encoder encodes an section, it wraps it in an Extension message:
PMAP TID=121 LEN [… encoded extension section …]
If fields in the extension section must utlilize bits in a presence map, the encoded extension section starts with PMAP.
Encoding backward compatibility: Let’s say a V1 decoder receives an message encoded with V2. The decoder first reads the V1 fields (all it knows). The next thing in the stream is the extension secition, which starts with a PMAP and the tid 121. It recognizes this as an Extension message and just skips it.
Encoding forward compatibility: Let’s say a V2 decoder receives an message encoded with V1. The decoder first read the non-extension part. It then looks for the next message in the stream. Since this message is not the 121 - Extension message, it knows the extension section is not present. The additional constraint here is that the fields in the extension section must be optional in the corresponding application type.
For this to work in general, there are few constraints that must be met:
-
elements may only appear as the last components of a top level template (after resolving any static template refereces).
-
Any field operator in an extension section must either specify no dictionary or must specify the special dictionary “extension”. An extension dictionary is local to a template and a specific extension section. This way we avoid that operators in extension sections pollute dictionaries seen by ordinary fields (otherwise it would be dangerous to skip 121 messages).
-
The 121 Extension messsage must not be used in any other situation than as a result of encoding a template with an section. If this constraint is not met, the forward compatibility feature won’t work.
-
Dynamic template references are not allowed in an extension section. There are two reasons: They’d pollute the previous value of the implicit copy operator for TIDs, and the actual contained templates could possible pollute arbitrary dictionaries. The dictionary constraint described above should be possible to enforce by static examination of a template.
This solution might look complex at first but wouldn’t be particulary hard to implement. The simplest level of support would be for a decoder to recognize the 121 tid and know how to skip that message.
/David
May be we could create a special relation between templates – like
“Russian nesting dolls”, or template inheritance.
If template T3 ← T2 ← T1 then if message M3 has been T3-encoded, it
then can be decoded by T2 and or T1.
What you get when you decode M3 following T2 or T1 is not specified.
That would solve Hanno’s problem. That would also allow the notion of
template specialization etc.
What do you think???
Hanno,
There is no way to know how long the message is without the correct
template, so a new message with an unknown or ‘extended’ template
can’t be fully decoded (a result of the decision to not include a
message length in FAST or SCP).
Perhaps an optional length for messages requiring a new template would
maintain the integrity of the transport layer without affecting the
message contents.
Then you could create a revised template (instead of 7 it would 7.1?)
that could have additional fields that would be ignored until you get
a hold of the new template.
Greg.
Hanno, this is an interesting problem.
The short answer is no. There is no way for the receiver to detect
that there is another field in the message. As you mention, you
could put a placeholder into the template, maybe an optional field
at the end of the template. This would maybe work in some instances,
but you would be restricted in choice of operator etc.
We did discuss this some when we were updating the spec from 1.0 to
1.1, but nothing came out of that discussion if I recall correctly.
It’s worth discussing again, though. Anyone has ideas on this?
/Rolf
Rolf,
I have a related question. Is there a way to send a new message
without having sent a new template definition, i.e. if I add a
field to my message, is there a way for the receiver to ignore
that new field until he receives a new template definition from
me, perhaps by appending it to the end of my message and having a
placeholder in my initial template definition? Or is it a strict
requirement to always send a new template definition prior to
sending a message for it.
Thanks, Hanno.