Add SocketDefaults to store socket option attributes
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "packet-socket-helper.h"
|
||||
#include "ns3/packet-socket-factory.h"
|
||||
#include "ns3/socket-defaults.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -11,6 +12,8 @@ PacketSocketHelper::Install (NodeContainer c)
|
||||
Ptr<Node> node = *i;
|
||||
Ptr<PacketSocketFactory> factory = CreateObject<PacketSocketFactory> ();
|
||||
node->AggregateObject (factory);
|
||||
Ptr<SocketDefaults> sockDefaults = CreateObject<SocketDefaults> ();
|
||||
node->AggregateObject (sockDefaults);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "ns3/net-device.h"
|
||||
#include "ns3/callback.h"
|
||||
#include "ns3/node.h"
|
||||
#include "ns3/socket-defaults.h"
|
||||
|
||||
#include "ipv4-l4-demux.h"
|
||||
#include "udp-l4-protocol.h"
|
||||
@@ -61,6 +62,7 @@ AddInternetStack (Ptr<Node> node)
|
||||
Ptr<UdpImpl> udpImpl = CreateObject<UdpImpl> ();
|
||||
Ptr<TcpImpl> tcpImpl = CreateObject<TcpImpl> ();
|
||||
Ptr<Ipv4Impl> ipv4Impl = CreateObject<Ipv4Impl> ();
|
||||
Ptr<SocketDefaults> sockDef = CreateObject<SocketDefaults> ();
|
||||
|
||||
udpImpl->SetUdp (udp);
|
||||
tcpImpl->SetTcp (tcp);
|
||||
@@ -72,6 +74,7 @@ AddInternetStack (Ptr<Node> node)
|
||||
node->AggregateObject (udpImpl);
|
||||
node->AggregateObject (tcpImpl);
|
||||
node->AggregateObject (ipv4L4Demux);
|
||||
node->AggregateObject (sockDef);
|
||||
}
|
||||
|
||||
}//namespace ns3
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#include "tcp-typedefs.h"
|
||||
#include "ns3/simulator.h"
|
||||
#include "ns3/packet.h"
|
||||
#include "ns3/uinteger.h"
|
||||
#include "ns3/socket-defaults.h"
|
||||
#include "ns3/trace-source-accessor.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -185,6 +187,17 @@ TcpSocket::SetNode (Ptr<Node> node)
|
||||
m_cnCount = t->GetDefaultConnCount ();
|
||||
m_delAckTimout = Seconds(t->GetDefaultDelAckTimeout ());
|
||||
m_delAckMaxCount = t->GetDefaultDelAckCount ();
|
||||
|
||||
// Pull default values for socket options from SocketDefaults
|
||||
// object that was aggregated to the node
|
||||
Ptr<SocketDefaults> sd = node->GetObject<SocketDefaults> ();
|
||||
NS_ASSERT (sd != 0);
|
||||
UintegerValue uiv;
|
||||
sd->GetAttribute ("DefaultSndBufLimit", uiv);
|
||||
m_sndBufLimit = uiv.Get();
|
||||
sd->GetAttribute ("DefaultRcvBufLimit", uiv);
|
||||
m_rcvBufLimit = uiv.Get();
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -23,13 +23,15 @@
|
||||
#include "ns3/inet-socket-address.h"
|
||||
#include "ns3/ipv4-route.h"
|
||||
#include "ns3/ipv4.h"
|
||||
#include "ns3/ipv4.h"
|
||||
#include "ns3/udp.h"
|
||||
#include "ns3/socket-defaults.h"
|
||||
#include "ns3/trace-source-accessor.h"
|
||||
#include "ns3/uinteger.h"
|
||||
#include "udp-socket.h"
|
||||
#include "udp-l4-protocol.h"
|
||||
#include "ipv4-end-point.h"
|
||||
#include "ipv4-l4-demux.h"
|
||||
#include "ns3/ipv4.h"
|
||||
#include "ns3/udp.h"
|
||||
#include "ns3/trace-source-accessor.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("UdpSocket");
|
||||
|
||||
@@ -89,9 +91,14 @@ void
|
||||
UdpSocket::SetNode (Ptr<Node> node)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
// Pull default values for socket options from SocketDefaults
|
||||
// object that was aggregated to the node
|
||||
m_node = node;
|
||||
Ptr<Udp> u = node->GetObject<Udp> ();
|
||||
m_rcvBufLimit =u->GetDefaultRxBuffer ();
|
||||
Ptr<SocketDefaults> sd = node->GetObject<SocketDefaults> ();
|
||||
NS_ASSERT (sd != 0);
|
||||
UintegerValue uiv;
|
||||
sd->GetAttribute ("DefaultRcvBufLimit", uiv);
|
||||
m_rcvBufLimit = uiv.Get();
|
||||
|
||||
}
|
||||
void
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/node.h"
|
||||
#include "ns3/packet.h"
|
||||
#include "ns3/uinteger.h"
|
||||
#include "ns3/socket-defaults.h"
|
||||
#include "ns3/trace-source-accessor.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("PacketSocket");
|
||||
@@ -56,6 +58,16 @@ PacketSocket::SetNode (Ptr<Node> node)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
m_node = node;
|
||||
// Pull default values for socket options from SocketDefaults
|
||||
// object that was aggregated to the node
|
||||
Ptr<SocketDefaults> sd = node->GetObject<SocketDefaults> ();
|
||||
NS_ASSERT (sd != 0);
|
||||
UintegerValue uiv;
|
||||
sd->GetAttribute ("DefaultSndBufLimit", uiv);
|
||||
m_sndBufLimit = uiv.Get();
|
||||
sd->GetAttribute ("DefaultRcvBufLimit", uiv);
|
||||
m_rcvBufLimit = uiv.Get();
|
||||
|
||||
}
|
||||
|
||||
PacketSocket::~PacketSocket ()
|
||||
|
||||
@@ -54,23 +54,33 @@ SocketOptions::~SocketOptions (void)
|
||||
void
|
||||
SocketOptions::SetSndBuf (uint32_t size)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
Ptr<Socket> sock = GetObject<Socket> ();
|
||||
sock->SetSndBuf (size);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
SocketOptions::GetSndBuf (void) const
|
||||
{
|
||||
return 0;
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
Ptr<Socket> sock = GetObject<Socket> ();
|
||||
return sock->GetSndBuf ();
|
||||
}
|
||||
|
||||
void
|
||||
SocketOptions::SetRcvBuf (uint32_t size)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
Ptr<Socket> sock = GetObject<Socket> ();
|
||||
sock->SetRcvBuf (size);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
SocketOptions::GetRcvBuf (void) const
|
||||
{
|
||||
return 0;
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
Ptr<Socket> sock = GetObject<Socket> ();
|
||||
return sock->GetRcvBuf ();
|
||||
}
|
||||
|
||||
Socket::Socket (void)
|
||||
|
||||
@@ -28,22 +28,8 @@ TypeId Udp::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::Udp")
|
||||
.SetParent<SocketFactory> ()
|
||||
.AddAttribute ("DefaultRxBufferSize",
|
||||
"Default UDP maximum receive buffer size (bytes)",
|
||||
UintegerValue (0xffffffffl),
|
||||
MakeUintegerAccessor (&Udp::m_defaultRxBuffer),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
Udp::Udp ()
|
||||
{}
|
||||
|
||||
uint32_t
|
||||
Udp::GetDefaultRxBuffer (void) const
|
||||
{
|
||||
return m_defaultRxBuffer;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -44,8 +44,6 @@ class Udp : public SocketFactory
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
Udp ();
|
||||
|
||||
/**
|
||||
* \return smart pointer to Socket
|
||||
*
|
||||
@@ -54,9 +52,6 @@ public:
|
||||
*/
|
||||
virtual Ptr<Socket> CreateSocket (void) = 0;
|
||||
|
||||
uint32_t GetDefaultRxBuffer (void) const;
|
||||
private:
|
||||
uint32_t m_defaultRxBuffer;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -23,6 +23,7 @@ def build(bld):
|
||||
'node-list.cc',
|
||||
'socket.cc',
|
||||
'socket-factory.cc',
|
||||
'socket-defaults.cc',
|
||||
'packet-socket-factory.cc',
|
||||
'packet-socket.cc',
|
||||
'udp.cc',
|
||||
@@ -56,6 +57,7 @@ def build(bld):
|
||||
'node-list.h',
|
||||
'socket.h',
|
||||
'socket-factory.h',
|
||||
'socket-defaults.h',
|
||||
'packet-socket-factory.h',
|
||||
'udp.h',
|
||||
'tcp.h',
|
||||
|
||||
Reference in New Issue
Block a user