24 #include "ns3/config.h"
25 #include "ns3/ipv4-end-point.h"
27 #include "ns3/ipv6-end-point.h"
31 #include "ns3/tcp-dctcp.h"
32 #include "ns3/tcp-l4-protocol.h"
33 #include "ns3/tcp-linux-reno.h"
34 #include "ns3/tcp-tx-buffer.h"
61 void ConfigureProperties()
override;
62 void ConfigureEnvironment()
override;
83 bool foundTag =
false;
96 "IP TOS should have ECT1 for SYN packet for DCTCP traffic");
103 "IP TOS should have ECT1 for data packets for DCTCP traffic");
113 "IP TOS should not have ECT1 for SYN packet for DCTCP traffic");
120 "IP TOS should have ECT0 for data packets for non-DCTCP but "
121 "ECN enabled traffic");
136 unsigned(ipTosTag.
GetTos()),
138 "IP TOS should have ECT1 for SYN+ACK packet for DCTCP traffic");
144 unsigned(ipTosTag.
GetTos()),
146 "IP TOS should have ECT1 for pure ACK packets for DCTCP traffic");
155 "IP TOS should have neither ECT0 nor ECT1 for SYN+ACK packet "
156 "for non-DCTCP traffic");
162 "IP TOS should not have ECT1 for pure ACK packets for "
163 "non-DCTCP traffic but ECN enabled traffic");
180 "The flag ECE should be set in TCP header of the packet sent by the receiver when "
181 "it receives a packet with CE bit set in IP header");
187 "The flag ECE should be not be set in TCP header of the packet "
188 "sent by the receiver if it receives a packet without CE bit set "
189 "in IP header in spite of Sender not sending CWR flags to it");
197 TcpGeneralTest::ConfigureProperties();
205 TcpGeneralTest::ConfigureEnvironment();
263 static TypeId tid =
TypeId(
"ns3::TcpDctcpCongestedRouter")
265 .SetGroupName(
"Internet")
273 TcpSocketBase::ReTxTimeout();
288 bool isRetransmission =
false;
291 isRetransmission =
true;
296 uint8_t flags = withAck ? TcpHeader::ACK : 0;
310 NS_LOG_INFO(
"Backoff mechanism by reducing CWND by half because we've received ECN Echo");
312 flags |= TcpHeader::CWR;
334 NS_LOG_LOGIC(
" ECT bits should not be set on retransmitted packets ");
362 if (
m_tcb->
m_ecnState != TcpSocketState::ECN_DISABLED && !isRetransmission)
400 if (
m_tcb->
m_ecnState != TcpSocketState::ECN_DISABLED && !isRetransmission)
432 flags |= TcpHeader::FIN;
465 NS_LOG_LOGIC(
this <<
" SendDataPacket Schedule ReTxTimeout at time "
481 << sz <<
" with remaining data " << remainingData <<
" via TcpL4Protocol to "
492 << sz <<
" with remaining data " << remainingData <<
" via TcpL4Protocol to "
513 return CopyObject<TcpDctcpCongestedRouter>(
this);
521 return TcpGeneralTest::CreateSenderSocket(node);
532 return TcpGeneralTest::CreateSocket(node,
533 TcpSocketMsgBase::GetTypeId(),
534 TcpDctcp::GetTypeId());
543 return TcpGeneralTest::CreateReceiverSocket(node);
547 return TcpGeneralTest::CreateSocket(node,
548 TcpSocketMsgBase::GetTypeId(),
549 TcpDctcp::GetTypeId());
576 uint32_t segmentsAcked,
580 const std::string& name);
583 void DoRun()
override;
601 uint32_t segmentsAcked,
605 const std::string& name)
609 m_segmentsAcked(segmentsAcked),
610 m_ssThresh(ssThresh),
612 m_highTxMark(highTxMark),
613 m_lastAckedSeq(lastAckedSeq)
622 Simulator::Destroy();
628 m_state = CreateObject<TcpSocketState>();
650 "cWnd has not updated correctly");
671 "DCTCP falls to New Reno for slowstart"),
674 "ECT Test : Check if ECT is set on Syn, Syn+Ack, "
675 "Ack and Data packets for DCTCP packets"),
679 "ECT Test : Check if ECT is not set on Syn, Syn+Ack and Ack but set on "
680 "Data packets for non-DCTCP but ECN enabled traffic"),
683 "ECE Functionality Test: ECE should only be sent by "
684 "receiver when it receives CE flags"),
Validates the setting of ECT and ECE codepoints for DCTCP enabled traffic.
void ConfigureEnvironment() override
Change the configuration of the environment.
uint32_t m_receiverSent
Number of packets sent by the receiver.
uint8_t m_testCase
Test type.
TcpDctcpCodePointsTest(uint8_t testCase, const std::string &desc)
Constructor.
Ptr< TcpSocketMsgBase > CreateSenderSocket(Ptr< Node > node) override
Create and install the socket to install on the sender.
Ptr< TcpSocketMsgBase > CreateReceiverSocket(Ptr< Node > node) override
Create and install the socket to install on the receiver.
uint32_t m_senderReceived
Number of packets received by the sender.
void Rx(const Ptr< const Packet > p, const TcpHeader &h, SocketWho who) override
Packet received from IP layer.
void ConfigureProperties() override
Change the configuration of the socket properties.
void Tx(const Ptr< const Packet > p, const TcpHeader &h, SocketWho who) override
Packet transmitted down to IP layer.
uint32_t m_senderSent
Number of packets sent by the sender.
A TCP socket which sends a data packet with CE flags set for test 3.
uint32_t m_dataPacketSent
Number of packets sent.
Ptr< TcpSocketBase > Fork() override
Call CopyObject<> to clone me.
static TypeId GetTypeId()
Get the type ID.
TcpDctcpCongestedRouter(const TcpDctcpCongestedRouter &other)
Constructor.
uint8_t m_testCase
Test type.
uint32_t SendDataPacket(SequenceNumber32 seq, uint32_t maxSize, bool withAck) override
Extract at most maxSize bytes from the TxBuffer at sequence seq, add the TCP header,...
void ReTxTimeout() override
An RTO event happened.
void SetTestCase(uint8_t testCase)
Set the test case type.
TcpDctcpCongestedRouter()
DCTCP should be same as Linux during slow start.
uint32_t m_segmentsAcked
segments acked
uint32_t m_ssThresh
ss thresh
TcpDctcpToLinuxReno(uint32_t cWnd, uint32_t segmentSize, uint32_t ssThresh, uint32_t segmentsAcked, SequenceNumber32 highTxMark, SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name)
Constructor.
void ExecuteTest()
Execute the test.
Ptr< TcpSocketState > m_state
state
SequenceNumber32 m_lastAckedSeq
last acked seq
SequenceNumber32 m_highTxMark
high tx mark
void DoRun() override
Implementation to actually run this TestCase.
uint32_t m_segmentSize
segment size
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsExpired() const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Ipv4Address GetLocalAddress() const
Get the local address.
uint16_t GetPeerPort() const
Get the peer port.
uint16_t GetLocalPort() const
Get the local port.
Ipv4Address GetPeerAddress() const
Get the peer address.
uint16_t GetLocalPort() const
Get the local port.
Ipv6Address GetPeerAddress() const
Get the peer address.
Ipv6Address GetLocalAddress() const
Get the local address.
uint16_t GetPeerPort() const
Get the peer port.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void AddPacketTag(const Tag &tag) const
Add a packet tag.
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
bool ReplacePacketTag(Tag &tag)
Replace the value of a packet tag.
bool IsManualIpTtl() const
Checks if the socket has a specific IPv4 TTL set.
virtual uint8_t GetIpTtl() const
Query the value of IP Time to Live field of this socket.
uint8_t GetIpTos() const
Query the value of IP Type of Service of this socket.
Ptr< NetDevice > m_boundnetdevice
the device this socket is bound to (might be null).
virtual uint8_t GetIpv6HopLimit() const
Query the value of IP Hop Limit field of this socket.
void NotifyDataSent(uint32_t size)
Notify through the callback (if set) that some data have been sent.
uint8_t GetPriority() const
Query the priority value of this socket.
uint8_t GetIpv6Tclass() const
Query the value of IPv6 Traffic Class field of this socket.
bool IsManualIpv6HopLimit() const
Checks if the socket has a specific IPv6 Hop Limit set.
bool IsManualIpv6Tclass() const
Checks if the socket has a specific IPv6 Tclass set.
indicates whether the socket has IP_TOS set.
void SetTos(uint8_t tos)
Set the tag's TOS.
uint8_t GetTos() const
Get the tag's TOS.
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer.
void SetTtl(uint8_t ttl)
Set the tag's TTL.
This class implements a tag that carries the socket-specific HOPLIMIT of a packet to the IPv6 layer.
void SetHopLimit(uint8_t hopLimit)
Set the tag's Hop Limit.
indicates whether the socket has IPV6_TCLASS set.
void SetTclass(uint8_t tclass)
Set the tag's Tclass.
indicates whether the socket has a priority set.
void SetPriority(uint8_t priority)
Set the tag's priority.
General infrastructure for TCP testing.
SocketWho
Used as parameter of methods, specifies on what node the caller is interested (e.g.
virtual Ptr< TcpSocketMsgBase > CreateSocket(Ptr< Node > node, TypeId socketType, TypeId congControl)
Create a socket.
void SetUseEcn(SocketWho who, TcpSocketState::UseEcn_t useEcn)
Forcefully set the ECN mode of use.
Ptr< TcpCongestionOps > m_congestionControl
Congestion control.
TracedCallback< Ptr< const Packet >, const TcpHeader &, Ptr< const TcpSocketBase > > m_txTrace
Trace of transmitted packets.
Ptr< TcpL4Protocol > m_tcp
the associated TCP L4 protocol
Ptr< TcpSocketState > m_tcb
Congestion control information.
bool m_closeOnEmpty
Close socket upon tx buffer emptied.
TracedValue< Time > m_rto
Retransmit timeout.
Ptr< TcpTxBuffer > m_txBuffer
Tx buffer.
EventId m_delAckEvent
Delayed ACK timeout event.
void AddOptions(TcpHeader &tcpHeader)
Add options to TcpHeader.
TracedValue< TcpStates_t > m_state
TCP state.
EventId m_retxEvent
Retransmission event.
TracedValue< SequenceNumber32 > m_ecnCWRSeq
Sequence number of the last sent CWR.
uint32_t m_delAckCount
Delayed ACK counter.
Ipv4EndPoint * m_endPoint
the IPv4 endpoint
virtual uint16_t AdvertisedWindowSize(bool scale=true) const
The amount of Rx window announced to the peer.
Ipv6EndPoint * m_endPoint6
the IPv6 endpoint
TracedValue< SequenceNumber32 > m_ecnEchoSeq
Sequence number of the last received ECN Echo.
Class for inserting callbacks special points of the flow of TCP sockets.
void UpdateRttHistory(const SequenceNumber32 &seq, uint32_t sz, bool isRetransmission) override
Update the RTT history, when we send TCP segments.
uint32_t m_segmentSize
Segment size.
TracedValue< SequenceNumber32 > m_highTxMark
Highest seqno ever sent, regardless of ReTx.
TracedValue< TcpCongState_t > m_congState
State in the Congestion state machine.
SequenceNumber32 m_lastAckedSeq
Last sequence ACKed.
TracedValue< uint32_t > m_cWnd
Congestion window.
Ptr< TcpRxBuffer > m_rxBuffer
Rx buffer (reordering buffer)
TracedValue< EcnState_t > m_ecnState
Current ECN State, represented as combination of EcnState values.
TracedValue< uint32_t > m_ssThresh
Slow start threshold.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
@ UNIT
This test suite implements a Unit Test.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
T Get() const
Get the underlying value.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void SetDefault(std::string name, const AttributeValue &value)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
SequenceNumber< uint32_t, int32_t > SequenceNumber32
32 bit Sequence number.
Time Now()
create an ns3::Time instance which contains the current simulation time.
@ ESTABLISHED
Connection established
@ CLOSE_WAIT
Remote side has shutdown and is waiting for us to finish writing our data and to shutdown (we have to...
@ FIN_WAIT_1
Our side has shutdown, waiting to complete transmission of remaining buffered data
@ LAST_ACK
Our side has shutdown after remote has shutdown.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static TcpDctcpTestSuite g_tcpdctcpTest
static var for test initialization