Hi Larry
I like the idea of a stack. I have just done a quick google and found some
interesting links, for example
http://www.eventhelix.com/RealtimeMa...atternCatalog/
has quite a few design patterns that look promising.
>> Also, the comms layer will probably need some kind of dynamic
>> configuration,
>> such as baud rate, stop bits, etc. How do we configure this layer? The
>> only
>> thing that has a handle to a TransportLayer object is the LinkLayer
>> object,
>> but the LinkLayer knows nothing of baud rates and stop bits. Where does
>> the
>> information come from? Do we have to pass it down the layers until the
>> object that understands the configuration gets it? That doesn't seem
>> right
>> at all.
>
> With the Stack model each generic and specific Layer is free to
> implement properties as required, so ApplicationLayer would implement
> Property FriendlyName, then DOOMLayer (Inherits ApplicationLayer) would
> always return "DOOM" for this property, and so on.
I'm not sure I follow you here. How does this help with the configuration of
the comms parameters required in the transport layer?
Charles
"Larry Lard" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
>
> Charles Law wrote:
>> This is going to seem like a basic OO question, but it comes up and bites
>> me
>> every now and again.
>>
>> Suppose we have a multi-tiered protocol to implement, what is the
>> logical,
>> OO way to design the handler? For example, let's say that we have to
>> implement the ISO 7-layer protocol, or something like an Allen-Bradley
>> master-slave protocol. At the lowest layer we might only need to top and
>> tail the data being transported, such as DLE STX [data from network
>> layer]
>> DLE ETX BCC.
>>
>> [data from network layer] might comprise DST SRC CMD STS TNS [data from
>> application layer]
>>
>> [data from application layer] might comprise FNC ADDR [data].
>>
>> We could have a class for each layer, where each contains an instance of
>> the
>> next layer down, e.g.
>>
>> Public Class ApplicationLayer
>>
>> Private m_NetworkLayer As NetworkLayer
>>
>> End Class
>>
>> Public Class NetworkLayer
>>
>> Private m_LinkLayer As LinkLayer
>>
>> End Class
>>
>> Public Class LinkLayer
>>
>> Private m_TransportLayer As TransportLayer
>>
>> End Class
>>
>> In the last case, TransportLayer could be a serial link implementation,
>> or
>> some other type of communications handler.
>>
>> Each layer would pass data on to the next layer down, and return results
>> to
>> the caller; the next layer up.
>>
>> Is this how other people would do it? I can't put my finger on why, but
>> there is something that just doesn't sit well with me about this method.
>> What if we want to dispense with the network layer? Do we have to change
>> the
>> code in ApplicationLayer to keep a local LinkLayer instance? Wouldn't
>> that
>> upset things a bit?
>
> This feels wrong to me because I don't see how containment correctly
> describes the relationship of layers to each other - they feel like
> siblings more than parents/children.
>
>
>>
>> I suppose each local instance should be based on a common interface, so
>> that
>> layers become, to some extent, interchangeable. Have I just answered my
>> own
>> question?
>
> How about this: A given scenario of layers is a Stack (I believe this
> term is the one used in networking). A Stack contains an *ordered* set
> of Layer objects. The base Layer class defines Transmit and Receive
> methods that operate on a <unit of transmission> - each specialization
> of Layer overrides as necessary.
>
> There are two levels of inheritance from Layer - for example for
> networking the first ('generic') level would be the 7 ISO levels,
> ApplicationLayer, TransportLayer, etc; then deriving from *those* would
> be *particular* ('specific') layers, eg TCP would derive from
> TransportLayer (assuming I've correctly remembered which ISO layer TCP
> maps to...)
>
>
>>
>> What if we want to change the comms layer to something else: does that
>> work
>> in the same way?
>>
>> Also, the comms layer will probably need some kind of dynamic
>> configuration,
>> such as baud rate, stop bits, etc. How do we configure this layer? The
>> only
>> thing that has a handle to a TransportLayer object is the LinkLayer
>> object,
>> but the LinkLayer knows nothing of baud rates and stop bits. Where does
>> the
>> information come from? Do we have to pass it down the layers until the
>> object that understands the configuration gets it? That doesn't seem
>> right
>> at all.
>
> With the Stack model each generic and specific Layer is free to
> implement properties as required, so ApplicationLayer would implement
> Property FriendlyName, then DOOMLayer (Inherits ApplicationLayer) would
> always return "DOOM" for this property, and so on.
>
>>
>> The same problem could occur in the network layer. An address is probably
>> required to ensure that the correct target gets the data, but where is
>> this
>> address managed?
>>
>> A lot of this is me just thinking out loud, but I would be interested in
>> other p
>
> What I haven't thought about at all is the <unit of transmission> - how
> about a Byte(), then you could have these methods on Layer (which is
> MustInherit):
>
> Public Function DecorateForTransmission(ToSend() As Byte) As Byte()
> Public Function UndecorateOnReception(Received() As Byte) As Byte()
>
> (shorter names in real thing!)
>
> This assumes all layers are happy with a Byte() as the unit of
> transmission, which I can immediately see is going to be a problem with
> packet-based systems.
>
> Finally, to transmit, Stack would take some input at the Application
> level, run through each Layer's DecorateForTransmission in turn, then
> call ... I dunno, ActuallyTransmit on the 'bottom' Layer; reverse the
> process to receive...
>
> Anyway, just some initial hand-wavy thoughts.
>
> --
> Larry Lard
> Replies to group please
>