Error during simulation:send()/sendDelayed()

289 views
Skip to first unread message

Aditi Gupta

unread,
Apr 18, 2020, 6:46:26 PM4/18/20
to OMNeT++ Users
I am getting following error while simulating my code in omnet++ in a debug mode.

<!> send()/sendDelayed(): Cannot send message (omnetpp::cPacket)c1-1662, it is currently contained/owned by (omnetpp::cPacket)simulation.scheduled-events.c2-1688.c1-1657.c1-1658.c2-1689.c2-1690.c1-1659.c1-1660.c2-1691.c1-1661 -- in module (Aggregator) Aggregation.aggregator (id=3), at t=18s, event #7227

Here,c1-xxx and c2-xxx are flow of packets which are coming from 2 client whose inter arrival rate is exponentially distributed.
In aggregator module these packets are aggregating and being forwarded to server for deaggregation.

below is the code for aggregation module:

omnet_error.jpg

void Aggregator :: initialize()
{
    timeout=3.0;
    timeoutEvent=new cPacket("timeout");
    //initialize the timer
    scheduleAt(simTime()+timeout,timeoutEvent);
}
void Aggregator :: handleMessage(cMessage *msg)
{
    if(msg==timeoutEvent)
    {
        concateMsg();
        send(con_message,"out");
        cancelEvent(timeoutEvent);
        scheduleAt(simTime()+timeout,timeoutEvent);
    }
    else{
            cPacket *pkt = check_and_cast<cPacket *>(msg);//type casting message into packet type
            take(pkt);//take ownership
            vect.push_back(pkt);
    }
}
void Aggregator::concateMsg()
{
    cPacket *last=nullptr;
        while(!vect.empty()) {
            if (last)
                vect.back()->encapsulate(last);
            last = vect.back();
            vect.pop_back();
            if(last->getByteLength()>=1500) {
                send(last,"out");
                last = nullptr;
           }
        }
        if (last)
                con_message=last;

}

Alfonso Ariza Quintana

unread,
Apr 19, 2020, 5:45:17 AM4/19/20
to omn...@googlegroups.com

void Aggregator :: handleMessage(cMessage *msg)
{
    if(msg==timeoutEvent)
    {

        while(!pending.empty()) {

               send(pending.back(),"out");

               pending.pop_back();
        }

        scheduleAt(simTime()+timeout,timeoutEvent);
    }
    else{
            cPacket *pkt = check_and_cast<cPacket *>(msg);//type casting message into packet type

            if (pending.empty() || pending.back()->getByteLength()>=1500)
                     pending.push_back(pkt);

            else

                     pending.back()->encpasulate(pkt);
    }
}

 

Sent from Mail for Windows 10

 


De: omn...@googlegroups.com <omn...@googlegroups.com> en nombre de Aditi Gupta <gupta8...@gmail.com>
Enviado: Sunday, April 19, 2020 12:46:25 AM
Para: OMNeT++ Users <omn...@googlegroups.com>
Asunto: [Omnetpp-l] Error during simulation:send()/sendDelayed()
 
--
You received this message because you are subscribed to the Google Groups "OMNeT++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/omnetpp/1adcbe57-3d09-4458-89b4-8cb90759dfd4%40googlegroups.com.

Aditi Gupta

unread,
Apr 19, 2020, 1:30:19 PM4/19/20
to OMNeT++ Users
Can you please explain,the reason for this error.
And your code is little bit ambiguous.
To unsubscribe from this group and stop receiving emails from it, send an email to omn...@googlegroups.com.

Alfonso Ariza Quintana

unread,
Apr 19, 2020, 2:20:48 PM4/19/20
to omn...@googlegroups.com

Probably, you try to sent two times the same packet

 

Enviado desde Correo para Windows 10

 


