Bug 52

Summary: Cannot deserialize headers from packets built from raw data
Product: ns-3 Reporter: Gustavo J. A. M. Carneiro <gjcarneiro>
Component: coreAssignee: ns-bugs <ns-bugs>
Status: RESOLVED INVALID    
Severity: blocker    
Priority: P1    
Version: pre-release   
Hardware: PC   
OS: Linux   

Description Gustavo J. A. M. Carneiro 2007-07-15 19:48:45 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 ());
Comment 1 Gustavo J. A. M. Carneiro 2007-07-15 19:53:07 EDT
And another reason this limitation must be eliminated is that we might want to interface ns-3 with real live traffic, someday...
Comment 2 Mathieu Lacage 2007-07-16 01:45:00 EDT
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.
Comment 3 Gustavo J. A. M. Carneiro 2007-07-16 05:25:15 EDT
I never call it, so I assume it is active by default?
Comment 4 Mathieu Lacage 2007-07-16 05:28:42 EDT
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
Comment 5 Tom Henderson 2007-07-16 18:20:29 EDT
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?
Comment 6 Mathieu Lacage 2007-07-17 02:14:26 EDT
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.