View | Details | Raw Unified | Return to bug 131
Collapse All | Expand All

(-)a/src/internet-node/tcp-socket.cc (+9 lines)
 Lines 305-310   int TcpSocket::Send (const uint8_t* buf, Link Here 
305
      //PendingData::Add always copies the data buffer, never modifies
305
      //PendingData::Add always copies the data buffer, never modifies
306
      m_pendingData->Add (size,buf);
306
      m_pendingData->Add (size,buf);
307
      Actions_t action = ProcessEvent (APP_SEND);
307
      Actions_t action = ProcessEvent (APP_SEND);
308
      // We do not model any limit to the buffer, so report that the
309
      // maximum is available
310
      NotifySend (std::numeric_limits<uint32_t>::max ());
308
      if (!ProcessAction (action)) 
311
      if (!ProcessAction (action)) 
309
        {
312
        {
310
          return -1; // Failed, return zero
313
          return -1; // Failed, return zero
 Lines 591-596   bool TcpSocket::ProcessPacketAction (Act Link Here 
591
      if (tcpHeader.GetAckNumber () > m_highestRxAck)
594
      if (tcpHeader.GetAckNumber () > m_highestRxAck)
592
      {
595
      {
593
        m_highestRxAck = tcpHeader.GetAckNumber ();
596
        m_highestRxAck = tcpHeader.GetAckNumber ();
597
        // We do not model any limit to the buffer, so report that the
598
        // maximum is available
599
        NotifySend (std::numeric_limits<uint32_t>::max ());
594
      }
600
      }
595
      SendPendingData ();
601
      SendPendingData ();
596
      break;
602
      break;
 Lines 932-937   void TcpSocket::CommonNewAck (SequenceNu Link Here 
932
  NS_LOG_LOGIC ("TCP " << this << " NewAck " << ack 
938
  NS_LOG_LOGIC ("TCP " << this << " NewAck " << ack 
933
           << " numberAck " << (ack - m_highestRxAck)); // Number bytes ack'ed
939
           << " numberAck " << (ack - m_highestRxAck)); // Number bytes ack'ed
934
  m_highestRxAck = ack;         // Note the highest recieved Ack
940
  m_highestRxAck = ack;         // Note the highest recieved Ack
941
  // We do not model any limit to the buffer, so report that the
942
  // maximum is available
943
  NotifySend (std::numeric_limits<uint32_t>::max ());
935
  if (ack > m_nextTxSequence) 
944
  if (ack > m_nextTxSequence) 
936
    {
945
    {
937
      m_nextTxSequence = ack; // If advanced
946
      m_nextTxSequence = ack; // If advanced
(-)a/src/node/socket.cc (-2 / +20 lines)
 Lines 64-74   Socket::SetAcceptCallback ( Link Here 
64
  m_closeRequested = closeRequested;
64
  m_closeRequested = closeRequested;
65
}
65
}
66
66
67
void 
67
bool
68
Socket::SetSendCallback (Callback<void, Ptr<Socket>, uint32_t> dataSent)
68
Socket::SetDataSentCallback (Callback<void, Ptr<Socket>, uint32_t> dataSent)
69
{
69
{
70
  NS_LOG_FUNCTION;
70
  NS_LOG_FUNCTION;
71
  m_dataSent = dataSent;
71
  m_dataSent = dataSent;
72
  return true;
73
}
74
75
void 
76
Socket::SetSendCallback (Callback<void, Ptr<Socket>, uint32_t> sendCb)
77
{
78
  NS_LOG_FUNCTION;
79
  m_sendCb = sendCb;
72
}
80
}
73
81
74
void 
82
void 
 Lines 200-205   Socket::NotifyDataSent (uint32_t size) Link Here 
200
}
208
}
201
209
202
void 
210
void 
211
Socket::NotifySend (uint32_t spaceAvailable)
212
{
213
  NS_LOG_FUNCTION;
214
  if (!m_sendCb.IsNull ())
215
    {
216
      m_sendCb (this, spaceAvailable);
217
    }
218
}
219
220
void 
203
Socket::NotifyDataReceived (Ptr<Packet> p, const Address &from)
221
Socket::NotifyDataReceived (Ptr<Packet> p, const Address &from)
204
{
222
{
205
  NS_LOG_FUNCTION;
223
  NS_LOG_FUNCTION;
(-)a/src/node/socket.h (-1 / +32 lines)
 Lines 120-126   public: Link Here 
120
                          Callback<void, Ptr<Socket>, 
120
                          Callback<void, Ptr<Socket>, 
121
                            const Address&> newConnectionCreated,
121
                            const Address&> newConnectionCreated,
122
                          Callback<void, Ptr<Socket> > closeRequested);
122
                          Callback<void, Ptr<Socket> > closeRequested);
123
  void SetSendCallback (Callback<void, Ptr<Socket>, uint32_t> dataSent);
123
  /**
124
   * \brief Notify application when a packet has been sent from transport 
125
   *        protocol (non-standard socket call)
126
   * \param dataSent Callback for the event that data is sent from the
127
   *        underlying transport protocol.  This callback is passed a
128
   *        pointer to the socket, and the number of bytes sent.
129
   * \returns whether or not this socket supports this callback.  Note 
130
   *        that this is a non-standard socket call.  Some socket 
131
   *        implementations in ns-3 may not support this call, so the
132
   *        user should check this return value to confirm that the
133
   *        callback is supported.
134
   */
135
  virtual bool SetDataSentCallback (Callback<void, Ptr<Socket>, uint32_t> dataSent);
136
  /**
137
   * \brief Notify application when space in transmit buffer is added
138
   *
139
   *        This callback is intended to notify a 
140
   *        socket that would have been blocked in a blocking socket model
141
   *        that some data has been acked and removed from the transmit
142
   *        buffer, and that it can call send again.  The semantics for
143
   *        reliable stream sockets are that when data is acked and removed
144
   *        from the transmit buffer, this callback is invoked.
145
   *
146
   * \param sendCb Callback for the event that the socket transmit buffer
147
   *        fill level has decreased.  This callback is passed a pointer to
148
   *        the socket, and the number of bytes available for writing
149
   *        into the buffer (an absolute value).  If there is no transmit
150
   *        buffer limit, a maximum-sized integer is always returned.
151
   */
152
  void SetSendCallback (Callback<void, Ptr<Socket>, uint32_t> sendCb);
124
  /**
153
  /**
125
   * \brief Receive data
154
   * \brief Receive data
126
   * \param receivedData Invoked whenever new data is received.
155
   * \param receivedData Invoked whenever new data is received.
 Lines 232-237   protected: Link Here 
232
  void NotifyNewConnectionCreated (Ptr<Socket> socket, const Address &from);
261
  void NotifyNewConnectionCreated (Ptr<Socket> socket, const Address &from);
233
  void NotifyCloseRequested (void);
262
  void NotifyCloseRequested (void);
234
  void NotifyDataSent (uint32_t size);
263
  void NotifyDataSent (uint32_t size);
264
  void NotifySend (uint32_t spaceAvailable);
235
  void NotifyDataReceived (Ptr<Packet> p, const Address &from);
265
  void NotifyDataReceived (Ptr<Packet> p, const Address &from);
236
266
237
  Callback<void,Ptr<Socket> >    m_closeCompleted;
267
  Callback<void,Ptr<Socket> >    m_closeCompleted;
 Lines 242-247   protected: Link Here 
242
  Callback<bool, Ptr<Socket>, const Address &>   m_connectionRequest;
272
  Callback<bool, Ptr<Socket>, const Address &>   m_connectionRequest;
243
  Callback<void, Ptr<Socket>, const Address&>    m_newConnectionCreated;
273
  Callback<void, Ptr<Socket>, const Address&>    m_newConnectionCreated;
244
  Callback<void, Ptr<Socket>, uint32_t>          m_dataSent;
274
  Callback<void, Ptr<Socket>, uint32_t>          m_dataSent;
275
  Callback<void, Ptr<Socket>, uint32_t >         m_sendCb;
245
  Callback<void, Ptr<Socket>, Ptr<Packet>,const Address&> m_receivedData;
276
  Callback<void, Ptr<Socket>, Ptr<Packet>,const Address&> m_receivedData;
246
};
277
};
247
278

Return to bug 131