12#include "ns3/ipv4-end-point.h"
13#include "ns3/ipv4-interface-address.h"
14#include "ns3/ipv4-route.h"
15#include "ns3/ipv4-routing-protocol.h"
17#include "ns3/ipv6-end-point.h"
18#include "ns3/ipv6-route.h"
19#include "ns3/ipv6-routing-protocol.h"
23#include "ns3/tcp-l4-protocol.h"
24#include "ns3/tcp-rx-buffer.h"
25#include "ns3/tcp-tx-buffer.h"
125 static TypeId tid =
TypeId(
"ns3::TcpSocketCongestedRouter")
127 .SetGroupName(
"Internet")
150 bool isRetransmission =
false;
151 if (seq !=
m_tcb->m_highTxMark)
153 isRetransmission =
true;
203 p->AddPacketTag(ipTosTag);
220 p->AddPacketTag(ipTosTag);
242 p->AddPacketTag(ipTclassTag);
259 p->AddPacketTag(ipTclassTag);
266 p->AddPacketTag(ipTtlTag);
273 p->AddPacketTag(ipHopLimitTag);
281 p->ReplacePacketTag(priorityTag);
319 NS_LOG_LOGIC(
this <<
" SendDataPacket Schedule ReTxTimeout at time "
335 << sz <<
" with remaining data " << remainingData <<
" via TcpL4Protocol to "
346 << sz <<
" with remaining data " << remainingData <<
" via TcpL4Protocol to "
353 if (seq + sz >
m_tcb->m_highTxMark)
357 (seq + sz -
m_tcb->m_highTxMark.Get()));
360 m_tcb->m_highTxMark = std::max(seq + sz,
m_tcb->m_highTxMark.Get());
372 m_cwndChangeCount(0),
375 m_receiverReceived(0),
399 if (newValue < oldValue)
404 "Congestion window should be reduced once per every window");
407 "Congestion window should not drop below 2 segments");
421 "SYN should be received as first message at the receiver");
427 "The flags ECE + CWR should be set in the TCP header of first message received "
428 "at receiver when sender is ECN Capable");
435 "The flags ECE + CWR should not be set in the TCP header of first message "
436 "received at receiver when sender is not ECN Capable");
443 "ACK should be received as second message at receiver");
449 "Sender should send CWR on receipt of ECE");
460 "SYN+ACK received as first message at sender");
466 "The flag ECE should be set in the TCP header of first message received at "
467 "sender when both receiver and sender are ECN Capable");
474 "The flag ECE should not be set in the TCP header of first message received at "
475 "sender when either receiver or sender are not ECN Capable");
482 "The flag ECE should not be set in TCP header of the packet sent "
483 "by the receiver after sender sends CWR flags to receiver and "
484 "receiver receives a packet without CE bit set in IP header");
499 bool found = p->PeekPacketTag(ipTosTag);
503 ipTos =
static_cast<uint16_t
>(ipTosTag.
GetTos());
509 "IP TOS should have ECT set if ECN negotiation between "
510 "endpoints is successful");
519 "IP TOS should have CE bit set for 3rd and 5th packet sent in test case 5");
525 "IP TOS should have ECT set if ECN negotiation between "
526 "endpoints is successful");
533 "IP TOS should not have ECT set if ECN negotiation between "
534 "endpoints is unsuccessful");
569 "ECN Negotiation Test : ECN incapable sender and ECN incapable receiver"),
573 "ECN Negotiation Test : ECN capable sender and ECN incapable receiver"),
577 "ECN Negotiation Test : ECN incapable sender and ECN capable receiver"),
580 new TcpEcnTest(4,
"ECN Negotiation Test : ECN capable sender and ECN capable receiver"),
585 "ECE and CWR Functionality Test: ECN capable sender and ECN capable receiver"),
590 "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.
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 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
Tracks the congestion window changes.
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.
@ 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
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
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.