Changes for bug 205, unlisted FIN bug ns-3.1-RC1
authorCraig Dowell <craigdo@ee.washington.edu>
Mon, 16 Jun 2008 16:25:52 -0700
changeset 32768869a79a391f
parent 3275 b0d91237f2ec
child 3277 cd7a3f08e91a
Changes for bug 205, unlisted FIN bug
examples/tcp-large-transfer.cc
src/applications/packet-sink/packet-sink.cc
src/applications/packet-sink/packet-sink.h
src/internet-stack/tcp-socket-impl.cc
src/internet-stack/udp-socket-impl.cc
src/node/packet-socket.cc
src/node/socket.cc
src/node/socket.h
     1.1 --- a/examples/tcp-large-transfer.cc	Mon Jun 16 14:17:27 2008 +0100
     1.2 +++ b/examples/tcp-large-transfer.cc	Mon Jun 16 16:25:52 2008 -0700
     1.3 @@ -87,7 +87,7 @@
     1.4    // Users may find it convenient to turn on explicit debugging
     1.5    // for selected modules; the below lines suggest how to do this
     1.6    //  LogComponentEnable("TcpL4Protocol", LOG_LEVEL_ALL);
     1.7 -  //  LogComponentEnable("TcpSocket", LOG_LEVEL_ALL);
     1.8 +  //  LogComponentEnable("TcpSocketImpl", LOG_LEVEL_ALL);
     1.9    //  LogComponentEnable("PacketSink", LOG_LEVEL_ALL);
    1.10    //  LogComponentEnable("TcpLargeTransfer", LOG_LEVEL_ALL);
    1.11  
    1.12 @@ -182,8 +182,7 @@
    1.13   // NS_LOG_LOGIC("Starting flow at time " <<  Simulator::Now ().GetSeconds ());
    1.14    localSocket->Connect (InetSocketAddress (servAddress, servPort));//connect
    1.15    localSocket->SetConnectCallback (MakeCallback (&CloseConnection),
    1.16 -                                   Callback<void, Ptr<Socket> > (),
    1.17 -                                       Callback<void, Ptr<Socket> > ());
    1.18 +                                   Callback<void, Ptr<Socket> > ());
    1.19    //we want to close as soon as the connection is established
    1.20    //the tcp state machine and outgoing buffer will assure that
    1.21    //all of the data is delivered
     2.1 --- a/src/applications/packet-sink/packet-sink.cc	Mon Jun 16 14:17:27 2008 +0100
     2.2 +++ b/src/applications/packet-sink/packet-sink.cc	Mon Jun 16 16:25:52 2008 -0700
     2.3 @@ -67,6 +67,10 @@
     2.4  void
     2.5  PacketSink::DoDispose (void)
     2.6  {
     2.7 +  if (m_socket != 0)
     2.8 +    {
     2.9 +      m_socket->Close ();
    2.10 +    }
    2.11    m_socket = 0;
    2.12  
    2.13    // chain up
    2.14 @@ -88,8 +92,7 @@
    2.15    m_socket->SetRecvCallback (MakeCallback(&PacketSink::HandleRead, this));
    2.16    m_socket->SetAcceptCallback (
    2.17              MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
    2.18 -            MakeNullCallback<void, Ptr<Socket>, const Address&> (),
    2.19 -            MakeCallback(&PacketSink::CloseConnection, this) );
    2.20 +            MakeNullCallback<void, Ptr<Socket>, const Address&> ());
    2.21  }
    2.22  
    2.23  void PacketSink::StopApplication()     // Called at time specified by Stop
    2.24 @@ -117,9 +120,4 @@
    2.25      }
    2.26  }
    2.27  
    2.28 -void PacketSink::CloseConnection (Ptr<Socket> socket)
    2.29 -{
    2.30 -  socket->Close ();
    2.31 -}
    2.32 -
    2.33  } // Namespace ns3
     3.1 --- a/src/applications/packet-sink/packet-sink.h	Mon Jun 16 14:17:27 2008 +0100
     3.2 +++ b/src/applications/packet-sink/packet-sink.h	Mon Jun 16 16:25:52 2008 -0700
     3.3 @@ -80,9 +80,7 @@
     3.4    virtual void StartApplication (void);    // Called at time specified by Start
     3.5    virtual void StopApplication (void);     // Called at time specified by Stop
     3.6  
     3.7 -  virtual void HandleRead (Ptr<Socket> socket);
     3.8 -
     3.9 -  virtual void CloseConnection (Ptr<Socket> socket);
    3.10 +  void HandleRead (Ptr<Socket> socket);
    3.11  
    3.12    Ptr<Socket>     m_socket;       // Associated socket
    3.13    Address         m_local;        // Local address to bind to
     4.1 --- a/src/internet-stack/tcp-socket-impl.cc	Mon Jun 16 14:17:27 2008 +0100
     4.2 +++ b/src/internet-stack/tcp-socket-impl.cc	Mon Jun 16 16:25:52 2008 -0700
     4.3 @@ -620,7 +620,6 @@
     4.4        NS_LOG_LOGIC ("TcpSocketImpl " << this << " transition to CLOSED from " 
     4.5                 << m_state << " event " << e << " closeNot " << m_closeNotified
     4.6                 << " action " << stateAction.action);
     4.7 -      NotifyCloseCompleted ();
     4.8        m_closeNotified = true;
     4.9        NS_LOG_LOGIC ("TcpSocketImpl " << this << " calling Closed from PE"
    4.10                << " origState " << saveState
    4.11 @@ -854,7 +853,6 @@
    4.12          {
    4.13            NS_LOG_LOGIC ("TCP " << this 
    4.14                << " calling AppCloseRequest");
    4.15 -          NotifyCloseRequested(); 
    4.16            m_closeRequestNotified = true;
    4.17          }
    4.18        NS_LOG_LOGIC ("TcpSocketImpl " << this 
    4.19 @@ -1298,7 +1296,7 @@
    4.20      } 
    4.21    if (!m_pendingData)
    4.22      {
    4.23 -      if (m_state == FIN_WAIT_1 || m_state == FIN_WAIT_2)
    4.24 +      if (m_state == FIN_WAIT_1)
    4.25          { // Must have lost FIN, re-send
    4.26            SendEmptyPacket (TcpHeader::FIN);
    4.27          }
     5.1 --- a/src/internet-stack/udp-socket-impl.cc	Mon Jun 16 14:17:27 2008 +0100
     5.2 +++ b/src/internet-stack/udp-socket-impl.cc	Mon Jun 16 16:25:52 2008 -0700
     5.3 @@ -199,7 +199,6 @@
     5.4  UdpSocketImpl::Close(void)
     5.5  {
     5.6    NS_LOG_FUNCTION_NOARGS ();
     5.7 -  NotifyCloseCompleted ();
     5.8    return 0;
     5.9  }
    5.10  
     6.1 --- a/src/node/packet-socket.cc	Mon Jun 16 14:17:27 2008 +0100
     6.2 +++ b/src/node/packet-socket.cc	Mon Jun 16 16:25:52 2008 -0700
     6.3 @@ -184,7 +184,6 @@
     6.4        return -1;
     6.5      }
     6.6    m_state = STATE_CLOSED;
     6.7 -  NotifyCloseCompleted ();
     6.8    return 0;
     6.9  }
    6.10  
     7.1 --- a/src/node/socket.cc	Mon Jun 16 14:17:27 2008 +0100
     7.2 +++ b/src/node/socket.cc	Mon Jun 16 16:25:52 2008 -0700
     7.3 @@ -51,34 +51,23 @@
     7.4  }
     7.5  
     7.6  void 
     7.7 -Socket::SetCloseCallback (Callback<void,Ptr<Socket> > closeCompleted)
     7.8 -{
     7.9 -  NS_LOG_FUNCTION_NOARGS ();
    7.10 -  m_closeCompleted = closeCompleted;
    7.11 -}
    7.12 -
    7.13 -void 
    7.14  Socket::SetConnectCallback (
    7.15    Callback<void, Ptr<Socket> > connectionSucceeded,
    7.16 -  Callback<void, Ptr<Socket> > connectionFailed,
    7.17 -  Callback<void, Ptr<Socket> > halfClose)
    7.18 +  Callback<void, Ptr<Socket> > connectionFailed)
    7.19  {
    7.20    NS_LOG_FUNCTION_NOARGS ();
    7.21    m_connectionSucceeded = connectionSucceeded;
    7.22    m_connectionFailed = connectionFailed;
    7.23 -  m_halfClose = halfClose;
    7.24  }
    7.25  
    7.26  void 
    7.27  Socket::SetAcceptCallback (
    7.28    Callback<bool, Ptr<Socket>, const Address &> connectionRequest,
    7.29 -  Callback<void, Ptr<Socket>, const Address&> newConnectionCreated,
    7.30 -  Callback<void, Ptr<Socket> > closeRequested)
    7.31 +  Callback<void, Ptr<Socket>, const Address&> newConnectionCreated)
    7.32  {
    7.33    NS_LOG_FUNCTION_NOARGS ();
    7.34    m_connectionRequest = connectionRequest;
    7.35    m_newConnectionCreated = newConnectionCreated;
    7.36 -  m_closeRequested = closeRequested;
    7.37  }
    7.38  
    7.39  bool 
    7.40 @@ -110,15 +99,6 @@
    7.41    return Send (p, 0);
    7.42  }
    7.43  
    7.44 -void
    7.45 -Socket::NotifyCloseUnblocks (void)
    7.46 -{
    7.47 -  NS_LOG_FUNCTION_NOARGS ();
    7.48 -  if (!m_closeUnblocks.IsNull ())
    7.49 -  {
    7.50 -    m_closeUnblocks (this);
    7.51 -  }
    7.52 -}
    7.53  
    7.54  int Socket::Listen (uint32_t queueLimit)
    7.55  {
    7.56 @@ -199,15 +179,6 @@
    7.57    return p->GetSize ();
    7.58  }
    7.59  
    7.60 -void 
    7.61 -Socket::NotifyCloseCompleted (void)
    7.62 -{
    7.63 -  NS_LOG_FUNCTION_NOARGS ();
    7.64 -  if (!m_closeCompleted.IsNull ())
    7.65 -    {
    7.66 -      m_closeCompleted (this);
    7.67 -    }
    7.68 -}
    7.69  
    7.70  void 
    7.71  Socket::NotifyConnectionSucceeded (void)
    7.72 @@ -229,16 +200,6 @@
    7.73      }
    7.74  }
    7.75  
    7.76 -void 
    7.77 -Socket::NotifyHalfClose (void)
    7.78 -{
    7.79 -  NS_LOG_FUNCTION_NOARGS ();
    7.80 -  if (!m_halfClose.IsNull ())
    7.81 -    {
    7.82 -      m_halfClose (this);
    7.83 -    }
    7.84 -}
    7.85 -
    7.86  bool 
    7.87  Socket::NotifyConnectionRequest (const Address &from)
    7.88  {
    7.89 @@ -268,16 +229,6 @@
    7.90  }
    7.91  
    7.92  void 
    7.93 -Socket::NotifyCloseRequested (void)
    7.94 -{
    7.95 -  NS_LOG_FUNCTION_NOARGS ();
    7.96 -  if (!m_closeRequested.IsNull ())
    7.97 -    {
    7.98 -      m_closeRequested (this);
    7.99 -    }
   7.100 -}
   7.101 -
   7.102 -void 
   7.103  Socket::NotifyDataSent (uint32_t size)
   7.104  {
   7.105    NS_LOG_FUNCTION_NOARGS ();
     8.1 --- a/src/node/socket.h	Mon Jun 16 14:17:27 2008 +0100
     8.2 +++ b/src/node/socket.h	Mon Jun 16 16:25:52 2008 -0700
     8.3 @@ -102,12 +102,6 @@
     8.4     * \returns the node this socket is associated with.
     8.5     */
     8.6    virtual Ptr<Node> GetNode (void) const = 0;
     8.7 -
     8.8 -  /**
     8.9 -   * \param closeCompleted Callback invoked when the close operation is
    8.10 -   *        completed.
    8.11 -   */
    8.12 -  void SetCloseCallback (Callback<void, Ptr<Socket> > closeCompleted);
    8.13    /**
    8.14     * \param connectionSucceeded this callback is invoked when the 
    8.15     *        connection request initiated by the user is successfully 
    8.16 @@ -117,13 +111,9 @@
    8.17     *        connection request initiated by the user is unsuccessfully 
    8.18     *        completed. The callback is passed back a pointer to the 
    8.19     *        same socket object. 
    8.20 -   * \param halfClose XXX When exactly is this callback invoked? If 
    8.21 -   *        it invoked when the other side closes the connection ? 
    8.22 -   *        Or when I call Close ?
    8.23     */
    8.24    void SetConnectCallback (Callback<void, Ptr<Socket> > connectionSucceeded,
    8.25 -                           Callback<void,  Ptr<Socket> > connectionFailed,
    8.26 -                           Callback<void,  Ptr<Socket> > halfClose);
    8.27 +                           Callback<void,  Ptr<Socket> > connectionFailed);
    8.28    /**
    8.29     * \brief Accept connection requests from remote hosts
    8.30     * \param connectionRequest Callback for connection request from peer. 
    8.31 @@ -140,14 +130,11 @@
    8.32     *        back to the user through this callback. This user callback is 
    8.33     *        passed a pointer to the new socket, and the ip address and 
    8.34     *        port number of the connection originator.
    8.35 -   * \param closeRequested Callback for connection close request from peer.
    8.36 -   *        XXX: when is this callback invoked ?
    8.37     */
    8.38    void SetAcceptCallback (Callback<bool, Ptr<Socket>, 
    8.39                              const Address &> connectionRequest,
    8.40                            Callback<void, Ptr<Socket>, 
    8.41 -                            const Address&> newConnectionCreated,
    8.42 -                          Callback<void, Ptr<Socket> > closeRequested);
    8.43 +                            const Address&> newConnectionCreated);
    8.44    /**
    8.45     * \brief Notify application when a packet has been sent from transport 
    8.46     *        protocol (non-standard socket call)
    8.47 @@ -509,24 +496,16 @@
    8.48                  Address &fromAddress);
    8.49   
    8.50  protected:
    8.51 -  void NotifyCloseUnblocks (void);
    8.52 -  void NotifyCloseCompleted (void);
    8.53    void NotifyConnectionSucceeded (void);
    8.54    void NotifyConnectionFailed (void);
    8.55 -  void NotifyHalfClose (void);
    8.56    bool NotifyConnectionRequest (const Address &from);
    8.57    void NotifyNewConnectionCreated (Ptr<Socket> socket, const Address &from);
    8.58 -  void NotifyCloseRequested (void);
    8.59    void NotifyDataSent (uint32_t size);
    8.60    void NotifySend (uint32_t spaceAvailable);
    8.61    void NotifyDataRecv (void);
    8.62  
    8.63 -  Callback<void, Ptr<Socket> >   m_closeUnblocks;
    8.64 -  Callback<void,Ptr<Socket> >    m_closeCompleted;
    8.65    Callback<void, Ptr<Socket> >   m_connectionSucceeded;
    8.66    Callback<void, Ptr<Socket> >   m_connectionFailed;
    8.67 -  Callback<void, Ptr<Socket> >   m_halfClose;
    8.68 -  Callback<void, Ptr<Socket> >   m_closeRequested;
    8.69    Callback<bool, Ptr<Socket>, const Address &>   m_connectionRequest;
    8.70    Callback<void, Ptr<Socket>, const Address&>    m_newConnectionCreated;
    8.71    Callback<void, Ptr<Socket>, uint32_t>          m_dataSent;