comp.lang.ada
 help / color / mirror / Atom feed
* Example of OSI package/data structure?
@ 2001-11-28  8:28 Vincent Smeets
  2001-11-28  9:46 ` Patrick Hohmeyer
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Vincent Smeets @ 2001-11-28  8:28 UTC (permalink / raw)


Hallo,

Can someone point me to an example of an implementation for the ISO/OSI
protocol stack?

I have a description of a protocol that has to be coded in Ada95. I it
now coded (hacked) in a bad form in Ada83 and I want to redesign it for
Ada95.

First I need a package structure. I want to decopple every layer as much
as possible and was thinking of a tagged type for the device and extend
it in every next layer. I have three ideas from which I think the first
is the best (your opinion please?):

OSI
OSI.Physical
OSI.Physical.Data_Link
OSI.Physical.Data_Link.Network
OSI.Physical.Data_Link.Network.Transport
OSI.Physical.Data_Link.Network.Transport.Session
OSI.Physical.Data_Link.Network.Transport.Session.Presentation
OSI.Physical.Data_Link.Network.Transport.Session.Presentation.Application

OSI
OSI.Application
OSI.Application.Presentation
OSI.Application.Presentation.Session
OSI.Application.Presentation.Session.Transport
OSI.Application.Presentation.Session.Transport.Network
OSI.Application.Presentation.Session.Transport.Network.Data_Link
OSI.Application.Presentation.Session.Transport.Network.Data_Link.Physical

OSI
OSI.Physical
OSI.Data_Link
OSI.Network
OSI.Transport
OSI.Session
OSI.Presentation
OSI.Application

Next; what type definition can I use for my device. As I only have two
physical devices, I would like to define only two variables in the
package Physical that has to be used for the operations and not allow
the user to define extra variables. Something like:
	type Device (<>) is tagged limited private;
	Device_1 : Device;
	Device_2 : Device;
The problem is that this doesn't work and if the type is extended, the
variables has to be redefined to contain the extension.

I hope you have enough information. Can you give me some help or point
me to an example?

Thanks,
Vincent

-- 
Vincent Smeets
SchlumbergerSema -
Competence Center Informatik GmbH 
Lohberg 10 - 49716 Meppen - Germany
tel:  +49 5931-805-461
fax:  +49 5931-805-175
mail: VSmeets@slb.com
web:  www.cci.de



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Example of OSI package/data structure?
  2001-11-28  8:28 Example of OSI package/data structure? Vincent Smeets
@ 2001-11-28  9:46 ` Patrick Hohmeyer
  2001-11-28 10:47   ` Vincent Smeets
  2001-11-28 11:15 ` David C. Hoos
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Patrick Hohmeyer @ 2001-11-28  9:46 UTC (permalink / raw)


Hmm, no help, just some hints ;-)

Vincent Smeets wrote :

> Hallo,
> 
> Can someone point me to an example of an implementation for the ISO/OSI
> protocol stack?
> 
> I have a description of a protocol that has to be coded in Ada95. I it
> now coded (hacked) in a bad form in Ada83 and I want to redesign it for
> Ada95.
> 
> First I need a package structure. I want to decopple every layer as much
> as possible and was thinking of a tagged type for the device and extend
> it in every next layer. I have three ideas from which I think the first
> is the best (your opinion please?):
> 
> OSI
> OSI.Physical
> OSI.Physical.Data_Link
> OSI.Physical.Data_Link.Network
> OSI.Physical.Data_Link.Network.Transport
> OSI.Physical.Data_Link.Network.Transport.Session
> OSI.Physical.Data_Link.Network.Transport.Session.Presentation
> OSI.Physical.Data_Link.Network.Transport.Session.Presentation.Application

Why do you want Data_Link inherit from Physical ?
This would give Data_Link the same interface as Physical
plus an addition.
Is that what you want ?
Shouldn't Data_Link and Physical be two complete different interfaces.

And it would label Data_Link an extention of Physical.
But aren't in the OSI philosophy these two *independent* layers,
communication with each other through an interface?

I simply dont see my Browser as an extended Ethernet card.
IMHO he _uses_ the Ethernet card, but he _is_ _not_ an Ethernet card.

