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");
}
}
}
--
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.
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