--- a/src/internet-node/tcp-socket.cc Tue Apr 22 22:08:53 2008 -0700
+++ b/src/internet-node/tcp-socket.cc Tue Apr 22 22:29:16 2008 -0700
@@ -370,6 +370,9 @@
" state " << m_state);
Actions_t action = ProcessEvent (APP_SEND);
NS_LOG_DEBUG(" action " << action);
+ // We do not model any limit to the buffer, so report that the
+ // maximum is available
+ NotifySend (std::numeric_limits<uint32_t>::max ());
if (!ProcessAction (action))
{
return -1; // Failed, return zero
@@ -689,6 +692,9 @@
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<uint32_t>::max ());
}
SendPendingData ();
break;
@@ -1077,6 +1083,9 @@
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<uint32_t>::max ());
if (ack > m_nextTxSequence)
{
m_nextTxSequence = ack; // If advanced
--- a/src/node/socket.cc Tue Apr 22 22:08:53 2008 -0700
+++ b/src/node/socket.cc Tue Apr 22 22:29:16 2008 -0700
@@ -64,11 +64,19 @@
m_closeRequested = closeRequested;
}
-void
-Socket::SetSendCallback (Callback<void, Ptr<Socket>, uint32_t> dataSent)
+bool
+Socket::SetDataSentCallback (Callback<void, Ptr<Socket>, uint32_t> dataSent)
{
NS_LOG_FUNCTION_NOARGS ();
m_dataSent = dataSent;
+ return true;
+}
+
+void
+Socket::SetSendCallback (Callback<void, Ptr<Socket>, uint32_t> sendCb)
+{
+ NS_LOG_FUNCTION_NOARGS ();
+ m_sendCb = sendCb;
}
void
@@ -203,6 +211,16 @@
}
void
+Socket::NotifySend (uint32_t spaceAvailable)
+{
+ NS_LOG_FUNCTION_NOARGS ();
+ if (!m_sendCb.IsNull ())
+ {
+ m_sendCb (this, spaceAvailable);
+ }
+}
+
+void
Socket::NotifyDataReceived (Ptr<Packet> p, const Address &from)
{
NS_LOG_FUNCTION_NOARGS ();
--- a/src/node/socket.h Tue Apr 22 22:08:53 2008 -0700
+++ b/src/node/socket.h Tue Apr 22 22:29:16 2008 -0700
@@ -120,7 +120,36 @@
Callback<void, Ptr<Socket>,
const Address&> newConnectionCreated,
Callback<void, Ptr<Socket> > closeRequested);
- void SetSendCallback (Callback<void, Ptr<Socket>, 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<void, Ptr<Socket>, 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<void, Ptr<Socket>, uint32_t> sendCb);
/**
* \brief Receive data
* \param receivedData Invoked whenever new data is received.
@@ -232,6 +261,7 @@
void NotifyNewConnectionCreated (Ptr<Socket> socket, const Address &from);
void NotifyCloseRequested (void);
void NotifyDataSent (uint32_t size);
+ void NotifySend (uint32_t spaceAvailable);
void NotifyDataReceived (Ptr<Packet> p, const Address &from);
Callback<void,Ptr<Socket> > m_closeCompleted;
@@ -242,6 +272,7 @@
Callback<bool, Ptr<Socket>, const Address &> m_connectionRequest;
Callback<void, Ptr<Socket>, const Address&> m_newConnectionCreated;
Callback<void, Ptr<Socket>, uint32_t> m_dataSent;
+ Callback<void, Ptr<Socket>, uint32_t > m_sendCb;
Callback<void, Ptr<Socket>, Ptr<Packet>,const Address&> m_receivedData;
};