Test the behavior of TCP pacing. More...
Public Member Functions | |
TcpPacingTest (uint32_t segmentSize, uint32_t packetSize, uint32_t packets, uint16_t pacingSsRatio, uint16_t pacingCaRatio, uint32_t ssThresh, bool paceInitialWindow, uint32_t delAckMaxCount, const TypeId &congControl, const std::string &desc) | |
Constructor. | |
Public Member Functions inherited from ns3::TcpGeneralTest | |
TcpGeneralTest (const std::string &desc) | |
TcpGeneralTest constructor. | |
~TcpGeneralTest () override | |
Public Member Functions inherited from ns3::TestCase | |
TestCase (const TestCase &)=delete | |
virtual | ~TestCase () |
Destructor. | |
std::string | GetName () const |
TestCase & | operator= (const TestCase &)=delete |
Protected Member Functions | |
void | BytesInFlightTrace (uint32_t oldValue, uint32_t newValue) override |
Bytes in flight changes. | |
void | ConfigureEnvironment () override |
Change the configuration of the environment. | |
void | ConfigureProperties () override |
Change the configuration of the socket properties. | |
void | CWndTrace (uint32_t oldValue, uint32_t newValue) override |
Tracks the congestion window changes. | |
void | NormalClose (SocketWho who) override |
Socket closed normally. | |
void | PhyDrop (SocketWho who) override |
Link drop. | |
void | QueueDrop (SocketWho who) override |
Drop on the queue. | |
void | RttTrace (Time oldTime, Time newTime) override |
Rtt changes. | |
void | Rx (const Ptr< const Packet > p, const TcpHeader &h, SocketWho who) override |
Packet received from IP layer. | |
void | Tx (const Ptr< const Packet > p, const TcpHeader &h, SocketWho who) override |
Packet transmitted down to IP layer. | |
virtual void | UpdateExpectedInterval () |
Update the expected interval at which next packet will be sent. | |
Protected Member Functions inherited from ns3::TcpGeneralTest | |
virtual void | AfterRTOExpired (const Ptr< const TcpSocketState > tcb, SocketWho who) |
Rto has expired. | |
virtual void | BeforeRTOExpired (const Ptr< const TcpSocketState > tcb, SocketWho who) |
Rto has expired. | |
virtual void | CongStateTrace (const TcpSocketState::TcpCongState_t oldValue, const TcpSocketState::TcpCongState_t newValue) |
State on Ack state machine changes. | |
virtual Ptr< SimpleChannel > | CreateChannel () |
Create and return the channel installed between the two socket. | |
virtual Ptr< ErrorModel > | CreateReceiverErrorModel () |
Create and return the error model to install in the receiver node. | |
virtual Ptr< TcpSocketMsgBase > | CreateReceiverSocket (Ptr< Node > node) |
Create and install the socket to install on the receiver. | |
virtual Ptr< ErrorModel > | CreateSenderErrorModel () |
Create and return the error model to install in the sender node. | |
virtual Ptr< TcpSocketMsgBase > | CreateSenderSocket (Ptr< Node > node) |
Create and install the socket to install on the sender. | |
virtual Ptr< TcpSocketMsgBase > | CreateSocket (Ptr< Node > node, TypeId socketType, TypeId congControl) |
Create a socket. | |
virtual Ptr< TcpSocketMsgBase > | CreateSocket (Ptr< Node > node, TypeId socketType, TypeId congControl, TypeId recoveryAlgorithm) |
Create a socket. | |
virtual void | CWndInflTrace (uint32_t oldValue, uint32_t newValue) |
Tracks the inflated congestion window changes. | |
virtual void | DataSent (uint32_t size, SocketWho who) |
Notifying application for sent data. | |
void | DoConnect () |
Scheduled at 0.0, SENDER starts the connection to RECEIVER. | |
void | DoRun () override |
Execute the tcp test. | |
void | DoTeardown () override |
Teardown the TCP test. | |
virtual void | ErrorClose (SocketWho who) |
Socket closed with an error. | |
virtual void | FinalChecks () |
Performs the (eventual) final checks through test asserts. | |
Time | GetClockGranularity (SocketWho who) |
Get the clock granularity attribute. | |
Time | GetConnTimeout (SocketWho who) |
Get the retransmission time for the SYN segments. | |
uint32_t | GetDelAckCount (SocketWho who) |
Get the number of delayed ack (if present) | |
Time | GetDelAckTimeout (SocketWho who) |
Get the timeout of delayed ack (if present) | |
uint32_t | GetDupAckCount (SocketWho who) |
Get the number of dupack received. | |
SequenceNumber32 | GetHighestTxMark (SocketWho who) |
Get the highest tx mark of the node specified. | |
uint32_t | GetInitialCwnd (SocketWho who) |
Get the initial congestion window. | |
uint32_t | GetInitialSsThresh (SocketWho who) |
Get the initial slow start threshold. | |
Time | GetMinRto (SocketWho who) |
Get the minimum RTO attribute. | |
uint32_t | GetMtu () const |
Get the MTU of the environment. | |
EventId | GetPersistentEvent (SocketWho who) |
Get the persistent event of the selected socket. | |
Time | GetPersistentTimeout (SocketWho who) |
Get the persistent timeout of the selected socket. | |
uint32_t | GetPktCount () const |
Get the number of application packets. | |
Time | GetPktInterval () const |
Get the interval to wait for each packet sent down from application to TCP. | |
uint32_t | GetPktSize () const |
Get the application packet size. | |
Time | GetPropagationDelay () const |
Get the channel Propagation Delay. | |
Ptr< TcpSocketMsgBase > | GetReceiverSocket () |
Get the pointer to a previously created receiver socket. | |
uint32_t | GetReTxThreshold (SocketWho who) |
Get the retransmission threshold. | |
Time | GetRto (SocketWho who) |
Get the retransmission time. | |
Ptr< RttEstimator > | GetRttEstimator (SocketWho who) |
Get the Rtt estimator of the socket. | |
uint32_t | GetRWnd (SocketWho who) |
Get the rWnd of the selected socket. | |
Ptr< TcpRxBuffer > | GetRxBuffer (SocketWho who) |
Get the Rx buffer from selected socket. | |
uint32_t | GetSegSize (SocketWho who) |
Get the segment size of the node specified. | |
Ptr< TcpSocketMsgBase > | GetSenderSocket () |
Get the pointer to a previously created sender socket. | |
Time | GetStartTime () const |
Get the data start time. | |
Ptr< TcpSocketState > | GetTcb (SocketWho who) |
Get the TCB from selected socket. | |
TcpSocket::TcpStates_t | GetTcpState (SocketWho who) |
Get the state of the TCP state machine. | |
Ptr< TcpTxBuffer > | GetTxBuffer (SocketWho who) |
Get the Tx buffer from selected socket. | |
virtual void | HighestTxSeqTrace (SequenceNumber32 oldValue, SequenceNumber32 newValue) |
Highest tx seq changes. | |
virtual void | NextTxSeqTrace (SequenceNumber32 oldValue, SequenceNumber32 newValue) |
Next tx seq changes. | |
virtual void | ProcessedAck (const Ptr< const TcpSocketState > tcb, const TcpHeader &h, SocketWho who) |
Processed ack. | |
virtual void | RateSampleUpdatedTrace (const TcpRateLinux::TcpRateSample &sample) |
Track the rate sample value of TcpRateLinux. | |
virtual void | RateUpdatedTrace (const TcpRateLinux::TcpRateConnection &rate) |
Track the rate value of TcpRateLinux. | |
virtual void | RcvAck (const Ptr< const TcpSocketState > tcb, const TcpHeader &h, SocketWho who) |
Received ack. | |
virtual void | ReceivePacket (Ptr< Socket > socket) |
Packet received. | |
virtual void | RtoTrace (Time oldValue, Time newValue) |
RTO changes. | |
void | SendPacket (Ptr< Socket > socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval) |
Send packets to other endpoint. | |
void | SetAppPktCount (uint32_t pktCount) |
Set app packet count. | |
void | SetAppPktInterval (Time pktInterval) |
Interval between app-generated packet. | |
void | SetAppPktSize (uint32_t pktSize) |
Set app packet size. | |
void | SetCongestionControl (TypeId congControl) |
Congestion control of the sender socket. | |
void | SetDelAckMaxCount (SocketWho who, uint32_t count) |
Forcefully set the delayed acknowledgement count. | |
void | SetInitialCwnd (SocketWho who, uint32_t initialCwnd) |
Forcefully set the initial cwnd. | |
void | SetInitialSsThresh (SocketWho who, uint32_t initialSsThresh) |
Forcefully set the initial ssthresh. | |
void | SetMTU (uint32_t mtu) |
MTU of the bottleneck link. | |
void | SetPaceInitialWindow (SocketWho who, bool paceWindow) |
Enable or disable pacing of the initial window. | |
void | SetPacingStatus (SocketWho who, bool pacing) |
Enable or disable pacing in the TCP socket. | |
void | SetPropagationDelay (Time propDelay) |
Propagation delay of the bottleneck link. | |
void | SetRcvBufSize (SocketWho who, uint32_t size) |
Forcefully set a defined size for rx buffer. | |
void | SetRecoveryAlgorithm (TypeId recovery) |
recovery algorithm of the sender socket | |
void | SetSegmentSize (SocketWho who, uint32_t segmentSize) |
Forcefully set the segment size. | |
void | SetTransmitStart (Time startTime) |
Set the initial time at which the application sends the first data packet. | |
void | SetUseEcn (SocketWho who, TcpSocketState::UseEcn_t useEcn) |
Forcefully set the ECN mode of use. | |
virtual void | SsThreshTrace (uint32_t oldValue, uint32_t newValue) |
Slow start threshold changes. | |
virtual void | UpdatedRttHistory (const SequenceNumber32 &seq, uint32_t sz, bool isRetransmission, SocketWho who) |
Updated the Rtt history. | |
Protected Member Functions inherited from ns3::TestCase | |
TestCase (std::string name) | |
Constructor. | |
void | AddTestCase (TestCase *testCase, Duration duration=Duration::QUICK) |
Add an individual child TestCase to this test suite. | |
TestCase * | GetParent () const |
Get the parent of this TestCase. | |
bool | IsStatusFailure () const |
Check if any tests failed. | |
bool | IsStatusSuccess () const |
Check if all tests passed. | |
void | SetDataDir (std::string directory) |
Set the data directory where reference trace files can be found. | |
void | ReportTestFailure (std::string cond, std::string actual, std::string limit, std::string message, std::string file, int32_t line) |
Log the failure of this TestCase. | |
bool | MustAssertOnFailure () const |
Check if this run should assert on failure. | |
bool | MustContinueOnFailure () const |
Check if this run should continue on failure. | |
std::string | CreateDataDirFilename (std::string filename) |
Construct the full path to a file in the data directory. | |
std::string | CreateTempDirFilename (std::string filename) |
Construct the full path to a file in a temporary directory. | |
Private Attributes | |
uint32_t | m_bytesInFlight |
Current bytes in flight. | |
uint32_t | m_curCwnd |
Current sender cWnd. | |
uint32_t | m_delAckMaxCount |
Delayed ack count for receiver. | |
EventId | m_event |
Check event. | |
Time | m_expectedInterval |
Theoretical estimate of the time at which next packet is scheduled for transmission. | |
bool | m_initial |
True on first run. | |
uint32_t | m_initialCwnd |
Initial value of cWnd. | |
bool | m_isConnAboutToEnd |
True when sender receives a FIN/ACK from receiver. | |
bool | m_isFullCwndSent |
True if all bytes for that cWnd is sent and sender is waiting for an ACK. | |
Time | m_nextPacketInterval |
Time maintained by Tx () trace about interval at which next packet will be sent. | |
bool | m_paceInitialWindow |
True if initial window should be paced. | |
uint16_t | m_pacingCaRatio |
Pacing factor during Congestion Avoidance. | |
uint16_t | m_pacingSsRatio |
Pacing factor during Slow Start. | |
uint32_t | m_packets |
Number of packets. | |
uint32_t | m_packetSize |
Size of the packets. | |
uint32_t | m_packetsSent |
Number of packets sent by sender so far. | |
Time | m_prevTxTime |
Time when Tx was previously called. | |
uint32_t | m_segmentSize |
Segment size. | |
uint32_t | m_ssThresh |
Slow start threshold. | |
Time | m_tracedRtt |
Traced value of RTT, which may be different from the environment RTT in case of delayed ACKs. | |
Time | m_transmissionStartTime |
Time at which sender starts data transmission. | |
Additional Inherited Members | |
Public Types inherited from ns3::TcpGeneralTest | |
enum | SocketWho { SENDER , RECEIVER } |
Used as parameter of methods, specifies on what node the caller is interested (e.g. More... | |
Public Types inherited from ns3::TestCase | |
enum class | Duration { QUICK = 1 , EXTENSIVE = 2 , TAKES_FOREVER = 3 } |
How long the test takes to execute. More... | |
Static Public Attributes inherited from ns3::TestCase | |
static constexpr auto | QUICK = Duration::QUICK |
Deprecated test duration simple enums. | |
static constexpr auto | EXTENSIVE = Duration::EXTENSIVE |
static constexpr auto | TAKES_FOREVER = Duration::TAKES_FOREVER |
Protected Attributes inherited from ns3::TcpGeneralTest | |
TypeId | m_congControlTypeId |
Congestion control. | |
TypeId | m_recoveryTypeId |
Recovery. | |
Test the behavior of TCP pacing.
This test checks that packets are paced at correct intervals. The test uses a shadow pacing rate calculation assumed to match the internal pacing calculation. Therefore, if you modify the values of pacingSsRatio and pacingCaRatio herein, ensure that you also change values used in the TCP implementation to match.
This test environment uses an RTT of 100ms The time interval between two consecutive packet transmissions is measured Pacing rate should be at least cwnd / rtt to transmit cwnd segments per rtt. Linux multiples this basic ratio by an additional factor, to yield pacingRate = (factor * cwnd) / rtt Since pacingRate can also be written as segmentSize / interval we can solve for interval = (segmentSize * rtt) / (factor * cwnd)
The test checks whether the measured interval lies within a tolerance value of the expected interval. The tolerance or error margin was chosen to be 10 Nanoseconds, that could be due to delay introduced by the application's send process.
This check should not be performed for a packet transmission after the sender has sent all bytes corresponding to the window and is awaiting an ACK from the receiver (corresponding to m_isFullCwndSent). Pacing check should be performed when the sender is actively sending packets from cwnd.
The same argument applies when the sender has finished sending packets and is awaiting a FIN/ACK from the receiver, to send the final ACK
As can be seen in TcpSocketBase::UpdatePacingRate (), different pacing ratios are used when cwnd < ssThresh / 2 and when cwnd > ssThresh / 2
A few key points to note:
Definition at line 78 of file tcp-pacing-test.cc.
TcpPacingTest::TcpPacingTest | ( | uint32_t | segmentSize, |
uint32_t | packetSize, | ||
uint32_t | packets, | ||
uint16_t | pacingSsRatio, | ||
uint16_t | pacingCaRatio, | ||
uint32_t | ssThresh, | ||
bool | paceInitialWindow, | ||
uint32_t | delAckMaxCount, | ||
const TypeId & | congControl, | ||
const std::string & | desc ) |
Constructor.
segmentSize | Segment size at the TCP layer (bytes). |
packetSize | Size of packets sent at the application layer (bytes). |
packets | Number of packets. |
pacingSsRatio | Pacing Ratio during Slow Start (multiplied by 100) |
pacingCaRatio | Pacing Ratio during Congestion Avoidance (multiplied by 100) |
ssThresh | slow start threshold (bytes) |
paceInitialWindow | whether to pace the initial window |
delAckMaxCount | Delayed ACK max count parameter |
congControl | Type of congestion control. |
desc | The test description. |
Definition at line 151 of file tcp-pacing-test.cc.
References ns3::TcpGeneralTest::m_congControlTypeId.
|
overrideprotectedvirtual |
Bytes in flight changes.
This applies only for sender socket.
oldValue | old value |
newValue | new value |
Reimplemented from ns3::TcpGeneralTest.
Definition at line 236 of file tcp-pacing-test.cc.
References m_bytesInFlight.
|
overrideprotectedvirtual |
Change the configuration of the environment.
Reimplemented from ns3::TcpGeneralTest.
Definition at line 187 of file tcp-pacing-test.cc.
References ns3::TcpGeneralTest::ConfigureEnvironment(), m_packets, m_packetSize, ns3::MilliSeconds(), ns3::NanoSeconds(), ns3::Seconds(), ns3::TcpGeneralTest::SetAppPktCount(), ns3::TcpGeneralTest::SetAppPktInterval(), ns3::TcpGeneralTest::SetAppPktSize(), ns3::TcpGeneralTest::SetMTU(), ns3::TcpGeneralTest::SetPropagationDelay(), and ns3::TcpGeneralTest::SetTransmitStart().
|
overrideprotectedvirtual |
Change the configuration of the socket properties.
Reimplemented from ns3::TcpGeneralTest.
Definition at line 199 of file tcp-pacing-test.cc.
References ns3::TcpGeneralTest::ConfigureProperties(), m_delAckMaxCount, m_initialCwnd, m_paceInitialWindow, m_segmentSize, m_ssThresh, NS_LOG_DEBUG, ns3::TcpGeneralTest::RECEIVER, ns3::TcpGeneralTest::SENDER, ns3::TcpGeneralTest::SetDelAckMaxCount(), ns3::TcpGeneralTest::SetInitialCwnd(), ns3::TcpGeneralTest::SetInitialSsThresh(), ns3::TcpGeneralTest::SetPaceInitialWindow(), ns3::TcpGeneralTest::SetPacingStatus(), and ns3::TcpGeneralTest::SetSegmentSize().
Tracks the congestion window changes.
oldValue | old value |
newValue | new value |
Reimplemented from ns3::TcpGeneralTest.
Definition at line 222 of file tcp-pacing-test.cc.
References m_curCwnd, m_initial, NS_LOG_FUNCTION, and UpdateExpectedInterval().
|
overrideprotectedvirtual |
Socket closed normally.
who | the socket closed (SENDER or RECEIVER) |
Reimplemented from ns3::TcpGeneralTest.
Definition at line 347 of file tcp-pacing-test.cc.
References ns3::EventId::Cancel(), m_event, and ns3::TcpGeneralTest::SENDER.
|
overrideprotectedvirtual |
Link drop.
who | where the drop occurred (SENDER or RECEIVER) |
Reimplemented from ns3::TcpGeneralTest.
Definition at line 341 of file tcp-pacing-test.cc.
References NS_FATAL_ERROR.
|
overrideprotectedvirtual |
Drop on the queue.
who | where the drop occurred (SENDER or RECEIVER) |
Reimplemented from ns3::TcpGeneralTest.
Definition at line 335 of file tcp-pacing-test.cc.
References NS_FATAL_ERROR.
Rtt changes.
This applies only for sender socket.
oldTime | old value |
newTime | new value |
Reimplemented from ns3::TcpGeneralTest.
Definition at line 214 of file tcp-pacing-test.cc.
References m_tracedRtt, NS_LOG_FUNCTION, and UpdateExpectedInterval().
|
overrideprotectedvirtual |
Packet received from IP layer.
p | packet |
h | header |
who | the socket which has received the packet (SENDER or RECEIVER) |
Reimplemented from ns3::TcpGeneralTest.
Definition at line 269 of file tcp-pacing-test.cc.
References ns3::TcpHeader::ACK, ns3::TcpHeader::FIN, ns3::TcpHeader::GetFlags(), m_isConnAboutToEnd, NS_LOG_DEBUG, and ns3::TcpGeneralTest::SENDER.
|
overrideprotectedvirtual |
Packet transmitted down to IP layer.
p | packet |
h | header |
who | the socket which has received the packet (SENDER or RECEIVER) |
Reimplemented from ns3::TcpGeneralTest.
Definition at line 290 of file tcp-pacing-test.cc.
References ns3::Time::GetSeconds(), m_bytesInFlight, m_curCwnd, m_expectedInterval, m_isConnAboutToEnd, m_isFullCwndSent, m_nextPacketInterval, m_packetsSent, m_prevTxTime, m_segmentSize, ns3::NanoSeconds(), ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_TEST_ASSERT_MSG_LT_OR_EQ, and ns3::TcpGeneralTest::SENDER.
|
protectedvirtual |
Update the expected interval at which next packet will be sent.
Definition at line 242 of file tcp-pacing-test.cc.
References ns3::TcpGeneralTest::GetPropagationDelay(), ns3::Time::GetSeconds(), m_curCwnd, m_expectedInterval, m_initialCwnd, m_paceInitialWindow, m_pacingCaRatio, m_pacingSsRatio, m_segmentSize, m_ssThresh, m_tracedRtt, and ns3::Seconds().
Referenced by CWndTrace(), and RttTrace().
|
private |
Current bytes in flight.
Definition at line 133 of file tcp-pacing-test.cc.
Referenced by BytesInFlightTrace(), and Tx().
|
private |
Current sender cWnd.
Definition at line 130 of file tcp-pacing-test.cc.
Referenced by CWndTrace(), Tx(), and UpdateExpectedInterval().
|
private |
Delayed ack count for receiver.
Definition at line 139 of file tcp-pacing-test.cc.
Referenced by ConfigureProperties().
|
private |
|
private |
Theoretical estimate of the time at which next packet is scheduled for transmission.
Definition at line 142 of file tcp-pacing-test.cc.
Referenced by Tx(), and UpdateExpectedInterval().
|
private |
|
private |
Initial value of cWnd.
Definition at line 129 of file tcp-pacing-test.cc.
Referenced by ConfigureProperties(), and UpdateExpectedInterval().
|
private |
True when sender receives a FIN/ACK from receiver.
Definition at line 140 of file tcp-pacing-test.cc.
|
private |
True if all bytes for that cWnd is sent and sender is waiting for an ACK.
Definition at line 131 of file tcp-pacing-test.cc.
Referenced by Tx().
|
private |
Time maintained by Tx () trace about interval at which next packet will be sent.
Definition at line 145 of file tcp-pacing-test.cc.
Referenced by Tx().
|
private |
True if initial window should be paced.
Definition at line 138 of file tcp-pacing-test.cc.
Referenced by ConfigureProperties(), and UpdateExpectedInterval().
|
private |
Pacing factor during Congestion Avoidance.
Definition at line 136 of file tcp-pacing-test.cc.
Referenced by UpdateExpectedInterval().
|
private |
Pacing factor during Slow Start.
Definition at line 135 of file tcp-pacing-test.cc.
Referenced by UpdateExpectedInterval().
|
private |
Number of packets.
Definition at line 126 of file tcp-pacing-test.cc.
Referenced by ConfigureEnvironment().
|
private |
Size of the packets.
Definition at line 125 of file tcp-pacing-test.cc.
Referenced by ConfigureEnvironment().
|
private |
Number of packets sent by sender so far.
Definition at line 144 of file tcp-pacing-test.cc.
Referenced by Tx().
|
private |
Time when Tx was previously called.
Definition at line 134 of file tcp-pacing-test.cc.
Referenced by Tx().
|
private |
Segment size.
Definition at line 124 of file tcp-pacing-test.cc.
Referenced by ConfigureProperties(), Tx(), and UpdateExpectedInterval().
|
private |
Slow start threshold.
Definition at line 137 of file tcp-pacing-test.cc.
Referenced by ConfigureProperties(), and UpdateExpectedInterval().
|
private |
Traced value of RTT, which may be different from the environment RTT in case of delayed ACKs.
Definition at line 147 of file tcp-pacing-test.cc.
Referenced by RttTrace(), and UpdateExpectedInterval().
|
private |
Time at which sender starts data transmission.
Definition at line 141 of file tcp-pacing-test.cc.