diff --git a/src/internet-node/tcp-socket.cc b/src/internet-node/tcp-socket.cc index 63b33bafb..8127d8f87 100644 --- a/src/internet-node/tcp-socket.cc +++ b/src/internet-node/tcp-socket.cc @@ -79,8 +79,9 @@ TcpSocket::GetTypeId () m_pendingData (0), m_rtt (0), m_lastMeasuredRtt (Seconds(0.0)), - m_rxAvailable (0), //XXX zero? - m_maxTxBuffer (65536) //interpret 0 as no limit, //XXX hook into default values + m_rxAvailable (0), + m_sndBufLimit (0xffffffff), + m_rcvBufLimit (0xffffffff) { NS_LOG_FUNCTION (this); @@ -126,7 +127,8 @@ TcpSocket::TcpSocket(const TcpSocket& sock) m_cnTimeout (sock.m_cnTimeout), m_cnCount (sock.m_cnCount), m_rxAvailable (0), - m_maxTxBuffer (0) //interpret 0 as no limit, //XXX hook into default values + m_sndBufLimit (0xffffffff), + m_rcvBufLimit (0xffffffff) { NS_LOG_FUNCTION_NOARGS (); NS_LOG_LOGIC("Invoked the copy constructor"); @@ -436,25 +438,21 @@ TcpSocket::SendTo (const Address &address, Ptr p) } } -// XXX Raj to make this functional uint32_t TcpSocket::GetTxAvailable (void) const { - if (m_maxTxBuffer == 0) //interpret this as infinite buffer - { - return std::numeric_limits::max (); - } + NS_LOG_FUNCTION_NOARGS (); if (m_pendingData != 0) - { - uint32_t unAckedDataSize = + { + uint32_t unAckedDataSize = m_pendingData->SizeFromSeq (m_firstPendingSequence, m_highestRxAck); - NS_ASSERT (m_maxTxBuffer >= unAckedDataSize); //else a logical error - return m_maxTxBuffer-unAckedDataSize; - } + NS_ASSERT (m_sndBufLimit >= unAckedDataSize); //else a logical error + return m_sndBufLimit-unAckedDataSize; + } else - { - return m_maxTxBuffer; - } + { + return m_sndBufLimit; + } } int @@ -469,6 +467,7 @@ TcpSocket::Listen (uint32_t q) Ptr TcpSocket::Recv (uint32_t maxSize, uint32_t flags) { + NS_LOG_FUNCTION_NOARGS (); if (m_deliveryQueue.empty() ) { return 0; @@ -489,36 +488,38 @@ TcpSocket::Recv (uint32_t maxSize, uint32_t flags) uint32_t TcpSocket::GetRxAvailable (void) const { + NS_LOG_FUNCTION_NOARGS (); // We separately maintain this state to avoid walking the queue // every time this might be called return m_rxAvailable; } -// XXX Raj to finish void TcpSocket::SetSndBuf (uint32_t size) { - + NS_LOG_FUNCTION_NOARGS (); + m_sndBufLimit = size; } -// XXX Raj to finish uint32_t TcpSocket::GetSndBuf (void) const { - return 0; + NS_LOG_FUNCTION_NOARGS (); + return m_sndBufLimit; } -// XXX Raj to finish void TcpSocket::SetRcvBuf (uint32_t size) { + NS_LOG_FUNCTION_NOARGS (); + m_rcvBufLimit = size; } -// XXX Raj to finish uint32_t TcpSocket::GetRcvBuf (void) const { - return 0; + NS_LOG_FUNCTION_NOARGS (); + return m_rcvBufLimit; } void diff --git a/src/internet-node/tcp-socket.h b/src/internet-node/tcp-socket.h index f68e19884..dbaedc835 100644 --- a/src/internet-node/tcp-socket.h +++ b/src/internet-node/tcp-socket.h @@ -187,8 +187,8 @@ private: std::queue > m_deliveryQueue; uint32_t m_rxAvailable; - // buffer limit for the outgoing queue - uint32_t m_maxTxBuffer; + uint32_t m_sndBufLimit; // buffer limit for the outgoing queue + uint32_t m_rcvBufLimit; // maximum receive socket buffer size }; }//namespace ns3