fix valgrind warnings for new TCP code
This commit is contained in:
@@ -67,16 +67,22 @@ TcpNewReno::~TcpNewReno (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
TcpNewReno::SetNode (Ptr<Node> node)
|
||||
/** We initialize m_cWnd from this function, after attributes initialized */
|
||||
int
|
||||
TcpNewReno::Listen (void)
|
||||
{
|
||||
TcpSocketBase::SetNode (node);
|
||||
/*
|
||||
* Initialize congestion window, default to 1 MSS (RFC2001, sec.1) and must
|
||||
* not be larger than 2 MSS (RFC2581, sec.3.1). Both m_initiaCWnd and
|
||||
* m_segmentSize are set by the attribute system in ns3::TcpSocket.
|
||||
*/
|
||||
m_cWnd = m_initialCWnd * m_segmentSize;
|
||||
NS_LOG_FUNCTION (this);
|
||||
InitializeCwnd ();
|
||||
return TcpSocketBase::Listen ();
|
||||
}
|
||||
|
||||
/** We initialize m_cWnd from this function, after attributes initialized */
|
||||
int
|
||||
TcpNewReno::Connect (const Address & address)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << address);
|
||||
InitializeCwnd ();
|
||||
return TcpSocketBase::Connect (address);
|
||||
}
|
||||
|
||||
/** Limit the size of in-flight data by cwnd and receiver's rxwin */
|
||||
@@ -189,7 +195,6 @@ TcpNewReno::SetSegSize (uint32_t size)
|
||||
{
|
||||
NS_ABORT_MSG_UNLESS (m_state == CLOSED, "TcpNewReno::SetSegSize() cannot change segment size after connection started.");
|
||||
m_segmentSize = size;
|
||||
m_cWnd = m_initialCWnd * m_segmentSize;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -209,7 +214,6 @@ TcpNewReno::SetInitialCwnd (uint32_t cwnd)
|
||||
{
|
||||
NS_ABORT_MSG_UNLESS (m_state == CLOSED, "TcpNewReno::SetInitialCwnd() cannot change initial cwnd after connection started.");
|
||||
m_initialCWnd = cwnd;
|
||||
m_cWnd = m_initialCWnd * m_segmentSize;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
@@ -218,4 +222,15 @@ TcpNewReno::GetInitialCwnd (void) const
|
||||
return m_initialCWnd;
|
||||
}
|
||||
|
||||
void
|
||||
TcpNewReno::InitializeCwnd (void)
|
||||
{
|
||||
/*
|
||||
* Initialize congestion window, default to 1 MSS (RFC2001, sec.1) and must
|
||||
* not be larger than 2 MSS (RFC2581, sec.3.1). Both m_initiaCWnd and
|
||||
* m_segmentSize are set by the attribute system in ns3::TcpSocket.
|
||||
*/
|
||||
m_cWnd = m_initialCWnd * m_segmentSize;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -44,8 +44,9 @@ public:
|
||||
TcpNewReno (const TcpNewReno& sock);
|
||||
virtual ~TcpNewReno (void);
|
||||
|
||||
// Set associated Node, TcpL4Protocol, RttEstimator to this socket
|
||||
virtual void SetNode (Ptr<Node> node);
|
||||
// From TcpSocketBase
|
||||
virtual int Connect (const Address &address);
|
||||
virtual int Listen (void);
|
||||
|
||||
protected:
|
||||
virtual uint32_t Window (void); // Return the max possible number of unacked bytes
|
||||
@@ -60,6 +61,8 @@ protected:
|
||||
virtual uint32_t GetSSThresh (void) const;
|
||||
virtual void SetInitialCwnd (uint32_t cwnd);
|
||||
virtual uint32_t GetInitialCwnd (void) const;
|
||||
private:
|
||||
void InitializeCwnd (void); // set m_cWnd when connection starts
|
||||
|
||||
protected:
|
||||
TracedValue<uint32_t> m_cWnd; //< Congestion window
|
||||
|
||||
@@ -67,16 +67,22 @@ TcpReno::~TcpReno (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
TcpReno::SetNode (Ptr<Node> node)
|
||||
/** We initialize m_cWnd from this function, after attributes initialized */
|
||||
int
|
||||
TcpReno::Listen (void)
|
||||
{
|
||||
TcpSocketBase::SetNode (node);
|
||||
/*
|
||||
* Initialize congestion window, default to 1 MSS (RFC2001, sec.1) and must
|
||||
* not be larger than 2 MSS (RFC2581, sec.3.1). Both m_initiaCWnd and
|
||||
* m_segmentSize are set by the attribute system in ns3::TcpSocket.
|
||||
*/
|
||||
m_cWnd = m_initialCWnd * m_segmentSize;
|
||||
NS_LOG_FUNCTION (this);
|
||||
InitializeCwnd ();
|
||||
return TcpSocketBase::Listen ();
|
||||
}
|
||||
|
||||
/** We initialize m_cWnd from this function, after attributes initialized */
|
||||
int
|
||||
TcpReno::Connect (const Address & address)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << address);
|
||||
InitializeCwnd ();
|
||||
return TcpSocketBase::Connect (address);
|
||||
}
|
||||
|
||||
/** Limit the size of in-flight data by cwnd and receiver's rxwin */
|
||||
@@ -180,7 +186,6 @@ TcpReno::SetSegSize (uint32_t size)
|
||||
{
|
||||
NS_ABORT_MSG_UNLESS (m_state == CLOSED, "TcpReno::SetSegSize() cannot change segment size after connection started.");
|
||||
m_segmentSize = size;
|
||||
m_cWnd = m_initialCWnd * m_segmentSize;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -200,7 +205,6 @@ TcpReno::SetInitialCwnd (uint32_t cwnd)
|
||||
{
|
||||
NS_ABORT_MSG_UNLESS (m_state == CLOSED, "TcpReno::SetInitialCwnd() cannot change initial cwnd after connection started.");
|
||||
m_initialCWnd = cwnd;
|
||||
m_cWnd = m_initialCWnd * m_segmentSize;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
@@ -209,4 +213,15 @@ TcpReno::GetInitialCwnd (void) const
|
||||
return m_initialCWnd;
|
||||
}
|
||||
|
||||
void
|
||||
TcpReno::InitializeCwnd (void)
|
||||
{
|
||||
/*
|
||||
* Initialize congestion window, default to 1 MSS (RFC2001, sec.1) and must
|
||||
* not be larger than 2 MSS (RFC2581, sec.3.1). Both m_initiaCWnd and
|
||||
* m_segmentSize are set by the attribute system in ns3::TcpSocket.
|
||||
*/
|
||||
m_cWnd = m_initialCWnd * m_segmentSize;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -46,8 +46,9 @@ public:
|
||||
TcpReno (const TcpReno& sock);
|
||||
virtual ~TcpReno (void);
|
||||
|
||||
// Set associated Node, TcpL4Protocol, RttEstimator to this socket
|
||||
virtual void SetNode (Ptr<Node> node);
|
||||
// From TcpSocketBase
|
||||
virtual int Connect (const Address &address);
|
||||
virtual int Listen (void);
|
||||
|
||||
protected:
|
||||
virtual uint32_t Window (void); // Return the max possible number of unacked bytes
|
||||
@@ -62,6 +63,8 @@ protected:
|
||||
virtual uint32_t GetSSThresh (void) const;
|
||||
virtual void SetInitialCwnd (uint32_t cwnd);
|
||||
virtual uint32_t GetInitialCwnd (void) const;
|
||||
private:
|
||||
void InitializeCwnd (void); // set m_cWnd when connection starts
|
||||
|
||||
protected:
|
||||
TracedValue<uint32_t> m_cWnd; //< Congestion window
|
||||
|
||||
@@ -66,16 +66,22 @@ TcpTahoe::~TcpTahoe (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
TcpTahoe::SetNode (Ptr<Node> node)
|
||||
/** We initialize m_cWnd from this function, after attributes initialized */
|
||||
int
|
||||
TcpTahoe::Listen (void)
|
||||
{
|
||||
TcpSocketBase::SetNode (node);
|
||||
/*
|
||||
* Initialize congestion window, default to 1 MSS (RFC2001, sec.1) and must
|
||||
* not be larger than 2 MSS (RFC2581, sec.3.1). Both m_initiaCWnd and
|
||||
* m_segmentSize are set by the attribute system in ns3::TcpSocket.
|
||||
*/
|
||||
m_cWnd = m_initialCWnd * m_segmentSize;
|
||||
NS_LOG_FUNCTION (this);
|
||||
InitializeCwnd ();
|
||||
return TcpSocketBase::Listen ();
|
||||
}
|
||||
|
||||
/** We initialize m_cWnd from this function, after attributes initialized */
|
||||
int
|
||||
TcpTahoe::Connect (const Address & address)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << address);
|
||||
InitializeCwnd ();
|
||||
return TcpSocketBase::Connect (address);
|
||||
}
|
||||
|
||||
/** Limit the size of in-flight data by cwnd and receiver's rxwin */
|
||||
@@ -158,7 +164,6 @@ TcpTahoe::SetSegSize (uint32_t size)
|
||||
{
|
||||
NS_ABORT_MSG_UNLESS (m_state == CLOSED, "TcpTahoe::SetSegSize() cannot change segment size after connection started.");
|
||||
m_segmentSize = size;
|
||||
m_cWnd = m_initialCWnd * m_segmentSize;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -178,7 +183,6 @@ TcpTahoe::SetInitialCwnd (uint32_t cwnd)
|
||||
{
|
||||
NS_ABORT_MSG_UNLESS (m_state == CLOSED, "TcpTahoe::SetInitialCwnd() cannot change initial cwnd after connection started.");
|
||||
m_initialCWnd = cwnd;
|
||||
m_cWnd = m_initialCWnd * m_segmentSize;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
@@ -187,4 +191,15 @@ TcpTahoe::GetInitialCwnd (void) const
|
||||
return m_initialCWnd;
|
||||
}
|
||||
|
||||
void
|
||||
TcpTahoe::InitializeCwnd (void)
|
||||
{
|
||||
/*
|
||||
* Initialize congestion window, default to 1 MSS (RFC2001, sec.1) and must
|
||||
* not be larger than 2 MSS (RFC2581, sec.3.1). Both m_initiaCWnd and
|
||||
* m_segmentSize are set by the attribute system in ns3::TcpSocket.
|
||||
*/
|
||||
m_cWnd = m_initialCWnd * m_segmentSize;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -50,8 +50,9 @@ public:
|
||||
TcpTahoe (const TcpTahoe& sock);
|
||||
virtual ~TcpTahoe (void);
|
||||
|
||||
// Set associated Node, TcpL4Protocol, RttEstimator to this socket
|
||||
virtual void SetNode (Ptr<Node> node);
|
||||
// From TcpSocketBase
|
||||
virtual int Connect (const Address &address);
|
||||
virtual int Listen (void);
|
||||
|
||||
protected:
|
||||
virtual uint32_t Window (void); // Return the max possible number of unacked bytes
|
||||
@@ -66,6 +67,8 @@ protected:
|
||||
virtual uint32_t GetSSThresh (void) const;
|
||||
virtual void SetInitialCwnd (uint32_t cwnd);
|
||||
virtual uint32_t GetInitialCwnd (void) const;
|
||||
private:
|
||||
void InitializeCwnd (void); // set m_cWnd when connection starts
|
||||
|
||||
protected:
|
||||
TracedValue<uint32_t> m_cWnd; //< Congestion window
|
||||
|
||||
@@ -345,14 +345,15 @@ Ns3TcpCwndTestCase1::DoRun (void)
|
||||
// reflecting the change from LARGEST_CWND back to MSS
|
||||
//
|
||||
const uint32_t MSS = 536;
|
||||
const uint32_t N_EVENTS = 20;
|
||||
const uint32_t N_EVENTS = 21;
|
||||
|
||||
CwndEvent event;
|
||||
|
||||
NS_TEST_ASSERT_MSG_EQ (m_responses.GetN (), N_EVENTS, "Unexpectedly low number of cwnd change events");
|
||||
|
||||
|
||||
for (uint32_t i = 0, from = MSS, to = MSS * 2; i < N_EVENTS; ++i, from += MSS, to += MSS)
|
||||
// Ignore the first event logged (i=0) when m_cWnd goes from 0 to MSS bytes
|
||||
for (uint32_t i = 1, from = MSS, to = MSS * 2; i < N_EVENTS; ++i, from += MSS, to += MSS)
|
||||
{
|
||||
event = m_responses.Get (i);
|
||||
NS_TEST_ASSERT_MSG_EQ (event.m_oldCwnd, from, "Wrong old cwnd value in cwnd change event " << i);
|
||||
@@ -507,8 +508,8 @@ Ns3TcpCwndTestCase2::DoRun (void)
|
||||
// the congestion window as it opens up when the ns-3 TCP under test
|
||||
// transmits its bits
|
||||
//
|
||||
// From inspecting the results, we know that we should see 43 congestion
|
||||
// window change events. On the ninth change event, the window should
|
||||
// From inspecting the results, we know that we should see N_EVENTS congestion
|
||||
// window change events. On the tenth change event, the window should
|
||||
// be cut from 5360 to 4288 due to 3 dup acks (NewReno behavior is to
|
||||
// cut in half, and then add 3 segments (5360/2 + 3*536 = 4288)
|
||||
// It should then increment cwnd by one segment per ack throughout
|
||||
@@ -516,16 +517,18 @@ Ns3TcpCwndTestCase2::DoRun (void)
|
||||
// within the fast recovery window (with sequence numbers starting at
|
||||
// 9113, 10721, and 12329). This last segment (12329) is not recovered
|
||||
// by a fast retransmit and consequently, a coarse timeout is taken and
|
||||
// cwnd is reset to MSS at event index 31. It slow starts again, and takes
|
||||
// another fast retransmit at index 41.
|
||||
// cwnd is reset to MSS at event index 32. It slow starts again, and takes
|
||||
// another fast retransmit at index 42.
|
||||
//
|
||||
const uint32_t MSS = 536;
|
||||
const uint32_t N_EVENTS = 44;
|
||||
|
||||
CwndEvent event;
|
||||
|
||||
NS_TEST_ASSERT_MSG_EQ (m_responses.GetN (), 43, "Unexpected number of cwnd change events");
|
||||
NS_TEST_ASSERT_MSG_EQ (m_responses.GetN (), N_EVENTS, "Unexpected number of cwnd change events");
|
||||
|
||||
for (uint32_t i = 0, from = MSS, to = MSS * 2; i < 9; ++i, from += MSS, to += MSS)
|
||||
// Ignore the first event logged (i=0) when m_cWnd goes from 0 to MSS bytes
|
||||
for (uint32_t i = 1, from = MSS, to = MSS * 2; i < 10; ++i, from += MSS, to += MSS)
|
||||
{
|
||||
event = m_responses.Get (i);
|
||||
NS_TEST_ASSERT_MSG_EQ (event.m_oldCwnd, from, "Wrong old cwnd value in cwnd change event " << i);
|
||||
@@ -533,11 +536,11 @@ Ns3TcpCwndTestCase2::DoRun (void)
|
||||
}
|
||||
|
||||
// Cwnd should be back to (10/2 + 3) = 8*MSS
|
||||
event = m_responses.Get (9);
|
||||
NS_TEST_ASSERT_MSG_EQ (event.m_newCwnd, 8*MSS, "Wrong new cwnd value in cwnd change event " << 9);
|
||||
event = m_responses.Get (10);
|
||||
NS_TEST_ASSERT_MSG_EQ (event.m_newCwnd, 8*MSS, "Wrong new cwnd value in cwnd change event " << 10);
|
||||
|
||||
// Fast recovery
|
||||
for (uint32_t i = 10, from = 8*MSS, to = 9 * MSS; i < 31; ++i, from += MSS, to += MSS)
|
||||
for (uint32_t i = 11, from = 8*MSS, to = 9 * MSS; i < 32; ++i, from += MSS, to += MSS)
|
||||
{
|
||||
event = m_responses.Get (i);
|
||||
NS_TEST_ASSERT_MSG_EQ (event.m_oldCwnd, from, "Wrong old cwnd value in cwnd change event " << i);
|
||||
@@ -545,7 +548,7 @@ Ns3TcpCwndTestCase2::DoRun (void)
|
||||
}
|
||||
|
||||
// Slow start again after coarse timeout
|
||||
for (uint32_t i = 32, from = MSS, to = MSS * 2; i < 41; ++i, from += MSS, to += MSS)
|
||||
for (uint32_t i = 33, from = MSS, to = MSS * 2; i < 42; ++i, from += MSS, to += MSS)
|
||||
{
|
||||
event = m_responses.Get (i);
|
||||
NS_TEST_ASSERT_MSG_EQ (event.m_oldCwnd, from, "Wrong old cwnd value in cwnd change event " << i);
|
||||
@@ -553,8 +556,8 @@ Ns3TcpCwndTestCase2::DoRun (void)
|
||||
}
|
||||
|
||||
// Fast retransmit again; cwnd should be back to 8*MSS
|
||||
event = m_responses.Get (41);
|
||||
NS_TEST_ASSERT_MSG_EQ (event.m_newCwnd, 8*MSS, "Wrong new cwnd value in cwnd change event " << 41);
|
||||
event = m_responses.Get (42);
|
||||
NS_TEST_ASSERT_MSG_EQ (event.m_newCwnd, 8*MSS, "Wrong new cwnd value in cwnd change event " << 42);
|
||||
|
||||
return GetErrorStatus ();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user