Bugzilla – Bug 52
Cannot deserialize headers from packets built from raw data
Last modified: 2007-07-17 02:14:26 EDT
This code: Packet packet; { OlsrPacketHeader hdr; // Build an OLSR packet header hdr.m_packetLength = (hdr.GetSize () + 0); hdr.m_packetSequenceNumber = 123; packet.AddHeader (hdr); } { Packet packet1 (packet.PeekData (), packet.GetSize ()); OlsrPacketHeader hdr; packet1.RemoveHeader (hdr); } Gives me a "Removing unexpected header." assertion error. Changing "packet1.RemoveHeader (hdr);" to "packet.RemoveHeader (hdr);" makes it work, which indicates that the problem is that creating a packet from data/size and then deserializing headers from it does not work. This is a serious limitation, because it means we can't create a packet from the headers infrastructure, send it through a socket (code below) and read it back with header deserialization routines. m_sendSocket->Send (packet.PeekData (), packet.GetSize ());
And another reason this limitation must be eliminated is that we might want to interface ns-3 with real live traffic, someday...
This is not a bug. You just have to make sure you never enable the metadata support which is, obviously, incompatible with reading headers from raw data. i.e., make sure you never call Packet::EnableMetadata.
I never call it, so I assume it is active by default?
It is not active by default but it is used by the ascii tracer so, you cannot use the ascii tracer with raw data packets
should there be a mode that allows mixed operation of metadata-encoded headers and non-metadata-encoded? (i.e., not dying in a fatal assert when metadata remove header fails)? Another possibility might be to overload RemoveHeader and allow to pass in a pretty-print function as an optional argument?
We could implement a mode where we store the metadata when we have some, we use it to pretty print but we do not check correctness of add/remove operations. That would be quite a bit of work though. i.e.: patches are welcome.