But if you want to go with your "extention" vision,
tagged types and the first package structure are appropriated.

I recommend the "use" vision.
There the third structure and no tagged types are recommended.

The "extention" vision makes it very hard to have 2 Data_Link go over
the same physical device, as they are an extention of a Device,
so 2 different Data_Links _are_ 2 (different) physical devices
and I dont see how you are gonna solve this paradox.

That's why I'd prefer the "use" approch.

> OSI
> OSI.Application
> OSI.Application.Presentation
> OSI.Application.Presentation.Session
> OSI.Application.Presentation.Session.Transport
> OSI.Application.Presentation.Session.Transport.Network
> OSI.Application.Presentation.Session.Transport.Network.Data_Link
> OSI.Application.Presentation.Session.Transport.Network.Data_Link.Physical

Physical isn't an extention of Data_Link so this one definitly not ;)

> OSI
> OSI.Physical
> OSI.Data_Link
> OSI.Network
> OSI.Transport
> OSI.Session
> OSI.Presentation
> OSI.Application

I would go with this one, but it depends on how you see the layers.
As extentions of each other or as independent entitys who communicate?

> Next; what type definition can I use for my device. As I only have two
> physical devices, I would like to define only two variables in the
> package Physical that has to be used for the operations and not allow
> the user to define extra variables. Something like:
> type Device (<>) is tagged limited private;
> Device_1 : Device;
> Device_2 : Device;
> The problem is that this doesn't work and if the type is extended, the
> variables has to be redefined to contain the extension.

First question :
  Why do you want to limite you to 2 vars in the ads?
  Might it be possible that you will reuse the package on
  a system with more than 2 devices?

Second :
  When the user cant define variables, how is he supposed to
  work with the type?
  What you really want is not preventing the /definition/ of variables,
  but the /initialization/ of variables.

Limited private is a good choice for the type.
Then you need an initialization procedure
(a function or constant wont work, as the user cant assign anything)
something like :
procedure Init_Device (Device_To_Init : out Device;
  Device_Number : in Natural);
and when Device_Number is greater than the number of devices
in this implementation, you raise an exception.

This one lets the user point two variable Device
to the same physical device.
To prevent this, you may mark a Device "occupied" until
it is liberated with a second function.
Think like a file.
You may even use an only slighly modified Sequentiel_IO.ads for
the specification of the Physical package.

> I hope you have enough information. Can you give me some help or point
> me to an example?
> 
> Thanks,
> Vincent
> 

