Bug 1956 - It is not possible to reuse a PacketSocket after a Close()
It is not possible to reuse a PacketSocket after a Close()
Product: ns-3
Classification: Unclassified
Component: network
All All
: P5 minor
Assigned To: ns-bugs
Depends on:
  Show dependency treegraph
Reported: 2014-07-28 16:48 EDT by Tommaso Pecorella
Modified: 2014-07-29 17:41 EDT (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Tommaso Pecorella 2014-07-28 16:48:16 EDT
Reported here:

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.
Comment 1 Tommaso Pecorella 2014-07-29 17:41:02 EDT
The bug is more complex. The PacketSocket has an internal state machine. The states are:
   * \brief States of the socket
  enum State {
    STATE_BOUND,     // open and bound
    STATE_CONNECTED, // open, bound and connected

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).