23 #include "ns3/ipv4-interface-address.h" 24 #include "ns3/ipv4-route.h" 25 #include "ns3/ipv6-route.h" 26 #include "ns3/ipv4-routing-protocol.h" 27 #include "ns3/ipv6-routing-protocol.h" 28 #include "../model/ipv4-end-point.h" 29 #include "../model/ipv6-end-point.h" 34 #include "ns3/tcp-l4-protocol.h" 35 #include "ns3/tcp-tx-buffer.h" 36 #include "ns3/tcp-rx-buffer.h" 62 TcpEcnTest (uint32_t testcase,
const std::string &desc);
65 virtual void CWndTrace (uint32_t oldValue, uint32_t newValue);
132 static TypeId tid =
TypeId (
"ns3::TcpSocketCongestedRouter")
134 .SetGroupName (
"Internet")
158 bool isRetransmission =
false;
161 isRetransmission =
true;
178 NS_LOG_INFO (
"Backoff mechanism by reducing CWND by half because we've received ECN Echo");
347 NS_LOG_LOGIC (
this <<
" SendDataPacket Schedule ReTxTimeout at time " <<
359 NS_LOG_DEBUG (
"Send segment of size " << sz <<
" with remaining data " <<
361 ". Header " << header);
367 NS_LOG_DEBUG (
"Send segment of size " << sz <<
" with remaining data " <<
369 ". Header " << header);
388 return CopyObject<TcpSocketCongestedRouter> (
this);
394 m_cwndChangeCount (0),
396 m_senderReceived (0),
397 m_receiverReceived (0),
398 m_testcase (testcase)
421 if (newValue < oldValue)
477 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 even after sender sends CWR flags to receiver if it receives a packet with CE bit set in IP header");
481 NS_TEST_ASSERT_MSG_EQ (((h.
GetFlags ()) &
TcpHeader::ECE), 0,
"The flag ECE should not be set in TCP header of the packet sent by the receiver after sender sends CWR flags to receiver and receiver receives a packet without CE bit set in IP header");
500 ipTos =
static_cast<uint16_t
> (ipTosTag.
GetTos ());
504 NS_TEST_ASSERT_MSG_EQ (ipTos, 0x2,
"IP TOS should have ECT set if ECN negotiation between endpoints is successful");
510 NS_TEST_ASSERT_MSG_EQ (ipTos, 0x3,
"IP TOS should have CE bit set for 3rd and 4th packet sent in test case 5");
514 NS_TEST_ASSERT_MSG_EQ (ipTos, 0x2,
"IP TOS should have ECT set if ECN negotiation between endpoints is successful");
519 NS_TEST_ASSERT_MSG_NE (ipTos, 0x2,
"IP TOS should not have ECT set if ECN negotiation between endpoints is unsuccessful");
554 AddTestCase (
new TcpEcnTest (1,
"ECN Negotiation Test : ECN incapable sender and ECN incapable receiver"),
556 AddTestCase (
new TcpEcnTest (2,
"ECN Negotiation Test : ECN capable sender and ECN incapable receiver"),
558 AddTestCase (
new TcpEcnTest (3,
"ECN Negotiation Test : ECN incapable sender and ECN capable receiver"),
560 AddTestCase (
new TcpEcnTest (4,
"ECN Negotiation Test : ECN capable sender and ECN capable receiver"),
562 AddTestCase (
new TcpEcnTest (5,
"ECE and CWR Functionality Test: ECN capable sender and ECN capable receiver"),
564 AddTestCase (
new TcpEcnTest (6,
"Congestion Window Reduction Test :ECN capable sender and ECN capable receiver"),
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.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
checks if ECT, CWR and ECE bits are set correctly in different scenarios
Last ACK received had ECE bit set in TCP header.
Normal state, no dubious events.
uint32_t m_receiverReceived
ECN functionality as described in RFC 3168.
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
virtual void CWndTrace(uint32_t oldValue, uint32_t newValue)
Tracks the congestion window changes.
#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.
static const char *const EcnStateName[TcpSocketState::ECN_CWR_SENT+1]
Literal names of ECN states for use in log messages.
static const char *const TcpCongStateName[TcpSocketState::CA_LAST_STATE]
Literal names of TCP states for use in log messages.
TracedValue< EcnState_t > m_ecnState
Current ECN State, represented as combination of EcnState values.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
uint32_t m_dataPacketSent
Ptr< TcpSocketState > m_tcb
Congestion control information.
uint32_t m_segmentSize
Segment size.
virtual Ptr< TcpSocketMsgBase > CreateSenderSocket(Ptr< Node > node)
Create and install the socket to install on the sender.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
void SetTos(uint8_t tos)
Set the tag's TOS.
TcpSocketCongestedRouter()
virtual void ConfigureProperties(void)
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...
TracedValue< TcpStates_t > m_state
TCP state.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
uint16_t GetPeerPort()
Get the peer port.
uint32_t m_delAckCount
Delayed ACK counter.
virtual uint8_t GetIpTtl(void) const
Query the value of IP Time to Live field of this socket.
Ptr< TcpCongestionOps > m_congestionControl
Congestion control.
static TypeId GetTypeId(void)
Get the type ID.
TcpSocketCongestedRouter(const TcpSocketCongestedRouter &other)
Constructor.
TracedValue< uint32_t > m_cWndInfl
Inflated congestion window trace (used only for backward compatibility purpose)
uint8_t MarkEcnCe(uint8_t tos) const
Mark CE.
cWnd was reduced due to some Congestion Notification event.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
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.
TcpEcnTest(uint32_t testcase, const std::string &desc)
Constructor.
uint16_t GetLocalPort()
Get the local port.
Ptr< TcpSocketBase > Fork(void)
Call CopyObject<> to clone me.
Ipv6EndPoint * m_endPoint6
the IPv6 endpoint
#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.
void NotifyDataSent(uint32_t size)
Notify through the callback (if set) that some data have been sent.
void ConfigureProperties()
Change the configuration of the socket properties.
Ptr< TcpRxBuffer > m_rxBuffer
Rx buffer (reordering buffer)
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.
void SetEcn(SocketWho who, TcpSocketBase::EcnMode_t ecnMode)
Forcefully set the ecn mode on.
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.
virtual void Tx(const Ptr< const Packet > p, const TcpHeader &h, SocketWho who)
Packet transmitted down to IP layer.
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.
indicates whether the socket has IPV6_TCLASS set.
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
TracedValue< SequenceNumber32 > m_ecnCWRSeq
Sequence number of the last sent CWR.
Our side has shutdown after remote has shutdown.
static Time Now(void)
Return the current simulation virtual time.
void SetTestCase(uint8_t testCase)
Remote side has shutdown and is waiting for us to finish writing our data and to shutdown (we have to...
virtual void ReTxTimeout(void)
An RTO event happened.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
TracedValue< uint32_t > m_cWnd
Congestion window.
uint8_t GetIpv6Tclass(void) const
Query the value of IPv6 Traffic Class field of this socket.
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.
virtual Ptr< TcpSocketMsgBase > CreateSenderSocket(Ptr< Node > node)
Create and install the socket to install on the sender.
Sender has reduced the congestion window, and sent a packet with CWR bit set in TCP header...
A TCP socket which sends certain data packets with CE flags set for tests 5 and 6.
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...
uint32_t m_senderReceived
TracedValue< Time > m_rto
Retransmit timeout.
ns3::TcpEcnTestSuite g_tcpECNTestSuite
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.
Ipv4Address GetPeerAddress(void)
Get the peer address.
uint16_t GetPeerPort(void)
Get the peer port.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
TracedValue< SequenceNumber32 > m_highTxMark
Highest seqno ever sent, regardless of ReTx.
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.
uint32_t m_cwndChangeCount
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.
virtual void Rx(const Ptr< const Packet > p, const TcpHeader &h, SocketWho who)
Packet received from IP layer.
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.
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.
uint8_t MarkEcnEct0(uint8_t tos) const
Mark ECT(0)
TypeId m_congControlTypeId
Congestion control.