-- 
Patrick Hohmeyer



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Example of OSI package/data structure?
  2001-11-28  9:46 ` Patrick Hohmeyer
@ 2001-11-28 10:47   ` Vincent Smeets
  2001-11-30  8:46     ` Patrick Hohmeyer
  0 siblings, 1 reply; 8+ messages in thread
From: Vincent Smeets @ 2001-11-28 10:47 UTC (permalink / raw)


Thank you for your reply. I will explain why I was thinking about type
extension but I also will try to redesign using separate packages
side-by-side. You have made me think in an other direction.

Patrick Hohmeyer wrote:
> 
> Hmm, no help, just some hints ;-)
> 
> Why do you want Data_Link inherit from Physical ?

I was thinking of Physical being a channel (line) and Data_Link
extending it with the ability to transfer data over that channel
(defining Send and Receive procedures).

> This would give Data_Link the same interface as Physical
> plus an addition.
> Is that what you want ?
> Shouldn't Data_Link and Physical be two complete different interfaces.
> 
> And it would label Data_Link an extention of Physical.
> But aren't in the OSI philosophy these two *independent* layers,
> communication with each other through an interface?
> 
> I simply dont see my Browser as an extended Ethernet card.
> IMHO he _uses_ the Ethernet card, but he _is_ _not_ an Ethernet card.

I see your browser and ethernet as a channel to transfer data. The
browser sends and receives special formatted data and the ethernet
transfers just data. The browser extends the ethernet with the
processing of e.g. http/html.

> But if you want to go with your "extention" vision,
> tagged types and the first package structure are appropriated.
> 
> I recommend the "use" vision.
> There the third structure and no tagged types are recommended.
> 
> The "extention" vision makes it very hard to have 2 Data_Link go over
> the same physical device, as they are an extention of a Device,
> so 2 different Data_Links _are_ 2 (different) physical devices
> and I dont see how you are gonna solve this paradox.
> 
> That's why I'd prefer the "use" approch.
> 
> First question :
>   Why do you want to limite you to 2 vars in the ads?
>   Might it be possible that you will reuse the package on
>   a system with more than 2 devices?

not without a software change.

> Second :
>   When the user cant define variables, how is he supposed to
>   work with the type?
>   What you really want is not preventing the /definition/ of variables,
>   but the /initialization/ of variables.

I was thinking of allowing something like:
	Data_Link.Send (
		Channel => Physical.Device_1'Access,
		Data    => "data");

> Limited private is a good choice for the type.
> Then you need an initialization procedure
> (a function or constant wont work, as the user cant assign anything)
> something like :
> procedure Init_Device (Device_To_Init : out Device;
>   Device_Number : in Natural);
> and when Device_Number is greater than the number of devices
> in this implementation, you raise an exception.

I know the way of using limited types but then you have to control the
number of open instances. I was thinking of having only two instances
that are always open. That way I can leave out the controlling code.

> This one lets the user point two variable Device
> to the same physical device.
> To prevent this, you may mark a Device "occupied" until
> it is liberated with a second function.
> Think like a file.
> You may even use an only slighly modified Sequentiel_IO.ads for
> the specification of the Physical package.
> 
> > I hope you have enough information. Can you give me some help or point
> > me to an example?
> >
> > Thanks,
> > Vincent
> >
> 
> --
> Patrick Hohmeyer

-- 
Vincent Smeets
SchlumbergerSema -
Competence Center Informatik GmbH 
Lohberg 10 - 49716 Meppen - Germany
tel:  +49 5931-805-461
fax:  +49 5931-805-175
mail: VSmeets@slb.com
web:  www.cci.de



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Example of OSI package/data structure?
  2001-11-28  8:28 Example of OSI package/data structure? Vincent Smeets
  2001-11-28  9:46 ` Patrick Hohmeyer
