error while adding trailer pls help

46 views
Skip to first unread message

sai

unread,
Dec 8, 2013, 8:19:06 AM12/8/13
to ns-3-...@googlegroups.com




 Hi all,

     I want to add trailer to the packet for that purpose i have written the following .cc and .h files but i am  getting the following error, please help  i am unable to resolve thanks in advance.

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=693
terminate called without an active exception
Command ['/home/sai/ns-allinone-3.18/ns-3.18/build/src/dsr/examples/ns3.18-dsr-debug', '--SimulatorImplementationType=ns3::VisualSimulatorImpl'] terminated with signal SIGIOT. Run it under a debugger to get more information (./waf --run <program> --command-template="gdb --args %s <args>").



dsr-trailer.cc

#include "ns3/assert.h"
#include "ns3/log.h"
#include "ns3/trailer.h"
#include "dsr-trailer.h"

namespace ns3 {
namespace dsr {

NS_LOG_COMPONENT_DEFINE ("DsrTrailer");

NS_OBJECT_ENSURE_REGISTERED (DsrTrailer);

TypeId DsrTrailer::GetTypeId ()
{
  static TypeId tid = TypeId ("ns3::dsr::DsrTrailer")
    .AddConstructor<DsrTrailer> ()
    .SetParent<Trailer> ()
  ;
  return tid;
}

TypeId DsrTrailer::GetInstanceTypeId () const
{
  return GetTypeId ();
}

DsrTrailer::DsrTrailer ()
:m_last(0)
{
}

DsrTrailer::~DsrTrailer ()
{
}

void DsrTrailer::SetIsLast (uint16_t last)
{
  NS_LOG_INFO("NS_LOG_INFO last"<<last);
  m_last = last;
}

uint16_t DsrTrailer::GetIsLast () const
{
 NS_LOG_INFO("NS_LOG_INFO last"<<m_last);

  return m_last;
}

void DsrTrailer::Print (std::ostream &os) const
{
  os
  << "last: " <<GetIsLast ();
}

uint32_t DsrTrailer::GetSerializedSize () const
{
 NS_LOG_INFO("NS_LOG_INFO GetSerializedSize"<<m_last);

  return 2;
}

void DsrTrailer::Serialize (Buffer::Iterator start) const
{
 NS_LOG_INFO("NS_LOG_INFO Serialize"<<m_last);

 // Buffer::Iterator i = start;

  start.WriteU16(m_last);
}

uint32_t DsrTrailer::Deserialize (Buffer::Iterator start)
{

 // Buffer::Iterator i = start;

  m_last = start.ReadU16();
  NS_LOG_INFO("NS_LOG_INFO DESerialize"<<m_last);

  return 2;//GetSerializedSize ();
}

}
}


dsr-trailer.h


#ifndef DSR_TRAILER_H
#define DSR_TRAILER_H

#include <vector>
#include <list>
#include <ostream>

#include "ns3/trailer.h"
#include "ns3/ipv4-address.h"

namespace ns3 {
namespace dsr {
class DsrTrailer : public Trailer
{
public:
  /**
   * \brief Get the type identificator.
   * \return type identificator
   */
  static TypeId GetTypeId ();
  /**
   * \brief Get the instance type ID.
   * \return instance type ID
   */
  virtual TypeId GetInstanceTypeId () const;
  /**
   * \brief Constructor.
   */
  DsrTrailer ();
  /**
   * \brief Destructor.
   */
  virtual ~DsrTrailer ();
  /**
   * \brief Set the "Next header" field.
   * \param nextHeader the next header number
   */

  uint16_t GetIsLast () const;


  void SetIsLast (uint16_t last);


  virtual void Print (std::ostream &os) const;
  /**
   * \brief Get the serialized size of the packet.
   * \return size
   */
  virtual uint32_t GetSerializedSize () const;
  /**
   * \brief Serialize the packet.
   * \param start Buffer iterator
   */
  virtual void Serialize (Buffer::Iterator start) const;
  /**
   * \brief Deserialize the packet.
   * \param start Buffer iterator
   * \return size of the packet
   */
  virtual uint32_t Deserialize (Buffer::Iterator start);

private:
  /**
   * \brief The "next header" field.
   */
  uint16_t m_last;
};
}  // namespace dsr
}  // namespace ns3

#endif /* DSR_FS_HEADER_H */



Reply all
Reply to author
Forward
0 new messages