Bug 1607

Summary: OnOff Application over TCP with IPv6
Product: ns-3 Reporter: Sebastian Robitzsch <srobitzsch>
Component: applicationsAssignee: George Riley <riley>
Status: RESOLVED FIXED    
Severity: normal CC: ns-bugs
Priority: P5    
Version: ns-3.16   
Hardware: All   
OS: All   
Attachments: Enabling OnOff application to work with IPv6 ... sry ... not a proper patch

Description Sebastian Robitzsch 2013-03-23 06:45:15 UTC
Dear all,

When using the OnOff application in combination with ns3::TcpSocketFactory and IPv6, the TCP session cannot be established at all. Right after the socket was created it got closed again without listening to any packet. The reason for this is when working with IPv6, the wrong binding function (m_socket->Bind() instead of m_socket->Bind6()) is called when binding the application to a previously created socket.

/*
 * File: src/applications/model/onoff-application.cc
*/
void OnOffApplication::StartApplication () // Called at time specified by Start
{
  NS_LOG_FUNCTION (this);

  // Create the socket if not already
  if (!m_socket)
    {
      m_socket = Socket::CreateSocket (GetNode (), m_tid);

+      if (Inet6SocketAddress::IsMatchingType (m_peer))
+    	  m_socket->Bind6 ();
+      else if (InetSocketAddress::IsMatchingType (m_peer))
+    	  m_socket->Bind ();

-     m_socket->Bind ();

      m_socket->Connect (m_peer);
      m_socket->SetAllowBroadcast (true);
      m_socket->ShutdownRecv ();

      m_socket->SetConnectCallback (
        MakeCallback (&OnOffApplication::ConnectionSucceeded, this),
        MakeCallback (&OnOffApplication::ConnectionFailed, this));
    }
  // Insure no pending event
  CancelEvents ();
  // If we are not yet connected, there is nothing to do here
  // The ConnectionComplete upcall will start timers at that time
  //if (!m_connected) return;
  ScheduleStartEvent ();
}


Rgds,
Sebastian
Comment 1 Sebastian Robitzsch 2013-03-23 06:53:02 UTC
Created attachment 1537 [details]
Enabling OnOff application to work with IPv6 ... sry ... not a proper patch
Comment 2 Tommaso Pecorella 2013-03-23 13:49:30 UTC
Actually the bug is in *all* the applications... ouch.
Comment 3 Tommaso Pecorella 2013-03-23 13:58:50 UTC
Fixed in changeset: 9268 - 21270128f7b6