@ 2001-11-28 11:15 ` David C. Hoos
  2001-11-28 11:59 ` Larry Kilgallen
  2001-11-28 12:06 ` Lutz Donnerhacke
  3 siblings, 0 replies; 8+ messages in thread
From: David C. Hoos @ 2001-11-28 11:15 UTC (permalink / raw)
  To: comp.lang.ada

I know of no implementation (Ada or otherwise) that strictly
follows the OSI model.

However, there is an implementation of IP version 4 worth
looking at here:
https://www.iks-jena.de/mitarb/lutz/ada/net/

In general, though I would not think it wise to derive one layer
from the other (going in either direction) because the layers are
distinct in their function and purpose.  The only thing that they
should have in common is that each layer should have a clean
interface with each of its neighbors in the stack.

Just off the top of my head, I would start with an organization
plan something like this:

Net;
Net.Physical;
Net.Link;
Net.Network;
Net.Transport;
Net.Session;
Net.Presentation;
Net.Application;

Each of the above would define abstract interfaces from which
specific implementations would be derived.  For example, you
might have:

Net.Physical.Serial;
Net.Physical.Ethernet;
Net.Physical.MIL_STD_188_220;

Net.Link.Arp;
Net.Link.Rarp;

Net.Network.IP;
Net.Network.ICMP;
Net.Network.IGMP;

Net.Transport.TCP;
Net.Transport.UDP;

etc., etc.

Also, in practice the session, presentation and application
layers are often collapsed into one. 

You will note that I have named no package OSI.  It just
seems  to me that Net is a better name for the root package,
since this is what it's all about.

As a general implementation scheme I have a task that does
a blocking read on the physical device, and delivers received
packets to a handler that has been registered with that task.
Such registrations could be for all packets, or only for
packets of a certain kind.
In this way, the same handler can receive packets from its
choice of lower-level packet sources.

In the send direction, each layer simply calls a Send procedure
for the next lower layer of its choice.

Since the programs I write usually have multiple threads of
execution wishing to send to the network, I protect the
lowest layer with a semaphore implemented in Ada95;

I hope these ramblings provide you with some food for thought.
 
----- Original Message ----- 
From: "Vincent Smeets" <VSmeets@meppen.sema.slb.com>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: Wednesday, November 28, 2001 2:28 AM
Subject: Example of OSI package/data structure?


> Hallo,
> 
> Can someone point me to an example of an implementation for the ISO/OSI
> protocol stack?
> 
> I have a description of a protocol that has to be coded in Ada95. I it
> now coded (hacked) in a bad form in Ada83 and I want to redesign it for
> Ada95.
> 
> First I need a package structure. I want to decopple every layer as much
> as possible and was thinking of a tagged type for the device and extend
> it in every next layer. I have three ideas from which I think the first
> is the best (your opinion please?):
> 
> OSI
> OSI.Physical
> OSI.Physical.Data_Link
> OSI.Physical.Data_Link.Network
> OSI.Physical.Data_Link.Network.Transport
> OSI.Physical.Data_Link.Network.Transport.Session
> OSI.Physical.Data_Link.Network.Transport.Session.Presentation
> OSI.Physical.Data_Link.Network.Transport.Session.Presentation.Application
> 
> OSI
> OSI.Application
> OSI.Application.Presentation
> OSI.Application.Presentation.Session
> OSI.Application.Presentation.Session.Transport
> OSI.Application.Presentation.Session.Transport.Network
> OSI.Application.Presentation.Session.Transport.Network.Data_Link
> OSI.Application.Presentation.Session.Transport.Network.Data_Link.Physical
> 
> OSI
> OSI.Physical
> OSI.Data_Link
> OSI.Network
> OSI.Transport
> OSI.Session
> OSI.Presentation
> OSI.Application
> 
> Next; what type definition can I use for my device. As I only have two
> physical devices, I would like to define only two variables in the
> package Physical that has to be used for the operations and not allow
> the user to define extra variables. Something like:
> type Device (<>) is tagged limited private;
> Device_1 : Device;
> Device_2 : Device;
> The problem is that this doesn't work and if the type is extended, the
> variables has to be redefined to contain the extension.
> 
> I hope you have enough information. Can you give me some help or point
> me to an example?
> 
> Thanks,
> Vincent
> 
> -- 
> Vincent Smeets
> SchlumbergerSema -
> Competence Center Informatik GmbH 
> Lohberg 10 - 49716 Meppen - Germany
> tel:  +49 5931-805-461
> fax:  +49 5931-805-175
> mail: VSmeets@slb.com
> web:  www.cci.de
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada
> 




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Example of OSI package/data structure?
  2001-11-28  8:28 Example of OSI package/data structure? Vincent Smeets
  2001-11-28  9:46 ` Patrick Hohmeyer
  2001-11-28 11:15 ` David C. Hoos
@ 2001-11-28 11:59 ` Larry Kilgallen
  2001-11-28 12:06 ` Lutz Donnerhacke
  3 siblings, 0 replies; 8+ messages in thread
From: Larry Kilgallen @ 2001-11-28 11:59 UTC (permalink / raw)


In article <3C04A024.DEAFCE6@meppen.sema.slb.com>, Vincent Smeets <VSmeets@meppen.sema.slb.com> writes:

> I have a description of a protocol that has to be coded in Ada95. I it
> now coded (hacked) in a bad form in Ada83 and I want to redesign it for
> Ada95.
> 
> First I need a package structure. I want to decopple every layer as much
> as possible and was thinking of a tagged type for the device and extend
> it in every next layer. I have three ideas from which I think the first
> is the best (your opinion please?):

I think you are starting at the wrong end of the problem.

The first step should be to build an ASN.1 compiler that emits Ada.
In my experience that is much easier for Ada95 than for Ada83 because
of additional attributes for creating access values for precompiled
data.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Example of OSI package/data structure?
  2001-11-28  8:28 Example of OSI package/data structure? Vincent Smeets
                   ` (2 preceding siblings ...)
  2001-11-28 11:59 ` Larry Kilgallen
@ 2001-11-28 12:06 ` Lutz Donnerhacke
  2001-11-28 14:49   ` Vincent Smeets
  3 siblings, 1 reply; 8+ messages in thread
From: Lutz Donnerhacke @ 2001-11-28 12:06 UTC (permalink / raw)


* Vincent Smeets wrote:
>Can someone point me to an example of an implementation for the ISO/OSI
>protocol stack?

http://www.iks-jena.de/mitarb/lutz/ada/net/



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Example of OSI package/data structure?
  2001-11-28 12:06 ` Lutz Donnerhacke
