23 #include "ns3/ipv4-end-point.h"
24 #include "ns3/ipv4-interface-address.h"
25 #include "ns3/ipv4-route.h"
26 #include "ns3/ipv4-routing-protocol.h"
28 #include "ns3/ipv6-end-point.h"
29 #include "ns3/ipv6-route.h"
30 #include "ns3/ipv6-routing-protocol.h"
34 #include "ns3/tcp-l4-protocol.h"
35 #include "ns3/tcp-rx-buffer.h"
36 #include "ns3/tcp-tx-buffer.h"
64 TcpEcnTest(uint32_t testcase,
const std::string& desc);
67 void CWndTrace(uint32_t oldValue, uint32_t newValue)
override;
136 static TypeId tid =
TypeId(
"ns3::TcpSocketCongestedRouter")
138 .SetGroupName(
"Internet")
161 bool isRetransmission =
false;
164 isRetransmission =
true;
342 NS_LOG_LOGIC(
this <<
" SendDataPacket Schedule ReTxTimeout at time "
358 << sz <<
" with remaining data " << remainingData <<
" via TcpL4Protocol to "
369 << sz <<
" with remaining data " << remainingData <<
" via TcpL4Protocol to "
390 return CopyObject<TcpSocketCongestedRouter>(
this);
395 m_cwndChangeCount(0),
398 m_receiverReceived(0),
422 if (newValue < oldValue)
427 "Congestion window should be reduced once per every window");
430 "Congestion window should not drop below 2 segments");
444 "SYN should be received as first message at the receiver");
450 "The flags ECE + CWR should be set in the TCP header of first message received "
451 "at receiver when sender is ECN Capable");
458 "The flags ECE + CWR should not be set in the TCP header of first message "
459 "received at receiver when sender is not ECN Capable");
466 "ACK should be received as second message at receiver");
472 "Sender should send CWR on receipt of ECE");
483 "SYN+ACK received as first message at sender");
489 "The flag ECE should be set in the TCP header of first message received at "
490 "sender when both receiver and sender are ECN Capable");
497 "The flag ECE should not be set in the TCP header of first message received at "
498 "sender when either receiver or sender are not ECN Capable");
505 "The flag ECE should not be set in TCP header of the packet sent "
506 "by the receiver after sender sends CWR flags to receiver and "
507 "receiver receives a packet without CE bit set in IP header");
526 ipTos =
static_cast<uint16_t
>(ipTosTag.
GetTos());
532 "IP TOS should have ECT set if ECN negotiation between "
533 "endpoints is successful");
542 "IP TOS should have CE bit set for 3rd and 5th packet sent in test case 5");
548 "IP TOS should have ECT set if ECN negotiation between "
549 "endpoints is successful");
556 "IP TOS should not have ECT set if ECN negotiation between "
557 "endpoints is unsuccessful");
592 "ECN Negotiation Test : ECN incapable sender and ECN incapable receiver"),
596 "ECN Negotiation Test : ECN capable sender and ECN incapable receiver"),
600 "ECN Negotiation Test : ECN incapable sender and ECN capable receiver"),
603 new TcpEcnTest(4,
"ECN Negotiation Test : ECN capable sender and ECN capable receiver"),
608 "ECE and CWR Functionality Test: ECN capable sender and ECN capable receiver"),
613 "Congestion Window Reduction Test :ECN capable sender and ECN capable receiver"),
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.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now()
Return the current simulation virtual time.
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.
checks if ECT, CWR and ECE bits are set correctly in different scenarios
void ConfigureProperties() override
Change the configuration of the socket properties.
uint32_t m_senderSent
Number of segments sent by the sender.
Ptr< TcpSocketMsgBase > CreateSenderSocket(Ptr< Node > node) override
Create and install the socket to install on the sender.
void CWndTrace(uint32_t oldValue, uint32_t newValue) override
TcpEcnTest(uint32_t testcase, const std::string &desc)
Constructor.
uint32_t m_cwndChangeCount
Number of times the congestion window did change.
uint32_t m_senderReceived
Number of segments received by the sender.
uint32_t m_receiverReceived
Number of segments received by the receiver.
void Tx(const Ptr< const Packet > p, const TcpHeader &h, SocketWho who) override
Packet transmitted down to IP layer.
uint32_t m_testcase
Test case type.
void Rx(const Ptr< const Packet > p, const TcpHeader &h, SocketWho who) override
Packet received from IP layer.
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 > 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.
TypeId m_congControlTypeId
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.
uint8_t MarkEcnEct0(uint8_t tos) const
Mark ECT(0) codepoint.
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
uint8_t MarkEcnCe(uint8_t tos) const
Mark CE codepoint.
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.
A TCP socket which sends certain data packets with CE flags set for tests 5 and 6.
uint32_t m_dataPacketSent
Number of packets sent.
TcpSocketCongestedRouter()
void ReTxTimeout() override
An RTO event happened.
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,...
uint8_t m_testcase
Test case type.
static TypeId GetTypeId()
Get the type ID.
Ptr< TcpSocketBase > Fork() override
Call CopyObject<> to clone me.
TcpSocketCongestedRouter(const TcpSocketCongestedRouter &other)
Constructor.
void SetTestCase(uint8_t testCase)
Set the test case type.
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.
TracedValue< SequenceNumber32 > m_highTxMark
Highest seqno ever sent, regardless of ReTx.
@ 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.
Ptr< TcpRxBuffer > m_rxBuffer
Rx buffer (reordering buffer)
static const char *const EcnStateName[TcpSocketState::ECN_CWR_SENT+1]
Literal names of ECN states for use in log messages.
TracedValue< EcnState_t > m_ecnState
Current ECN State, represented as combination of EcnState values.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
@ UNIT
This test suite implements a Unit Test.
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.
#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.
@ 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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static TcpEcnTestSuite g_tcpECNTestSuite
static var for test initialization