internet: TcpGeneralTest constructor refactoring
This commit is contained in:
@@ -237,11 +237,20 @@ However, other things should be checked in the test:
|
||||
* Persistent timer setup
|
||||
* Persistent timer teardown if rWnd increases
|
||||
|
||||
At first, we should define the general parameters for the TCP connection, which
|
||||
To construct the test case, just derive from the TcpGeneralTest class:
|
||||
|
||||
The code is the following:
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
TcpZeroWindowTest::TcpZeroWindowTest (const std::string &desc)
|
||||
: TcpGeneralTest (desc)
|
||||
{
|
||||
}
|
||||
|
||||
Then, we should define the general parameters for the TCP connection, which
|
||||
will be one-sided (one node is acting as SENDER, while the other is acting as
|
||||
RECEIVER). They are coded in the constructor of the test case, as subclass of
|
||||
TcpGeneralTest (see the doxygen documentation to discover all methods you have
|
||||
at your disposal):
|
||||
RECEIVER):
|
||||
|
||||
* Application packet size set to 500, and 20 packet in total (it means a stream
|
||||
of 10k bytes)
|
||||
@@ -252,22 +261,52 @@ at your disposal):
|
||||
|
||||
We have also to define the link properties, because the above definition does
|
||||
not work for every combination of propagation delay and sender application behavior.
|
||||
We can specify the following parameters through the same test constructor:
|
||||
|
||||
* Link one-way propagation delay: 50 ms
|
||||
* Application packet generation interval: 10 ms
|
||||
* Application starting time: 20 s after the starting point
|
||||
|
||||
The code is the following:
|
||||
To define the properties of the environment (e.g. properties which should be
|
||||
set before the object creation, such as propagation delay) we implement the method
|
||||
ConfigureEnvironment:
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
TcpZeroWindowTest::TcpZeroWindowTest (const std::string &desc)
|
||||
: TcpGeneralTest (desc, 500, 20, Seconds (0.01), Seconds (0.05), Seconds (2.0),
|
||||
0xffffffff, 10, 500)
|
||||
void
|
||||
TcpZeroWindowTest::ConfigureEnvironment ()
|
||||
{
|
||||
TcpGeneralTest::ConfigureEnvironment ();
|
||||
SetAppPktCount (20);
|
||||
SetMTU (500);
|
||||
SetTransmitStart (Seconds (2.0));
|
||||
SetPropagationDelay (MilliSeconds (50));
|
||||
}
|
||||
|
||||
For other properties, set after the object creation, we can use ConfigureProperties.
|
||||
The difference is that some values, for example initial congestion window
|
||||
or initial slow start threshold, are applicable only to a single instance, not
|
||||
to every instance we have. Usually, methods which requires an id and a value
|
||||
are meant to be called inside ConfigureProperties. Please see the doxygen
|
||||
documentation for an exhaustive list of the tunable properties.
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
void
|
||||
TcpZeroWindowTest::ConfigureProperties ()
|
||||
{
|
||||
TcpGeneralTest::ConfigureProperties ();
|
||||
SetInitialCwnd (SENDER, 10);
|
||||
}
|
||||
|
||||
To see the default value for the experiment, please see the implementation of
|
||||
both methods inside TcpGeneralTest class.
|
||||
|
||||
.. note::
|
||||
If some configuration parameters are missing, add a method called
|
||||
"SetSomeValue" which takes as input the value only (if it is meant to be
|
||||
called inside ConfigureEnvironment) or the socket and the value (if it is
|
||||
meant to be called inside ConfigureProperties).
|
||||
|
||||
To define a zero-window situation, we choose (by design) to initiate the connection
|
||||
with a 0-byte rx buffer. This implies that the RECEIVER, in its first SYN-ACK,
|
||||
advertizes a zero window. To this aim, we implement the method
|
||||
|
||||
@@ -48,6 +48,7 @@ protected:
|
||||
virtual void BytesInFlightTrace (uint32_t oldValue, uint32_t newValue);
|
||||
|
||||
void PktDropped (const Ipv4Header &ipH, const TcpHeader& tcpH, Ptr<const Packet> p);
|
||||
void ConfigureEnvironment ();
|
||||
|
||||
void FinalChecks ();
|
||||
|
||||
@@ -60,9 +61,9 @@ private:
|
||||
std::vector<uint32_t> m_toDrop; // List of SequenceNumber to drop
|
||||
};
|
||||
|
||||
TcpBytesInFlightTest::TcpBytesInFlightTest (const std::string &desc, std::vector<uint32_t> &toDrop)
|
||||
: TcpGeneralTest (desc, 500, 30, Seconds (0.01), Seconds (0.05), Seconds (2.0),
|
||||
0xffffffff,1, 500),
|
||||
TcpBytesInFlightTest::TcpBytesInFlightTest (const std::string &desc,
|
||||
std::vector<uint32_t> &toDrop)
|
||||
: TcpGeneralTest (desc),
|
||||
m_realBytesInFlight (0),
|
||||
m_guessedBytesInFlight (0),
|
||||
m_dupAckRecv (0),
|
||||
@@ -72,6 +73,16 @@ TcpBytesInFlightTest::TcpBytesInFlightTest (const std::string &desc, std::vector
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
TcpBytesInFlightTest::ConfigureEnvironment ()
|
||||
{
|
||||
TcpGeneralTest::ConfigureEnvironment ();
|
||||
SetAppPktCount (30);
|
||||
SetPropagationDelay (MilliSeconds (50));
|
||||
SetTransmitStart (Seconds (2.0));
|
||||
|
||||
}
|
||||
|
||||
Ptr<ErrorModel>
|
||||
TcpBytesInFlightTest::CreateReceiverErrorModel ()
|
||||
{
|
||||
|
||||
@@ -31,11 +31,30 @@ TcpNewRenoCongAvoidNormalTest::TcpNewRenoCongAvoidNormalTest (uint32_t segmentSi
|
||||
uint32_t packets,
|
||||
TypeId &typeId,
|
||||
const std::string &desc)
|
||||
: TcpGeneralTest (desc, packetSize, packets, Seconds (0.01), Seconds (0.5),
|
||||
Seconds (10), 0, 1, segmentSize, typeId, 1500),
|
||||
: TcpGeneralTest (desc),
|
||||
m_segmentSize (segmentSize),
|
||||
m_packetSize (packetSize),
|
||||
m_packets (packets),
|
||||
m_increment (0),
|
||||
m_initial (true)
|
||||
{
|
||||
m_congControlTypeId = typeId;
|
||||
}
|
||||
|
||||
void
|
||||
TcpNewRenoCongAvoidNormalTest::ConfigureEnvironment ()
|
||||
{
|
||||
TcpGeneralTest::ConfigureEnvironment ();
|
||||
SetAppPktSize (m_packetSize);
|
||||
SetAppPktCount (m_packets);
|
||||
SetMTU (1500);
|
||||
}
|
||||
|
||||
void TcpNewRenoCongAvoidNormalTest::ConfigureProperties ()
|
||||
{
|
||||
TcpGeneralTest::ConfigureProperties ();
|
||||
SetSegmentSize (SENDER, m_segmentSize);
|
||||
SetInitialSsThresh (SENDER, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace ns3 {
|
||||
* it checks that the increment has not passed the 1 MSS limit.
|
||||
*/
|
||||
class
|
||||
TcpNewRenoCongAvoidNormalTest : public TcpGeneralTest
|
||||
TcpNewRenoCongAvoidNormalTest : public TcpGeneralTest
|
||||
{
|
||||
public:
|
||||
TcpNewRenoCongAvoidNormalTest (uint32_t segmentSize, uint32_t packetSize,
|
||||
@@ -61,6 +61,13 @@ protected:
|
||||
void NormalClose (SocketWho who);
|
||||
void Check ();
|
||||
|
||||
void ConfigureEnvironment ();
|
||||
void ConfigureProperties ();
|
||||
|
||||
private:
|
||||
uint32_t m_segmentSize;
|
||||
uint32_t m_packetSize;
|
||||
uint32_t m_packets;
|
||||
uint32_t m_increment;
|
||||
EventId m_event;
|
||||
bool m_initial;
|
||||
|
||||
@@ -66,7 +66,7 @@ TcpSocketHalfAck::Fork (void)
|
||||
}
|
||||
|
||||
void
|
||||
TcpSocketHalfAck::ReceivedData(Ptr<Packet> packet, const TcpHeader &tcpHeader)
|
||||
TcpSocketHalfAck::ReceivedData (Ptr<Packet> packet, const TcpHeader &tcpHeader)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << packet << tcpHeader);
|
||||
static uint32_t times = 1;
|
||||
@@ -74,7 +74,7 @@ TcpSocketHalfAck::ReceivedData(Ptr<Packet> packet, const TcpHeader &tcpHeader)
|
||||
Ptr<Packet> halved = packet->Copy ();
|
||||
|
||||
if (times % 2 == 0)
|
||||
halved->RemoveAtEnd (packet->GetSize() / 2);
|
||||
halved->RemoveAtEnd (packet->GetSize () / 2);
|
||||
|
||||
times++;
|
||||
|
||||
@@ -95,7 +95,9 @@ class TcpDataSentCbTestCase : public TcpGeneralTest
|
||||
{
|
||||
public:
|
||||
TcpDataSentCbTestCase (const std::string &desc, uint32_t size, uint32_t packets) :
|
||||
TcpGeneralTest (desc, size, packets),
|
||||
TcpGeneralTest (desc),
|
||||
m_pktSize (size),
|
||||
m_pktCount (packets),
|
||||
m_notifiedData (0)
|
||||
{ }
|
||||
|
||||
@@ -103,13 +105,23 @@ protected:
|
||||
virtual Ptr<TcpSocketMsgBase> CreateReceiverSocket (Ptr<Node> node);
|
||||
|
||||
virtual void DataSent (uint32_t size, SocketWho who);
|
||||
|
||||
virtual void ConfigureEnvironment ();
|
||||
virtual void FinalChecks ();
|
||||
|
||||
private:
|
||||
uint32_t m_pktSize;
|
||||
uint32_t m_pktCount;
|
||||
uint32_t m_notifiedData;
|
||||
};
|
||||
|
||||
void
|
||||
TcpDataSentCbTestCase::ConfigureEnvironment ()
|
||||
{
|
||||
TcpGeneralTest::ConfigureEnvironment ();
|
||||
SetAppPktCount (m_pktCount);
|
||||
SetAppPktSize (m_pktSize);
|
||||
}
|
||||
|
||||
void
|
||||
TcpDataSentCbTestCase::DataSent (uint32_t size, SocketWho who)
|
||||
{
|
||||
@@ -119,9 +131,9 @@ TcpDataSentCbTestCase::DataSent (uint32_t size, SocketWho who)
|
||||
}
|
||||
|
||||
void
|
||||
TcpDataSentCbTestCase::FinalChecks()
|
||||
TcpDataSentCbTestCase::FinalChecks ()
|
||||
{
|
||||
NS_TEST_ASSERT_MSG_EQ (m_notifiedData, GetPktSize () * GetPktCount () ,
|
||||
NS_TEST_ASSERT_MSG_EQ (m_notifiedData, GetPktSize () * GetPktCount (),
|
||||
"Notified more data than application sent");
|
||||
}
|
||||
|
||||
|
||||
@@ -27,17 +27,31 @@ NS_LOG_COMPONENT_DEFINE ("TcpFastRetrTest");
|
||||
|
||||
TcpFastRetrTest::TcpFastRetrTest (TypeId typeId, uint32_t seqToKill,
|
||||
const std::string &msg)
|
||||
: TcpGeneralTest (msg, 500, 100, Seconds (0.01), Seconds (0.5), Seconds (10),
|
||||
0, 1, 500, typeId, 1500),
|
||||
m_pktDropped (false),
|
||||
m_pktWasDropped (false),
|
||||
m_seqToKill (seqToKill),
|
||||
m_dupAckReceived (0),
|
||||
m_sndNextExpSeq (0),
|
||||
m_rcvNextExpAck (1),
|
||||
m_countRetr (0),
|
||||
m_bytesRcvButNotAcked (0)
|
||||
: TcpGeneralTest (msg),
|
||||
m_pktDropped (false),
|
||||
m_pktWasDropped (false),
|
||||
m_seqToKill (seqToKill),
|
||||
m_dupAckReceived (0),
|
||||
m_sndNextExpSeq (0),
|
||||
m_rcvNextExpAck (1),
|
||||
m_countRetr (0),
|
||||
m_bytesRcvButNotAcked (0)
|
||||
{
|
||||
m_congControlTypeId = typeId;
|
||||
}
|
||||
|
||||
void
|
||||
TcpFastRetrTest::ConfigureProperties ()
|
||||
{
|
||||
TcpGeneralTest::ConfigureProperties ();
|
||||
SetInitialSsThresh (SENDER, 0);
|
||||
}
|
||||
|
||||
void
|
||||
TcpFastRetrTest::ConfigureEnvironment ()
|
||||
{
|
||||
TcpGeneralTest::ConfigureEnvironment ();
|
||||
SetAppPktCount (100);
|
||||
}
|
||||
|
||||
Ptr<ErrorModel>
|
||||
@@ -218,7 +232,7 @@ TcpFastRetrTest::RcvAck (const Ptr<const TcpSocketState> tcb, const TcpHeader &h
|
||||
NS_TEST_ASSERT_MSG_EQ (GetDupAckCount (SENDER), m_dupAckReceived,
|
||||
"Dupack count differs");
|
||||
|
||||
if (GetDupAckCount(SENDER) == 0 &&
|
||||
if (GetDupAckCount (SENDER) == 0 &&
|
||||
GetDupAckCount (SENDER) < GetReTxThreshold (SENDER))
|
||||
{
|
||||
NS_TEST_ASSERT_MSG_EQ (GetCongStateFrom (tcb), TcpSocketState::CA_OPEN,
|
||||
@@ -288,7 +302,7 @@ TcpFastRetrTest::ProcessedAck (const Ptr<const TcpSocketState> tcb, const TcpHea
|
||||
}
|
||||
|
||||
void
|
||||
TcpFastRetrTest::RTOExpired(const Ptr<const TcpSocketState> tcb, SocketWho who)
|
||||
TcpFastRetrTest::RTOExpired (const Ptr<const TcpSocketState> tcb, SocketWho who)
|
||||
{
|
||||
NS_ASSERT_MSG (true == false, "RTO isn't expected here");
|
||||
}
|
||||
|
||||
@@ -58,7 +58,10 @@ protected:
|
||||
virtual void RTOExpired (const Ptr<const TcpSocketState> tcb, SocketWho who);
|
||||
|
||||
void PktDropped (const Ipv4Header &ipH, const TcpHeader& tcpH, Ptr<const Packet> p);
|
||||
void FinalChecks ();
|
||||
virtual void FinalChecks ();
|
||||
|
||||
virtual void ConfigureProperties ();
|
||||
virtual void ConfigureEnvironment ();
|
||||
|
||||
bool m_pktDropped;
|
||||
bool m_pktWasDropped;
|
||||
|
||||
@@ -32,25 +32,9 @@ namespace ns3 {
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("TcpGeneralTest");
|
||||
|
||||
TcpGeneralTest::TcpGeneralTest (const std::string &desc,
|
||||
uint32_t pktSize, uint32_t pktCount,
|
||||
const Time& pktInterval,
|
||||
const Time& propagationDelay, const Time& startTime,
|
||||
uint32_t initialSlowStartThresh, uint32_t initialCwnd,
|
||||
uint32_t segmentSize,
|
||||
TypeId congestionControl,
|
||||
uint32_t mtu)
|
||||
TcpGeneralTest::TcpGeneralTest (const std::string &desc)
|
||||
: TestCase (desc),
|
||||
m_congControlTypeId (congestionControl),
|
||||
m_propagationDelay (propagationDelay),
|
||||
m_startTime (startTime),
|
||||
m_mtu (mtu),
|
||||
m_pktSize (pktSize),
|
||||
m_pktCount (pktCount),
|
||||
m_interPacketInterval (pktInterval),
|
||||
m_initialSlowStartThresh (initialSlowStartThresh),
|
||||
m_initialCwnd (initialCwnd),
|
||||
m_segmentSize (segmentSize),
|
||||
m_congControlTypeId (TcpNewReno::GetTypeId ()),
|
||||
m_remoteAddr (Ipv4Address::GetAny (), 4477)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << desc);
|
||||
@@ -104,9 +88,35 @@ TcpGeneralTest::DoTeardown (void)
|
||||
NS_LOG_INFO ("Done.");
|
||||
}
|
||||
|
||||
void
|
||||
TcpGeneralTest::ConfigureEnvironment ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
SetCongestionControl (m_congControlTypeId);
|
||||
SetPropagationDelay (MilliSeconds (500));
|
||||
SetTransmitStart (Seconds (10));
|
||||
SetAppPktSize (500);
|
||||
SetAppPktCount (10);
|
||||
SetAppPktInterval (MilliSeconds (1));
|
||||
SetMTU (1500);
|
||||
}
|
||||
|
||||
void
|
||||
TcpGeneralTest::ConfigureProperties ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
SetInitialCwnd (SENDER, 1);
|
||||
SetInitialSsThresh (SENDER, UINT32_MAX);
|
||||
SetSegmentSize (SENDER, 500);
|
||||
SetSegmentSize (RECEIVER, 500);
|
||||
}
|
||||
|
||||
void
|
||||
TcpGeneralTest::DoRun (void)
|
||||
{
|
||||
ConfigureEnvironment ();
|
||||
|
||||
NS_LOG_INFO ("Create nodes.");
|
||||
NodeContainer nodes;
|
||||
nodes.Create (2);
|
||||
@@ -170,10 +180,7 @@ TcpGeneralTest::DoRun (void)
|
||||
m_receiverSocket->TraceConnectWithoutContext ("Rx",
|
||||
MakeCallback (&TcpGeneralTest::RxPacketCb, this));
|
||||
|
||||
InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 4477);
|
||||
m_receiverSocket->Bind (local);
|
||||
m_receiverSocket->Listen ();
|
||||
m_receiverSocket->ShutdownSend ();
|
||||
InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 4477); m_receiverSocket->Bind (local);
|
||||
|
||||
m_senderSocket = CreateSenderSocket (nodes.Get (0));
|
||||
m_senderSocket->SetCloseCallbacks (MakeCallback (&TcpGeneralTest::NormalCloseCb, this),
|
||||
@@ -185,6 +192,8 @@ TcpGeneralTest::DoRun (void)
|
||||
m_senderSocket->SetUpdateRttHistoryCb (MakeCallback (&TcpGeneralTest::UpdateRttHistoryCb, this));
|
||||
m_senderSocket->TraceConnectWithoutContext ("CongestionWindow",
|
||||
MakeCallback (&TcpGeneralTest::CWndTrace, this));
|
||||
m_senderSocket->TraceConnectWithoutContext ("SlowStartThreshold",
|
||||
MakeCallback (&TcpGeneralTest::SsThreshTrace, this));
|
||||
m_senderSocket->TraceConnectWithoutContext ("CongState",
|
||||
MakeCallback (&TcpGeneralTest::CongStateTrace, this));
|
||||
m_senderSocket->TraceConnectWithoutContext ("Tx",
|
||||
@@ -198,6 +207,11 @@ TcpGeneralTest::DoRun (void)
|
||||
|
||||
m_remoteAddr = InetSocketAddress (serverAddress, 4477);
|
||||
|
||||
ConfigureProperties ();
|
||||
|
||||
m_receiverSocket->Listen ();
|
||||
m_receiverSocket->ShutdownSend ();
|
||||
|
||||
Simulator::Schedule (Seconds (0.0),
|
||||
&TcpGeneralTest::DoConnect, this);
|
||||
Simulator::ScheduleWithContext (nodes.Get (0)->GetId (),
|
||||
@@ -256,10 +270,6 @@ TcpGeneralTest::CreateSocket (Ptr<Node> node, TypeId socketType,
|
||||
socket->SetRtt (rtt);
|
||||
socket->SetCongestionControlAlgorithm (algo);
|
||||
|
||||
socket->SetAttribute ("InitialSlowStartThreshold", UintegerValue (m_initialSlowStartThresh));
|
||||
socket->SetAttribute ("SegmentSize", UintegerValue (m_segmentSize));
|
||||
socket->SetAttribute ("InitialCwnd", UintegerValue (m_initialCwnd));
|
||||
|
||||
return socket;
|
||||
}
|
||||
|
||||
@@ -586,6 +596,40 @@ TcpGeneralTest::GetSegSize (SocketWho who)
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
TcpGeneralTest::GetInitialCwnd (SocketWho who)
|
||||
{
|
||||
if (who == SENDER)
|
||||
{
|
||||
return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetInitialCwnd ();
|
||||
}
|
||||
else if (who == RECEIVER)
|
||||
{
|
||||
return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetInitialCwnd ();
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_FATAL_ERROR ("Not defined");
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
TcpGeneralTest::GetInitialSsThresh (SocketWho who)
|
||||
{
|
||||
if (who == SENDER)
|
||||
{
|
||||
return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetInitialSSThresh ();
|
||||
}
|
||||
else if (who == RECEIVER)
|
||||
{
|
||||
return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetInitialSSThresh ();
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_FATAL_ERROR ("Not defined");
|
||||
}
|
||||
}
|
||||
|
||||
Time
|
||||
TcpGeneralTest::GetRto (SocketWho who)
|
||||
{
|
||||
@@ -778,6 +822,57 @@ TcpGeneralTest::SetRcvBufSize (SocketWho who, uint32_t size)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TcpGeneralTest::SetSegmentSize (SocketWho who, uint32_t segmentSize)
|
||||
{
|
||||
if (who == SENDER)
|
||||
{
|
||||
m_senderSocket->SetSegSize (segmentSize);
|
||||
}
|
||||
else if (who == RECEIVER)
|
||||
{
|
||||
m_receiverSocket->SetSegSize (segmentSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_FATAL_ERROR ("Not defined");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TcpGeneralTest::SetInitialCwnd (SocketWho who, uint32_t initialCwnd)
|
||||
{
|
||||
if (who == SENDER)
|
||||
{
|
||||
m_senderSocket->SetInitialCwnd (initialCwnd);
|
||||
}
|
||||
else if (who == RECEIVER)
|
||||
{
|
||||
m_receiverSocket->SetInitialCwnd (initialCwnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_FATAL_ERROR ("Not defined");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TcpGeneralTest::SetInitialSsThresh (SocketWho who, uint32_t initialSsThresh)
|
||||
{
|
||||
if (who == SENDER)
|
||||
{
|
||||
m_senderSocket->SetInitialSSThresh (initialSsThresh);
|
||||
}
|
||||
else if (who == RECEIVER)
|
||||
{
|
||||
m_receiverSocket->SetInitialSSThresh (initialSsThresh);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_FATAL_ERROR ("Not defined");
|
||||
}
|
||||
}
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (TcpSocketMsgBase);
|
||||
|
||||
TypeId
|
||||
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
TcpSocketSmallAcks (const TcpSocketSmallAcks &other)
|
||||
TcpSocketSmallAcks (const TcpSocketSmallAcks &other)
|
||||
: TcpSocketMsgBase (other),
|
||||
m_bytesToAck (other.m_bytesToAck),
|
||||
m_bytesLeftToBeAcked (other.m_bytesLeftToBeAcked),
|
||||
@@ -213,25 +213,12 @@ public:
|
||||
/**
|
||||
* \brief TcpGeneralTest constructor
|
||||
*
|
||||
* \param pktSize application packet size
|
||||
* \param pktCount count of application packet to generate
|
||||
* \param pktInterval (application) interval between each generated packet
|
||||
* \param propagationDelay propagation delay of the channel
|
||||
* \param startTime time of the first application-generated packet
|
||||
* \param mtu MTU of the environment
|
||||
* Please use the method ConfigureEnvironment () to configure other
|
||||
* parameters than the test description.
|
||||
*
|
||||
* \param desc description of the test
|
||||
*/
|
||||
TcpGeneralTest (const std::string &desc,
|
||||
uint32_t pktSize = 500,
|
||||
uint32_t pktCount = 10,
|
||||
const Time& pktInterval = Seconds (0.01),
|
||||
const Time& propagationDelay = Seconds (0.5),
|
||||
const Time& startTime = Seconds (10),
|
||||
uint32_t initialSlowStartThresh = 0xffff,
|
||||
uint32_t initialCwnd = 1,
|
||||
uint32_t segmentSize = 500,
|
||||
TypeId congestionControl = TcpNewReno::GetTypeId (),
|
||||
uint32_t mtu = 1500);
|
||||
TcpGeneralTest (const std::string &desc);
|
||||
~TcpGeneralTest ();
|
||||
|
||||
/**
|
||||
@@ -314,9 +301,28 @@ protected:
|
||||
* As environment, two socket are connected through a SimpleChannel. Each device
|
||||
* has an MTU of 1500 bytes, and the application starts to send packet at
|
||||
* 10s of simulated time, through SendPacket.
|
||||
*
|
||||
* If you need to change parameters of the environment, please inherit an
|
||||
* implement the method ConfigureEnvironment (); that will be called at the
|
||||
* beginning of this method. To configure Socket parameters (i.e. parameters
|
||||
* that should be applied after socket have been created) use ConfigureProperties.
|
||||
*
|
||||
* Please do not use any Config:: statements.
|
||||
*
|
||||
* \see ConfigureEnvironment
|
||||
*/
|
||||
virtual void DoRun (void);
|
||||
|
||||
/**
|
||||
* \brief Change the configuration of the evironment
|
||||
*/
|
||||
virtual void ConfigureEnvironment (void);
|
||||
|
||||
/**
|
||||
* \brief Change the configuration of the socket properties
|
||||
*/
|
||||
virtual void ConfigureProperties (void);
|
||||
|
||||
/**
|
||||
* \brief Teardown the TCP test
|
||||
*/
|
||||
@@ -362,6 +368,18 @@ protected:
|
||||
*/
|
||||
uint32_t GetReTxThreshold (SocketWho who);
|
||||
|
||||
/**
|
||||
* \brief Get the initial slow start threshold
|
||||
* \return initial slow start threshold
|
||||
*/
|
||||
uint32_t GetInitialSsThresh (SocketWho who);
|
||||
|
||||
/**
|
||||
* \brief Get the initial congestion window
|
||||
* \return initial cwnd
|
||||
*/
|
||||
uint32_t GetInitialCwnd (SocketWho who);
|
||||
|
||||
/**
|
||||
* \brief Get the number of dupack received
|
||||
* \param who node to get the parameter from
|
||||
@@ -471,6 +489,83 @@ protected:
|
||||
*/
|
||||
void SetRcvBufSize (SocketWho who, uint32_t size);
|
||||
|
||||
/**
|
||||
* \brief Forcefully set the segment size
|
||||
*
|
||||
* \param who socket to force
|
||||
* \param segmentSize segmentSize
|
||||
*/
|
||||
void SetSegmentSize (SocketWho who, uint32_t segmentSize);
|
||||
|
||||
/**
|
||||
* \brief Forcefully set the initial cwnd
|
||||
*
|
||||
* \param who socket to force
|
||||
* \param initialCwnd size of the initial cwnd
|
||||
*/
|
||||
void SetInitialCwnd (SocketWho who, uint32_t initialCwnd);
|
||||
|
||||
/**
|
||||
* \brief Forcefully set the initial ssth
|
||||
*
|
||||
* \param who socket to force
|
||||
* \param initialSsThresh size of the initial ssth
|
||||
*/
|
||||
void SetInitialSsThresh (SocketWho who, uint32_t initialSsThresh);
|
||||
|
||||
/**
|
||||
* \brief Set app packet size
|
||||
*
|
||||
* The application will generate packet of this size.
|
||||
*
|
||||
* \param pktSize size of the packet
|
||||
*/
|
||||
void SetAppPktSize (uint32_t pktSize) { m_pktSize = pktSize; }
|
||||
|
||||
/**
|
||||
* \brief Set app packet count
|
||||
*
|
||||
* The application will generate this count of packets.
|
||||
*
|
||||
* \param pktCount count of packets to generate
|
||||
*/
|
||||
void SetAppPktCount (uint32_t pktCount) { m_pktCount = pktCount; }
|
||||
|
||||
/**
|
||||
* \brief Interval between app-generated packet
|
||||
*
|
||||
* \param pktInterval interval
|
||||
*/
|
||||
void SetAppPktInterval (Time pktInterval) { m_interPacketInterval = pktInterval; }
|
||||
|
||||
/**
|
||||
* \brief Propagation delay of the bottleneck link
|
||||
*
|
||||
* \param propDelay propagation delay
|
||||
*/
|
||||
void SetPropagationDelay (Time propDelay) { m_propagationDelay = propDelay; }
|
||||
|
||||
/**
|
||||
* \brief Set the initial time at which the application sends the first data packet
|
||||
*
|
||||
* \param startTime start time
|
||||
*/
|
||||
void SetTransmitStart (Time startTime) { m_startTime = startTime; }
|
||||
|
||||
/**
|
||||
* \brief Congestion control of the sender socket
|
||||
*
|
||||
* \param congControl typeid of the congestion control algorithm
|
||||
*/
|
||||
void SetCongestionControl (TypeId congControl) { m_congControlTypeId = congControl; }
|
||||
|
||||
/**
|
||||
* \brief MTU of the bottleneck link
|
||||
*
|
||||
* \param mtu MTU
|
||||
*/
|
||||
void SetMTU (uint32_t mtu) { m_mtu = mtu; }
|
||||
|
||||
/**
|
||||
* \brief State on Ack state machine changes
|
||||
* \param oldValue old value
|
||||
@@ -503,6 +598,19 @@ protected:
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Slow start threshold changes
|
||||
*
|
||||
* This applies only for sender socket.
|
||||
*
|
||||
*
|
||||
* \param oldValue old value
|
||||
* \param newValue new value
|
||||
*/
|
||||
virtual void SsThreshTrace (uint32_t oldValue, uint32_t newValue)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Bytes in flight changes
|
||||
*
|
||||
@@ -690,25 +798,6 @@ protected:
|
||||
return m_interPacketInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get the initial slow start threshold
|
||||
* \return initial slow start threshold
|
||||
*/
|
||||
uint32_t GetInitialSsThresh () const
|
||||
{
|
||||
return m_initialSlowStartThresh;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get the initial congestion window
|
||||
* \return initial cwnd
|
||||
*/
|
||||
uint32_t GetInitialCwnd () const
|
||||
{
|
||||
return m_initialCwnd;
|
||||
}
|
||||
|
||||
|
||||
TypeId m_congControlTypeId; //!< Congestion control
|
||||
|
||||
private:
|
||||
@@ -723,9 +812,6 @@ private:
|
||||
uint32_t m_pktCount; //!< Count of the application packet
|
||||
Time m_interPacketInterval; //!< Time between sending application packet
|
||||
// down to tcp socket
|
||||
uint32_t m_initialSlowStartThresh; //!< Initial slow start threshold
|
||||
uint32_t m_initialCwnd; //!< Initial congestion window
|
||||
uint32_t m_segmentSize; //!< Segment size
|
||||
|
||||
Ptr<TcpSocketMsgBase> m_senderSocket; //!< Pointer to sender socket
|
||||
Ptr<TcpSocketMsgBase> m_receiverSocket; //!< Pointer to receiver socket
|
||||
|
||||
@@ -50,6 +50,8 @@ protected:
|
||||
virtual Ptr<TcpSocketMsgBase> CreateSenderSocket (Ptr<Node> node);
|
||||
virtual void Rx (const Ptr<const Packet> p, const TcpHeader&h, SocketWho who);
|
||||
|
||||
virtual void ConfigureEnvironment ();
|
||||
|
||||
void FinalChecks ();
|
||||
|
||||
private:
|
||||
@@ -94,13 +96,20 @@ DummyCongControl::GetTypeId (void)
|
||||
}
|
||||
|
||||
TcpPktsAckedOpenTest::TcpPktsAckedOpenTest (const std::string &desc)
|
||||
: TcpGeneralTest (desc, 500, 20, Seconds (0.01), Seconds (0.05), Seconds (2.0),
|
||||
0xffffffff,1, 500),
|
||||
: TcpGeneralTest (desc),
|
||||
m_segmentsAcked (0),
|
||||
m_segmentsReceived (0)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
TcpPktsAckedOpenTest::ConfigureEnvironment ()
|
||||
{
|
||||
TcpGeneralTest::ConfigureEnvironment ();
|
||||
SetAppPktCount (20);
|
||||
SetMTU (500);
|
||||
}
|
||||
|
||||
Ptr<TcpSocketMsgBase>
|
||||
TcpPktsAckedOpenTest::CreateSenderSocket (Ptr<Node> node)
|
||||
{
|
||||
|
||||
@@ -28,11 +28,25 @@ namespace ns3 {
|
||||
NS_LOG_COMPONENT_DEFINE ("TcpRtoTest");
|
||||
|
||||
TcpRtoTest::TcpRtoTest (TypeId &congControl, const std::string &desc)
|
||||
: TcpGeneralTest (desc, 500, 100, Seconds (0.01), Seconds (0.5),
|
||||
Seconds (10), 0, 1, 500, congControl, 1500),
|
||||
m_rtoExpired (false),
|
||||
m_segmentReceived (false)
|
||||
: TcpGeneralTest (desc),
|
||||
m_rtoExpired (false),
|
||||
m_segmentReceived (false)
|
||||
{
|
||||
m_congControlTypeId = congControl;
|
||||
}
|
||||
|
||||
void
|
||||
TcpRtoTest::ConfigureEnvironment ()
|
||||
{
|
||||
TcpGeneralTest::ConfigureEnvironment ();
|
||||
SetAppPktCount (100);
|
||||
}
|
||||
|
||||
void
|
||||
TcpRtoTest::ConfigureProperties ()
|
||||
{
|
||||
TcpGeneralTest::ConfigureProperties ();
|
||||
SetInitialSsThresh (SENDER, 0);
|
||||
}
|
||||
|
||||
Ptr<TcpSocketMsgBase>
|
||||
@@ -114,14 +128,21 @@ TcpRtoTest::FinalChecks ()
|
||||
// TcpTimeRtoTest
|
||||
|
||||
TcpTimeRtoTest::TcpTimeRtoTest (TypeId &congControl, const std::string &desc)
|
||||
: TcpGeneralTest (desc, 500, 100, Seconds (0.01), Seconds (0.5),
|
||||
Seconds (10), 0xffff, 1, 500, congControl, 1500),
|
||||
m_senderSentSegments (0),
|
||||
m_closed (false)
|
||||
: TcpGeneralTest (desc),
|
||||
m_senderSentSegments (0),
|
||||
m_closed (false)
|
||||
{
|
||||
|
||||
m_congControlTypeId = congControl;
|
||||
}
|
||||
|
||||
void
|
||||
TcpTimeRtoTest::ConfigureEnvironment ()
|
||||
{
|
||||
TcpGeneralTest::ConfigureEnvironment ();
|
||||
SetAppPktCount (100);
|
||||
}
|
||||
|
||||
|
||||
Ptr<TcpSocketMsgBase>
|
||||
TcpTimeRtoTest::CreateSenderSocket (Ptr<Node> node)
|
||||
{
|
||||
|
||||
@@ -47,6 +47,8 @@ protected:
|
||||
virtual void ProcessedAck (const Ptr<const TcpSocketState> tcb,
|
||||
const TcpHeader& h, SocketWho who);
|
||||
virtual void FinalChecks ();
|
||||
virtual void ConfigureProperties ();
|
||||
virtual void ConfigureEnvironment ();
|
||||
|
||||
private:
|
||||
bool m_rtoExpired;
|
||||
@@ -71,6 +73,8 @@ protected:
|
||||
virtual void Tx (const Ptr<const Packet> p, const TcpHeader&h, SocketWho who);
|
||||
virtual void FinalChecks ();
|
||||
|
||||
virtual void ConfigureEnvironment ();
|
||||
|
||||
void PktDropped (const Ipv4Header &ipH, const TcpHeader& tcpH, Ptr<const Packet> p);
|
||||
|
||||
private:
|
||||
|
||||
@@ -50,21 +50,35 @@ protected:
|
||||
virtual void RttTrace (Time oldTime, Time newTime);
|
||||
void FinalChecks ();
|
||||
|
||||
virtual void ConfigureEnvironment ();
|
||||
|
||||
private:
|
||||
bool m_enableTs;
|
||||
bool m_rttChanged;
|
||||
SequenceNumber32 m_highestTxSeq;
|
||||
uint32_t m_pktCount;
|
||||
};
|
||||
|
||||
TcpRttEstimationTest::TcpRttEstimationTest (const std::string &desc, bool enableTs, uint32_t dataPkt)
|
||||
: TcpGeneralTest (desc, 500, dataPkt, Seconds (0.01), Seconds (0.05), Seconds (2.0),
|
||||
0xffffffff,1, 500),
|
||||
TcpRttEstimationTest::TcpRttEstimationTest (const std::string &desc, bool enableTs,
|
||||
uint32_t pktCount)
|
||||
: TcpGeneralTest (desc),
|
||||
m_enableTs (enableTs),
|
||||
m_rttChanged (false),
|
||||
m_highestTxSeq (0)
|
||||
m_highestTxSeq (0),
|
||||
m_pktCount (pktCount)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
TcpRttEstimationTest::ConfigureEnvironment ()
|
||||
{
|
||||
TcpGeneralTest::ConfigureEnvironment ();
|
||||
SetAppPktCount (m_pktCount);
|
||||
SetPropagationDelay (MilliSeconds (50));
|
||||
SetTransmitStart (Seconds (2.0));
|
||||
SetMTU (500);
|
||||
}
|
||||
|
||||
Ptr<TcpSocketMsgBase>
|
||||
TcpRttEstimationTest::CreateReceiverSocket (Ptr<Node> node)
|
||||
{
|
||||
|
||||
@@ -34,14 +34,46 @@ TcpSlowStartNormalTest::TcpSlowStartNormalTest (uint32_t segmentSize,
|
||||
uint32_t packets,
|
||||
TypeId &typeId,
|
||||
const std::string &desc)
|
||||
: TcpGeneralTest (desc, packetSize, packets, Seconds (0.01), Seconds (0.5),
|
||||
Seconds (10), initSsTh, 1, segmentSize, typeId, 1500),
|
||||
m_ackedBytes (0),
|
||||
m_sentBytes (0),
|
||||
m_totalAckedBytes (0),
|
||||
m_allowedIncrease (0),
|
||||
m_initial (true)
|
||||
: TcpGeneralTest (desc),
|
||||
m_ackedBytes (0),
|
||||
m_sentBytes (0),
|
||||
m_totalAckedBytes (0),
|
||||
m_allowedIncrease (0),
|
||||
m_initial (true),
|
||||
m_segmentSize (segmentSize),
|
||||
m_packetSize (packetSize),
|
||||
m_packets (packets)
|
||||
{
|
||||
m_congControlTypeId = typeId;
|
||||
}
|
||||
|
||||
void
|
||||
TcpSlowStartNormalTest::ConfigureEnvironment ()
|
||||
{
|
||||
TcpGeneralTest::ConfigureEnvironment ();
|
||||
SetAppPktCount (m_packets);
|
||||
SetAppPktSize (m_packetSize);
|
||||
}
|
||||
|
||||
void
|
||||
TcpSlowStartNormalTest::ConfigureProperties ()
|
||||
{
|
||||
TcpGeneralTest::ConfigureProperties ();
|
||||
SetInitialSsThresh (SENDER, 400000);
|
||||
SetSegmentSize (SENDER, m_segmentSize);
|
||||
SetSegmentSize (RECEIVER, m_segmentSize);
|
||||
}
|
||||
|
||||
void
|
||||
TcpSlowStartNormalTest::QueueDrop (SocketWho who)
|
||||
{
|
||||
NS_FATAL_ERROR ("Drop on the queue; cannot validate slow start");
|
||||
}
|
||||
|
||||
void
|
||||
TcpSlowStartNormalTest::PhyDrop (SocketWho who)
|
||||
{
|
||||
NS_FATAL_ERROR ("Drop on the phy: cannot validate slow start");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +103,7 @@ TcpSlowStartNormalTest::CWndTrace (uint32_t oldValue, uint32_t newValue)
|
||||
|
||||
// The increase in RFC should be <= of segSize. In ns-3 we force = segSize
|
||||
NS_TEST_ASSERT_MSG_EQ (increase, segSize, "Increase different than segsize");
|
||||
NS_TEST_ASSERT_MSG_LT_OR_EQ (newValue, GetInitialSsThresh (), "cWnd increased over ssth");
|
||||
NS_TEST_ASSERT_MSG_LT_OR_EQ (newValue, GetInitialSsThresh (SENDER), "cWnd increased over ssth");
|
||||
|
||||
NS_LOG_INFO ("Incremented cWnd by " << segSize << " bytes in Slow Start " <<
|
||||
"achieving a value of " << newValue);
|
||||
@@ -98,7 +130,7 @@ TcpSlowStartNormalTest::Rx (const Ptr<const Packet> p, const TcpHeader &h, Socke
|
||||
|
||||
if (who == SENDER && Simulator::Now ().GetSeconds () > 5.0)
|
||||
{
|
||||
uint32_t acked = h.GetAckNumber().GetValue() - m_totalAckedBytes - 1;
|
||||
uint32_t acked = h.GetAckNumber ().GetValue () - m_totalAckedBytes - 1;
|
||||
m_totalAckedBytes += acked;
|
||||
m_ackedBytes += acked;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace ns3 {
|
||||
* \see CWndTrace
|
||||
*/
|
||||
class
|
||||
TcpSlowStartNormalTest : public TcpGeneralTest
|
||||
TcpSlowStartNormalTest : public TcpGeneralTest
|
||||
{
|
||||
public:
|
||||
TcpSlowStartNormalTest (uint32_t segmentSize, uint32_t packetSize,
|
||||
@@ -48,6 +48,11 @@ protected:
|
||||
virtual void CWndTrace (uint32_t oldValue, uint32_t newValue);
|
||||
virtual void Tx (const Ptr<const Packet> p, const TcpHeader &h, SocketWho who);
|
||||
virtual void Rx (const Ptr<const Packet> p, const TcpHeader &h, SocketWho who);
|
||||
void QueueDrop (SocketWho who);
|
||||
void PhyDrop (SocketWho who);
|
||||
|
||||
virtual void ConfigureEnvironment ();
|
||||
virtual void ConfigureProperties ();
|
||||
|
||||
uint32_t m_ackedBytes;
|
||||
uint32_t m_sentBytes;
|
||||
@@ -56,6 +61,11 @@ protected:
|
||||
|
||||
bool m_initial;
|
||||
|
||||
private:
|
||||
uint32_t m_segmentSize;
|
||||
uint32_t m_packetSize;
|
||||
uint32_t initialSsTh;
|
||||
uint32_t m_packets;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -67,7 +77,7 @@ protected:
|
||||
* Slow start behavior should not change.
|
||||
*/
|
||||
class
|
||||
TcpSlowStartAttackerTest : public TcpSlowStartNormalTest
|
||||
TcpSlowStartAttackerTest : public TcpSlowStartNormalTest
|
||||
{
|
||||
public:
|
||||
TcpSlowStartAttackerTest (uint32_t segmentSize, uint32_t packetSize,
|
||||
|
||||
@@ -42,6 +42,9 @@ protected:
|
||||
void NormalClose (SocketWho who);
|
||||
void FinalChecks ();
|
||||
|
||||
virtual void ConfigureEnvironment ();
|
||||
virtual void ConfigureProperties ();
|
||||
|
||||
void IncreaseBufSize ();
|
||||
|
||||
protected:
|
||||
@@ -53,15 +56,31 @@ protected:
|
||||
};
|
||||
|
||||
TcpZeroWindowTest::TcpZeroWindowTest (const std::string &desc)
|
||||
: TcpGeneralTest (desc, 500, 20, Seconds (0.01), Seconds (0.05), Seconds (2.0),
|
||||
0xffffffff, 10, 500),
|
||||
m_zeroWindowProbe (false),
|
||||
m_windowUpdated (false),
|
||||
m_senderFinished (false),
|
||||
m_receiverFinished (false)
|
||||
: TcpGeneralTest (desc),
|
||||
m_zeroWindowProbe (false),
|
||||
m_windowUpdated (false),
|
||||
m_senderFinished (false),
|
||||
m_receiverFinished (false)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
TcpZeroWindowTest::ConfigureEnvironment ()
|
||||
{
|
||||
TcpGeneralTest::ConfigureEnvironment ();
|
||||
SetAppPktCount (20);
|
||||
SetMTU (500);
|
||||
SetTransmitStart (Seconds (2.0));
|
||||
SetPropagationDelay (MilliSeconds (50));
|
||||
}
|
||||
|
||||
void
|
||||
TcpZeroWindowTest::ConfigureProperties ()
|
||||
{
|
||||
TcpGeneralTest::ConfigureProperties ();
|
||||
SetInitialCwnd (SENDER, 10);
|
||||
}
|
||||
|
||||
void
|
||||
TcpZeroWindowTest::IncreaseBufSize ()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user