@ 2001-11-28 14:49   ` Vincent Smeets
  0 siblings, 0 replies; 8+ messages in thread
From: Vincent Smeets @ 2001-11-28 14:49 UTC (permalink / raw)


Lutz Donnerhacke wrote:
> 
> * Vincent Smeets wrote:
> >Can someone point me to an example of an implementation for the ISO/OSI
> >protocol stack?
> 
> http://www.iks-jena.de/mitarb/lutz/ada/net/

Thank you. I can use your packages as a good example.

Maybe you could provide your Ada-Files in a zip file too. It was a lot
of work to make compilable Ada files out of a set of HTML files.

Vincent

-- 
Vincent Smeets
SchlumbergerSema -
Competence Center Informatik GmbH 
Lohberg 10 - 49716 Meppen - Germany
tel:  +49 5931-805-461
fax:  +49 5931-805-175
mail: VSmeets@slb.com
web:  www.cci.de



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Example of OSI package/data structure?
  2001-11-28 10:47   ` Vincent Smeets
@ 2001-11-30  8:46     ` Patrick Hohmeyer
  0 siblings, 0 replies; 8+ messages in thread
From: Patrick Hohmeyer @ 2001-11-30  8:46 UTC (permalink / raw)


Vincent Smeets wrote :

> Thank you for your reply. I will explain why I was thinking about type
> extension but I also will try to redesign using separate packages
> side-by-side. You have made me think in an other direction.

:) It's always good to look from different sides. ;)

> > First question :
> >   Why do you want to limite you to 2 vars in the ads?
> >   Might it be possible that you will reuse the package on
> >   a system with more than 2 devices?
> 
> not without a software change.

OK

> I was thinking of allowing something like:
> Data_Link.Send (
> Channel => Physical.Device_1'Access,
> Data    => "data");
> 
> I know the way of using limited types but then you have to control the
> number of open instances. I was thinking of having only two instances
> that are always open. That way I can leave out the controlling code.
> 

I type is something you can define variables of.
That's somehow the interest of a type.

You might choose to define the Device as an access type :

--------------------
type device is limited private;

Device_1 : T_Device;
Device_2 : T_Device;
--...

private

type T_Device;
type device is access T_device;
--------------------

and everytime you got an Null pointer passed, you know
that it wasn't one of the devices defined in the package.
Or (similiar) put an boolean ok field into the type that is initialised
to false and you set it to true for your 2 devices.
But this still enables the definition of variables outside the package,
they would only be useless.

I would prefere an enumeration type :
type devices is (Device_1,Device_2);

And then you have somewhere in the adb an array that maps the enumeration
to the actual device.

The device type will actually be in the private part,
so that only the child packages can define variables of it.

This limites the choice of the user to the 2 device
and he can even easily store wich device he had use.

But that's just my humble preference.

Oh, and there's the possibility of abstract types,
but to define an abstract type, just to prevent more instances
of a valid type sounds somehow like an abuse to me.
AND you'll have a strange hierarchy
(that might be non-valid in Ada, I haven't tested it) :

abstract device
  device
    abstract data link
      data link
        abstract ... etc.

-- 
Patrick Hohmeyer



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2001-11-30  8:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-28  8:28 Example of OSI package/data structure? Vincent Smeets
2001-11-28  9:46 ` Patrick Hohmeyer
2001-11-28 10:47   ` Vincent Smeets
2001-11-30  8:46     ` Patrick Hohmeyer
2001-11-28 11:15 ` David C. Hoos
2001-11-28 11:59 ` Larry Kilgallen
2001-11-28 12:06 ` Lutz Donnerhacke
2001-11-28 14:49   ` Vincent Smeets

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox