Move Tcp attributes from factory to TcpSocket

This commit is contained in:
Tom Henderson
2008-05-21 00:38:49 -07:00
parent ef99300eff
commit 72d054a867
8 changed files with 234 additions and 208 deletions

View File

@@ -30,111 +30,8 @@ TcpSocketFactory::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::TcpSocketFactory")
.SetParent<SocketFactory> ()
.AddAttribute ("DefaultSegmentSize",
"Default TCP maximum segment size in bytes (may be adjusted based on MTU discovery)",
UintegerValue (536),
MakeUintegerAccessor (&TcpSocketFactory::m_defaultSegSize),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("DefaultAdvertisedWindowSize",
"Default TCP advertised window size (bytes)",
UintegerValue (0xffff),
MakeUintegerAccessor (&TcpSocketFactory::m_defaultAdvWin),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("DefaultSlowStartThreshold",
"Default TCP slow start threshold (bytes)",
UintegerValue (0xffff),
MakeUintegerAccessor (&TcpSocketFactory::m_defaultSsThresh),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("DefaultTxBufferSize",
"Default TCP maximum transmit buffer size (bytes)",
UintegerValue (0xffffffffl),
MakeUintegerAccessor (&TcpSocketFactory::m_defaultTxBuffer),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("DefaultRxBufferSize",
"Default TCP maximum receive buffer size (bytes)",
UintegerValue (0xffffffffl),
MakeUintegerAccessor (&TcpSocketFactory::m_defaultRxBuffer),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("DefaultInitialCongestionWindowSize",
"Default TCP initial congestion window size (segments)",
UintegerValue (1),
MakeUintegerAccessor (&TcpSocketFactory::m_defaultInitialCwnd),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("DefaultConnTimeout",
"Default TCP retransmission timeout when opening connection (seconds)",
UintegerValue (3),
MakeUintegerAccessor (&TcpSocketFactory::m_defaultConnTimeout),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("DefaultConnCount",
"Default number of connection attempts (SYN retransmissions) before returning failure",
UintegerValue (6),
MakeUintegerAccessor (&TcpSocketFactory::m_defaultConnCount),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("DefaultDelAckTimeout",
"Default timeout value for TCP delayed acks, in seconds",
DoubleValue (0.2),
MakeDoubleAccessor (&TcpSocketFactory::m_defaultDelAckTimeout),
MakeDoubleChecker<double> ())
.AddAttribute ("DefaultDelAckCount",
"Default number of packets to wait before sending a TCP ack",
UintegerValue (2),
MakeUintegerAccessor (&TcpSocketFactory::m_defaultDelAckCount),
MakeUintegerChecker<uint32_t> ())
;
;
return tid;
}
uint32_t
TcpSocketFactory::GetDefaultSegSize (void) const
{
return m_defaultSegSize;
}
uint32_t
TcpSocketFactory::GetDefaultAdvWin (void) const
{
return m_defaultAdvWin;
}
uint32_t
TcpSocketFactory::GetDefaultSsThresh (void) const
{
return m_defaultSsThresh;
}
uint32_t
TcpSocketFactory::GetDefaultTxBuffer (void) const
{
return m_defaultTxBuffer;
}
uint32_t
TcpSocketFactory::GetDefaultRxBuffer (void) const
{
return m_defaultRxBuffer;
}
uint32_t
TcpSocketFactory::GetDefaultInitialCwnd (void) const
{
return m_defaultInitialCwnd;
}
uint32_t
TcpSocketFactory::GetDefaultConnTimeout (void) const
{
return m_defaultConnTimeout;
}
uint32_t
TcpSocketFactory::GetDefaultConnCount (void) const
{
return m_defaultConnCount;
}
double
TcpSocketFactory::GetDefaultDelAckTimeout (void) const
{
return m_defaultDelAckTimeout;
}
uint32_t
TcpSocketFactory::GetDefaultDelAckCount (void) const
{
return m_defaultDelAckCount;
}
} // namespace ns3

View File

@@ -48,29 +48,6 @@ public:
virtual Ptr<Socket> CreateSocket (void) = 0;
uint32_t GetDefaultSegSize (void) const;
uint32_t GetDefaultAdvWin (void) const;
uint32_t GetDefaultSsThresh (void) const;
uint32_t GetDefaultTxBuffer (void) const;
uint32_t GetDefaultRxBuffer (void) const;
uint32_t GetDefaultInitialCwnd (void) const;
uint32_t GetDefaultConnTimeout (void) const;
uint32_t GetDefaultConnCount (void) const;
double GetDefaultDelAckTimeout (void) const;
uint32_t GetDefaultDelAckCount (void) const;
private:
uint32_t m_defaultSegSize;
uint32_t m_defaultAdvWin;
uint32_t m_defaultSsThresh;
uint32_t m_defaultTxBuffer;
uint32_t m_defaultRxBuffer;
uint32_t m_defaultInitialCwnd;
uint32_t m_defaultConnTimeout;
uint32_t m_defaultConnCount;
double m_defaultDelAckTimeout;
uint32_t m_defaultDelAckCount;
};
} // namespace ns3

View File

@@ -21,7 +21,9 @@
#include "ns3/object.h"
#include "ns3/log.h"
#include "ns3/uinteger.h"
#include "ns3/double.h"
#include "ns3/trace-source-accessor.h"
#include "ns3/nstime.h"
#include "tcp-socket.h"
NS_LOG_COMPONENT_DEFINE ("TcpSocket");
@@ -35,26 +37,66 @@ TcpSocket::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::TcpSocket")
.SetParent<Socket> ()
#if 0
.AddAttribute ("SndBufSize",
"TcpSocket maximum transmit buffer size (bytes)",
UintegerValue (0xffffffffl),
MakeUintegerAccessor (&TcpSocket::GetSndBufSize,
&TcpSocket::SetSndBufSize),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("RcvBufSize",
"TcpSocket maximum receive buffer size (bytes)",
UintegerValue (0xffffffffl),
MakeUintegerAccessor (&TcpSocket::GetRcvBufSize,
&TcpSocket::SetRcvBufSize),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("IpTtl",
"socket-specific TTL for unicast IP packets (if non-zero)",
UintegerValue (0),
MakeUintegerAccessor (&TcpSocket::GetIpTtl,
&TcpSocket::SetIpTtl),
.AddAttribute ("SegmentSize",
"TCP maximum segment size in bytes (may be adjusted based on MTU discovery)",
UintegerValue (536),
MakeUintegerAccessor (&TcpSocket::GetSegSize,
&TcpSocket::SetSegSize),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("IpMulticastTtl",
"socket-specific TTL for multicast IP packets (if non-zero)",
UintegerValue (0),
MakeUintegerAccessor (&TcpSocket::GetIpMulticastTtl,
&TcpSocket::SetIpMulticastTtl),
.AddAttribute ("AdvertisedWindowSize",
"TCP advertised window size (bytes)",
UintegerValue (0xffff),
MakeUintegerAccessor (&TcpSocket::GetAdvWin,
&TcpSocket::SetAdvWin),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("SlowStartThreshold",
"TCP slow start threshold (bytes)",
UintegerValue (0xffff),
MakeUintegerAccessor (&TcpSocket::GetSSThresh,
&TcpSocket::SetSSThresh),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("InitialCwnd",
"TCP initial congestion window size (segments)",
UintegerValue (1),
MakeUintegerAccessor (&TcpSocket::GetInitialCwnd,
&TcpSocket::SetInitialCwnd),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("ConnTimeout",
"TCP retransmission timeout when opening connection (seconds)",
TimeValue (Seconds (3)),
MakeTimeAccessor (&TcpSocket::GetConnTimeout,
&TcpSocket::SetConnTimeout),
MakeTimeChecker ())
.AddAttribute ("ConnCount",
"Number of connection attempts (SYN retransmissions) before returning failure",
UintegerValue (6),
MakeUintegerAccessor (&TcpSocket::GetConnCount,
&TcpSocket::SetConnCount),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("DelAckTimeout",
"Timeout value for TCP delayed acks, in seconds",
TimeValue (Seconds (0.2)),
MakeTimeAccessor (&TcpSocket::GetDelAckTimeout,
&TcpSocket::SetDelAckTimeout),
MakeTimeChecker ())
.AddAttribute ("DelAckCount",
"Number of packets to wait before sending a TCP ack",
UintegerValue (2),
MakeUintegerAccessor (&TcpSocket::GetDelAckMaxCount,
&TcpSocket::SetDelAckMaxCount),
MakeUintegerChecker<uint32_t> ())
#endif
;
return tid;
}

View File

@@ -28,6 +28,7 @@
#include "ns3/callback.h"
#include "ns3/ptr.h"
#include "ns3/object.h"
#include "ns3/nstime.h"
namespace ns3 {
@@ -61,16 +62,28 @@ public:
virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags) = 0;
virtual uint32_t GetRxAvailable (void) const = 0;
public:
#if 0
private:
// Indirect the attribute setting and getting through private virtual methods
virtual void SetSndBufSize (uint32_t size) = 0;
virtual uint32_t GetSndBufSize (void) const = 0;
virtual void SetRcvBufSize (uint32_t size) = 0;
virtual uint32_t GetRcvBufSize (void) const = 0;
virtual void SetIpTtl (uint32_t ipTtl) = 0;
virtual uint32_t GetIpTtl (void) const = 0;
virtual void SetIpMulticastTtl (uint32_t ipTtl) = 0;
virtual uint32_t GetIpMulticastTtl (void) const = 0;
#endif
virtual void SetSegSize (uint32_t size) = 0;
virtual uint32_t GetSegSize (void) const = 0;
virtual void SetAdvWin (uint32_t window) = 0;
virtual uint32_t GetAdvWin (void) const = 0;
virtual void SetSSThresh (uint32_t threshold) = 0;
virtual uint32_t GetSSThresh (void) const = 0;
virtual void SetInitialCwnd (uint32_t count) = 0;
virtual uint32_t GetInitialCwnd (void) const = 0;
virtual void SetConnTimeout (Time timeout) = 0;
virtual Time GetConnTimeout (void) const = 0;
virtual void SetConnCount (uint32_t count) = 0;
virtual uint32_t GetConnCount (void) const = 0;
virtual void SetDelAckTimeout (Time timeout) = 0;
virtual Time GetDelAckTimeout (void) const = 0;
virtual void SetDelAckMaxCount (uint32_t count) = 0;
virtual uint32_t GetDelAckMaxCount (void) const = 0;
};

View File

@@ -61,7 +61,7 @@ public:
virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags) = 0;
virtual uint32_t GetRxAvailable (void) const = 0;
public:
private:
// Indirect the attribute setting and getting through private virtual methods
virtual void SetRcvBufSize (uint32_t size) = 0;
virtual uint32_t GetRcvBufSize (void) const = 0;