diff --git a/examples/tcp-large-transfer.cc b/examples/tcp-large-transfer.cc index f648d50ea..2aab318a7 100644 --- a/examples/tcp-large-transfer.cc +++ b/examples/tcp-large-transfer.cc @@ -87,7 +87,7 @@ int main (int argc, char *argv[]) // Users may find it convenient to turn on explicit debugging // for selected modules; the below lines suggest how to do this // LogComponentEnable("TcpL4Protocol", LOG_LEVEL_ALL); - // LogComponentEnable("TcpSocket", LOG_LEVEL_ALL); + // LogComponentEnable("TcpSocketImpl", LOG_LEVEL_ALL); // LogComponentEnable("PacketSink", LOG_LEVEL_ALL); // LogComponentEnable("TcpLargeTransfer", LOG_LEVEL_ALL); @@ -182,8 +182,7 @@ void StartFlow(Ptr localSocket, uint32_t nBytes, // NS_LOG_LOGIC("Starting flow at time " << Simulator::Now ().GetSeconds ()); localSocket->Connect (InetSocketAddress (servAddress, servPort));//connect localSocket->SetConnectCallback (MakeCallback (&CloseConnection), - Callback > (), - Callback > ()); + Callback > ()); //we want to close as soon as the connection is established //the tcp state machine and outgoing buffer will assure that //all of the data is delivered diff --git a/src/applications/packet-sink/packet-sink.cc b/src/applications/packet-sink/packet-sink.cc index 73dfda731..406078dc7 100644 --- a/src/applications/packet-sink/packet-sink.cc +++ b/src/applications/packet-sink/packet-sink.cc @@ -67,6 +67,10 @@ PacketSink::~PacketSink() void PacketSink::DoDispose (void) { + if (m_socket != 0) + { + m_socket->Close (); + } m_socket = 0; // chain up @@ -88,8 +92,7 @@ void PacketSink::StartApplication() // Called at time specified by Start m_socket->SetRecvCallback (MakeCallback(&PacketSink::HandleRead, this)); m_socket->SetAcceptCallback ( MakeNullCallback, const Address &> (), - MakeNullCallback, const Address&> (), - MakeCallback(&PacketSink::CloseConnection, this) ); + MakeNullCallback, const Address&> ()); } void PacketSink::StopApplication() // Called at time specified by Stop @@ -117,9 +120,4 @@ void PacketSink::HandleRead (Ptr socket) } } -void PacketSink::CloseConnection (Ptr socket) -{ - socket->Close (); -} - } // Namespace ns3 diff --git a/src/applications/packet-sink/packet-sink.h b/src/applications/packet-sink/packet-sink.h index 20781a79e..440af90cd 100644 --- a/src/applications/packet-sink/packet-sink.h +++ b/src/applications/packet-sink/packet-sink.h @@ -80,9 +80,7 @@ private: virtual void StartApplication (void); // Called at time specified by Start virtual void StopApplication (void); // Called at time specified by Stop - virtual void HandleRead (Ptr socket); - - virtual void CloseConnection (Ptr socket); + void HandleRead (Ptr socket); Ptr m_socket; // Associated socket Address m_local; // Local address to bind to diff --git a/src/internet-stack/tcp-socket-impl.cc b/src/internet-stack/tcp-socket-impl.cc index 7cd0d246d..0d97c90ee 100644 --- a/src/internet-stack/tcp-socket-impl.cc +++ b/src/internet-stack/tcp-socket-impl.cc @@ -620,7 +620,6 @@ Actions_t TcpSocketImpl::ProcessEvent (Events_t e) NS_LOG_LOGIC ("TcpSocketImpl " << this << " transition to CLOSED from " << m_state << " event " << e << " closeNot " << m_closeNotified << " action " << stateAction.action); - NotifyCloseCompleted (); m_closeNotified = true; NS_LOG_LOGIC ("TcpSocketImpl " << this << " calling Closed from PE" << " origState " << saveState @@ -854,7 +853,6 @@ bool TcpSocketImpl::ProcessPacketAction (Actions_t a, Ptr p, { NS_LOG_LOGIC ("TCP " << this << " calling AppCloseRequest"); - NotifyCloseRequested(); m_closeRequestNotified = true; } NS_LOG_LOGIC ("TcpSocketImpl " << this @@ -1298,7 +1296,7 @@ void TcpSocketImpl::Retransmit () } if (!m_pendingData) { - if (m_state == FIN_WAIT_1 || m_state == FIN_WAIT_2) + if (m_state == FIN_WAIT_1) { // Must have lost FIN, re-send SendEmptyPacket (TcpHeader::FIN); } diff --git a/src/internet-stack/udp-socket-impl.cc b/src/internet-stack/udp-socket-impl.cc index 5f9872089..003478a37 100644 --- a/src/internet-stack/udp-socket-impl.cc +++ b/src/internet-stack/udp-socket-impl.cc @@ -199,7 +199,6 @@ int UdpSocketImpl::Close(void) { NS_LOG_FUNCTION_NOARGS (); - NotifyCloseCompleted (); return 0; } diff --git a/src/node/packet-socket.cc b/src/node/packet-socket.cc index 4e6bb847c..8d6e8272c 100644 --- a/src/node/packet-socket.cc +++ b/src/node/packet-socket.cc @@ -184,7 +184,6 @@ PacketSocket::Close(void) return -1; } m_state = STATE_CLOSED; - NotifyCloseCompleted (); return 0; } diff --git a/src/node/socket.cc b/src/node/socket.cc index e5409ca0b..52f691c57 100644 --- a/src/node/socket.cc +++ b/src/node/socket.cc @@ -50,35 +50,24 @@ Socket::CreateSocket (Ptr node, TypeId tid) return s; } -void -Socket::SetCloseCallback (Callback > closeCompleted) -{ - NS_LOG_FUNCTION_NOARGS (); - m_closeCompleted = closeCompleted; -} - void Socket::SetConnectCallback ( Callback > connectionSucceeded, - Callback > connectionFailed, - Callback > halfClose) + Callback > connectionFailed) { NS_LOG_FUNCTION_NOARGS (); m_connectionSucceeded = connectionSucceeded; m_connectionFailed = connectionFailed; - m_halfClose = halfClose; } void Socket::SetAcceptCallback ( Callback, const Address &> connectionRequest, - Callback, const Address&> newConnectionCreated, - Callback > closeRequested) + Callback, const Address&> newConnectionCreated) { NS_LOG_FUNCTION_NOARGS (); m_connectionRequest = connectionRequest; m_newConnectionCreated = newConnectionCreated; - m_closeRequested = closeRequested; } bool @@ -110,15 +99,6 @@ Socket::Send (Ptr p) return Send (p, 0); } -void -Socket::NotifyCloseUnblocks (void) -{ - NS_LOG_FUNCTION_NOARGS (); - if (!m_closeUnblocks.IsNull ()) - { - m_closeUnblocks (this); - } -} int Socket::Listen (uint32_t queueLimit) { @@ -199,15 +179,6 @@ Socket::RecvFrom (uint8_t* buf, uint32_t size, uint32_t flags, return p->GetSize (); } -void -Socket::NotifyCloseCompleted (void) -{ - NS_LOG_FUNCTION_NOARGS (); - if (!m_closeCompleted.IsNull ()) - { - m_closeCompleted (this); - } -} void Socket::NotifyConnectionSucceeded (void) @@ -229,16 +200,6 @@ Socket::NotifyConnectionFailed (void) } } -void -Socket::NotifyHalfClose (void) -{ - NS_LOG_FUNCTION_NOARGS (); - if (!m_halfClose.IsNull ()) - { - m_halfClose (this); - } -} - bool Socket::NotifyConnectionRequest (const Address &from) { @@ -267,16 +228,6 @@ Socket::NotifyNewConnectionCreated (Ptr socket, const Address &from) } } -void -Socket::NotifyCloseRequested (void) -{ - NS_LOG_FUNCTION_NOARGS (); - if (!m_closeRequested.IsNull ()) - { - m_closeRequested (this); - } -} - void Socket::NotifyDataSent (uint32_t size) { diff --git a/src/node/socket.h b/src/node/socket.h index a15ad0061..d90ce26bf 100644 --- a/src/node/socket.h +++ b/src/node/socket.h @@ -102,12 +102,6 @@ public: * \returns the node this socket is associated with. */ virtual Ptr GetNode (void) const = 0; - - /** - * \param closeCompleted Callback invoked when the close operation is - * completed. - */ - void SetCloseCallback (Callback > closeCompleted); /** * \param connectionSucceeded this callback is invoked when the * connection request initiated by the user is successfully @@ -117,13 +111,9 @@ public: * connection request initiated by the user is unsuccessfully * completed. The callback is passed back a pointer to the * same socket object. - * \param halfClose XXX When exactly is this callback invoked? If - * it invoked when the other side closes the connection ? - * Or when I call Close ? */ void SetConnectCallback (Callback > connectionSucceeded, - Callback > connectionFailed, - Callback > halfClose); + Callback > connectionFailed); /** * \brief Accept connection requests from remote hosts * \param connectionRequest Callback for connection request from peer. @@ -140,14 +130,11 @@ public: * back to the user through this callback. This user callback is * passed a pointer to the new socket, and the ip address and * port number of the connection originator. - * \param closeRequested Callback for connection close request from peer. - * XXX: when is this callback invoked ? */ void SetAcceptCallback (Callback, const Address &> connectionRequest, Callback, - const Address&> newConnectionCreated, - Callback > closeRequested); + const Address&> newConnectionCreated); /** * \brief Notify application when a packet has been sent from transport * protocol (non-standard socket call) @@ -509,24 +496,16 @@ public: Address &fromAddress); protected: - void NotifyCloseUnblocks (void); - void NotifyCloseCompleted (void); void NotifyConnectionSucceeded (void); void NotifyConnectionFailed (void); - void NotifyHalfClose (void); bool NotifyConnectionRequest (const Address &from); void NotifyNewConnectionCreated (Ptr socket, const Address &from); - void NotifyCloseRequested (void); void NotifyDataSent (uint32_t size); void NotifySend (uint32_t spaceAvailable); void NotifyDataRecv (void); - Callback > m_closeUnblocks; - Callback > m_closeCompleted; Callback > m_connectionSucceeded; Callback > m_connectionFailed; - Callback > m_halfClose; - Callback > m_closeRequested; Callback, const Address &> m_connectionRequest; Callback, const Address&> m_newConnectionCreated; Callback, uint32_t> m_dataSent;