error in serialization

36 views
Skip to first unread message

sinda

unread,
Jan 3, 2018, 3:38:56 AM1/3/18
to ns-3-users
Hi ns3-users
I tried to send a packet at HWMP level so i added a trailer having:
  Ipv4Address address;
  double timestamp;

TseHeader::GetSerializedSize (void) const
{
  NS_LOG_FUNCTION (this);
  return 8;
}
void
TseHeader::Serialize (Buffer::Iterator start) const
{
  NS_LOG_FUNCTION (this << &start);
  uint32_t data= address.Get();
  start.WriteU32 (data);
  start.WriteU32 (timestamp);
}
I added this code in Hwmp-protocol.cc:
                  Ptr<Packet> signal = Create<Packet> ();
            SignalHeader header;
            TseHeader content;
            header.SetEntity(1);
            header.SetMessageLength(header.GetMessageLength()+ 12);
                  timestamp = ((double)Simulator::Now().GetSeconds())-timestamp;
            content.SetAddress(address);
            content.SetTimeStamp(timestamp);
            signal->AddHeader (header);
            signal->AddTrailer(content);
            QueuedPacket sin;
            sin.pkt=signal;
            sin.dst=dst;
            m_rqueue.push_back(sin);

This line ( signal->AddTrailer(content);) generates often this error:

assert failed. cond="Check (m_current)", msg="You have attempted to write after the end of the available buffer space. This usually indicates that Header::GetSerializedSize returned a size which is too small compared to what Header::Serialize is actually using.", file=./ns3/buffer.h, line=871
terminate called without an active exception

Please help me to correct this error.

Tommaso Pecorella

unread,
Jan 3, 2018, 7:14:30 PM1/3/18
to ns-3-users
The error is in the trailer.
Remember that you can not serialize a double.

T.

sinda

unread,
Jan 4, 2018, 2:52:50 AM1/4/18
to ns-3-users
Thank you for the response. I think that so but the error given by the debugger is in line (start.WriteU32 (data);), I don't understand why. Also, It gives an error in the serialized size.

Tommaso Pecorella

unread,
Jan 4, 2018, 6:15:56 PM1/4/18
to ns-3-users
Triple check the trailer serialized size and effective serialized elements.
As a side note, you posted the header's code, but not the trailer one.

T.
Reply all
Reply to author
Forward
0 new messages