Search code examples
omnet++

in omnet++ what will happen if you disconnect a gate while sending a packet on it?


I'm trying to understand the behavior of Omnetpp while disconnecting a gate in the middle of a transmission. does it cause a crash? or the packet will still reach the destination? can it cause serious problems?

In my scenario when two cars are close to each other they dynamically create a connection between their gates and then send some stuff. But as soon as the distance is greater than a threshold I disconnect the connection(in the middle of transmission probably). So I just want to know how Omnet deals with this because could not find anything regarding this question.


Solution

  • Once you send a packet on an outgoing gate, the send call looks up the receiving gate following the connection chain and finding the other gate at the end. An optional delay and datarate is also determined and based on this information the receiving event is put into the future event queue with proper timing and the destination module. Once the send() call returns, the message is in the future event queue and you can safely delete the connection. It will still be delivered to the destination module (unless you manually remove it from the FES after you deleted the connection.)