get rid of DefaultValue usage in internet-node
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
|
||||
#include "rtt-estimator.h"
|
||||
#include "ns3/simulator.h"
|
||||
#include "ns3/type-id-default-value.h"
|
||||
#include "ns3/double.h"
|
||||
|
||||
namespace ns3{
|
||||
|
||||
@@ -40,19 +40,21 @@ TypeId
|
||||
RttEstimator::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("RttEstimator")
|
||||
.SetParent<Object> ();
|
||||
.SetParent<Object> ()
|
||||
.AddAttribute ("MaxMultiplier",
|
||||
"XXX",
|
||||
Double (64.0),
|
||||
MakeDoubleAccessor (&RttEstimator::m_maxMultiplier),
|
||||
MakeDoubleChecker<double> ())
|
||||
.AddAttribute ("InitialEstimation",
|
||||
"XXX",
|
||||
Seconds (1.0),
|
||||
MakeTimeAccessor (&RttEstimator::est),
|
||||
MakeTimeChecker ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
//Default values
|
||||
TypeIdDefaultValue RttEstimator::defaultTid ("RttEstimator",
|
||||
"Tahoe round trip time estimation",
|
||||
RttEstimator::GetTypeId (), "RttMeanDeviation");
|
||||
NumericDefaultValue<double> RttEstimator::defaultMaxMultiplier ("RttMaxMultiplier","",64.0);
|
||||
|
||||
// RttEstimator Static Member variables
|
||||
Time RttEstimator::initialEstimate = Seconds (1.0); // Default initial estimate
|
||||
|
||||
//RttHistory methods
|
||||
RttHistory::RttHistory (SequenceNumber s, uint32_t c, Time t)
|
||||
: seq (s), count (c), time (t), retx (false)
|
||||
@@ -66,7 +68,7 @@ RttHistory::RttHistory (const RttHistory& h)
|
||||
|
||||
// Base class methods
|
||||
|
||||
RttEstimator::RttEstimator () : next (1), history (), est (initialEstimate),
|
||||
RttEstimator::RttEstimator () : next (1), history (),
|
||||
nSamples (0), multiplier (1.0)
|
||||
{
|
||||
//note next=1 everywhere since first segment will have sequence 1
|
||||
@@ -142,7 +144,7 @@ void RttEstimator::ClearSent ()
|
||||
|
||||
void RttEstimator::IncreaseMultiplier ()
|
||||
{
|
||||
multiplier = std::min (multiplier * 2.0, defaultMaxMultiplier.GetValue ());
|
||||
multiplier = std::min (multiplier * 2.0, m_maxMultiplier);
|
||||
}
|
||||
|
||||
void RttEstimator::ResetMultiplier ()
|
||||
@@ -153,24 +155,13 @@ void RttEstimator::ResetMultiplier ()
|
||||
void RttEstimator::Reset ()
|
||||
{ // Reset to initial state
|
||||
next = 1;
|
||||
est = initialEstimate;
|
||||
est = Seconds (1.0); // XXX: we should go back to the 'initial value' here. Need to add support in Object for this.
|
||||
history.clear (); // Remove all info from the history
|
||||
nSamples = 0;
|
||||
ResetMultiplier ();
|
||||
}
|
||||
|
||||
// Base class, static methods
|
||||
void RttEstimator::InitialEstimate (Time e)
|
||||
{ // Set a new default initial estimate
|
||||
initialEstimate = e;
|
||||
}
|
||||
|
||||
Ptr<RttEstimator> RttEstimator::CreateDefault ()
|
||||
{
|
||||
TypeId tid = defaultTid.GetValue ();
|
||||
Ptr<RttEstimator> rtte = tid.CreateObject (0.1, initialEstimate)->GetObject<RttEstimator> ();
|
||||
return rtte;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -183,13 +174,18 @@ RttMeanDeviation::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("RttMeanDeviation")
|
||||
.SetParent<RttEstimator> ()
|
||||
.AddConstructor<RttMeanDeviation, double> ()
|
||||
.AddConstructor<RttMeanDeviation, double, Time> ();
|
||||
.AddConstructor<RttMeanDeviation> ()
|
||||
.AddAttribute ("Gain",
|
||||
"XXX",
|
||||
Double (0.1),
|
||||
MakeDoubleAccessor (&RttMeanDeviation::gain),
|
||||
MakeDoubleChecker<double> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
RttMeanDeviation::RttMeanDeviation(double g) :
|
||||
gain (g), variance (ns3::Seconds(0))
|
||||
RttMeanDeviation::RttMeanDeviation() :
|
||||
variance (ns3::Seconds(0))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -198,11 +194,6 @@ RttMeanDeviation::RttMeanDeviation (const RttMeanDeviation& c)
|
||||
{
|
||||
}
|
||||
|
||||
RttMeanDeviation::RttMeanDeviation (double g, Time e) :
|
||||
RttEstimator (e), gain (g), variance (ns3::Seconds(0))
|
||||
{
|
||||
}
|
||||
|
||||
void RttMeanDeviation::Measurement (Time m)
|
||||
{
|
||||
if (nSamples)
|
||||
|
||||
@@ -71,19 +71,12 @@ public:
|
||||
private:
|
||||
SequenceNumber next; // Next expected sequence to be sent
|
||||
RttHistory_t history; // List of sent packet
|
||||
double m_maxMultiplier;
|
||||
Time m_initialEstimate;
|
||||
public:
|
||||
Time est; // Current estimate
|
||||
uint32_t nSamples;// Number of samples
|
||||
double multiplier; // RTO Multiplier
|
||||
public:
|
||||
static void InitialEstimate(Time);
|
||||
static Ptr<RttEstimator> CreateDefault(); // Retrieve current default
|
||||
|
||||
static TypeIdDefaultValue defaultTid;
|
||||
static NumericDefaultValue<double> defaultMaxMultiplier;
|
||||
|
||||
private:
|
||||
static Time initialEstimate; // Default initial estimate
|
||||
};
|
||||
|
||||
// The "Mean-Deviation" estimator, as discussed by Van Jacobson
|
||||
@@ -96,16 +89,8 @@ class RttMeanDeviation : public RttEstimator {
|
||||
public :
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
//Doc:Desc Constructor for {\tt RttMeanDeviation} specifying the gain factor for the
|
||||
//Doc:Desc estimator.
|
||||
//Doc:Arg1 Gain factor.
|
||||
RttMeanDeviation (double g);
|
||||
RttMeanDeviation ();
|
||||
|
||||
//Doc:Desc Constructor for {\tt RttMeanDeviation} specifying the gain factor
|
||||
//Doc:Desc and the initial estimate.
|
||||
//Doc:Arg1 Gain factor.
|
||||
//Doc:Arg2 Initial estimate.
|
||||
RttMeanDeviation (double g, Time e);
|
||||
|
||||
//Doc:Method
|
||||
RttMeanDeviation (const RttMeanDeviation&); // Copy constructor
|
||||
|
||||
@@ -44,11 +44,10 @@ TcpHeader::TcpHeader ()
|
||||
m_ackNumber (0),
|
||||
m_length (5),
|
||||
m_flags (0),
|
||||
m_windowSize (Tcp::defaultAdvWin.GetValue ()),
|
||||
m_windowSize (0),
|
||||
m_checksum (0),
|
||||
m_urgentPointer (0)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
TcpHeader::~TcpHeader ()
|
||||
{}
|
||||
|
||||
@@ -311,6 +311,14 @@ static TcpStateMachine tcpStateMachine; //only instance of a TcpStateMachine
|
||||
/* see http://www.iana.org/assignments/protocol-numbers */
|
||||
const uint8_t TcpL4Protocol::PROT_NUMBER = 6;
|
||||
|
||||
ObjectFactory
|
||||
TcpL4Protocol::GetDefaultRttEstimatorFactory (void)
|
||||
{
|
||||
ObjectFactory factory;
|
||||
factory.SetTypeId ("RttMeanDeviation");
|
||||
return factory;
|
||||
}
|
||||
|
||||
TypeId
|
||||
TcpL4Protocol::GetTypeId (void)
|
||||
{
|
||||
@@ -321,6 +329,11 @@ TcpL4Protocol::GetTypeId (void)
|
||||
Ptr<Node> (0),
|
||||
MakePtrAccessor (&TcpL4Protocol::m_node),
|
||||
MakePtrChecker<Node> ())
|
||||
.AddAttribute ("RttEstimatorFactory",
|
||||
"How RttEstimator objects are created.",
|
||||
GetDefaultRttEstimatorFactory (),
|
||||
MakeObjectFactoryAccessor (&TcpL4Protocol::m_rttFactory),
|
||||
MakeObjectFactoryChecker ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
@@ -365,7 +378,8 @@ Ptr<Socket>
|
||||
TcpL4Protocol::CreateSocket (void)
|
||||
{
|
||||
NS_LOG_FUNCTION;
|
||||
Ptr<Socket> socket = Create<TcpSocket> (m_node, this);
|
||||
Ptr<RttEstimator> rtt = m_rttFactory.Create<RttEstimator> ();
|
||||
Ptr<Socket> socket = CreateObject<TcpSocket> (m_node, this, rtt);
|
||||
return socket;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "ns3/packet.h"
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include "ns3/ptr.h"
|
||||
#include "ns3/object-factory.h"
|
||||
#include "ipv4-end-point-demux.h"
|
||||
#include "ipv4-l4-protocol.h"
|
||||
#include "ipv4-interface.h"
|
||||
@@ -103,10 +104,12 @@ protected:
|
||||
private:
|
||||
Ptr<Node> m_node;
|
||||
Ipv4EndPointDemux *m_endPoints;
|
||||
ObjectFactory m_rttFactory;
|
||||
private:
|
||||
friend class TcpSocket;
|
||||
void SendPacket (Ptr<Packet>, TcpHeader,
|
||||
Ipv4Address, Ipv4Address);
|
||||
static ObjectFactory GetDefaultRttEstimatorFactory (void);
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "tcp-typedefs.h"
|
||||
#include "ns3/simulator.h"
|
||||
#include "ns3/packet.h"
|
||||
#include "ns3/default-value.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -41,7 +40,7 @@ using namespace std;
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
TcpSocket::TcpSocket (Ptr<Node> node, Ptr<TcpL4Protocol> tcp)
|
||||
TcpSocket::TcpSocket (Ptr<Node> node, Ptr<TcpL4Protocol> tcp, Ptr<RttEstimator> rtt)
|
||||
: m_skipRetxResched (false),
|
||||
m_dupAckCount (0),
|
||||
m_endPoint (0),
|
||||
@@ -62,19 +61,22 @@ TcpSocket::TcpSocket (Ptr<Node> node, Ptr<TcpL4Protocol> tcp)
|
||||
m_lastRxAck (0),
|
||||
m_nextRxSequence (0),
|
||||
m_pendingData (0),
|
||||
m_segmentSize (Tcp::defaultSegSize.GetValue()),
|
||||
m_rxWindowSize (Tcp::defaultAdvWin.GetValue()),
|
||||
m_advertisedWindowSize (Tcp::defaultAdvWin.GetValue()),
|
||||
m_cWnd (Tcp::defaultInitialCWnd.GetValue() * m_segmentSize),
|
||||
m_ssThresh (Tcp::defaultSSThresh.GetValue()),
|
||||
m_initialCWnd (Tcp::defaultInitialCWnd.GetValue()),
|
||||
m_rtt (RttEstimator::CreateDefault()),
|
||||
m_lastMeasuredRtt (Seconds(0.0)),
|
||||
m_cnTimeout (Seconds (Tcp::defaultConnTimeout.GetValue ())),
|
||||
m_cnCount (Tcp::defaultConnCount.GetValue ())
|
||||
m_rtt (rtt),
|
||||
m_lastMeasuredRtt (Seconds(0.0))
|
||||
{
|
||||
NS_LOG_FUNCTION;
|
||||
NS_LOG_PARAMS (this<<node<<tcp);
|
||||
|
||||
Ptr<Tcp> t = node->GetObject<Tcp> ();
|
||||
m_segmentSize = t->GetDefaultSegSize ();
|
||||
m_rxWindowSize = t->GetDefaultAdvWin ();
|
||||
m_advertisedWindowSize = t->GetDefaultAdvWin ();
|
||||
m_cWnd = t->GetDefaultInitialCwnd () * m_segmentSize;
|
||||
m_ssThresh = t->GetDefaultSsThresh ();
|
||||
m_initialCWnd = t->GetDefaultInitialCwnd ();
|
||||
m_cnTimeout = Seconds (t->GetDefaultConnTimeout ());
|
||||
m_cnCount = t->GetDefaultConnCount ();
|
||||
|
||||
}
|
||||
|
||||
TcpSocket::~TcpSocket ()
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
/**
|
||||
* Create an unbound tcp socket.
|
||||
*/
|
||||
TcpSocket (Ptr<Node> node, Ptr<TcpL4Protocol> tcp);
|
||||
TcpSocket (Ptr<Node> node, Ptr<TcpL4Protocol> tcp, Ptr<RttEstimator> rtt);
|
||||
virtual ~TcpSocket ();
|
||||
|
||||
virtual enum SocketErrno GetErrno (void) const;
|
||||
|
||||
124
src/node/tcp.cc
124
src/node/tcp.cc
@@ -18,58 +18,100 @@
|
||||
* Author: Raj Bhattacharjea <raj.b@gatech.edu>
|
||||
*/
|
||||
#include "tcp.h"
|
||||
#include "ns3/uinteger.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NumericDefaultValue<uint32_t> Tcp::defaultSegSize
|
||||
("TcpDefaultSegmentSize",
|
||||
"Default TCP maximum segment size in bytes (may be adjusted based on MTU discovery)",
|
||||
536);
|
||||
|
||||
NumericDefaultValue<uint32_t> Tcp::defaultAdvWin
|
||||
("TcpDefaultAdvertisedWindowSize",
|
||||
"Default TCP advertised window size (bytes)",
|
||||
0xffff);
|
||||
|
||||
NumericDefaultValue<uint32_t> Tcp::defaultSSThresh
|
||||
("TcpDefaultSlowStartThreshold",
|
||||
"Default TCP slow start threshold (bytes)",
|
||||
0xffff);
|
||||
|
||||
NumericDefaultValue<uint32_t> Tcp::defaultTxBuffer
|
||||
("TcpDefaultTxBufferSize",
|
||||
"Default TCP maximum transmit buffer size (bytes)",
|
||||
0xffffffffl);
|
||||
|
||||
NumericDefaultValue<uint32_t> Tcp::defaultRxBuffer
|
||||
("TcpDefaultRxBufferSize",
|
||||
"Default TCP maximum receive buffer size (bytes)",
|
||||
0xffffffffl);
|
||||
|
||||
NumericDefaultValue<uint32_t> Tcp::defaultInitialCWnd
|
||||
("TcpDefaultInitialCongestionWindowSize",
|
||||
"Default TCP initial congestion window size (segments)",
|
||||
1);
|
||||
|
||||
NumericDefaultValue<uint32_t> Tcp::defaultConnTimeout
|
||||
("TcpDefaultConnTimeout",
|
||||
"Default TCP retransmission timeout when opening connection (seconds)",
|
||||
3);
|
||||
|
||||
NumericDefaultValue<uint32_t> Tcp::defaultConnCount
|
||||
("TcpDefaultConnCount",
|
||||
"Default number of connection attempts (SYN retransmissions) before returning failure",
|
||||
6);
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (Tcp);
|
||||
|
||||
TypeId
|
||||
Tcp::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("Tcp")
|
||||
.SetParent<SocketFactory> ();
|
||||
.SetParent<SocketFactory> ()
|
||||
.AddAttribute ("TcpDefaultSegmentSize",
|
||||
"Default TCP maximum segment size in bytes (may be adjusted based on MTU discovery)",
|
||||
Uinteger (536),
|
||||
MakeUintegerAccessor (&Tcp::m_defaultSegSize),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("TcpDefaultAdvertisedWindowSize",
|
||||
"Default TCP advertised window size (bytes)",
|
||||
Uinteger (0xffff),
|
||||
MakeUintegerAccessor (&Tcp::m_defaultAdvWin),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("TcpDefaultSlowStartThreshold",
|
||||
"Default TCP slow start threshold (bytes)",
|
||||
Uinteger (0xffff),
|
||||
MakeUintegerAccessor (&Tcp::m_defaultSsThresh),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("TcpDefaultTxBufferSize",
|
||||
"Default TCP maximum transmit buffer size (bytes)",
|
||||
Uinteger (0xffffffffl),
|
||||
MakeUintegerAccessor (&Tcp::m_defaultTxBuffer),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("TcpDefaultRxBufferSize",
|
||||
"Default TCP maximum receive buffer size (bytes)",
|
||||
Uinteger (0xffffffffl),
|
||||
MakeUintegerAccessor (&Tcp::m_defaultRxBuffer),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("TcpDefaultInitialCongestionWindowSize",
|
||||
"Default TCP initial congestion window size (segments)",
|
||||
Uinteger (1),
|
||||
MakeUintegerAccessor (&Tcp::m_defaultInitialCwnd),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("TcpDefaultConnTimeout",
|
||||
"Default TCP retransmission timeout when opening connection (seconds)",
|
||||
Uinteger (3),
|
||||
MakeUintegerAccessor (&Tcp::m_defaultConnTimeout),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("TcpDefaultConnCount",
|
||||
"Default number of connection attempts (SYN retransmissions) before returning failure",
|
||||
Uinteger (6),
|
||||
MakeUintegerAccessor (&Tcp::m_defaultConnCount),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Tcp::GetDefaultSegSize (void) const
|
||||
{
|
||||
return m_defaultSegSize;
|
||||
}
|
||||
uint32_t
|
||||
Tcp::GetDefaultAdvWin (void) const
|
||||
{
|
||||
return m_defaultAdvWin;
|
||||
}
|
||||
uint32_t
|
||||
Tcp::GetDefaultSsThresh (void) const
|
||||
{
|
||||
return m_defaultSsThresh;
|
||||
}
|
||||
uint32_t
|
||||
Tcp::GetDefaultTxBuffer (void) const
|
||||
{
|
||||
return m_defaultTxBuffer;
|
||||
}
|
||||
uint32_t
|
||||
Tcp::GetDefaultRxBuffer (void) const
|
||||
{
|
||||
return m_defaultRxBuffer;
|
||||
}
|
||||
uint32_t
|
||||
Tcp::GetDefaultInitialCwnd (void) const
|
||||
{
|
||||
return m_defaultInitialCwnd;
|
||||
}
|
||||
uint32_t
|
||||
Tcp::GetDefaultConnTimeout (void) const
|
||||
{
|
||||
return m_defaultConnTimeout;
|
||||
}
|
||||
uint32_t
|
||||
Tcp::GetDefaultConnCount (void) const
|
||||
{
|
||||
return m_defaultConnCount;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#ifndef TCP_H
|
||||
#define TCP_H
|
||||
|
||||
#include "ns3/default-value.h"
|
||||
#include "socket-factory.h"
|
||||
|
||||
namespace ns3 {
|
||||
@@ -48,18 +47,26 @@ public:
|
||||
|
||||
virtual Ptr<Socket> CreateSocket (void) = 0;
|
||||
|
||||
public:
|
||||
static NumericDefaultValue<uint32_t> defaultSegSize;
|
||||
static NumericDefaultValue<uint32_t> defaultAdvWin;
|
||||
static NumericDefaultValue<uint32_t> defaultSSThresh;
|
||||
static NumericDefaultValue<uint32_t> defaultTxBuffer;
|
||||
static NumericDefaultValue<uint32_t> defaultRxBuffer;
|
||||
static NumericDefaultValue<uint32_t> defaultInitialCWnd;
|
||||
static NumericDefaultValue<uint32_t> defaultConnTimeout;
|
||||
static NumericDefaultValue<uint32_t> defaultConnCount;
|
||||
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;
|
||||
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;
|
||||
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* UDP_H */
|
||||
#endif /* TCP_H */
|
||||
|
||||
Reference in New Issue
Block a user