A Discrete-Event Network Simulator
API
tcp-dctcp-test.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2017 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  * Author: Shravya K.S. <shravya.ks0@gmail.com>
19  *
20  */
21 
22 #include "ns3/ipv4.h"
23 #include "ns3/ipv6.h"
24 #include "../model/ipv4-end-point.h"
25 #include "../model/ipv6-end-point.h"
26 #include "tcp-general-test.h"
27 #include "ns3/node.h"
28 #include "ns3/log.h"
29 #include "tcp-error-model.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"
34 
35 using namespace ns3;
36 
37 NS_LOG_COMPONENT_DEFINE ("TcpDctcpTestSuite");
38 
46 {
47 public:
54  TcpDctcpCodePointsTest (uint8_t testCase, const std::string &desc);
55 
56 protected:
57  virtual void Tx (const Ptr<const Packet> p, const TcpHeader&h, SocketWho who);
58  virtual void Rx (const Ptr<const Packet> p, const TcpHeader&h, SocketWho who);
59  virtual Ptr<TcpSocketMsgBase> CreateSenderSocket (Ptr<Node> node);
60  virtual Ptr<TcpSocketMsgBase> CreateReceiverSocket (Ptr<Node> node);
61  void ConfigureProperties ();
62  void ConfigureEnvironment ();
63 
64 private:
65  uint32_t m_senderSent;
66  uint32_t m_receiverSent;
67  uint32_t m_senderReceived;
68  uint8_t m_testCase;
69 };
70 
71 TcpDctcpCodePointsTest::TcpDctcpCodePointsTest (uint8_t testCase, const std::string &desc)
72  : TcpGeneralTest (desc),
73  m_senderSent (0),
74  m_receiverSent (0),
75  m_senderReceived (0),
76  m_testCase (testCase)
77 {
78 }
79 
80 void
82 {
83  bool foundTag = false; // IpTosTag will only be found if ECN bits are set
84  if (who == SENDER && (m_testCase == 1 || m_testCase == 2))
85  {
86  m_senderSent++;
87  SocketIpTosTag ipTosTag;
88  foundTag = p->PeekPacketTag (ipTosTag);
89  if (m_testCase == 1)
90  {
91  if (m_senderSent == 1)
92  {
93  NS_TEST_ASSERT_MSG_EQ (foundTag, true, "Tag not found");
94  NS_TEST_ASSERT_MSG_EQ (unsigned (ipTosTag.GetTos ()), 0x1, "IP TOS should have ECT1 for SYN packet for DCTCP traffic");
95  }
96  if (m_senderSent == 3)
97  {
98  NS_TEST_ASSERT_MSG_EQ (foundTag, true, "Tag not found");
99  NS_TEST_ASSERT_MSG_EQ (unsigned (ipTosTag.GetTos ()), 0x1, "IP TOS should have ECT1 for data packets for DCTCP traffic");
100  }
101  }
102  else
103  {
104  if (m_senderSent == 1)
105  {
106  NS_TEST_ASSERT_MSG_EQ (foundTag, false, "IP TOS should not have ECT1 for SYN packet for DCTCP traffic");
107  }
108  if (m_senderSent == 3)
109  {
110  NS_TEST_ASSERT_MSG_EQ (foundTag, true, "Tag not found");
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");
112  }
113  }
114  }
115  else if (who == RECEIVER && (m_testCase == 1 || m_testCase == 2))
116  {
117  m_receiverSent++;
118  SocketIpTosTag ipTosTag;
119  foundTag = p->PeekPacketTag (ipTosTag);
120  if (m_testCase == 1)
121  {
122  if (m_receiverSent == 1)
123  {
124  NS_TEST_ASSERT_MSG_EQ (foundTag, true, "Tag not found");
125  NS_TEST_ASSERT_MSG_EQ (unsigned (ipTosTag.GetTos ()), 0x1, "IP TOS should have ECT1 for SYN+ACK packet for DCTCP traffic");
126  }
127  if (m_receiverSent == 2)
128  {
129  NS_TEST_ASSERT_MSG_EQ (foundTag, true, "Tag not found");
130  NS_TEST_ASSERT_MSG_EQ (unsigned (ipTosTag.GetTos ()), 0x1, "IP TOS should have ECT1 for pure ACK packets for DCTCP traffic");
131  }
132  }
133  else
134  {
135  if (m_receiverSent == 1)
136  {
137  NS_TEST_ASSERT_MSG_EQ (foundTag, false, "IP TOS should have neither ECT0 nor ECT1 for SYN+ACK packet for non-DCTCP traffic");
138  }
139  if (m_receiverSent == 2)
140  {
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");
142  }
143  }
144  }
145 }
146 
147 void
149 {
150  if (who == SENDER && m_testCase == 3)
151  {
153  if (m_senderReceived == 2 && m_testCase == 3)
154  {
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");
156  }
157  if (m_senderReceived > 2 && m_testCase == 3)
158  {
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");
160  }
161  }
162 }
163 
164 void
166 {
167  TcpGeneralTest::ConfigureProperties ();
168  SetUseEcn (SENDER, TcpSocketState::On);
169  SetUseEcn (RECEIVER, TcpSocketState::On);
170 }
171 
172 void
174 {
175  TcpGeneralTest::ConfigureEnvironment ();
176  Config::SetDefault ("ns3::TcpDctcp::UseEct0", BooleanValue (false));
177 }
178 
191 {
192 public:
197  static TypeId GetTypeId (void);
198 
200  uint8_t m_testCase;
201 
203  : TcpSocketMsgBase ()
204  {
205  m_dataPacketSent = 0;
206  }
207 
213  : TcpSocketMsgBase (other)
214  {
215  }
216 
217  void SetTestCase (uint8_t testCase);
218 protected:
219  virtual uint32_t SendDataPacket (SequenceNumber32 seq, uint32_t maxSize, bool withAck);
220  virtual void ReTxTimeout ();
221  Ptr<TcpSocketBase> Fork (void);
222 };
223 
225 
226 TypeId
228 {
229  static TypeId tid = TypeId ("ns3::TcpDctcpCongestedRouter")
231  .SetGroupName ("Internet")
232  .AddConstructor<TcpDctcpCongestedRouter> ()
233  ;
234  return tid;
235 }
236 
237 void
239 {
240  TcpSocketBase::ReTxTimeout ();
241 }
242 
243 void
245 {
246  m_testCase = testCase;
247 }
248 
249 uint32_t
250 TcpDctcpCongestedRouter::SendDataPacket (SequenceNumber32 seq, uint32_t maxSize, bool withAck)
251 {
252  NS_LOG_FUNCTION (this << seq << maxSize << withAck);
254 
255  bool isRetransmission = false;
256  if (seq != m_tcb->m_highTxMark)
257  {
258  isRetransmission = true;
259  }
260 
261  Ptr<Packet> p = m_txBuffer->CopyFromSequence (maxSize, seq)->GetPacketCopy ();
262  uint32_t sz = p->GetSize (); // Size of packet
263  uint8_t flags = withAck ? TcpHeader::ACK : 0;
264  uint32_t remainingData = m_txBuffer->SizeFromSequence (seq + SequenceNumber32 (sz));
265 
266  if (withAck)
267  {
269  m_delAckCount = 0;
270  }
271 
272  // For test 3, we don't send CWR flags on receipt of ECE to check if Receiver sends ECE only when there is CE flags
273  if (m_tcb->m_ecnState == TcpSocketState::ECN_ECE_RCVD && m_ecnEchoSeq.Get () > m_ecnCWRSeq.Get () && !isRetransmission && m_testCase != 3)
274  {
275  NS_LOG_INFO ("Backoff mechanism by reducing CWND by half because we've received ECN Echo");
276  m_congestionControl->ReduceCwnd (m_tcb);
278  flags |= TcpHeader::CWR;
279  m_ecnCWRSeq = seq;
280  m_tcb->m_ecnState = TcpSocketState::ECN_CWR_SENT;
281  NS_LOG_DEBUG (TcpSocketState::EcnStateName[m_tcb->m_ecnState] << " -> ECN_CWR_SENT");
282  NS_LOG_INFO ("CWR flags set");
283  NS_LOG_DEBUG (TcpSocketState::TcpCongStateName[m_tcb->m_congState] << " -> CA_CWR");
284  if (m_tcb->m_congState == TcpSocketState::CA_OPEN)
285  {
286  m_congestionControl->CongestionStateSet (m_tcb, TcpSocketState::CA_CWR);
287  m_tcb->m_congState = TcpSocketState::CA_CWR;
288  }
289  }
290  /*
291  * Add tags for each socket option.
292  * Note that currently the socket adds both IPv4 tag and IPv6 tag
293  * if both options are set. Once the packet got to layer three, only
294  * the corresponding tags will be read.
295  */
296  if (GetIpTos ())
297  {
298  SocketIpTosTag ipTosTag;
299 
300  NS_LOG_LOGIC (" ECT bits should not be set on retransmitted packets ");
301  if (m_testCase == 3 && m_dataPacketSent == 1 && !isRetransmission)
302  {
303  ipTosTag.SetTos (GetIpTos () | 0x3);
304  }
305  else
306  {
307  if (m_tcb->m_ecnState != TcpSocketState::ECN_DISABLED && (GetIpTos () & 0x3) == 0 && !isRetransmission)
308  {
309  ipTosTag.SetTos (GetIpTos () | 0x1);
310  }
311  else
312  {
313  ipTosTag.SetTos (GetIpTos ());
314  }
315  }
316  p->AddPacketTag (ipTosTag);
317  }
318  else
319  {
320  SocketIpTosTag ipTosTag;
321  if (m_testCase == 3 && m_dataPacketSent == 1 && !isRetransmission)
322  {
323  ipTosTag.SetTos (0x3);
324  }
325  else
326  {
327  if (m_tcb->m_ecnState != TcpSocketState::ECN_DISABLED && !isRetransmission)
328  {
329  ipTosTag.SetTos (0x1);
330  }
331  }
332  p->AddPacketTag (ipTosTag);
333  }
334 
335  if (IsManualIpv6Tclass ())
336  {
337  SocketIpv6TclassTag ipTclassTag;
338  if (m_testCase == 3 && m_dataPacketSent == 1 && !isRetransmission )
339  {
340  ipTclassTag.SetTclass (GetIpv6Tclass () | 0x3);
341  }
342  else
343  {
344  if (m_tcb->m_ecnState != TcpSocketState::ECN_DISABLED && (GetIpv6Tclass () & 0x3) == 0 && !isRetransmission)
345  {
346  ipTclassTag.SetTclass (GetIpv6Tclass () | 0x1);
347  }
348  else
349  {
350  ipTclassTag.SetTclass (GetIpv6Tclass ());
351  }
352  }
353  p->AddPacketTag (ipTclassTag);
354  }
355  else
356  {
357  SocketIpv6TclassTag ipTclassTag;
358  if (m_testCase == 3 && m_dataPacketSent == 1 && !isRetransmission)
359  {
360  ipTclassTag.SetTclass (0x3);
361  }
362  else
363  {
364  if (m_tcb->m_ecnState != TcpSocketState::ECN_DISABLED && !isRetransmission)
365  {
366  ipTclassTag.SetTclass (0x1);
367  }
368  }
369  p->AddPacketTag (ipTclassTag);
370  }
371 
372  if (IsManualIpTtl ())
373  {
374  SocketIpTtlTag ipTtlTag;
375  ipTtlTag.SetTtl (GetIpTtl ());
376  p->AddPacketTag (ipTtlTag);
377  }
378 
379  if (IsManualIpv6HopLimit ())
380  {
381  SocketIpv6HopLimitTag ipHopLimitTag;
382  ipHopLimitTag.SetHopLimit (GetIpv6HopLimit ());
383  p->AddPacketTag (ipHopLimitTag);
384  }
385 
386  uint8_t priority = GetPriority ();
387  if (priority)
388  {
389  SocketPriorityTag priorityTag;
390  priorityTag.SetPriority (priority);
391  p->ReplacePacketTag (priorityTag);
392  }
393 
394  if (m_closeOnEmpty && (remainingData == 0))
395  {
396  flags |= TcpHeader::FIN;
397  if (m_state == ESTABLISHED)
398  { // On active close: I am the first one to send FIN
399  NS_LOG_DEBUG ("ESTABLISHED -> FIN_WAIT_1");
401  }
402  else if (m_state == CLOSE_WAIT)
403  { // On passive close: Peer sent me FIN already
404  NS_LOG_DEBUG ("CLOSE_WAIT -> LAST_ACK");
405  m_state = LAST_ACK;
406  }
407  }
408  TcpHeader header;
409  header.SetFlags (flags);
410  header.SetSequenceNumber (seq);
411  header.SetAckNumber (m_tcb->m_rxBuffer->NextRxSequence ());
412  if (m_endPoint)
413  {
416  }
417  else
418  {
421  }
423  AddOptions (header);
424 
425  if (m_retxEvent.IsExpired ())
426  {
427  // Schedules retransmit timeout. m_rto should be already doubled.
428 
429  NS_LOG_LOGIC (this << " SendDataPacket Schedule ReTxTimeout at time " <<
430  Simulator::Now ().GetSeconds () << " to expire at time " <<
431  (Simulator::Now () + m_rto.Get ()).GetSeconds () );
432  m_retxEvent = Simulator::Schedule (m_rto, &TcpDctcpCongestedRouter::ReTxTimeout, this);
433  }
434 
435  m_txTrace (p, header, this);
436 
437  if (m_endPoint)
438  {
439  m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (),
441  NS_LOG_DEBUG ("Send segment of size " << sz << " with remaining data " <<
442  remainingData << " via TcpL4Protocol to " << m_endPoint->GetPeerAddress () <<
443  ". Header " << header);
444  }
445  else
446  {
447  m_tcp->SendPacket (p, header, m_endPoint6->GetLocalAddress (),
449  NS_LOG_DEBUG ("Send segment of size " << sz << " with remaining data " <<
450  remainingData << " via TcpL4Protocol to " << m_endPoint6->GetPeerAddress () <<
451  ". Header " << header);
452  }
453 
454  UpdateRttHistory (seq, sz, isRetransmission);
455 
456  // Notify the application of the data being sent unless this is a retransmit
457  if (seq + sz > m_tcb->m_highTxMark)
458  {
459  Simulator::ScheduleNow (&TcpDctcpCongestedRouter::NotifyDataSent, this,
460  (seq + sz - m_tcb->m_highTxMark.Get ()));
461  }
462  // Update highTxMark
463  m_tcb->m_highTxMark = std::max (seq + sz, m_tcb->m_highTxMark.Get ());
464  return sz;
465 }
466 
469 {
470  return CopyObject<TcpDctcpCongestedRouter> (this);
471 }
472 
475 {
476  if (m_testCase == 2)
477  {
478  return TcpGeneralTest::CreateSenderSocket (node);
479  }
480  else if (m_testCase == 3)
481  {
482  Ptr<TcpDctcpCongestedRouter> socket = DynamicCast<TcpDctcpCongestedRouter> (
483  CreateSocket (node,
485  TcpDctcp::GetTypeId ()));
486  socket->SetTestCase (m_testCase);
487  return socket;
488  }
489  else
490  {
491  return TcpGeneralTest::CreateSocket (node, TcpSocketMsgBase::GetTypeId (), TcpDctcp::GetTypeId ());
492  }
493 }
494 
497 {
498  if (m_testCase == 2)
499  {
500  return TcpGeneralTest::CreateReceiverSocket (node);
501  }
502  else
503  {
504  return TcpGeneralTest::CreateSocket (node, TcpSocketMsgBase::GetTypeId (), TcpDctcp::GetTypeId ());
505  }
506 }
507 
515 {
516 public:
529  TcpDctcpToNewReno (uint32_t cWnd, uint32_t segmentSize, uint32_t ssThresh,
530  uint32_t segmentsAcked, SequenceNumber32 highTxMark,
531  SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name);
532 
533 private:
534  virtual void DoRun (void);
537  void ExecuteTest (void);
538 
539  uint32_t m_cWnd;
540  uint32_t m_segmentSize;
541  uint32_t m_segmentsAcked;
542  uint32_t m_ssThresh;
547 };
548 
549 TcpDctcpToNewReno::TcpDctcpToNewReno (uint32_t cWnd, uint32_t segmentSize, uint32_t ssThresh,
550  uint32_t segmentsAcked, SequenceNumber32 highTxMark,
551  SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name)
552  : TestCase (name),
553  m_cWnd (cWnd),
554  m_segmentSize (segmentSize),
555  m_segmentsAcked (segmentsAcked),
556  m_ssThresh (ssThresh),
557  m_rtt (rtt),
558  m_highTxMark (highTxMark),
559  m_lastAckedSeq (lastAckedSeq)
560 {
561 }
562 
563 void
565 {
566  Simulator::Schedule (Seconds (0.0), &TcpDctcpToNewReno::ExecuteTest, this);
567  Simulator::Run ();
568  Simulator::Destroy ();
569 }
570 
571 void
573 {
574  m_state = CreateObject <TcpSocketState> ();
575  m_state->m_cWnd = m_cWnd;
580 
581  Ptr<TcpSocketState> state = CreateObject <TcpSocketState> ();
582  state->m_cWnd = m_cWnd;
583  state->m_ssThresh = m_ssThresh;
584  state->m_segmentSize = m_segmentSize;
585  state->m_highTxMark = m_highTxMark;
587 
588  Ptr<TcpDctcp> cong = CreateObject <TcpDctcp> ();
590 
591  Ptr<TcpNewReno> NewRenoCong = CreateObject <TcpNewReno> ();
592  NewRenoCong->IncreaseWindow (state, m_segmentsAcked);
593 
595  "cWnd has not updated correctly");
596 }
604 {
605 public:
617  TcpDctcpDecrementTest (uint32_t cWnd, uint32_t segmentSize, uint32_t segmentsAcked, SequenceNumber32 nextTxSequence,
618  SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name);
619 
620 private:
621  virtual void DoRun (void);
624  void ExecuteTest (void);
625 
626  uint32_t m_cWnd;
627  uint32_t m_segmentSize;
628  uint32_t m_segmentsAcked;
633 };
634 
635 TcpDctcpDecrementTest::TcpDctcpDecrementTest (uint32_t cWnd, uint32_t segmentSize, uint32_t segmentsAcked, SequenceNumber32 nextTxSequence,
636  SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name)
637  : TestCase (name),
638  m_cWnd (cWnd),
639  m_segmentSize (segmentSize),
640  m_segmentsAcked (segmentsAcked),
641  m_rtt (rtt),
642  m_nextTxSequence (nextTxSequence),
643  m_lastAckedSeq (lastAckedSeq)
644 {
645 }
646 
647 void
649 {
650  Config::SetDefault ("ns3::TcpDctcp::DctcpAlphaOnInit", DoubleValue (0));
651  Simulator::Schedule (Seconds (0.0), &TcpDctcpDecrementTest::ExecuteTest, this);
652  Simulator::Run ();
653  Simulator::Destroy ();
654 }
655 
656 void
658 {
659  m_state = CreateObject <TcpSocketState> ();
660  m_state->m_cWnd = m_cWnd;
664 
665  Ptr<TcpDctcp> cong = CreateObject <TcpDctcp> ();
666  m_state->m_ecnState = TcpSocketState::ECN_IDLE;
668  cong->ReduceCwnd (m_state);
670  "cWnd has updated correctly");
671 
672  m_state->m_ecnState = TcpSocketState::ECN_ECE_RCVD;
674  cong->ReduceCwnd (m_state);
675 
676  uint32_t val = (uint32_t)(m_cWnd * (1 - 0.0625 / 2.0));
678  "cWnd has updated correctly");
679 
680 }
681 
689 {
690 public:
691  TcpDctcpTestSuite () : TestSuite ("tcp-dctcp-test", UNIT)
692  {
693  AddTestCase (new TcpDctcpToNewReno (2 * 1446, 1446, 4 * 1446, 2, SequenceNumber32 (4753), SequenceNumber32 (3216), MilliSeconds (100), "DCTCP falls to New Reno for slowstart"), TestCase::QUICK);
694  AddTestCase (new TcpDctcpDecrementTest (4 * 1446, 1446, 2, SequenceNumber32 (3216), SequenceNumber32 (4753), MilliSeconds (100), "DCTCP decrement test"), TestCase::QUICK);
695  AddTestCase (new TcpDctcpCodePointsTest (1, "ECT Test : Check if ECT is set on Syn, Syn+Ack, Ack and Data packets for DCTCP packets"),
696  TestCase::QUICK);
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);
698  AddTestCase (new TcpDctcpCodePointsTest (3, "ECE Functionality Test: ECE should only be sent by reciever when it receives CE flags"),
699  TestCase::QUICK);
700  }
701 };
702 
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
static TypeId GetTypeId(void)
Get the type ID.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
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 "...
Connection established.
Definition: tcp-socket.h:71
AttributeValue implementation for Boolean.
Definition: boolean.h:36
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...
Definition: socket.h:1163
Ipv4EndPoint * m_endPoint
the IPv4 endpoint
#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:1343
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.
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.
Definition: log.h:205
Ptr< TcpSocketState > m_tcb
Congestion control information.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1078
uint32_t m_segmentSize
Segment size.
#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 IncreaseWindow(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
Try to increase the cWnd following the NewReno specification.
encapsulates test code
Definition: test.h:1153
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...
Definition: socket.h:1115
A TCP socket which sends a data packet with CE flags set for test 3.
TracedValue< TcpStates_t > m_state
TCP state.
uint32_t m_cWnd
cWnd
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:59
static TcpDctcpTestSuite g_tcpdctcpTest
static var for test initialization
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
uint32_t m_segmentsAcked
segments acked
void ExecuteTest(void)
Execute the test.
Ptr< TcpCongestionOps > m_congestionControl
Congestion control.
void SetSequenceNumber(SequenceNumber32 sequenceNumber)
Set the sequence Number.
Definition: tcp-header.cc:101
#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 DCTCP TestSuite.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
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.
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
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.
Definition: socket.cc:285
virtual void PktsAcked(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked, const Time &rtt)
Get information from the acked packet.
Definition: tcp-dctcp.cc:124
void ConfigureEnvironment()
Change the configuration of the environment.
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
virtual void ReTxTimeout()
An RTO event happened.
void SetFlags(uint8_t flags)
Set flags of the header.
Definition: tcp-header.cc:113
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.
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
SequenceNumber32 m_lastAckedSeq
last acked seq
indicates whether the socket has IPV6_TCLASS set.
Definition: socket.h:1354
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.
Definition: tcp-socket.h:75
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
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
SequenceNumber32 m_nextTxSequence
next seq num to be sent
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.
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).
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
TracedValue< Time > m_rto
Retransmit timeout.
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.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1070
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:812
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.
Definition: event-id.cc:53
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)
Reduce congestion window based on DCTCP algorithm.
Definition: tcp-dctcp.cc:116
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 use on.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:309
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.
Definition: packet.cc:885
This test suite implements a Unit Test.
Definition: test.h:1353
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
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
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:923
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.
Definition: socket.cc:396
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.