1

I have to run two TCP sessions with different RcvBufSize.

I know the following code can setup the RcvBufSize for all TCP sessions.

Config::SetDefault("ns3::TcpSocket::RcvBufSize", UintegerValue (1500000));

Actually, I'm looking for the function like setsockopt() to setup SO_RCVBUF for each TCP session.

I also tried to downcast Ptr<Socket> to Ptr<TcpSocket>, but SetRcvBufSize() is private function...

Is there anyway to solve this problem?

Ajay
  • 18,086
  • 12
  • 59
  • 105
wguo
  • 55
  • 1
  • 6

1 Answers1

0

I changed SndBufSize in my application using SetAttribute call. I have a class with the socket pointer member ns3::Ptr<ns3::Socket> m_pSocket and to change the send buffer size I do this:

// create tcp socket
m_pSocket = ns3::Socket::CreateSocket( GetNode(), ns3::TcpSocketFactory::GetTypeId() );
m_pSocket->SetAttribute("SndBufSize", ns3::UintegerValue(4096000));

So in your case you have to call:

yourSocket->SetAttribute("RcvBufSize", ns3::UintegerValue(1500000));

This way you can set every attribute of ns3::TcpSocket.

Dimitri Podborski
  • 3,714
  • 3
  • 19
  • 31