Just solved it, for future reference here it is: You can't create your
object like this:
PacketData vodinfo(10);
It must be:
AppData* vodinfo = new PacketData (10);
After that, everything works fine.
Andre
On Apr 14, 2009, at 10:04 AM, Andre Reis wrote:
Greetings,
I'm having an issue at a lower level of ns2, version 2.31. In my
application, I create a PacketData object, and send a new packet with
an UDP agent, like this:
PacketData vodinfo(10);
agent_->sendmsg(size_, &vodinfo);
I don't even fill the data in the object yet. At some point in the
simulation, Packet::copy() is called, and the simulator breaks with a
'Could not access memory (EXC_BAD_ACCESS)', which occurs in line 643
in packet.h:
inline Packet* Packet::copy() const
{
Packet* p = alloc();
memcpy(p->bits(), bits_, hdrlen_);
if (data_)
p->data_ = data_->copy(); <- fails here
p->txinfo_.init(&txinfo_);
return (p);
}
It would seem it cannot access 'p->data', which is a private AppData*
variable. Since this is so low-level in ns, I cannot imagine what the
cause of the problem might be.
Can someone provide some clues as to why this is happening?
With regards,
Andre Reis