[Ns-developers] DelayBox - ns-3
Mathieu Lacage
mathieu.lacage at sophia.inria.fr
Wed Apr 16 09:02:08 PDT 2008
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 ?
> 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).
> 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.
> 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