Bug 1829

Summary: Multiple TCP socket entries
Product: ns-3 Reporter: Konstantinos Katsaros <dinos.katsaros>
Component: tcpAssignee: Brian Swenson <bswenson3>
Status: RESOLVED FIXED    
Severity: normal CC: ns-bugs, tommaso.pecorella
Priority: P5    
Version: ns-3.19   
Hardware: All   
OS: All   
Attachments: patch

Description Konstantinos Katsaros 2014-01-09 17:07:05 UTC
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 UTC
Created attachment 1756 [details]
patch

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.

T.
Comment 2 Brian Swenson 2014-04-22 14:44:12 UTC
10697:323f8bb2ec61

Thanks for bug fix!