[Ns-developers] DelayBox - ns-3

Sam Jansen sam.jansen at gmail.com
Wed Apr 16 21:18:03 PDT 2008


On 16/04/2008, Mathieu Lacage <mathieu.lacage at sophia.inria.fr> wrote:
>
>  On Tue, 2008-04-15 at 19:47 -0700, Sam Jansen wrote:
>
>  > >  I suspect that the simplest way to solve your problem is this though:
>  > >
>  > >  // copy packet to avoid modifying the original packet
>  > >  Ptr<Packet> copy = p->Copy ();
>  > >  Ipv4Header iph;
>  > >  copy->RemoveHeader (iph);
>  > >  // copy will disappear when you are done with it.
>  > >
>  >
>  > Two things spring to mind:
>  >
>  > 1. A user of ns-3 can't even figure out how to read the IP header in a
>  > packet, a fundamental and comment operation. Matt hasn't done a thing
>  > wrong here, it's just that ns-3 does not make it obvious how to
>  > perform such a simple operation.
>
>
> Maybe you could point out how we can improve the doxygen documentation
>  to make that more obvious ?
>

I'm not too sure off the top of my head. I'll have a look through the
docs again and see if anything jumps out at me.

>
>  > 2. Why do I need to copy and modify a packet to look at the IP header?
>  > Why can't I do something like "const Ipv4Header* ip_hdr =
>  > p->PeekHeader<Ipv4Header>();". I haven't followed all of the
>  > implementation of the packet, so I'm not sure if this is possible, but
>  > you get the idea.
>
>
> It is certainly possible and there was such a method at some point (it
>  would not return a pointer but it took a reference as input). While it
>  should be trivial to add back, I suspect that matt's use-case would not
>  really benefit from it.
>
>  When I replied, I implicitely assumed that matt would not stop peeking
>  at the first header. i.e., I assumed that matt would want to peek at the
>  other headers inside the packet. If you want to do this, you _have_ to
>  call RemoveHeader first because that method will be responsible for
>  updating the status of the packet to allow you to extract the next
>  header. So, I assumed that you _needed_ to call RemoveHeader: if you do
>  that, you really most likely want to copy the packet first to avoid
>  modifying the behavior of the code which surrounds you (especially if,
>  as I suspect, matt is doing that from a trace hook).
>

Oh, I see. Fair enough.

>
>  > Inspecting a packet header in a packet is sure to be a very common
>  > operation for certain models. The discussion here suggests to me that
>  > doing so is neither obvious nor streamlined.
>
>
> Despite the fact that our codebase does not do that anywhere, I agree
>  with you that a PeekHeader might be helpful. The patch is trivial:
>  copy/paste RemoveHeader and remove the line which updates the buffer
>  status and metadata after deserialization.
>

Ok. The reason I wrote this email is because I've worked on simulation
models before where quickly inspecting a packet header was a
reasonably common operation (the particular case I am thiking of is
mac and routing protocols for an optical switch that had some funny
properties).

Another case I am familiar with that I was thinking of: it seems like
doing an operation like "I've got an IP packet, is it destined for me"
is a reasonable operation and one that should be easy. It's easily
enough to express in C code in an OS, so it probably should be here
to.

>
>  > Can we make simple operations in the real world simple in ns-3 please?
>
>
> That kind of feedback is exactly what is needed to improve ns-3 :)
>
>
>  Mathieu
>
>


More information about the Ns-developers mailing list