tcp: Corrected VS warnings, patch based on Robert's patch

This commit is contained in:
Natale Patriciello
2018-02-25 11:34:13 +01:00
parent 7552517ba1
commit 6a2611466e
20 changed files with 88 additions and 119 deletions

View File

@@ -18,7 +18,6 @@
*/
#include "tcp-bic.h"
#include "ns3/log.h"
#include "ns3/tcp-socket-base.h"
namespace ns3 {
@@ -52,9 +51,9 @@ TcpBic::GetTypeId (void)
"cWnd_max-BinarySearchCoefficient. It can be viewed as the gradient "
"of the slow start AIM phase: less this value is, "
"more steep the increment will be.",
IntegerValue (5),
MakeIntegerAccessor (&TcpBic::m_smoothPart),
MakeIntegerChecker <int> (1))
UintegerValue (5),
MakeUintegerAccessor (&TcpBic::m_smoothPart),
MakeUintegerChecker <uint32_t> (1))
.AddAttribute ("BinarySearchCoefficient", "Inverse of the coefficient for the "
"binary search. Default 4, as in Linux",
UintegerValue (4),
@@ -178,7 +177,7 @@ TcpBic::Update (Ptr<TcpSocketState> tcb)
else
{
/* binary search increase */
cnt = segCwnd / dist;
cnt = static_cast<uint32_t> (segCwnd / dist);
NS_LOG_INFO ("Binary search increase, cnt=" << cnt);
}
@@ -249,8 +248,8 @@ TcpBic::GetSsThresh (Ptr<const TcpSocketState> tcb, uint32_t bytesInFlight)
if (segCwnd < m_lastMaxCwnd && m_fastConvergence)
{
NS_LOG_INFO ("Fast Convergence. Last max cwnd: " << m_lastMaxCwnd <<
" updated to " << (uint32_t) m_beta * segCwnd);
m_lastMaxCwnd = m_beta * segCwnd;
" updated to " << static_cast<uint32_t> (m_beta * segCwnd));
m_lastMaxCwnd = static_cast<uint32_t> (m_beta * segCwnd);
}
else
{
@@ -266,7 +265,7 @@ TcpBic::GetSsThresh (Ptr<const TcpSocketState> tcb, uint32_t bytesInFlight)
}
else
{
ssThresh = std::max (segCwnd * m_beta, 2.0) * tcb->m_segmentSize;
ssThresh = static_cast<uint32_t> (std::max (segCwnd * m_beta, 2.0) * tcb->m_segmentSize);
NS_LOG_INFO ("More than lowWindow, ssTh= " << ssThresh);
}

View File

@@ -21,7 +21,6 @@
#define TCPBIC_H
#include "ns3/tcp-congestion-ops.h"
#include "ns3/traced-value.h"
class TcpBicIncrementTest;
class TcpBicDecrementTest;
@@ -131,7 +130,7 @@ private:
double m_beta; //!< Beta for cubic multiplicative increase
uint32_t m_maxIncr; //!< Maximum window increment
uint32_t m_lowWnd; //!< Lower bound on congestion window
int m_smoothPart; //!< Number of RTT needed to reach Wmax from Wmax-B
uint32_t m_smoothPart; //!< Number of RTT needed to reach Wmax from Wmax-B
// Bic parameters
uint32_t m_cWndCnt; //!< cWnd integer-to-float counter

View File

