Assert failed (buffer.h) when I add trail to the packet

35 views
Skip to first unread message

Peng Wang

unread,
Jun 17, 2014, 5:41:45 AM6/17/14
to ns-3-...@googlegroups.com
Hi, all,

I need to add data to existing packet, and I find a tutorial about it. I choose to use trailer to carry data, and then add it to the packet. Then, I create mytrailer.cc and mytrailer.h file totally according to the tutorial.

However, it seems that there are something wrong with it. 
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."

Does anyone have any solutions? Thanks in advance!

Best,
Peng

Konstantinos

unread,
Jun 17, 2014, 5:48:42 AM6/17/14
to ns-3-...@googlegroups.com
You need to be careful on the Serialize and Deserialize methods and also the GetSerializedSize which gives the number of bytes you have written.

Peng Wang

unread,
Jun 17, 2014, 6:01:20 AM6/17/14
to ns-3-...@googlegroups.com
Hi Konstantinos,

Thanks for your help! I only add a data (m_data) which is of type uint32_t. I returned the GetSerializedSize() as 4. 

The Serialize and Deserialize methods are simple here. 

void::MyTrailer::Serialize (Buffer::Iterator start) const
{
      start.WriteU32(m_data);
}

uint32_t MyTrailer::Deserialize (Buffer::Iterator start)
{
       m_data = start.ReadU32();
       return GetSerializedSize();
Reply all
Reply to author
Forward
0 new messages