# HG changeset patch # User Tom Henderson # Date 1203138915 28800 # Node ID cf358e79d706d62abec7c3c55a5e37fb44976c2f # Parent 7a249c7c28de6cf98aefb623ce1147b333bb0e5b new bug131 patch diff -r 7a249c7c28de -r cf358e79d706 src/internet-node/tcp-socket.cc --- a/src/internet-node/tcp-socket.cc Fri Feb 15 19:54:34 2008 -0800 +++ b/src/internet-node/tcp-socket.cc Fri Feb 15 21:15:15 2008 -0800 @@ -305,6 +305,9 @@ int TcpSocket::Send (const uint8_t* buf, //PendingData::Add always copies the data buffer, never modifies m_pendingData->Add (size,buf); Actions_t action = ProcessEvent (APP_SEND); + // We do not model any limit to the buffer, so report that the + // maximum is available + NotifySend (std::numeric_limits::max ()); if (!ProcessAction (action)) { return -1; // Failed, return zero @@ -591,6 +594,9 @@ bool TcpSocket::ProcessPacketAction (Act if (tcpHeader.GetAckNumber () > m_highestRxAck) { m_highestRxAck = tcpHeader.GetAckNumber (); + // We do not model any limit to the buffer, so report that the + // maximum is available + NotifySend (std::numeric_limits::max ()); } SendPendingData (); break; @@ -932,6 +938,9 @@ void TcpSocket::CommonNewAck (SequenceNu NS_LOG_LOGIC ("TCP " << this << " NewAck " << ack << " numberAck " << (ack - m_highestRxAck)); // Number bytes ack'ed m_highestRxAck = ack; // Note the highest recieved Ack + // We do not model any limit to the buffer, so report that the + // maximum is available + NotifySend (std::numeric_limits::max ()); if (ack > m_nextTxSequence) { m_nextTxSequence = ack; // If advanced diff -r 7a249c7c28de -r cf358e79d706 src/node/socket.cc --- a/src/node/socket.cc Fri Feb 15 19:54:34 2008 -0800 +++ b/src/node/socket.cc Fri Feb 15 21:15:15 2008 -0800 @@ -64,11 +64,19 @@ Socket::SetAcceptCallback ( m_closeRequested = closeRequested; } -void -Socket::SetSendCallback (Callback, uint32_t> dataSent) +bool +Socket::SetDataSentCallback (Callback, uint32_t> dataSent) { NS_LOG_FUNCTION; m_dataSent = dataSent; + return true; +} + +void +Socket::SetSendCallback (Callback, uint32_t> sendCb) +{ + NS_LOG_FUNCTION; + m_sendCb = sendCb; } void @@ -200,6 +208,16 @@ Socket::NotifyDataSent (uint32_t size) } void +Socket::NotifySend (uint32_t spaceAvailable) +{ + NS_LOG_FUNCTION; + if (!m_sendCb.IsNull ()) + { + m_sendCb (this, spaceAvailable); + } +} + +void Socket::NotifyDataReceived (Ptr p, const Address &from) { NS_LOG_FUNCTION; diff -r 7a249c7c28de -r cf358e79d706 src/node/socket.h --- a/src/node/socket.h Fri Feb 15 19:54:34 2008 -0800 +++ b/src/node/socket.h Fri Feb 15 21:15:15 2008 -0800 @@ -120,7 +120,36 @@ public: Callback, const Address&> newConnectionCreated, Callback > closeRequested); - void SetSendCallback (Callback, uint32_t> dataSent); + /** + * \brief Notify application when a packet has been sent from transport + * protocol (non-standard socket call) + * \param dataSent Callback for the event that data is sent from the + * underlying transport protocol. This callback is passed a + * pointer to the socket, and the number of bytes sent. + * \returns whether or not this socket supports this callback. Note + * that this is a non-standard socket call. Some socket + * implementations in ns-3 may not support this call, so the + * user should check this return value to confirm that the + * callback is supported. + */ + virtual bool SetDataSentCallback (Callback, uint32_t> dataSent); + /** + * \brief Notify application when space in transmit buffer is added + * + * This callback is intended to notify a + * socket that would have been blocked in a blocking socket model + * that some data has been acked and removed from the transmit + * buffer, and that it can call send again. The semantics for + * reliable stream sockets are that when data is acked and removed + * from the transmit buffer, this callback is invoked. + * + * \param sendCb Callback for the event that the socket transmit buffer + * fill level has decreased. This callback is passed a pointer to + * the socket, and the number of bytes available for writing + * into the buffer (an absolute value). If there is no transmit + * buffer limit, a maximum-sized integer is always returned. + */ + void SetSendCallback (Callback, uint32_t> sendCb); /** * \brief Receive data * \param receivedData Invoked whenever new data is received. @@ -232,6 +261,7 @@ protected: void NotifyNewConnectionCreated (Ptr socket, const Address &from); void NotifyCloseRequested (void); void NotifyDataSent (uint32_t size); + void NotifySend (uint32_t spaceAvailable); void NotifyDataReceived (Ptr p, const Address &from); Callback > m_closeCompleted; @@ -242,6 +272,7 @@ protected: Callback, const Address &> m_connectionRequest; Callback, const Address&> m_newConnectionCreated; Callback, uint32_t> m_dataSent; + Callback, uint32_t > m_sendCb; Callback, Ptr,const Address&> m_receivedData; };