[Ns-developers] DelayBox - ns-3
Sam Jansen
sam.jansen at gmail.com
Tue Apr 15 19:47:39 PDT 2008
While the blood has rushed to my head and I'm on my soapbox, some more comments.
On 13/04/2008, Mathieu Lacage <mathieu.lacage at sophia.inria.fr> wrote:
>
> On Sun, 2008-04-13 at 23:18 -0400, Matt Crinklaw wrote:
> > What is the appropriate way to extract the ip src/dst address from a packet?
> >
> > I see two options: enabling the metadata and somehow hooking into that
> > (it looks possible, but there isn't much information about the
> > metadata system and PacketMetadata/PacketMetadata::ItemIterator
> > classes).
>
>
> Nope, you won't be able to extract the information you want from the
> metadata.
>
>
> >
> > The other option that seems available is to serialize the packet and
> > then try to deserialize the header.
> >
> > Ipv4Header iph;
> > iph.Deserialize(packet->Serialize().Begin());
>
>
> Packet::Serialize/Deserialize are really not expected to be used in
> normal simulations and they really don't do what you think they are
> doing. i.e., they should be used only for distributed simulations by the
> simulation engine. That might need to be documented though.
>
> 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.
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.
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.
Can we make simple operations in the real world simple in ns-3 please?
More information about the Ns-developers
mailing list