13#include "ns3/config.h"
14#include "ns3/ipv4-end-point.h"
16#include "ns3/ipv6-end-point.h"
20#include "ns3/tcp-dctcp.h"
21#include "ns3/tcp-l4-protocol.h"
22#include "ns3/tcp-linux-reno.h"
23#include "ns3/tcp-tx-buffer.h"
72 bool foundTag =
false;
77 foundTag = p->PeekPacketTag(ipTosTag);
85 "IP TOS should have ECT1 for SYN packet for DCTCP traffic");
92 "IP TOS should have ECT1 for data packets for DCTCP traffic");
102 "IP TOS should not have ECT1 for SYN packet for DCTCP traffic");
109 "IP TOS should have ECT0 for data packets for non-DCTCP but "
110 "ECN enabled traffic");
118 foundTag = p->PeekPacketTag(ipTosTag);
125 unsigned(ipTosTag.
GetTos()),
127 "IP TOS should have ECT1 for SYN+ACK packet for DCTCP traffic");
133 unsigned(ipTosTag.
GetTos()),
135 "IP TOS should have ECT1 for pure ACK packets for DCTCP traffic");
144 "IP TOS should have neither ECT0 nor ECT1 for SYN+ACK packet "
145 "for non-DCTCP traffic");
151 "IP TOS should not have ECT1 for pure ACK packets for "
152 "non-DCTCP traffic but ECN enabled traffic");
169 "The flag ECE should be set in TCP header of the packet sent by the receiver when "
170 "it receives a packet with CE bit set in IP header");
176 "The flag ECE should be not be set in TCP header of the packet "
177 "sent by the receiver if it receives a packet without CE bit set "
178 "in IP header in spite of Sender not sending CWR flags to it");
252 static TypeId tid =
TypeId(
"ns3::TcpDctcpCongestedRouter")
254 .SetGroupName(
"Internet")
277 bool isRetransmission =
false;
278 if (seq !=
m_tcb->m_highTxMark)
280 isRetransmission =
true;
299 NS_LOG_INFO(
"Backoff mechanism by reducing CWND by half because we've received ECN Echo");
323 NS_LOG_LOGIC(
" ECT bits should not be set on retransmitted packets ");
340 p->AddPacketTag(ipTosTag);
356 p->AddPacketTag(ipTosTag);
378 p->AddPacketTag(ipTclassTag);
394 p->AddPacketTag(ipTclassTag);
401 p->AddPacketTag(ipTtlTag);
408 p->AddPacketTag(ipHopLimitTag);
416 p->ReplacePacketTag(priorityTag);
454 NS_LOG_LOGIC(
this <<
" SendDataPacket Schedule ReTxTimeout at time "
470 << sz <<
" with remaining data " << remainingData <<
" via TcpL4Protocol to "
481 << sz <<
" with remaining data " << remainingData <<
" via TcpL4Protocol to "
488 if (seq + sz >
m_tcb->m_highTxMark)
492 (seq + sz -
m_tcb->m_highTxMark.Get()));
495 m_tcb->m_highTxMark = std::max(seq + sz,
m_tcb->m_highTxMark.Get());
569 const std::string& name);
572 void DoRun()
override;
594 const std::string& name)
598 m_segmentsAcked(segmentsAcked),
599 m_ssThresh(ssThresh),
601 m_highTxMark(highTxMark),
602 m_lastAckedSeq(lastAckedSeq)
639 "cWnd has not updated correctly");
660 "DCTCP falls to New Reno for slowstart"),
661 TestCase::Duration::QUICK);
663 "ECT Test : Check if ECT is set on Syn, Syn+Ack, "
664 "Ack and Data packets for DCTCP packets"),
665 TestCase::Duration::QUICK);
668 "ECT Test : Check if ECT is not set on Syn, Syn+Ack and Ack but set on "
669 "Data packets for non-DCTCP but ECN enabled traffic"),
670 TestCase::Duration::QUICK);
672 "ECE Functionality Test: ECE should only be sent by "
673 "receiver when it receives CE flags"),
674 TestCase::Duration::QUICK);
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.
friend Ptr< T > CopyObject(Ptr< T > object)
Copy an Object.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
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.
static TypeId GetTypeId()
Get the type ID.
General infrastructure for TCP testing.
virtual Ptr< TcpSocketMsgBase > CreateSenderSocket(Ptr< Node > node)
Create and install the socket to install on the sender.
SocketWho
Used as parameter of methods, specifies on what node the caller is interested (e.g.
virtual Ptr< TcpSocketMsgBase > CreateReceiverSocket(Ptr< Node > node)
Create and install the socket to install on the receiver.
virtual Ptr< TcpSocketMsgBase > CreateSocket(Ptr< Node > node, TypeId socketType, TypeId congControl)
Create a socket.
virtual void ConfigureProperties()
Change the configuration of the socket properties.
void SetUseEcn(SocketWho who, TcpSocketState::UseEcn_t useEcn)
Forcefully set the ECN mode of use.
virtual void ConfigureEnvironment()
Change the configuration of the environment.
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.
virtual void ReTxTimeout()
An RTO event happened.
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.
static TypeId GetTypeId()
Get the type ID.
static const char *const TcpCongStateName[TcpSocketState::CA_LAST_STATE]
Literal names of TCP states for use in log messages.
@ CA_CWR
cWnd was reduced due to some congestion notification event, such as ECN, ICMP source quench,...
@ CA_OPEN
Normal state, no dubious events.
@ ECN_CWR_SENT
Sender has reduced the congestion window, and sent a packet with CWR bit set in TCP header.
@ ECN_DISABLED
ECN disabled traffic.
@ ECN_ECE_RCVD
Last ACK received had ECE bit set in TCP header.
static const char *const EcnStateName[TcpSocketState::ECN_CWR_SENT+1]
Literal names of ECN states for use in log messages.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
static constexpr auto UNIT
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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
SequenceNumber< uint32_t, int32_t > SequenceNumber32
32 bit Sequence number.
@ 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.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
static TcpDctcpTestSuite g_tcpdctcpTest
static var for test initialization