[ns] Packet::copy() issue with ns2.33

Swaroop Shere swaroopshere at yahoo.co.in
Mon Jun 1 16:25:51 PDT 2009


Hi guys,
      I found the solution to the problem. While debugging further, I found out that the virtual destructor ~AppData() was being called. Then I realized that I was instantiating the object of class PQR as follows:
PQR pkt(arguments);
whereas, the instantiation should have been
PQR* pkt = new PQR(arguments);
The former method resulted in pkt variable going out of scope at the end of the instantiating function, whereas, it does not happen in the latter method.

regards,
Swaroop

--- On Mon, 1/6/09, Swaroop Shere <swaroopshere at yahoo.co.in> wrote:

From: Swaroop Shere <swaroopshere at yahoo.co.in>
Subject: [ns] Packet::copy() issue with ns2.33
To: "ns-users" <ns-users at ISI.EDU>
Date: Monday, 1 June, 2009, 8:43 PM



From: swaroopshere at yahoo.co.in <swaroopshere at yahoo.co.in>
Subject: Packet::copy() issue with ns2.33
To: "ns-users" <ns-users at ISI.EDU>
Date: Monday, 1 June, 2009, 1:22 PM

Hi,
    I am writing a new protocol in NS2 and using application level data packets by extending AppData. So I have class ABC:: public AppData and class PQR::public ABC. I have defined the size() and copy() methods for both, and also defined the constants in packet.h in enum AppDataType.

Now, when I run the simulation, I get an error that says...
-----------------------------------------------------------------------
pure virtual method called
terminate called without an active exception
-----------------------------------------------------------------------
Upon debugging, I found out that this error comes when it executes 
Packet::copy(), specifically the statement
p->data_ = data_-> copy()

here, data_->copy() happens to be a pure virtual function, which is why I am
 getting the error, but I am wondering what is the cause.. I have defined the proper copy() functions for new AppData types...

It would be great if someone points me out my mistake.. If someone wants more information about my code, I would be happy to share it ...

thank you,

regards,
Swaroop





       Explore your hobbies and interests. Click here to begin.


      Explore and discover exciting holidays and getaways with Yahoo! India Travel http://in.travel.yahoo.com/



      Explore and discover exciting holidays and getaways with Yahoo! India Travel http://in.travel.yahoo.com/


More information about the Ns-users mailing list