A Discrete-Event Network Simulator
API
tcp-ecn-test.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2016 NITK Surathkal
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: Shravya Ks <shravya.ks0@gmail.com>
19  *
20  */
21 #include "ns3/ipv4.h"
22 #include "ns3/ipv6.h"
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"
30 #include "tcp-general-test.h"
31 #include "ns3/node.h"
32 #include "ns3/log.h"
33 #include "tcp-error-model.h"
34 #include "ns3/tcp-l4-protocol.h"
35 #include "ns3/tcp-tx-buffer.h"
36 #include "ns3/tcp-rx-buffer.h"
37 
38 namespace ns3 {
39 
40 NS_LOG_COMPONENT_DEFINE ("TcpEcnTestSuite");
53 class TcpEcnTest : public TcpGeneralTest
54 {
55 public:
62  TcpEcnTest (uint32_t testcase, const std::string &desc);
63 
64 protected:
65  virtual void CWndTrace (uint32_t oldValue, uint32_t newValue);
66  virtual void Rx (const Ptr<const Packet> p, const TcpHeader&h, SocketWho who);
67  virtual void Tx (const Ptr<const Packet> p, const TcpHeader&h, SocketWho who);
69  void ConfigureProperties ();
70 
71 private:
73  uint32_t m_senderSent;
74  uint32_t m_senderReceived;
76  uint32_t m_testcase;
77 };
78 
79 
93 {
94 public:
99  static TypeId GetTypeId (void);
100 
102  uint8_t m_testcase;
103 
105  : TcpSocketMsgBase ()
106  {
107  m_dataPacketSent = 0;
108  }
109 
115  : TcpSocketMsgBase (other)
116  {
117  }
118 
119  void SetTestCase (uint8_t testCase);
120 
121 protected:
122  virtual uint32_t SendDataPacket (SequenceNumber32 seq, uint32_t maxSize, bool withAck);
123  virtual void ReTxTimeout ();
124  Ptr<TcpSocketBase> Fork (void);
125 };
126 
127 NS_OBJECT_ENSURE_REGISTERED (TcpSocketCongestedRouter);
128 
129 TypeId
131 {
132  static TypeId tid = TypeId ("ns3::TcpSocketCongestedRouter")
134  .SetGroupName ("Internet")
135  .AddConstructor<TcpSocketCongestedRouter> ()
136  ;
137  return tid;
138 }
139 
140 void
142 {
144 }
145 
146 void
148 {
149  m_testcase = testCase;
150 }
151 
152 uint32_t
153 TcpSocketCongestedRouter::SendDataPacket (SequenceNumber32 seq, uint32_t maxSize, bool withAck)
154 {
155  NS_LOG_FUNCTION (this << seq << maxSize << withAck);
157 
158  bool isRetransmission = false;
159  if (seq != m_tcb->m_highTxMark)
160  {
161  isRetransmission = true;
162  }
163 
164  Ptr<Packet> p = m_txBuffer->CopyFromSequence (maxSize, seq)->GetPacketCopy ();
165  uint32_t sz = p->GetSize (); // Size of packet
166  uint8_t flags = withAck ? TcpHeader::ACK : 0;
167  uint32_t remainingData = m_txBuffer->SizeFromSequence (seq + SequenceNumber32 (sz));
168 
169  if (withAck)
170  {
172  m_delAckCount = 0;
173  }
174 
175  // Sender should reduce the Congestion Window as a response to receiver's ECN Echo notification only once per window
176  if (m_tcb->m_ecnState == TcpSocketState::ECN_ECE_RCVD && m_ecnEchoSeq.Get () > m_ecnCWRSeq.Get () && !isRetransmission)
177  {
178  NS_LOG_INFO ("Backoff mechanism by reducing CWND by half because we've received ECN Echo");
182  flags |= TcpHeader::CWR;
183  m_ecnCWRSeq = seq;
184  NS_LOG_DEBUG (TcpSocketState::EcnStateName[m_tcb->m_ecnState] << " -> ECN_CWR_SENT");
186  NS_LOG_INFO ("CWR flags set");
189  {
190  m_congestionControl->CongestionStateSet (m_tcb, TcpSocketState::CA_CWR);
192  }
193  }
194  /*
195  * Add tags for each socket option.
196  * Note that currently the socket adds both IPv4 tag and IPv6 tag
197  * if both options are set. Once the packet got to layer three, only
198  * the corresponding tags will be read.
199  */
200  if (GetIpTos ())
201  {
202  SocketIpTosTag ipTosTag;
203  if ( m_testcase == 5 && (m_dataPacketSent == 1 || m_dataPacketSent == 2 || m_dataPacketSent == 3 || m_dataPacketSent == 4))
204  {
205  ipTosTag.SetTos (MarkEcnCe (GetIpTos ()));
206  }
207  else if ( m_testcase == 6 && ( m_dataPacketSent == 10 || m_dataPacketSent == 11))
208  {
209  ipTosTag.SetTos (MarkEcnCe (GetIpTos ()));
210  }
211  else
212  {
213  if (m_tcb->m_ecnState != TcpSocketState::ECN_DISABLED && (GetIpTos () & 0x3) == 0)
214  {
215  ipTosTag.SetTos (MarkEcnEct0 (GetIpTos ()));
216  }
217  else
218  {
219  ipTosTag.SetTos (GetIpTos ());
220  }
221  }
222  p->AddPacketTag (ipTosTag);
223  }
224  else
225  {
226  SocketIpTosTag ipTosTag;
227  if ( m_testcase == 5 && (m_dataPacketSent == 1 || m_dataPacketSent == 2 || m_dataPacketSent == 3 || m_dataPacketSent == 4))
228  {
229  ipTosTag.SetTos (MarkEcnCe (GetIpTos ()));
230  }
231  else if ( m_testcase == 6 && ( m_dataPacketSent == 10 || m_dataPacketSent == 11))
232  {
233  ipTosTag.SetTos (MarkEcnCe (GetIpTos ()));
234  }
235  else
236  {
238  {
239  ipTosTag.SetTos (MarkEcnEct0 (GetIpTos ()));
240  }
241  }
242  p->AddPacketTag (ipTosTag);
243  }
244 
245  if (IsManualIpv6Tclass ())
246  {
247  SocketIpv6TclassTag ipTclassTag;
248  if ( m_testcase == 5 && (m_dataPacketSent == 1 || m_dataPacketSent == 2 || m_dataPacketSent == 3 || m_dataPacketSent == 4))
249  {
250  ipTclassTag.SetTclass (MarkEcnCe (GetIpv6Tclass ()));
251  }
252  else if ( m_testcase == 6 && ( m_dataPacketSent == 10 || m_dataPacketSent == 11))
253  {
254  ipTclassTag.SetTclass (MarkEcnCe (GetIpv6Tclass ()));
255  }
256  else
257  {
258  if (m_tcb->m_ecnState != TcpSocketState::ECN_DISABLED && (GetIpv6Tclass () & 0x3) == 0)
259  {
260  ipTclassTag.SetTclass (MarkEcnEct0 (GetIpv6Tclass ()));
261  }
262  else
263  {
264  ipTclassTag.SetTclass (GetIpv6Tclass ());
265  }
266  }
267  p->AddPacketTag (ipTclassTag);
268  }
269  else
270  {
271  SocketIpv6TclassTag ipTclassTag;
272  if ( m_testcase == 5 && (m_dataPacketSent == 1 || m_dataPacketSent == 2 || m_dataPacketSent == 3 || m_dataPacketSent == 4))
273  {
274  ipTclassTag.SetTclass (MarkEcnCe (GetIpv6Tclass ()));
275  }
276  else if ( m_testcase == 6 &&( m_dataPacketSent == 10 || m_dataPacketSent == 11 ))
277  {
278  ipTclassTag.SetTclass (MarkEcnCe (GetIpv6Tclass ()));
279  }
280  else
281  {
283  {
284  ipTclassTag.SetTclass (MarkEcnEct0 (GetIpv6Tclass ()));
285  }
286  }
287  p->AddPacketTag (ipTclassTag);
288  }
289 
290  if (IsManualIpTtl ())
291  {
292  SocketIpTtlTag ipTtlTag;
293  ipTtlTag.SetTtl (GetIpTtl ());
294  p->AddPacketTag (ipTtlTag);
295  }
296 
297  if (IsManualIpv6HopLimit ())
298  {
299  SocketIpv6HopLimitTag ipHopLimitTag;
300  ipHopLimitTag.SetHopLimit (GetIpv6HopLimit ());
301  p->AddPacketTag (ipHopLimitTag);
302  }
303 
304  uint8_t priority = GetPriority ();
305  if (priority)
306  {
307  SocketPriorityTag priorityTag;
308  priorityTag.SetPriority (priority);
309  p->ReplacePacketTag (priorityTag);
310  }
311 
312  if (m_closeOnEmpty && (remainingData == 0))
313  {
314  flags |= TcpHeader::FIN;
315  if (m_state == ESTABLISHED)
316  { // On active close: I am the first one to send FIN
317  NS_LOG_DEBUG ("ESTABLISHED -> FIN_WAIT_1");
319  }
320  else if (m_state == CLOSE_WAIT)
321  { // On passive close: Peer sent me FIN already
322  NS_LOG_DEBUG ("CLOSE_WAIT -> LAST_ACK");
323  m_state = LAST_ACK;
324  }
325  }
326  TcpHeader header;
327  header.SetFlags (flags);
328  header.SetSequenceNumber (seq);
329  header.SetAckNumber (m_tcb->m_rxBuffer->NextRxSequence ());
330  if (m_endPoint)
331  {
334  }
335  else
336  {
339  }
341  AddOptions (header);
342 
343  if (m_retxEvent.IsExpired ())
344  {
345  // Schedules retransmit timeout. m_rto should be already doubled.
346 
347  NS_LOG_LOGIC (this << " SendDataPacket Schedule ReTxTimeout at time " <<
348  Simulator::Now ().GetSeconds () << " to expire at time " <<
349  (Simulator::Now () + m_rto.Get ()).GetSeconds () );
351  }
352 
353  m_txTrace (p, header, this);
354 
355  if (m_endPoint)
356  {
357  m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (),
359  NS_LOG_DEBUG ("Send segment of size " << sz << " with remaining data " <<
360  remainingData << " via TcpL4Protocol to " << m_endPoint->GetPeerAddress () <<
361  ". Header " << header);
362  }
363  else
364  {
365  m_tcp->SendPacket (p, header, m_endPoint6->GetLocalAddress (),
367  NS_LOG_DEBUG ("Send segment of size " << sz << " with remaining data " <<
368  remainingData << " via TcpL4Protocol to " << m_endPoint6->GetPeerAddress () <<
369  ". Header " << header);
370  }
371 
372  UpdateRttHistory (seq, sz, isRetransmission);
373 
374  // Notify the application of the data being sent unless this is a retransmit
375  if (seq + sz > m_tcb->m_highTxMark)
376  {
378  (seq + sz - m_tcb->m_highTxMark.Get ()));
379  }
380  // Update highTxMark
381  m_tcb->m_highTxMark = std::max (seq + sz, m_tcb->m_highTxMark.Get ());
382  return sz;
383 }
384 
387 {
388  return CopyObject<TcpSocketCongestedRouter> (this);
389 }
390 
391 
392 TcpEcnTest::TcpEcnTest (uint32_t testcase, const std::string &desc)
393  : TcpGeneralTest (desc),
394  m_cwndChangeCount (0),
395  m_senderSent (0),
396  m_senderReceived (0),
397  m_receiverReceived (0),
398  m_testcase (testcase)
399 {
400 }
401 
402 void
404 {
406  if (m_testcase == 2 || m_testcase == 4 || m_testcase == 5 || m_testcase == 6)
407  {
409  }
410  if (m_testcase == 3 || m_testcase == 4 ||m_testcase == 5 || m_testcase == 6)
411  {
413  }
414 }
415 
416 void
417 TcpEcnTest::CWndTrace (uint32_t oldValue, uint32_t newValue)
418 {
419  if (m_testcase == 6)
420  {
421  if (newValue < oldValue)
422  {
424  NS_TEST_ASSERT_MSG_EQ (m_cwndChangeCount, 1, "Congestion window should be reduced once per every window");
425  NS_TEST_ASSERT_MSG_EQ (newValue, oldValue / 2, "Congestion window should be reduced by half");
426  }
427  }
428 }
429 
430 void
432 {
433  if (who == RECEIVER)
434  {
435  if (m_receiverReceived == 0)
436  {
437  NS_TEST_ASSERT_MSG_NE (((h.GetFlags ()) & TcpHeader::SYN), 0, "SYN should be received as first message at the receiver");
438  if (m_testcase == 2 || m_testcase == 4 || m_testcase == 5 ||m_testcase == 6)
439  {
440  NS_TEST_ASSERT_MSG_NE (((h.GetFlags ()) & TcpHeader::ECE) && ((h.GetFlags ()) & TcpHeader::CWR), 0, "The flags ECE + CWR should be set in the TCP header of first message received at receiver when sender is ECN Capable");
441  }
442  else
443  {
444  NS_TEST_ASSERT_MSG_EQ (((h.GetFlags ()) & TcpHeader::ECE) && ((h.GetFlags ()) & TcpHeader::CWR), 0, "The flags ECE + CWR should not be set in the TCP header of first message received at receiver when sender is not ECN Capable");
445  }
446  }
447  else if (m_receiverReceived == 1)
448  {
449  NS_TEST_ASSERT_MSG_NE (((h.GetFlags ()) & TcpHeader::ACK), 0, "ACK should be received as second message at receiver");
450  }
451  else if (m_receiverReceived == 3 && m_testcase == 5)
452  {
453  NS_TEST_ASSERT_MSG_NE (((h.GetFlags ()) & TcpHeader::CWR), 0, "Sender should send CWR on receipt of ECE");
454  }
456  }
457  else if (who == SENDER)
458  {
459  if (m_senderReceived == 0)
460  {
461  NS_TEST_ASSERT_MSG_NE (((h.GetFlags ()) & TcpHeader::SYN) && ((h.GetFlags ()) & TcpHeader::ACK), 0, "SYN+ACK received as first message at sender");
462  if (m_testcase == 4 || m_testcase == 5 || m_testcase == 6)
463  {
464  NS_TEST_ASSERT_MSG_NE ((h.GetFlags () & TcpHeader::ECE), 0, "The flag ECE should be set in the TCP header of first message received at sender when both receiver and sender are ECN Capable");
465  }
466  else
467  {
468  NS_TEST_ASSERT_MSG_EQ (((h.GetFlags ()) & TcpHeader::ECE), 0, "The flag ECE should not be set in the TCP header of first message received at sender when either receiver or sender are not ECN Capable");
469  }
470  }
471  if (m_senderReceived == 3 && m_testcase == 5)
472  {
473  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");
474  }
475  if (m_senderReceived == 4 && m_testcase == 5)
476  {
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");
478  }
479  if ( m_testcase == 5 && m_receiverReceived > 12)
480  {
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");
482  }
484  }
485 }
486 
487 void
489 {
490  if (who == SENDER)
491  {
492  m_senderSent++;
493  if (m_senderSent == 3)
494  {
495  SocketIpTosTag ipTosTag;
496  bool found = p->PeekPacketTag (ipTosTag);
497  uint16_t ipTos = 0;
498  if (found)
499  {
500  ipTos = static_cast<uint16_t> (ipTosTag.GetTos ());
501  }
502  if (m_testcase == 4 || m_testcase == 6)
503  {
504  NS_TEST_ASSERT_MSG_EQ (ipTos, 0x2, "IP TOS should have ECT set if ECN negotiation between endpoints is successful");
505  }
506  else if (m_testcase == 5)
507  {
508  if (m_senderSent == 3 || m_senderSent == 4)
509  {
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");
511  }
512  else
513  {
514  NS_TEST_ASSERT_MSG_EQ (ipTos, 0x2, "IP TOS should have ECT set if ECN negotiation between endpoints is successful");
515  }
516  }
517  else
518  {
519  NS_TEST_ASSERT_MSG_NE (ipTos, 0x2, "IP TOS should not have ECT set if ECN negotiation between endpoints is unsuccessful");
520  }
521  }
522  }
523 }
524 
527 {
528  if (m_testcase == 5 || m_testcase == 6)
529  {
530  Ptr<TcpSocketCongestedRouter> socket = DynamicCast<TcpSocketCongestedRouter> (
531  CreateSocket (node,
534  socket->SetTestCase (m_testcase);
535  return socket;
536  }
537  else
538  {
540  }
541 }
542 
549 static class TcpEcnTestSuite : public TestSuite
550 {
551 public:
552  TcpEcnTestSuite () : TestSuite ("tcp-ecn-test", UNIT)
553  {
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"),
566  }
568 
569 } // namespace ns3
Ipv6Address GetLocalAddress()
Get the local address.
void SetTclass(uint8_t tclass)
Set the tag&#39;s Tclass.
Definition: socket.cc:900
uint8_t GetTos(void) const
Get the tag&#39;s TOS.
Definition: socket.cc:791
#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
Definition: tcp-ecn-test.cc:53
Last ACK received had ECE bit set in TCP header.
Normal state, no dubious events.
Connection established.
Definition: tcp-socket.h:71
uint32_t m_receiverReceived
Definition: tcp-ecn-test.cc:75
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...
Definition: socket.h:1163
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.
Definition: object-base.h:45
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
EventId m_retxEvent
Retransmission event.
A suite of tests to run.
Definition: test.h:1341
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.
Definition: log.h:205
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.
Definition: log.h:281
Ptr< TcpRxBuffer > m_rxBuffer
Rx buffer (reordering buffer)
void SetTos(uint8_t tos)
Set the tag&#39;s TOS.
Definition: socket.cc:785
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...
Definition: socket.h:1115
TracedValue< TcpStates_t > m_state
TCP state.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:59
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.
Definition: socket.cc:520
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.
void SetSequenceNumber(SequenceNumber32 sequenceNumber)
Set the sequence Number.
Definition: tcp-header.cc:101
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1390
#define max(a, b)
Definition: 80211b.c:43
Ptr< TcpTxBuffer > m_txBuffer
Tx buffer.
void SetTtl(uint8_t ttl)
Set the tag&#39;s TTL.
Definition: socket.cc:604
TCP ECN TestSuite.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
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.
Definition: test.h:166
bool ReplacePacketTag(Tag &tag)
Replace the value of a packet tag.
Definition: packet.cc:877
Ipv4Address GetLocalAddress(void)
Get the local address.
indicates whether the socket has a priority set.
Definition: socket.h:1307
void NotifyDataSent(uint32_t size)
Notify through the callback (if set) that some data have been sent.
Definition: socket.cc:285
void ConfigureProperties()
Change the configuration of the socket properties.
Ptr< TcpL4Protocol > m_tcp
the associated TCP L4 protocol
void SetHopLimit(uint8_t hopLimit)
Set the tag&#39;s Hop Limit.
Definition: socket.cc:665
TracedValue< uint32_t > m_ssThresh
Slow start threshold.
void SetDestinationPort(uint16_t port)
Set the destination port.
Definition: tcp-header.cc:95
void SetFlags(uint8_t flags)
Set flags of the header.
Definition: tcp-header.cc:113
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.
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.
Definition: socket.cc:371
Header for the Transmission Control Protocol.
Definition: tcp-header.h:44
void SetSourcePort(uint16_t port)
Set the source port.
Definition: tcp-header.cc:89
indicates whether the socket has IPV6_TCLASS set.
Definition: socket.h:1354
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
Definition: simulator.h:1579
TracedValue< SequenceNumber32 > m_ecnCWRSeq
Sequence number of the last sent CWR.
Our side has shutdown after remote has shutdown.
Definition: tcp-socket.h:75
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:193
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...
Definition: tcp-socket.h:72
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.
Definition: socket.cc:495
Fast test.
Definition: test.h:1159
bool IsManualIpv6HopLimit(void) const
Checks if the socket has a specific IPv6 Hop Limit set.
Definition: socket.cc:383
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.
Definition: tcp-ecn-test.cc:92
General infrastructure for TCP testing.
Ptr< NetDevice > m_boundnetdevice
the device this socket is bound to (might be null).
Definition: socket.h:1076
uint8_t GetFlags() const
Get the flags.
Definition: tcp-header.cc:173
#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...
Definition: test.h:622
uint32_t m_senderReceived
Definition: tcp-ecn-test.cc:74
TracedValue< Time > m_rto
Retransmit timeout.
ns3::TcpEcnTestSuite g_tcpECNTestSuite
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:863
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.
Definition: socket.cc:545
void SetAckNumber(SequenceNumber32 ackNumber)
Set the ACK number.
Definition: tcp-header.cc:107
Ipv6Address GetPeerAddress()
Get the peer address.
Our side has shutdown, waiting to complete transmission of remaining buffered data.
Definition: tcp-socket.h:78
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
T Get(void) const
Get the underlying value.
Definition: traced-value.h:227
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.
Definition: event-id.cc:53
TracedValue< SequenceNumber32 > m_highTxMark
Highest seqno ever sent, regardless of ReTx.
void SetUseEcn(SocketWho who, TcpSocketState::UseEcn_t useEcn)
Forcefully set the ecn use on.
uint32_t m_senderSent
Definition: tcp-ecn-test.cc:73
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Definition: packet.cc:885
This test suite implements a Unit Test.
Definition: test.h:1351
void SetWindowSize(uint16_t windowSize)
Set the window size.
Definition: tcp-header.cc:119
void SetPriority(uint8_t priority)
Set the tag&#39;s priority.
Definition: socket.cc:842
uint32_t m_cwndChangeCount
Definition: tcp-ecn-test.cc:72
indicates whether the socket has IP_TOS set.
Definition: socket.h:1261
bool IsManualIpTtl(void) const
Checks if the socket has a specific IPv4 TTL set.
Definition: socket.cc:377
uint8_t GetIpTos(void) const
Query the value of IP Type of Service of this socket.
Definition: socket.cc:453
EventId m_delAckEvent
Delayed ACK timeout event.
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
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.
Definition: socket.cc:396
uint32_t m_testcase
Definition: tcp-ecn-test.cc:76
uint8_t MarkEcnEct0(uint8_t tos) const
Mark ECT(0)
TypeId m_congControlTypeId
Congestion control.