@@ -19,8 +19,6 @@
#ifndef TCPCONGESTIONOPS_H
#define TCPCONGESTIONOPS_H
#include "ns3/object.h"
#include "ns3/timer.h"
#include "ns3/tcp-socket-base.h"
namespace ns3 {
@@ -120,6 +118,9 @@ public:
virtual void PktsAcked (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked,
const Time& rtt)
{
NS_UNUSED (tcb);
NS_UNUSED (segmentsAcked);
NS_UNUSED (rtt);
}
/**
@@ -134,6 +135,8 @@ public:
virtual void CongestionStateSet (Ptr<TcpSocketState> tcb,
const TcpSocketState::TcpCongState_t newState)
{
NS_UNUSED (tcb);
NS_UNUSED (newState);
}
/**
@@ -148,6 +151,8 @@ public:
virtual void CwndEvent (Ptr<TcpSocketState> tcb,
const TcpSocketState::TcpCAEvent_t event)
{
NS_UNUSED (tcb);
NS_UNUSED (event);
}
// Present in Linux but not in ns-3 yet:
/* call when ack arrives (optional) */

View File

@@ -18,7 +18,6 @@
*/
#include "tcp-highspeed.h"
#include "ns3/tcp-socket-base.h"
#include "ns3/log.h"
namespace ns3 {
@@ -39,14 +38,14 @@ TcpHighSpeed::GetTypeId (void)
TcpHighSpeed::TcpHighSpeed (void)
: TcpNewReno (),
m_ackCnt (0)
m_ackCnt (0)
{
NS_LOG_FUNCTION (this);
}
TcpHighSpeed::TcpHighSpeed (const TcpHighSpeed& sock)
: TcpNewReno (sock),
m_ackCnt (sock.m_ackCnt)
m_ackCnt (sock.m_ackCnt)
{
NS_LOG_FUNCTION (this);
}
@@ -145,7 +144,7 @@ TcpHighSpeed::GetSsThresh (Ptr<const TcpSocketState> tcb,
uint32_t segCwnd = bytesInFlight / tcb->m_segmentSize;
double b = 1.0 - TableLookupB (segCwnd);
uint32_t ssThresh = std::max (2.0, segCwnd * b);
uint32_t ssThresh = static_cast<uint32_t> (std::max (2.0, segCwnd * b));
NS_LOG_DEBUG ("Calculated b(w) = " << b <<
" resulting (in segment) ssThresh=" << ssThresh);

View File

@@ -25,17 +25,7 @@
*/
#include "tcp-htcp.h"
#include "ns3/log.h"
#include "ns3/trace-source-accessor.h"
#include "ns3/simulator.h"
#include "ns3/abort.h"
#include "ns3/node.h"
#include "math.h"
#include "ns3/tcp-socket-base.h"
#include "ns3/sequence-number.h"
#include "ns3/double.h"
#include "ns3/nstime.h"
namespace ns3 {
@@ -186,7 +176,7 @@ uint32_t TcpHtcp::GetSsThresh (Ptr<const TcpSocketState> tcb,
UpdateAlpha ();
uint32_t segWin = 2 * tcb->m_segmentSize;
uint32_t bFlight = bytesInFlight * m_beta;
uint32_t bFlight = static_cast<uint32_t> (bytesInFlight * m_beta);
uint32_t ssThresh = std::max (segWin, bFlight);
m_minRtt = Time::Max ();
m_maxRtt = Time::Min ();
@@ -208,8 +198,8 @@ void TcpHtcp::PktsAcked (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked,
m_dataSent += segmentsAcked * tcb->m_segmentSize;
}
m_throughput = m_dataSent
/ (Simulator::Now ().GetSeconds () - m_lastCon.GetSeconds ());
m_throughput = static_cast<uint32_t> (m_dataSent
/ (Simulator::Now ().GetSeconds () - m_lastCon.GetSeconds ()));
UpdateAlpha ();
if (rtt < m_minRtt)

View File

@@ -28,8 +28,6 @@
#define TCP_HTCP_H
#include "ns3/tcp-congestion-ops.h"
#include "ns3/traced-value.h"
#include "ns3/sequence-number.h"
namespace ns3 {

View File

@@ -27,7 +27,6 @@
#include "tcp-illinois.h"
#include "ns3/tcp-socket-base.h"
#include "ns3/log.h"
namespace ns3 {
@@ -243,7 +242,7 @@ TcpIllinois::GetSsThresh (Ptr<const TcpSocketState> tcb, uint32_t bytesInFlight)
NS_LOG_FUNCTION (this << tcb << bytesInFlight);
uint32_t segBytesInFlight = bytesInFlight / tcb->m_segmentSize;
uint32_t ssThresh = std::max (2.0, (1.0 - m_beta) * segBytesInFlight);
uint32_t ssThresh = static_cast<uint32_t> (std::max (2.0, (1.0 - m_beta) * segBytesInFlight));
NS_LOG_DEBUG ("Calculated ssThresh (in segments) = " << ssThresh);

View File

@@ -20,7 +20,6 @@
*/
#include "tcp-ledbat.h"
#include "ns3/tcp-socket-base.h"
#include "ns3/log.h"
namespace ns3 {
@@ -140,7 +139,7 @@ uint32_t TcpLedbat::MinCircBuf (struct OwdCircBuf &b)
NS_LOG_FUNCTION_NOARGS ();
if (b.buffer.size () == 0)
{
return ~0;
return ~0U;
}
else
{
@@ -160,15 +159,6 @@ uint32_t TcpLedbat::BaseDelay ()
return MinCircBuf (m_baseHistory);
}
uint32_t TcpLedbat::GetSsThresh (Ptr<const TcpSocketState> tcb,
uint32_t bytesInFlight)
{
NS_LOG_FUNCTION (this << tcb << bytesInFlight);
uint32_t res;
res = TcpNewReno::GetSsThresh (tcb, bytesInFlight);
return res;
}
void TcpLedbat::IncreaseWindow (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked)
{
NS_LOG_FUNCTION (this << tcb << segmentsAcked);
@@ -204,20 +194,20 @@ void TcpLedbat::CongestionAvoidance (Ptr<TcpSocketState> tcb, uint32_t segmentsA
if (current_delay > base_delay)
{
queue_delay = current_delay - base_delay;
queue_delay = static_cast<int64_t> (current_delay - base_delay);
offset = m_target.GetMilliSeconds () - queue_delay;
}
else
{
queue_delay = base_delay - current_delay;
queue_delay = static_cast<int64_t> (base_delay - current_delay);
offset = m_target.GetMilliSeconds () + queue_delay;
}
offset *= m_gain;
m_sndCwndCnt = offset * segmentsAcked * tcb->m_segmentSize;
m_sndCwndCnt = static_cast<int32_t> (offset * segmentsAcked * tcb->m_segmentSize);
double inc = (m_sndCwndCnt * 1.0) / (m_target.GetMilliSeconds () * tcb->m_cWnd.Get ());
cwnd += (inc * tcb->m_segmentSize);
max_cwnd = (tcb->m_highTxMark.Get () - tcb->m_lastAckedSeq) + segmentsAcked * tcb->m_segmentSize;
max_cwnd = static_cast<uint32_t>(tcb->m_highTxMark.Get () - tcb->m_lastAckedSeq) + segmentsAcked * tcb->m_segmentSize;
cwnd = std::min (cwnd, max_cwnd);
cwnd = std::max (cwnd, tcb->m_segmentSize);
tcb->m_cWnd = cwnd;
@@ -241,7 +231,7 @@ void TcpLedbat::AddDelay (struct OwdCircBuf &cb, uint32_t owd, uint32_t maxlen)
cb.buffer.push_back (owd);
if (cb.buffer[cb.min] > owd)
{
cb.min = cb.buffer.size () - 1;
cb.min = static_cast<uint32_t> (cb.buffer.size () - 1);
}
if (cb.buffer.size () >= maxlen)
{
@@ -267,7 +257,7 @@ void TcpLedbat::UpdateBaseDelay (uint32_t owd)
AddDelay (m_baseHistory, owd, m_baseHistoLen);
return;
}
uint64_t timestamp = (uint64_t) Simulator::Now ().GetSeconds ();
uint64_t timestamp = static_cast<uint64_t> (Simulator::Now ().GetSeconds ());
if (timestamp - m_lastRollover > 60)
{
@@ -276,7 +266,7 @@ void TcpLedbat::UpdateBaseDelay (uint32_t owd)
}
else
{
uint32_t last = m_baseHistory.buffer.size () - 1;
uint32_t last = static_cast<uint32_t> (m_baseHistory.buffer.size () - 1);
if (owd < m_baseHistory.buffer[last])
{
m_baseHistory.buffer[last] = owd;
@@ -306,4 +296,5 @@ void TcpLedbat::PktsAcked (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked,
UpdateBaseDelay (tcb->m_rcvTimestampValue - tcb->m_rcvTimestampEchoReply);
}
}
}
} // namespace ns3

View File

@@ -24,7 +24,6 @@
#include <vector>
#include "ns3/tcp-congestion-ops.h"
#include "ns3/event-id.h"
namespace ns3 {
@@ -50,7 +49,7 @@ private:
* \brief The state of LEDBAT. If LEDBAT is not in VALID_OWD state, it falls to
* default congestion ops.
*/
enum State
enum State : uint32_t
{
LEDBAT_VALID_OWD = (1 << 1), //!< If valid timestamps are present
LEDBAT_CAN_SS = (1 << 3) //!< If LEDBAT allows Slow Start
@@ -96,16 +95,7 @@ public:
virtual void PktsAcked (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked,
const Time& rtt);
/**
* \brief Get the slow start threshold
*
* \param tcb internal congestion state
* \param bytesInFlight bytes in flight
*
* \return The slow start threshold
*/
virtual uint32_t GetSsThresh (Ptr<const TcpSocketState> tcb,
uint32_t bytesInFlight);
// Inherited
virtual Ptr<TcpCongestionOps> Fork ();
/**
@@ -198,8 +188,8 @@ private:
uint32_t m_noiseFilterLen; //!< Length of current delay buffer
uint64_t m_lastRollover; //!< Timestamp of last added delay
int32_t m_sndCwndCnt; //!< The congestion window addition parameter
struct OwdCircBuf m_baseHistory; //!< Buffer to store the base delay
struct OwdCircBuf m_noiseFilter; //!< Buffer to store the current delay
OwdCircBuf m_baseHistory; //!< Buffer to store the base delay
OwdCircBuf m_noiseFilter; //!< Buffer to store the current delay
uint32_t m_flag; //!< LEDBAT Flag
};

View File

@@ -233,7 +233,7 @@ TcpOptionMSS::Deserialize (Buffer::Iterator start)
uint8_t size = i.ReadU8 ();
NS_ASSERT (size == 4);
NS_ABORT_IF (size != 4);
m_mss = i.ReadNtohU16 ();
return GetSerializedSize ();

View File

@@ -82,7 +82,7 @@ TcpOptionSack::Serialize (Buffer::Iterator start) const
NS_LOG_FUNCTION (this);
Buffer::Iterator i = start;
i.WriteU8 (GetKind ()); // Kind
uint8_t length = GetNumSackBlocks () * 8 + 2;
uint8_t length = static_cast<uint8_t> (GetNumSackBlocks () * 8 + 2);
i.WriteU8 (length); // Length
for (SackList::const_iterator it = m_sackList.begin (); it != m_sackList.end (); ++it)
@@ -107,7 +107,7 @@ TcpOptionSack::Deserialize (Buffer::Iterator start)
}
uint8_t size = i.ReadU8 ();
NS_LOG_LOGIC ("Size: " << (uint32_t)size);
NS_LOG_LOGIC ("Size: " << static_cast<uint32_t> (size));
m_sackList.empty ();
uint8_t sackCount = (size - 2) / 8;
while (sackCount)
@@ -140,7 +140,7 @@ TcpOptionSack::GetNumSackBlocks (void) const
{
NS_LOG_FUNCTION (this);
NS_LOG_LOGIC ("Number of SACK blocks appended: " << m_sackList.size ());
return m_sackList.size ();
return static_cast<uint32_t> (m_sackList.size ());
}
void

View File

@@ -166,7 +166,7 @@ TcpOptionUnknown::Serialize (Buffer::Iterator i) const
}
i.WriteU8 (GetKind ());
i.WriteU8 (GetSerializedSize ());
i.WriteU8 (static_cast<uint8_t> (GetSerializedSize ()));
i.Write (m_content, m_size - 2);
}

View File

@@ -19,7 +19,6 @@
*/
#include "ns3/packet.h"
#include "ns3/fatal-error.h"
#include "ns3/log.h"
#include "tcp-rx-buffer.h"
@@ -188,8 +187,8 @@ TcpRxBuffer::Add (Ptr<Packet> p, TcpHeader const& tcph)
}
else
{
uint32_t start = headSeq - tcph.GetSequenceNumber ();
uint32_t length = tailSeq - headSeq;
uint32_t start = static_cast<uint32_t> (headSeq - tcph.GetSequenceNumber ());
uint32_t length = static_cast<uint32_t> (tailSeq - headSeq);
p = p->CreateFragment (start, length);
NS_ASSERT (length == p->GetSize ());
}
@@ -233,7 +232,7 @@ TcpRxBuffer::GetSackListSize () const
{
NS_LOG_FUNCTION (this);
return m_sackList.size ();
return static_cast<uint32_t> (m_sackList.size ());
}
void
@@ -349,7 +348,7 @@ TcpRxBuffer::ClearSackList (const SequenceNumber32 &seq)
it = m_sackList.erase (it);
}
else
{
{
it++;
}
}
@@ -368,7 +367,7 @@ TcpRxBuffer::Extract (uint32_t maxSize)
uint32_t extractSize = std::min (maxSize, m_availBytes);
NS_LOG_LOGIC ("Requested to extract " << extractSize << " bytes from TcpRxBuffer of size=" << m_size);
if (extractSize == 0) return 0; // No contiguous block to return
if (extractSize == 0) return nullptr; // No contiguous block to return
NS_ASSERT (m_data.size ()); // At least we have something to extract
Ptr<Packet> outPkt = Create<Packet> (); // The packet that contains all the data to return
BufIterator i;
@@ -399,7 +398,7 @@ TcpRxBuffer::Extract (uint32_t maxSize)
if (outPkt->GetSize () == 0)
{
NS_LOG_LOGIC ("Nothing extracted.");
return 0;
return nullptr;
}
NS_LOG_LOGIC ("Extracted " << outPkt->GetSize ( ) << " bytes, bufsize=" << m_size
<< ", num pkts in buffer=" << m_data.size ());

View File

@@ -28,7 +28,6 @@
*/
#include "tcp-scalable.h"
#include "ns3/tcp-socket-base.h"
#include "ns3/log.h"
namespace ns3 {
@@ -133,7 +132,7 @@ TcpScalable::GetSsThresh (Ptr<const TcpSocketState> tcb,
uint32_t segCwnd = bytesInFlight / tcb->m_segmentSize;
double b = 1.0 - m_mdFactor;
uint32_t ssThresh = std::max (2.0, segCwnd * b);
uint32_t ssThresh = static_cast<uint32_t> (std::max (2.0, segCwnd * b));
NS_LOG_DEBUG ("Calculated b(w) = " << b <<
" resulting (in segment) ssThresh=" << ssThresh);

View File

@@ -410,7 +410,7 @@ TcpSocketBase::TcpSocketBase (const TcpSocketBase& sock)
TcpSocketBase::~TcpSocketBase (void)
{
NS_LOG_FUNCTION (this);
m_node = 0;
m_node = nullptr;
if (m_endPoint != nullptr)
{
NS_ASSERT (m_tcp != nullptr);
@@ -423,14 +423,14 @@ TcpSocketBase::~TcpSocketBase (void)
*/
NS_ASSERT (m_endPoint != nullptr);
m_tcp->DeAllocate (m_endPoint);
NS_ASSERT (m_endPoint == 0);
NS_ASSERT (m_endPoint == nullptr);
}
if (m_endPoint6 != nullptr)
{
NS_ASSERT (m_tcp != nullptr);
NS_ASSERT (m_endPoint6 != nullptr);
m_tcp->DeAllocate (m_endPoint6);
NS_ASSERT (m_endPoint6 == 0);
NS_ASSERT (m_endPoint6 == nullptr);
}
m_tcp = 0;
CancelAllTimers ();
@@ -624,11 +624,11 @@ TcpSocketBase::Connect (const Address & address)
// If haven't do so, Bind() this socket first
if (InetSocketAddress::IsMatchingType (address))
{
if (m_endPoint == 0)
if (m_endPoint == nullptr)
{
if (Bind () == -1)
{
NS_ASSERT (m_endPoint == 0);
NS_ASSERT (m_endPoint == nullptr);
return -1; // Bind() failed
}
NS_ASSERT (m_endPoint != nullptr);
@@ -636,7 +636,7 @@ TcpSocketBase::Connect (const Address & address)
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
m_endPoint->SetPeer (transport.GetIpv4 (), transport.GetPort ());
SetIpTos (transport.GetTos ());
m_endPoint6 = 0;
m_endPoint6 = nullptr;
// Get the appropriate local address and port number from the routing protocol and set up endpoint
if (SetupEndpoint () != 0)
@@ -657,17 +657,17 @@ TcpSocketBase::Connect (const Address & address)
return Connect (InetSocketAddress (v4Addr, transport.GetPort ()));
}
if (m_endPoint6 == 0)
if (m_endPoint6 == nullptr)
{
if (Bind6 () == -1)
{
NS_ASSERT (m_endPoint6 == 0);
NS_ASSERT (m_endPoint6 == nullptr);
return -1; // Bind() failed
}
NS_ASSERT (m_endPoint6 != nullptr);
}
m_endPoint6->SetPeer (v6Addr, transport.GetPort ());
m_endPoint = 0;
m_endPoint = nullptr;
// Get the appropriate local address and port number from the routing protocol and set up endpoint
if (SetupEndpoint6 () != 0)
@@ -825,6 +825,7 @@ TcpSocketBase::Send (Ptr<Packet> p, uint32_t flags)
int
TcpSocketBase::SendTo (Ptr<Packet> p, uint32_t flags, const Address &address)
{
NS_UNUSED (address);
return Send (p, flags); // SendTo() and Send() are the same
}
@@ -960,7 +961,7 @@ TcpSocketBase::SetupCallback (void)
{
NS_LOG_FUNCTION (this);
if (m_endPoint == 0 && m_endPoint6 == 0)
if (m_endPoint == nullptr && m_endPoint6 == nullptr)
{
return -1;
}
@@ -1124,8 +1125,9 @@ TcpSocketBase::ForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl,
uint8_t icmpType, uint8_t icmpCode,
uint32_t icmpInfo)
{
NS_LOG_FUNCTION (this << icmpSource << (uint32_t)icmpTtl << (uint32_t)icmpType <<
(uint32_t)icmpCode << icmpInfo);
NS_LOG_FUNCTION (this << icmpSource << static_cast<uint32_t> (icmpTtl) <<
static_cast<uint32_t> (icmpType) <<
static_cast<uint32_t> (icmpCode) << icmpInfo);
if (!m_icmpCallback.IsNull ())
{
m_icmpCallback (icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo);
@@ -1137,8 +1139,9 @@ TcpSocketBase::ForwardIcmp6 (Ipv6Address icmpSource, uint8_t icmpTtl,
uint8_t icmpType, uint8_t icmpCode,
uint32_t icmpInfo)
{
NS_LOG_FUNCTION (this << icmpSource << (uint32_t)icmpTtl << (uint32_t)icmpType <<
(uint32_t)icmpCode << icmpInfo);
NS_LOG_FUNCTION (this << icmpSource << static_cast<uint32_t> (icmpTtl) <<
static_cast<uint32_t> (icmpType) <<
static_cast<uint32_t> (icmpCode) << icmpInfo);
if (!m_icmpCallback6.IsNull ())
{
m_icmpCallback6 (icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo);
@@ -1801,7 +1804,7 @@ TcpSocketBase::ProcessAck (const SequenceNumber32 &ackNumber, bool scoreboardUpd
// Recalculate the segs acked, that are from m_recover to ackNumber
// (which are the ones we have not passed to PktsAcked and that
// can increase cWnd)
segsAcked = (ackNumber - m_recover) / m_tcb->m_segmentSize;
segsAcked = static_cast<uint32_t>(ackNumber - m_recover) / m_tcb->m_segmentSize;
m_congestionControl->PktsAcked (m_tcb, segsAcked, m_lastRtt);
m_congestionControl->CwndEvent (m_tcb, TcpSocketState::CA_EVENT_COMPLETE_CWR);
m_congestionControl->CongestionStateSet (m_tcb, TcpSocketState::CA_OPEN);
@@ -1949,6 +1952,7 @@ void
TcpSocketBase::ProcessSynRcvd (Ptr<Packet> packet, const TcpHeader& tcpHeader,
const Address& fromAddress, const Address& toAddress)
{
NS_UNUSED (toAddress);
NS_LOG_FUNCTION (this << tcpHeader);
// Extract the flags. PSH and URG are not honoured.
@@ -2259,7 +2263,7 @@ void
TcpSocketBase::Destroy (void)
{
NS_LOG_FUNCTION (this);
m_endPoint = 0;
m_endPoint = nullptr;
if (m_tcp != nullptr)
{
m_tcp->RemoveSocket (this);
@@ -2275,7 +2279,7 @@ void
TcpSocketBase::Destroy6 (void)
{
NS_LOG_FUNCTION (this);
m_endPoint6 = 0;
m_endPoint6 = nullptr;
if (m_tcp != nullptr)
{
m_tcp->RemoveSocket (this);
@@ -2336,7 +2340,7 @@ TcpSocketBase::SendEmptyPacket (uint8_t flags)
p->ReplacePacketTag (priorityTag);
}
if (m_endPoint == 0 && m_endPoint6 == 0)
if (m_endPoint == nullptr && m_endPoint6 == nullptr)
{
NS_LOG_WARN ("Failed to send empty packet due to null endpoint");
return;
@@ -2467,7 +2471,7 @@ TcpSocketBase::DeallocateEndPoint (void)
CancelAllTimers ();
m_endPoint->SetDestroyCallback (MakeNullCallback<void> ());
m_tcp->DeAllocate (m_endPoint);
m_endPoint = 0;
m_endPoint = nullptr;
m_tcp->RemoveSocket (this);
}
else if (m_endPoint6 != nullptr)
@@ -2475,7 +2479,7 @@ TcpSocketBase::DeallocateEndPoint (void)
CancelAllTimers ();
m_endPoint6->SetDestroyCallback (MakeNullCallback<void> ());
m_tcp->DeAllocate (m_endPoint6);
m_endPoint6 = 0;
m_endPoint6 = nullptr;
m_tcp->RemoveSocket (this);
}
}
@@ -2487,7 +2491,7 @@ TcpSocketBase::SetupEndpoint ()
NS_LOG_FUNCTION (this);
Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> ();
NS_ASSERT (ipv4 != nullptr);
if (ipv4->GetRoutingProtocol () == 0)
if (ipv4->GetRoutingProtocol () == nullptr)
{
NS_FATAL_ERROR ("No Ipv4RoutingProtocol in the node");
}
@@ -2517,7 +2521,7 @@ TcpSocketBase::SetupEndpoint6 ()
NS_LOG_FUNCTION (this);
Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> ();
NS_ASSERT (ipv6 != nullptr);
if (ipv6->GetRoutingProtocol () == 0)
if (ipv6->GetRoutingProtocol () == nullptr)
{
NS_FATAL_ERROR ("No Ipv6RoutingProtocol in the node");
}
@@ -2529,7 +2533,7 @@ TcpSocketBase::SetupEndpoint6 ()
Ptr<Ipv6Route> route;
Ptr<NetDevice> oif = m_boundnetdevice;
route = ipv6->GetRoutingProtocol ()->RouteOutput (Ptr<Packet> (), header, oif, errno_);
if (route == 0)
if (route == nullptr)
{
NS_LOG_LOGIC ("Route to " << m_endPoint6->GetPeerAddress () << " does not exist");
NS_LOG_ERROR (errno_);
@@ -2548,6 +2552,7 @@ void
TcpSocketBase::CompleteFork (Ptr<Packet> p, const TcpHeader& h,
const Address& fromAddress, const Address& toAddress)
{
NS_UNUSED (p);
// Get port and address from peer (connecting host)
if (InetSocketAddress::IsMatchingType (toAddress))
{
@@ -2556,7 +2561,7 @@ TcpSocketBase::CompleteFork (Ptr<Packet> p, const TcpHeader& h,
InetSocketAddress::ConvertFrom (toAddress).GetPort (),
InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
m_endPoint6 = 0;
m_endPoint6 = nullptr;
}
else if (Inet6SocketAddress::IsMatchingType (toAddress))
{
@@ -2565,7 +2570,7 @@ TcpSocketBase::CompleteFork (Ptr<Packet> p, const TcpHeader& h,
Inet6SocketAddress::ConvertFrom (toAddress).GetPort (),
Inet6SocketAddress::ConvertFrom (fromAddress).GetIpv6 (),
Inet6SocketAddress::ConvertFrom (fromAddress).GetPort ());
m_endPoint = 0;
m_endPoint = nullptr;
}
m_tcp->AddSocket (this);
@@ -2784,7 +2789,7 @@ TcpSocketBase::SendPendingData (bool withAck)
{
return false; // Nothing to send
}
if (m_endPoint == 0 && m_endPoint6 == 0)
if (m_endPoint == nullptr && m_endPoint6 == nullptr)
{
NS_LOG_INFO ("TcpSocketBase::SendPendingData: No endpoint; m_shutdownSend=" << m_shutdownSend);
return false; // Is this the right way to handle this condition?

View File

@@ -25,7 +25,6 @@
*/
#include "tcp-vegas.h"
#include "ns3/tcp-socket-base.h"
#include "ns3/log.h"
namespace ns3 {
@@ -203,7 +202,7 @@ TcpVegas::IncreaseWindow (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked)
* target cwnd is throughput / minRtt
*/
double tmp = m_baseRtt.GetSeconds () / m_minRtt.GetSeconds ();
targetCwnd = segCwnd * tmp;
targetCwnd = static_cast<uint32_t> (segCwnd * tmp);
NS_LOG_DEBUG ("Calculated targetCwnd = " << targetCwnd);
NS_ASSERT (segCwnd >= targetCwnd); // implies baseRtt <= minRtt

View File

@@ -25,7 +25,6 @@
*/
#include "tcp-veno.h"
#include "ns3/tcp-socket-base.h"
#include "ns3/log.h"
namespace ns3 {
@@ -162,7 +161,7 @@ TcpVeno::IncreaseWindow (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked)
* target cwnd is throughput / minRtt
*/
double tmp = m_baseRtt.GetSeconds () / m_minRtt.GetSeconds ();
targetCwnd = segCwnd * tmp;
targetCwnd = static_cast<uint32_t> (segCwnd * tmp);
NS_LOG_DEBUG ("Calculated targetCwnd = " << targetCwnd);
NS_ASSERT (segCwnd >= targetCwnd); // implies baseRtt <= minRtt

View File

@@ -25,7 +25,6 @@
*/
#include "tcp-yeah.h"
#include "ns3/tcp-socket-base.h"
#include "ns3/log.h"
namespace ns3 {
@@ -87,7 +86,7 @@ TcpYeah::TcpYeah (void)
m_rho (16),
m_zeta (50),
m_stcpAiFactor (100),
m_stcp (0),
m_stcp (nullptr),
m_baseRtt (Time::Max ()),
m_minRtt (Time::Max ()),
m_cntRtt (0),
@@ -100,7 +99,7 @@ TcpYeah::TcpYeah (void)
{
NS_LOG_FUNCTION (this);
m_stcp = CreateObject <TcpScalable> ();
m_stcp->SetAttribute ("AIFactor", (UintegerValue) m_stcpAiFactor);
m_stcp->SetAttribute ("AIFactor", static_cast<UintegerValue> (m_stcpAiFactor));
}
TcpYeah::TcpYeah (const TcpYeah& sock)
@@ -244,7 +243,7 @@ TcpYeah::IncreaseWindow (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked)
// queue = rttQueue * bw = rttQueue * (cwnd/RTTmin)
double bw = segCwnd / m_minRtt.GetSeconds ();
uint32_t queue = bw * rttQueue.GetSeconds ();
uint32_t queue = static_cast<uint32_t> (bw * rttQueue.GetSeconds ());
NS_LOG_DEBUG ("Queue backlog = " << queue <<
" given by cwnd = " << segCwnd <<
", minRtt = " << m_minRtt.GetMilliSeconds () <<
@@ -272,7 +271,7 @@ TcpYeah::IncreaseWindow (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked)
if (m_renoCount <= 2)
{
m_renoCount = std::max (segCwnd >> 1, (uint32_t) 2);
m_renoCount = std::max (segCwnd >> 1, static_cast<uint32_t> (2));
}
else
{
@@ -331,13 +330,13 @@ TcpYeah::GetSsThresh (Ptr<const TcpSocketState> tcb,
else
{ // Competing with Reno flows
NS_LOG_LOGIC ("Competing with Reno flows upon loss");
reduction = std::max (segBytesInFlight >> 1, (uint32_t) 2);
reduction = std::max (segBytesInFlight >> 1, static_cast<uint32_t> (2));
}
NS_LOG_INFO ("Reduction amount upon loss = " << reduction);
m_fastCount = 0;
m_renoCount = std::max (m_renoCount >> 1, (uint32_t) 2);
m_renoCount = std::max (m_renoCount >> 1, static_cast<uint32_t> (2));
// Allow, at least, 2 segment to go out
uint32_t ret = std::max (bytesInFlight - (reduction * tcb->m_segmentSize),

View File

@@ -27,7 +27,6 @@
#ifndef TCPYEAH_H
#define TCPYEAH_H
#include "ns3/tcp-congestion-ops.h"
#include "ns3/tcp-scalable.h"
namespace ns3 {

View File

@@ -132,7 +132,7 @@ TcpBicIncrementTest::Update (Ptr<TcpSocketState> tcb)
Ptr<TcpBic> cong = CreateObject <TcpBic> ();
cong->m_lastMaxCwnd = m_lastMaxCwnd;
UintegerValue lowWindow, bsCoeff, wMax;
IntegerValue smoothPart;
UintegerValue smoothPart;
cong->GetAttribute ("LowWnd", lowWindow);
cong->GetAttribute ("BinarySearchCoefficient", bsCoeff);
cong->GetAttribute ("MaxIncr", wMax);