Bugzilla – Bug 1956
It is not possible to reuse a PacketSocket after a Close()
Last modified: 2014-07-29 17:41:02 EDT
Reported here: https://groups.google.com/forum/?hl=en#!topic/ns-3-users/2sJBuHQkWz8 If you use Close on a PacketSocket, both m_shutdownSend and m_shutdownRecv are set. However, they are not set back to false when the socket is re-opened with a new Connect.
The bug is more complex. The PacketSocket has an internal state machine. The states are: /** * \brief States of the socket */ enum State { STATE_OPEN, STATE_BOUND, // open and bound STATE_CONNECTED, // open, bound and connected STATE_CLOSED }; The real issue is that a socket starts in STATE_OPEN and it is left in STATE_CLOSED after a Close(). There is no way to return from STATE_CLOSED to STATE_OPEN, effectively making it impossible to "restart" the socket. Funny enough, it is possible to "use" a PacketSocket also in STATE_OPEN: SendTo () can be used on non-bound and non-connected sockets. The only trick is that non-bound sockets can not receive packets (missing m_node->RegisterProtocolHandler).