diff --git a/src/internet-node/udp-socket.cc b/src/internet-node/udp-socket.cc index 4aa9f0b11..8305b17ba 100644 --- a/src/internet-node/udp-socket.cc +++ b/src/internet-node/udp-socket.cc @@ -56,7 +56,8 @@ UdpSocket::UdpSocket () m_shutdownRecv (false), m_connected (false), m_rxAvailable (0), - m_udp_rmem (0) + m_sndBufLimit (0), + m_rcvBufLimit (0) { NS_LOG_FUNCTION_NOARGS (); } @@ -87,14 +88,16 @@ UdpSocket::~UdpSocket () void UdpSocket::SetNode (Ptr node) { + NS_LOG_FUNCTION_NOARGS (); m_node = node; Ptr u = node->GetObject (); - m_udp_rmem =u->GetDefaultRxBuffer (); + m_rcvBufLimit =u->GetDefaultRxBuffer (); } void UdpSocket::SetUdp (Ptr udp) { + NS_LOG_FUNCTION_NOARGS (); m_udp = udp; } @@ -337,6 +340,7 @@ UdpSocket::DoSendTo (Ptr p, Ipv4Address dest, uint16_t port) uint32_t UdpSocket::GetTxAvailable (void) const { + NS_LOG_FUNCTION_NOARGS (); // No finite send buffer is modelled return std::numeric_limits::max (); } @@ -354,6 +358,7 @@ UdpSocket::SendTo (const Address &address, Ptr p) Ptr UdpSocket::Recv (uint32_t maxSize, uint32_t flags) { + NS_LOG_FUNCTION_NOARGS (); if (m_deliveryQueue.empty() ) { return 0; @@ -374,6 +379,7 @@ UdpSocket::Recv (uint32_t maxSize, uint32_t flags) uint32_t UdpSocket::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; @@ -388,7 +394,7 @@ UdpSocket::ForwardUp (Ptr packet, Ipv4Address ipv4, uint16_t port) { return; } - if ((m_rxAvailable + packet->GetSize ()) <= m_udp_rmem) + if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufLimit) { Address address = InetSocketAddress (ipv4, port); SocketRxAddressTag tag; @@ -413,28 +419,33 @@ UdpSocket::ForwardUp (Ptr packet, Ipv4Address ipv4, uint16_t port) void UdpSocket::SetSndBuf (uint32_t size) { + NS_LOG_FUNCTION_NOARGS (); // return EINVAL since we are not modelling a finite send buffer // Enforcing buffer size should be added if we ever start to model // non-zero processing delay in the UDP/IP stack NS_LOG_WARN ("UdpSocket has infinite send buffer"); + m_sndBufLimit = size; } uint32_t UdpSocket::GetSndBuf (void) const { - return std::numeric_limits::max (); + NS_LOG_FUNCTION_NOARGS (); + return m_sndBufLimit; } void UdpSocket::SetRcvBuf (uint32_t size) { - m_udp_rmem = size; + NS_LOG_FUNCTION_NOARGS (); + m_rcvBufLimit = size; } uint32_t UdpSocket::GetRcvBuf (void) const { - return m_udp_rmem; + NS_LOG_FUNCTION_NOARGS (); + return m_rcvBufLimit; } diff --git a/src/internet-node/udp-socket.h b/src/internet-node/udp-socket.h index 8ed3ba67e..aa21a8e7f 100644 --- a/src/internet-node/udp-socket.h +++ b/src/internet-node/udp-socket.h @@ -96,7 +96,8 @@ private: std::queue > m_deliveryQueue; uint32_t m_rxAvailable; - uint32_t m_udp_rmem; + uint32_t m_sndBufLimit; + uint32_t m_rcvBufLimit; }; }//namespace ns3