Bug 1829 - Multiple TCP socket entries
Multiple TCP socket entries
Product: ns-3
Classification: Unclassified
Component: tcp
All All
: P5 normal
Assigned To: Brian Swenson
Depends on:
  Show dependency treegraph
Reported: 2014-01-09 17:07 EST by Konstantinos Katsaros
Modified: 2014-04-22 14:44 EDT (History)
2 users (show)

See Also:

patch (1.34 KB, patch)
2014-01-11 08:32 EST, Tommaso Pecorella
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantinos Katsaros 2014-01-09 17:07:05 EST
Initial discussion on the mailing list about some strange tracing behaviour of TCP sockets here https://groups.google.com/d/msg/ns-3-users/imAdVyvTwC8/uQR0cq46iFUJ

A TCP socket is added twice in the m_socket list, once on the creation and another  when the Bind() is called for a server and at the CompleteFork() for the client.

Quoting Tomasso here "this is stupid."

There are actually two bugs

Bug 1: sockets are duplicate in the sender (i.e., who's using Connect).
Bug 2: socket is duplicate **and not copied** in the receiver (who's using Listen).

Solution 1: do not add the socket to the socket list as soon as it's created.
Solution 2: do a check before adding a socket to the list (if it's already in the list, don't add it again).
Comment 1 Tommaso Pecorella 2014-01-11 08:32:37 EST
Created attachment 1756 [details]

Actually I was wrong (partially).

The socket is copied in the right way when there's fork.

Still, the sockets are duplicated if one uses the Tcp "way":
  Ptr<SocketFactory> sockFactory0 = node0->GetObject<TcpSocketFactory> ();
  Ptr<Socket> server = sockFactory0->CreateSocket ();

The proposed patch fixes this.

Comment 2 Brian Swenson 2014-04-22 14:44:12 EDT

Thanks for bug fix!