Enviado: Sunday, April 19, 2020 7:30:19 PM
Para: OMNeT++ Users <omn...@googlegroups.com>
Asunto: Re: [Omnetpp-l] Error during simulation:send()/sendDelayed()
 
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/omnetpp/8692d970-ffe9-4335-ae35-6804099acaf1%40googlegroups.com.

Aditi Gupta

unread,
Apr 19, 2020, 2:51:18 PM4/19/20
to OMNeT++ Users
So,what might be the problematic line in my code due to which this error is coming.

Alfonso Ariza Quintana

unread,
Apr 19, 2020, 2:57:17 PM4/19/20
to omn...@googlegroups.com

That you don’t set con_message to nullptr, if the first time last is not null you set con_message, but if the next time, last is nullptr,  con_message has the information of the previous packet.

 

The code that I have sent, remove unnecessary variables and reduce this type of problem.

 

But it is enough to set con_message = nullptr at the beginning of concateMsg

 

Enviado desde Correo para Windows 10

 

Enviado: Sunday, April 19, 2020 8:51:18 PM
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/omnetpp/12ce2851-19d6-4a7f-b0e6-12aca160af2b%40googlegroups.com.

Aditi Gupta

unread,
Apr 19, 2020, 7:08:29 PM4/19/20
to OMNeT++ Users
I made  con_message=nullptr;

But now I am getting this error.

omnetpp_error.jpg


Is this happening because the time out window is too small?

Alfonso Ariza Quintana

unread,
Apr 20, 2020, 4:16:15 AM4/20/20
to omn...@googlegroups.com
You need to check if con_message!=nullptr before sent it.

Enviado: lunes, 20 de abril de 2020 1:08
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/omnetpp/fb7ce728-2109-4b1d-a69e-182cf9c4f571%40googlegroups.com.

Aditi Gupta

unread,
Apr 20, 2020, 7:10:22 AM4/20/20
to OMNeT++ Users
The error is gone after making below changes in the code.

void Aggregator :: handleMessage(cMessage *msg)
{
    if(msg==timeoutEvent)
    {
        concateMsg();
        send(con_message,"out");//------------------------DELETED THIS LINE

        cancelEvent(timeoutEvent);
        scheduleAt(simTime()+timeout,timeoutEvent);
    }
    else{
            cPacket *pkt = check_and_cast<cPacket *>(msg);//type casting message into packet type
            take(pkt);//take ownership
            vect.push_back(pkt);
    }
}
void Aggregator::concateMsg()
{
    cPacket *last=nullptr;
        while(!vect.empty()) {
            if (last)
                vect.back()->encapsulate(last);
            last = vect.back();
            vect.pop_back();
            if(last->getByteLength()>=1500) {
                send(last,"out");
                last = nullptr;
           }
        }
       
if (last){
                con_message=last;
                send(con_message,"out");//-------------------------ADDED THIS
        }


}

Aditi Gupta

unread,
Apr 20, 2020, 7:20:11 AM4/20/20
to OMNeT++ Users

The error is gone after making below changes in the code.

void Aggregator :: handleMessage(cMessage *msg)
{
    if(msg==timeoutEvent)
    {
        concateMsg();
        send(con_message,"out");//------------------------DELETED THIS LINE

        cancelEvent(timeoutEvent);
        scheduleAt(simTime()+timeout,timeoutEvent);
    }
    else{
            cPacket *pkt = check_and_cast<cPacket *>(msg);//type casting message into packet type
            take(pkt);//take ownership
            vect.push_back(pkt);
    }
}
void Aggregator::concateMsg()
{
    con_message=nullptr; //---------------ADDED THIS
    cPacket *last=nullptr;
        while(!vect.empty()) {
            if (last)
                vect.back()->encapsulate(last);
            last = vect.back();
            vect.pop_back();
            if(last->getByteLength()>=1500) {
                send(last,"out");
                last = nullptr;
           }
        }
       
if (last){
                con_message=last;

                send(con_message,"out");//-------------------------ADDED THIS
        }


}
Reply all
Reply to author
Forward
0 new messages