Many undisposed messages

56 views
Skip to first unread message

Sebastian Kehr

unread,
Feb 4, 2010, 3:56:01 AM2/4/10
to omnetpp
Hey guys,

I have a module that is located between transport and network layer.
Packets from transport layer are modified in that layer and forwarded
to the network layer.
But every message message leaves a copy in the module, so the
simulation grows and a hundreds of thousands of message are created
but not deleted.

I can't find the leak in the code.

void Mobility::handleMessage(cMessage *msg)
{
/*
* TCP packets from network layer (lower layer)
*/
if(msg->arrivedOn("fromNetworkLayerTCP")){
send(msg, "toTCP");
/*
* self messages:
* handle flow request and flow remove requests
*/
}else if(msg->isSelfMessage()){

if(strcmp(msg->getName(), "flowRequest") == 0){
requestFlow(BEST_EFFORT, accessPoint);
}else if(strcmp(msg->getName(), "RequestRemove") == 0){
requestRemoveFlow(accessPoint);
}
delete msg; msg = NULL;

/*
* UDP packets from network layer (lower layer)
*/
}else if(msg->arrivedOn("fromNetworkLayerUDP")){

cPacket* dup = check_and_cast<cPacket*>(msg->dup());

if(dynamic_cast<FlowRequest*>(dup->decapsulate())){
handleFlowRequest(msg);

}else if(dynamic_cast<FlowRemoveRequest*>(dup->decapsulate())){
handleFlowRemoveRequest(msg);

}else{
send(msg, "toUDP");
}
delete dup; dup=NULL;

/*
* TCP packets from upper layer
*/
}else if(msg->arrivedOn("fromTCP")){
handleUpperLayer(msg);

/*
* UDP packets from upper layer
*/
}else if(msg->arrivedOn("fromUDP")){

cPacket* dup = check_and_cast<cPacket*>(msg->dup());
if(dynamic_cast<FlowRequest*>(dup->decapsulate())){
send(msg, "toNetworkLayerUDP");
}else
handleUpperLayer(msg);
delete dup; dup = NULL;

}else if(dynamic_cast<CHF_MMF_Add_Flow*>(msg)){
handleAddFlow(msg);

}else if(dynamic_cast<CHF_MMF_Remove_Flow*>(msg)){
handleRemoveFlow(msg);

}else{

delete msg; msg = NULL;
}
}


/*
* handles all messages coming from upper layers
* if no flow is registered for the destination of the packet, a new
flow request is send to CAP
*/
void Mobility::handleUpperLayer(cMessage* msg){
IPControlInfo *ctrl = dynamic_cast<IPControlInfo *>(msg-
>getControlInfo());
ASSERT(ctrl);

// if flow is not registered at cap --> request new flow
if(flowIDMap.find(ctrl->getDestAddr()) == flowIDMap.end()){

if(!waitFlowRequest){
requestFlow(defineTrafficClass(msg), ctrl->getDestAddr());
messageTemp.push(msg);
}

// flow is registered
}else{

if(msg->arrivedOn("fromTCP")){
TCPSegment* tcpSegment = check_and_cast<TCPSegment*>(msg);
tcpSegment->setFlowID(flowIDMap[ctrl->getDestAddr()]);
send(tcpSegment, "toNetworkLayerTCP");
}else{
UDPPacket* packet = check_and_cast<UDPPacket *>(msg);
packet->setFlowID(flowIDMap[ctrl->getDestAddr()]);
send(packet, "toNetworkLayerUDP");
}
}
}

Ester Lopez

unread,
Feb 4, 2010, 5:42:22 PM2/4/10
to omn...@googlegroups.com
Hi Sebastian,

Im not sure if my answer is accurate or not, cause i've only being using omnetpp without any extension (or whatever its called, you know mixim, inet...) and i dont know if you are using any of them or not. So to check all the code it will be necessary to see the code of the functions handleFlowRequest, handleFlowRemoveRequest, and handle add and remove flow, checking that you whether delete or send (or enqueue) the message in that functions.

As I see it a probable moment when the messages arent deleted are in:


 if(!waitFlowRequest){
                       requestFlow(defineTrafficClass(msg), ctrl->getDestAddr());
                       messageTemp.push(msg);
               }
That if the message is not registered and wait its true, then the reference to that message is lost, so it is never deleted (i think so i may be wrong!). And also you have to go on emptying the queue messageTemp somewhere.

So as i said, maybe i got everything wrong, but that is as i see it :S.

Cheers,
Ester


2010/2/4 Sebastian Kehr <sebasti...@live.de>

--
You received this message because you are subscribed to the Google Groups "omnetpp" group.
To post to this group, send email to omn...@googlegroups.com.
To unsubscribe from this group, send email to omnetpp+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/omnetpp?hl=en.


Sebastian Kehr

unread,
Feb 10, 2010, 4:30:13 AM2/10/10
to omnetpp
Hello Ester,

thanks for your reply. I checked all functions and discovered that I
always used the decapsulate() methode to cast the cMessage object in
the handleMessage().

After I replaced the decapsulate() with getEncapsulatedMsg() function
call, the problem was solved.

greetings

Reply all
Reply to author
Forward
0 new messages