24 #include "../model/ipv4-end-point.h" 25 #include "../model/ipv6-end-point.h" 30 #include "ns3/tcp-l4-protocol.h" 31 #include "ns3/tcp-dctcp.h" 32 #include "ns3/tcp-tx-buffer.h" 33 #include "ns3/config.h" 61 void ConfigureProperties ();
62 void ConfigureEnvironment ();
83 bool foundTag =
false;
106 NS_TEST_ASSERT_MSG_EQ (foundTag,
false,
"IP TOS should not have ECT1 for SYN packet for DCTCP traffic");
111 NS_TEST_ASSERT_MSG_EQ (
unsigned (ipTosTag.
GetTos ()), 0x2,
"IP TOS should have ECT0 for data packets for non-DCTCP but ECN enabled traffic");
137 NS_TEST_ASSERT_MSG_EQ (foundTag,
false,
"IP TOS should have neither ECT0 nor ECT1 for SYN+ACK packet for non-DCTCP traffic");
141 NS_TEST_ASSERT_MSG_EQ (foundTag,
false,
"IP TOS should not have ECT1 for pure ACK packets for non-DCTCP traffic but ECN enabled traffic");
155 NS_TEST_ASSERT_MSG_NE (((h.
GetFlags ()) & TcpHeader::ECE), 0,
"The flag ECE should be set in TCP header of the packet sent by the receiver when it receives a packet with CE bit set in IP header");
159 NS_TEST_ASSERT_MSG_EQ (((h.
GetFlags ()) & TcpHeader::ECE), 0,
"The flag ECE should be not be set in TCP header of the packet sent by the receiver if it receives a packet without CE bit set in IP header inspite of Sender not sending CWR flags to it");
167 TcpGeneralTest::ConfigureProperties ();
175 TcpGeneralTest::ConfigureEnvironment ();
229 static TypeId tid =
TypeId (
"ns3::TcpDctcpCongestedRouter")
231 .SetGroupName (
"Internet")
240 TcpSocketBase::ReTxTimeout ();
255 bool isRetransmission =
false;
258 isRetransmission =
true;
263 uint8_t flags = withAck ? TcpHeader::ACK : 0;
275 NS_LOG_INFO (
"Backoff mechanism by reducing CWND by half because we've received ECN Echo");
278 flags |= TcpHeader::CWR;
300 NS_LOG_LOGIC (
" ECT bits should not be set on retransmitted packets ");
327 if (
m_tcb->
m_ecnState != TcpSocketState::ECN_DISABLED && !isRetransmission)
364 if (
m_tcb->
m_ecnState != TcpSocketState::ECN_DISABLED && !isRetransmission)
396 flags |= TcpHeader::FIN;
429 NS_LOG_LOGIC (
this <<
" SendDataPacket Schedule ReTxTimeout at time " <<
441 NS_LOG_DEBUG (
"Send segment of size " << sz <<
" with remaining data " <<
443 ". Header " << header);
449 NS_LOG_DEBUG (
"Send segment of size " << sz <<
" with remaining data " <<
451 ". Header " << header);
470 return CopyObject<TcpDctcpCongestedRouter> (
this);
478 return TcpGeneralTest::CreateSenderSocket (node);
485 TcpDctcp::GetTypeId ()));
491 return TcpGeneralTest::CreateSocket (node, TcpSocketMsgBase::GetTypeId (), TcpDctcp::GetTypeId ());
500 return TcpGeneralTest::CreateReceiverSocket (node);
504 return TcpGeneralTest::CreateSocket (node, TcpSocketMsgBase::GetTypeId (), TcpDctcp::GetTypeId ());
534 virtual void DoRun (
void);
555 m_segmentsAcked (segmentsAcked),
556 m_ssThresh (ssThresh),
558 m_highTxMark (highTxMark),
559 m_lastAckedSeq (lastAckedSeq)
568 Simulator::Destroy ();
574 m_state = CreateObject <TcpSocketState> ();
595 "cWnd has not updated correctly");
621 virtual void DoRun (
void);
640 m_segmentsAcked (segmentsAcked),
642 m_nextTxSequence (nextTxSequence),
643 m_lastAckedSeq (lastAckedSeq)
653 Simulator::Destroy ();
659 m_state = CreateObject <TcpSocketState> ();
670 "cWnd has updated correctly");
676 uint32_t val = (uint32_t)(
m_cWnd * (1 - 0.0625 / 2.0));
678 "cWnd has updated correctly");
697 AddTestCase (
new TcpDctcpCodePointsTest (2,
"ECT Test : Check if ECT is not set on Syn, Syn+Ack and Ack but set on Data packets for non-DCTCP but ECN enabled traffic"),TestCase::QUICK);
Ipv6Address GetLocalAddress()
Get the local address.
void SetTclass(uint8_t tclass)
Set the tag's Tclass.
uint8_t GetTos(void) const
Get the tag's TOS.
static TypeId GetTypeId(void)
Get the type ID.
Simulation virtual time values and global simulation resolution.
uint32_t m_ssThresh
ss thresh
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
AttributeValue implementation for Boolean.
void ExecuteTest(void)
Execute the test.
TcpDctcpCongestedRouter(const TcpDctcpCongestedRouter &other)
Constructor.
Class for inserting callbacks special points of the flow of TCP sockets.
This class implements a tag that carries the socket-specific HOPLIMIT of a packet to the IPv6 layer...
Ipv4EndPoint * m_endPoint
the IPv4 endpoint
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
EventId m_retxEvent
Retransmission event.
TcpDctcpToNewReno(uint32_t cWnd, uint32_t segmentSize, uint32_t ssThresh, uint32_t segmentsAcked, SequenceNumber32 highTxMark, SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name)
Constructor.
DCTCP should be same as NewReno during slow start.
TcpDctcpCongestedRouter()
TracedValue< EcnState_t > m_ecnState
Current ECN State, represented as combination of EcnState values.
void SetTestCase(uint8_t testCase)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< TcpSocketState > m_tcb
Congestion control information.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
uint32_t m_segmentSize
Segment size.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Ptr< TcpRxBuffer > m_rxBuffer
Rx buffer (reordering buffer)
void SetTos(uint8_t tos)
Set the tag's TOS.
virtual void IncreaseWindow(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
Try to increase the cWnd following the NewReno specification.
void ConfigureProperties()
Change the configuration of the socket properties.
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer...
A TCP socket which sends a data packet with CE flags set for test 3.
TracedValue< TcpStates_t > m_state
TCP state.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
static TcpDctcpTestSuite g_tcpdctcpTest
static var for test initialization
uint16_t GetPeerPort()
Get the peer port.
uint32_t m_delAckCount
Delayed ACK counter.
uint32_t m_senderReceived
virtual uint8_t GetIpTtl(void) const
Query the value of IP Time to Live field of this socket.
uint32_t m_segmentsAcked
segments acked
void ExecuteTest(void)
Execute the test.
Ptr< TcpCongestionOps > m_congestionControl
Congestion control.
Ptr< TcpTxBuffer > m_txBuffer
Tx buffer.
void SetTtl(uint8_t ttl)
Set the tag's TTL.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
uint16_t GetLocalPort()
Get the local port.
Ipv6EndPoint * m_endPoint6
the IPv6 endpoint
uint32_t m_segmentSize
segment size
#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.
bool ReplacePacketTag(Tag &tag)
Replace the value of a packet tag.
Ipv4Address GetLocalAddress(void)
Get the local address.
indicates whether the socket has a priority set.
uint32_t m_dataPacketSent
Ptr< TcpSocketState > m_state
state
virtual void Tx(const Ptr< const Packet > p, const TcpHeader &h, SocketWho who)
Packet transmitted down to IP layer.
SequenceNumber32 m_lastAckedSeq
Last sequence ACKed.
void NotifyDataSent(uint32_t size)
Notify through the callback (if set) that some data have been sent.
virtual void PktsAcked(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked, const Time &rtt)
Timing information on received ACK.
void ConfigureEnvironment()
Change the configuration of the environment.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Ptr< TcpL4Protocol > m_tcp
the associated TCP L4 protocol
void SetHopLimit(uint8_t hopLimit)
Set the tag's Hop Limit.
TracedValue< uint32_t > m_ssThresh
Slow start threshold.
virtual void ReTxTimeout()
An RTO event happened.
virtual Ptr< TcpSocketMsgBase > CreateSocket(Ptr< Node > node, TypeId socketType, TypeId congControl)
Create a socket.
virtual void UpdateRttHistory(const SequenceNumber32 &seq, uint32_t sz, bool isRetransmission)
Update the RTT history, when we send TCP segments.
void AddOptions(TcpHeader &tcpHeader)
Add options to TcpHeader.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
TracedValue< TcpCongState_t > m_congState
State in the Congestion state machine.
bool IsManualIpv6Tclass(void) const
Checks if the socket has a specific IPv6 Tclass set.
SequenceNumber32 m_lastAckedSeq
last acked seq
indicates whether the socket has IPV6_TCLASS set.
Test to validate cWnd decrement DCTCP.
TracedValue< SequenceNumber32 > m_ecnCWRSeq
Sequence number of the last sent CWR.
Our side has shutdown after remote has shutdown.
Remote side has shutdown and is waiting for us to finish writing our data and to shutdown (we have to...
TracedValue< uint32_t > m_cWnd
Congestion window.
uint8_t GetIpv6Tclass(void) const
Query the value of IPv6 Traffic Class field of this socket.
SequenceNumber32 m_nextTxSequence
next seq num to be sent
bool IsManualIpv6HopLimit(void) const
Checks if the socket has a specific IPv6 Hop Limit set.
SocketWho
Used as parameter of methods, specifies on what node the caller is interested (e.g.
SequenceNumber32 m_lastAckedSeq
last acked seq
General infrastructure for TCP testing.
Ptr< NetDevice > m_boundnetdevice
the device this socket is bound to (might be null).
#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...
TracedValue< Time > m_rto
Retransmit timeout.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
uint16_t GetLocalPort(void)
Get the local port.
virtual uint16_t AdvertisedWindowSize(bool scale=true) const
The amount of Rx window announced to the peer.
virtual uint8_t GetIpv6HopLimit(void) const
Query the value of IP Hop Limit field of this socket.
Ipv6Address GetPeerAddress()
Get the peer address.
Our side has shutdown, waiting to complete transmission of remaining buffered data.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
T Get(void) const
Get the underlying value.
TracedValue< SequenceNumber32 > m_ecnEchoSeq
Sequence number of the last received ECN Echo.
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetDefault(std::string name, const AttributeValue &value)
Ipv4Address GetPeerAddress(void)
Get the peer address.
TcpDctcpDecrementTest(uint32_t cWnd, uint32_t segmentSize, uint32_t segmentsAcked, SequenceNumber32 nextTxSequence, SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name)
Constructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint32_t m_segmentSize
segment size
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint16_t GetPeerPort(void)
Get the peer port.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
uint32_t m_segmentsAcked
segments acked
TracedValue< SequenceNumber32 > m_highTxMark
Highest seqno ever sent, regardless of ReTx.
virtual void Rx(const Ptr< const Packet > p, const TcpHeader &h, SocketWho who)
Packet received from IP layer.
virtual void ReduceCwnd(Ptr< TcpSocketState > tcb)
Reduces congestion window on receipt of ECN Echo Flag.
Ptr< TcpSocketState > m_state
state
virtual Ptr< TcpSocketMsgBase > CreateReceiverSocket(Ptr< Node > node)
Create and install the socket to install on the receiver.
Ptr< TcpSocketBase > Fork(void)
Call CopyObject<> to clone me.
void SetUseEcn(SocketWho who, TcpSocketState::UseEcn_t useEcn)
Forcefully set the ECN mode of use.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
SequenceNumber32 m_highTxMark
high tx mark
virtual Ptr< TcpSocketMsgBase > CreateSenderSocket(Ptr< Node > node)
Create and install the socket to install on the sender.
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
This test suite implements a Unit Test.
void SetPriority(uint8_t priority)
Set the tag's priority.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
indicates whether the socket has IP_TOS set.
bool IsManualIpTtl(void) const
Checks if the socket has a specific IPv4 TTL set.
uint8_t GetIpTos(void) const
Query the value of IP Type of Service of this socket.
EventId m_delAckEvent
Delayed ACK timeout event.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
TcpDctcpCodePointsTest(uint8_t testCase, const std::string &desc)
Constructor.
bool m_closeOnEmpty
Close socket upon tx buffer emptied.
TracedCallback< Ptr< const Packet >, const TcpHeader &, Ptr< const TcpSocketBase > > m_txTrace
Trace of transmitted packets.
uint8_t GetPriority(void) const
Query the priority value of this socket.
Validates the setting of ECT and ECE codepoints for DCTCP enabled traffic.
TracedValue< SequenceNumber32 > m_nextTxSequence
Next seqnum to be sent (SND.NXT), ReTx pushes it back.
virtual uint32_t SendDataPacket(SequenceNumber32 seq, uint32_t maxSize, bool withAck)
Extract at most maxSize bytes from the TxBuffer at sequence seq, add the TCP header, and send to TcpL4Protocol.