Implementation of non-IP and non-ethernet protocols

273 views
Skip to first unread message

Raja Baz

unread,
Jun 17, 2009, 5:53:00 AM6/17/09
to ns-3-users
Hello everyone,

I'm currently considering using ns3 to simulate a particularly odd
network I want to see if this is possible, and if so, what would be
the best way to go about doing so.

The network that I'm trying to simulate is a token-ring type network
that was implemented and ran on some microprocessors linked together
over RS232 type links(a ring of four at the time). I have the code
that ran on those processors(it's written in c) and it seperates
network from physical from application so porting to a different
underlying technology isn't that hard. However, some assumptions are
made(and correct me if I'm wrong) in ns3 like the fact that each
packet must contain a protocol number which don't fully suit me.

Is ns3 the right tool for the job? And if so, what would be the best
way to go about implementing this?

From what I've read so far(in the manual and some source code) it
looks like I should get the code that I have(with hopefully as few
modifications as possible) to act as a protocol stack as a first step,
but I'm still pretty new to this.

Mathieu Lacage

unread,
Jun 17, 2009, 6:53:42 AM6/17/09
to ns-3-...@googlegroups.com
On Wed, 2009-06-17 at 02:53 -0700, Raja Baz wrote:
> Hello everyone,
>
> I'm currently considering using ns3 to simulate a particularly odd
> network I want to see if this is possible, and if so, what would be
> the best way to go about doing so.
>
> The network that I'm trying to simulate is a token-ring type network
> that was implemented and ran on some microprocessors linked together
> over RS232 type links(a ring of four at the time). I have the code
> that ran on those processors(it's written in c) and it seperates
> network from physical from application so porting to a different
> underlying technology isn't that hard. However, some assumptions are
> made(and correct me if I'm wrong) in ns3 like the fact that each
> packet must contain a protocol number which don't fully suit me.

I don't really know the answer to your question, but, here is some
information you might find useful to answer it yourself.

The NetDevice base class in ns-3 defines the layer 2 to 3 and 3 to 2
interface. If you implement correctly this API, existing ns-3 code
within layers 3, 4, and 5, should be able to work on top of your
specific NetDevice. The reason why the NetDevice class requires the use
of a per-packet protocol integer is that layer 3 (IP and ARP) needs to
be able to send and receive IP and ARP packets over your layer 2 so, it
need to be able to tell when it receives a packet if it is an IP or an
ARP packet. This is what the protocol number field is used for. I don't
know what your layer 2 protocol looks like but it seems to me that, if
you want to make ip+arp work on top of it, it will be hard to avoid the
requirement of being able to tell whether a layer 2 packet contains an
ip or an arp payload.

Raja Baz

unread,
Jun 17, 2009, 7:01:39 AM6/17/09
to ns-3-...@googlegroups.com

I don't want to put ip or arp over my protocol. What I'm trying to do is simulate a full fledged protocol stack(from layer 2 all the way up). The token ring is actually a replacement for layer 3 not layer 2.

Gustavo Carneiro

unread,
Jun 17, 2009, 7:39:47 AM6/17/09
to ns-3-...@googlegroups.com


2009/6/17 Raja Baz <entr...@gmail.com>


Hello everyone,

I'm currently considering using ns3 to simulate a particularly odd
network I want to see if this is possible, and if so, what would be
the best way to go about doing so.

The network that I'm trying to simulate is a token-ring type network
that was implemented and ran on some microprocessors linked together
over RS232 type links(a ring of four at the time). I have the code
that ran on those processors(it's written in c) and it seperates
network from physical from application so porting to a different
underlying technology isn't that hard. However, some assumptions are
made(and correct me if I'm wrong) in ns3 like the fact that each
packet must contain a protocol number which don't fully suit me.

This is not entirely correct.  Instead of saying "each packet must contain a protocol number" what is really true is "each NetDevice must report a protocol number for each packet received".  If you want design your NetDevice in such a way that it does not read any protocol number from the packet itself but instead reports a fixed protocol number, you are free to do so.  Of course at this point you can forget about IP/ARP working on your netdevice, but you are free to design a different L3 stack on top of the netdevice.

Regards,
--
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert

Raja Baz

unread,
Jun 17, 2009, 7:44:48 AM6/17/09
to ns-3-...@googlegroups.com
I don't want IP/ARP to work on top of my net device, I'm implementing a totally separate network stack.

Mathieu Lacage

unread,
Jun 17, 2009, 7:58:22 AM6/17/09
to ns-3-...@googlegroups.com
On Wed, 2009-06-17 at 14:01 +0300, Raja Baz wrote:

>
> I don't want to put ip or arp over my protocol. What I'm trying to do
> is simulate a full fledged protocol stack(from layer 2 all the way
> up). The token ring is actually a replacement for layer 3 not layer
> 2.

Well, you don't need to use the ns-3 Node and NetDevice class then. All
you need to do is reuse only the src/simulator, src/core, and src/common
code.

Mathieu


Raja Baz

unread,
Jun 17, 2009, 8:12:41 AM6/17/09
to ns-3-...@googlegroups.com

Well, okay then. So how do I learn how to use these? All the examples provided use the node abstraction and most of the documentation refers to it. So how do I start off with this? I'm not really familiar with ns3. So what should I read(source code is an option, of course, but it helps if I have a higher level description of how things work together)




Mathieu Lacage

unread,
Jun 17, 2009, 8:20:56 AM6/17/09
to ns-3-...@googlegroups.com
On Wed, 2009-06-17 at 15:12 +0300, Raja Baz wrote:

> Well, okay then. So how do I learn how to use these? All the examples
> provided use the node abstraction and most of the documentation refers
> to it. So how do I start off with this? I'm not really familiar with
> ns3. So what should I read(source code is an option, of course, but it
> helps if I have a higher level description of how things work
> together)

Well, you are saying that you don't need ip, you don't need to interface
with other ns-3 models, so, all you need is samples/main-simulator.cc

Or, maybe, you want to simulate networks with mixes of your stuff and
other ns-3 network models ? If so, how do you plan to make them
inter-operate at the networking level ?

Mathieu


Raja Baz

unread,
Jun 17, 2009, 9:04:42 AM6/17/09
to ns-3-...@googlegroups.com

Well, the channel(and specifically the point-to-point channel) seem like sane abstractions. Same goes for the net-device(though not the point to point net device, for reasons stated earlier) abstraction and the packet abstraction. The node abstraction is also useful(and makes sense, since I do have nodes talking to each other, though not using IP). I don't need any of the rest really. For the time being I don't plan

So maybe write a different netdevice that attaches to a point to point channel and then use that.




Raja Baz

unread,
Jun 17, 2009, 9:05:34 AM6/17/09
to ns-3-...@googlegroups.com

Ignore the cut-off sentence >_<

Mathieu Lacage

unread,
Jun 17, 2009, 9:23:42 AM6/17/09
to ns-3-...@googlegroups.com
If you want to make your layer 2 be able to work with the ns-3 ip layer
3, then, you will need to keep track of the protocol number correctly.

Now, if you want to implement a new layer 3, it's a different story:
src/internet-stack/ipv4-l3-protocol.cc is an implementation. You need to
call Node::RegisterProtocolHandler to receive packets from a device and
to call Device::Send to send packets on a device.

Mathieu
>
>
>
>
>
>
>
>
> >

Raja Baz

unread,
Jun 17, 2009, 9:28:27 AM6/17/09
to ns-3-...@googlegroups.com

Yep, that's exactly what I want to do, implement a different layer 3(A token ring network rather than an IP based network with routers and whatnot). Where nodes on the ring communicate via point to point channels to their neighbours. I'll take a look at the way ipv4-l3-protocol works and see if I can figure this out.

Thank you for your help 

Mathieu
>
>
>
>
>
>
>
>
> >




Mathieu Lacage

unread,
Jun 17, 2009, 9:33:10 AM6/17/09
to ns-3-...@googlegroups.com
On Wed, 2009-06-17 at 16:28 +0300, Raja Baz wrote:

>
> Yep, that's exactly what I want to do, implement a different layer 3(A
> token ring network rather than an IP based network with routers and
> whatnot). Where nodes on the ring communicate via point to point
> channels to their neighbours. I'll take a look at the way
> ipv4-l3-protocol works and see if I can figure this out.

And to allow an application to send traffic to this layer 3, you will
need to create a SocketFactory. i.e., see Ipv4RawSocketFactoryImpl

Mathieu
>

Reply all
Reply to author
Forward
0 new messages