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 "ns3/ipv4-end-point.h"
29 #include "ns3/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:
72  uint32_t m_cwndChangeCount;
73  uint32_t m_senderSent;
74  uint32_t m_senderReceived;
75  uint32_t m_receiverReceived;
76  uint32_t m_testcase;
77 };
78 
79 
93 {
94 public:
99  static TypeId GetTypeId (void);
100 
101  uint32_t m_dataPacketSent;
102  uint8_t m_testcase;
103 
105  : TcpSocketMsgBase ()
106  {
107  m_dataPacketSent = 0;
108  }
109 
115  : TcpSocketMsgBase (other)
116  {
117  }
118 
123  void SetTestCase (uint8_t testCase);
124 
125 protected:
126  virtual uint32_t SendDataPacket (SequenceNumber32 seq, uint32_t maxSize, bool withAck);
127  virtual void ReTxTimeout ();
128  Ptr<TcpSocketBase> Fork (void);
129 };
130 
131 NS_OBJECT_ENSURE_REGISTERED (TcpSocketCongestedRouter);
132 
133 TypeId
135 {
136  static TypeId tid = TypeId ("ns3::TcpSocketCongestedRouter")
138  .SetGroupName ("Internet")
139  .AddConstructor<TcpSocketCongestedRouter> ()
140  ;
141  return tid;
142 }
143 
144 void
146 {
148 }
149 
150 void
152 {
153  m_testcase = testCase;
154 }
155 
156 uint32_t
157 TcpSocketCongestedRouter::SendDataPacket (SequenceNumber32 seq, uint32_t maxSize, bool withAck)
158 {
159  NS_LOG_FUNCTION (this << seq << maxSize << withAck);
161 
162  bool isRetransmission = false;
163  if (seq != m_tcb->m_highTxMark)
164  {
165  isRetransmission = true;
166  }
167 
168  Ptr<Packet> p = m_txBuffer->CopyFromSequence (maxSize, seq)->GetPacketCopy ();
169  uint32_t sz = p->GetSize (); // Size of packet
170  uint8_t flags = withAck ? TcpHeader::ACK : 0;
171  uint32_t remainingData = m_txBuffer->SizeFromSequence (seq + SequenceNumber32 (sz));
172 
173  if (withAck)
174  {
176  m_delAckCount = 0;
177  }
178 
179  // Sender should reduce the Congestion Window as a response to receiver's ECN Echo notification only once per window
180  if (m_tcb->m_ecnState == TcpSocketState::ECN_ECE_RCVD && m_ecnEchoSeq.Get () > m_ecnCWRSeq.Get () && !isRetransmission)
181  {
182  NS_LOG_DEBUG (TcpSocketState::EcnStateName[m_tcb->m_ecnState] << " -> ECN_CWR_SENT");
184  m_ecnCWRSeq = seq;
185  flags |= TcpHeader::CWR;
186  NS_LOG_INFO ("CWR flags set");
187  }
188  /*
189  * Add tags for each socket option.
190  * Note that currently the socket adds both IPv4 tag and IPv6 tag
191  * if both options are set. Once the packet got to layer three, only
192  * the corresponding tags will be read.
193  */
194  if (GetIpTos ())
195  {
196  SocketIpTosTag ipTosTag;
197  if ( m_testcase == 5 && (m_dataPacketSent == 1 || m_dataPacketSent == 3))
198  {
199  ipTosTag.SetTos (MarkEcnCe (GetIpTos ()));
200  }
201  else if ( m_testcase == 6 && ( m_dataPacketSent == 4 || m_dataPacketSent == 5))
202  {
203  ipTosTag.SetTos (MarkEcnCe (GetIpTos ()));
204  }
205  else
206  {
207  if (m_tcb->m_ecnState != TcpSocketState::ECN_DISABLED && (GetIpTos () & 0x3) == 0)
208  {
209  ipTosTag.SetTos (MarkEcnEct0 (GetIpTos ()));
210  }
211  else
212  {
213  ipTosTag.SetTos (GetIpTos ());
214  }
215  }
216  p->AddPacketTag (ipTosTag);
217  }
218  else
219  {
220  SocketIpTosTag ipTosTag;
221  if ( m_testcase == 5 && (m_dataPacketSent == 1 || m_dataPacketSent == 3))
222  {
223  ipTosTag.SetTos (MarkEcnCe (GetIpTos ()));
224  }
225  else if ( m_testcase == 6 && ( m_dataPacketSent == 4 || m_dataPacketSent == 5))
226  {
227  ipTosTag.SetTos (MarkEcnCe (GetIpTos ()));
228  }
229  else
230  {
232  {
233  ipTosTag.SetTos (MarkEcnEct0 (GetIpTos ()));
234  }
235  }
236  p->AddPacketTag (ipTosTag);
237  }
238 
239  if (IsManualIpv6Tclass ())
240  {
241  SocketIpv6TclassTag ipTclassTag;
242  if ( m_testcase == 5 && (m_dataPacketSent == 1 || m_dataPacketSent == 3))
243  {
244  ipTclassTag.SetTclass (MarkEcnCe (GetIpv6Tclass ()));
245  }
246  else if ( m_testcase == 6 && ( m_dataPacketSent == 4 || m_dataPacketSent == 5))
247  {
248  ipTclassTag.SetTclass (MarkEcnCe (GetIpv6Tclass ()));
249  }
250  else
251  {
252  if (m_tcb->m_ecnState != TcpSocketState::ECN_DISABLED && (GetIpv6Tclass () & 0x3) == 0)
253  {
254  ipTclassTag.SetTclass (MarkEcnEct0 (GetIpv6Tclass ()));
255  }
256  else
257  {
258  ipTclassTag.SetTclass (GetIpv6Tclass ());
259  }
260  }
261  p->AddPacketTag (ipTclassTag);
262  }
263  else
264  {
265  SocketIpv6TclassTag ipTclassTag;
266  if ( m_testcase == 5 && (m_dataPacketSent == 1 || m_dataPacketSent == 3))
267  {
268  ipTclassTag.SetTclass (MarkEcnCe (GetIpv6Tclass ()));
269  }
270  else if ( m_testcase == 6 &&( m_dataPacketSent == 4 || m_dataPacketSent == 5 ))
271  {
272  ipTclassTag.SetTclass (MarkEcnCe (GetIpv6Tclass ()));
273  }
274  else
275  {
277  {
278  ipTclassTag.SetTclass (MarkEcnEct0 (GetIpv6Tclass ()));
279  }
280  }
281  p->AddPacketTag (ipTclassTag);
282  }
283 
284  if (IsManualIpTtl ())
285  {
286  SocketIpTtlTag ipTtlTag;
287  ipTtlTag.SetTtl (GetIpTtl ());
288  p->AddPacketTag (ipTtlTag);
289  }
290 
291  if (IsManualIpv6HopLimit ())
292  {
293  SocketIpv6HopLimitTag ipHopLimitTag;
294  ipHopLimitTag.SetHopLimit (GetIpv6HopLimit ());
295  p->AddPacketTag (ipHopLimitTag);
296  }
297 
298  uint8_t priority = GetPriority ();
299  if (priority)
300  {
301  SocketPriorityTag priorityTag;
302  priorityTag.SetPriority (priority);
303  p->ReplacePacketTag (priorityTag);
304  }
305 
306  if (m_closeOnEmpty && (remainingData == 0))
307  {
308  flags |= TcpHeader::FIN;
309  if (m_state == ESTABLISHED)
310  { // On active close: I am the first one to send FIN
311  NS_LOG_DEBUG ("ESTABLISHED -> FIN_WAIT_1");
313  }
314  else if (m_state == CLOSE_WAIT)
315  { // On passive close: Peer sent me FIN already
316  NS_LOG_DEBUG ("CLOSE_WAIT -> LAST_ACK");
317  m_state = LAST_ACK;
318  }
319  }
320  TcpHeader header;
321  header.SetFlags (flags);
322  header.SetSequenceNumber (seq);
323  header.SetAckNumber (m_tcb->m_rxBuffer->NextRxSequence ());
324  if (m_endPoint)
325  {
328  }
329  else
330  {
333  }
335  AddOptions (header);
336 
337  if (m_retxEvent.IsExpired ())
338  {
339  // Schedules retransmit timeout. m_rto should be already doubled.
340 
341  NS_LOG_LOGIC (this << " SendDataPacket Schedule ReTxTimeout at time " <<
342  Simulator::Now ().GetSeconds () << " to expire at time " <<
343  (Simulator::Now () + m_rto.Get ()).GetSeconds () );
345  }
346 
347  m_txTrace (p, header, this);
348 
349  if (m_endPoint)
350  {
351  m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (),
353  NS_LOG_DEBUG ("Send segment of size " << sz << " with remaining data " <<
354  remainingData << " via TcpL4Protocol to " << m_endPoint->GetPeerAddress () <<
355  ". Header " << header);
356  }
357  else
358  {
359  m_tcp->SendPacket (p, header, m_endPoint6->GetLocalAddress (),
361  NS_LOG_DEBUG ("Send segment of size " << sz << " with remaining data " <<
362  remainingData << " via TcpL4Protocol to " << m_endPoint6->GetPeerAddress () <<
363  ". Header " << header);
364  }
365 
366  UpdateRttHistory (seq, sz, isRetransmission);
367 
368  // Notify the application of the data being sent unless this is a retransmit
369  if (seq + sz > m_tcb->m_highTxMark)
370  {
372  (seq + sz - m_tcb->m_highTxMark.Get ()));
373  }
374  // Update highTxMark
375  m_tcb->m_highTxMark = std::max (seq + sz, m_tcb->m_highTxMark.Get ());
376  return sz;
377 }
378 
381 {
382  return CopyObject<TcpSocketCongestedRouter> (this);
383 }
384 
385 
386 TcpEcnTest::TcpEcnTest (uint32_t testcase, const std::string &desc)
387  : TcpGeneralTest (desc),
388  m_cwndChangeCount (0),
389  m_senderSent (0),
390  m_senderReceived (0),
391  m_receiverReceived (0),
392  m_testcase (testcase)
393 {
394 }
395 
396 void
398 {
400  if (m_testcase == 2 || m_testcase == 4 || m_testcase == 5 || m_testcase == 6)
401  {
403  }
404  if (m_testcase == 3 || m_testcase == 4 ||m_testcase == 5 || m_testcase == 6)
405  {
407  }
408 }
409 
410 void
411 TcpEcnTest::CWndTrace (uint32_t oldValue, uint32_t newValue)
412 {
413  if (m_testcase == 6)
414  {
415  if (newValue < oldValue)
416  {
418  NS_TEST_ASSERT_MSG_EQ (m_cwndChangeCount, 1, "Congestion window should be reduced once per every window");
419  NS_TEST_ASSERT_MSG_EQ (newValue, 1000, "Congestion window should not drop below 2 segments");
420  }
421  }
422 }
423 
424 void
426 {
427  if (who == RECEIVER)
428  {
429  if (m_receiverReceived == 0)
430  {
431  NS_TEST_ASSERT_MSG_NE (((h.GetFlags ()) & TcpHeader::SYN), 0, "SYN should be received as first message at the receiver");
432  if (m_testcase == 2 || m_testcase == 4 || m_testcase == 5 ||m_testcase == 6)
433  {
434  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");
435  }
436  else
437  {
438  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");
439  }
440  }
441  else if (m_receiverReceived == 1)
442  {
443  NS_TEST_ASSERT_MSG_NE (((h.GetFlags ()) & TcpHeader::ACK), 0, "ACK should be received as second message at receiver");
444  }
445  else if (m_receiverReceived == 3 && m_testcase == 5)
446  {
447  NS_TEST_ASSERT_MSG_NE (((h.GetFlags ()) & TcpHeader::CWR), 0, "Sender should send CWR on receipt of ECE");
448  }
450  }
451  else if (who == SENDER)
452  {
453  if (m_senderReceived == 0)
454  {
455  NS_TEST_ASSERT_MSG_NE (((h.GetFlags ()) & TcpHeader::SYN) && ((h.GetFlags ()) & TcpHeader::ACK), 0, "SYN+ACK received as first message at sender");
456  if (m_testcase == 4 || m_testcase == 5 || m_testcase == 6)
457  {
458  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");
459  }
460  else
461  {
462  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");
463  }
464  }
465  if ( m_testcase == 5 && m_receiverReceived > 12)
466  {
467  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");
468  }
470  }
471 }
472 
473 void
475 {
476  if (who == SENDER)
477  {
478  m_senderSent++;
479  if (m_senderSent == 3)
480  {
481  SocketIpTosTag ipTosTag;
482  bool found = p->PeekPacketTag (ipTosTag);
483  uint16_t ipTos = 0;
484  if (found)
485  {
486  ipTos = static_cast<uint16_t> (ipTosTag.GetTos ());
487  }
488  if (m_testcase == 4 || m_testcase == 6)
489  {
490  NS_TEST_ASSERT_MSG_EQ (ipTos, 0x2, "IP TOS should have ECT set if ECN negotiation between endpoints is successful");
491  }
492  else if (m_testcase == 5)
493  {
494  if (m_senderSent == 3 || m_senderSent == 5)
495  {
496  NS_TEST_ASSERT_MSG_EQ (ipTos, 0x3, "IP TOS should have CE bit set for 3rd and 5th packet sent in test case 5");
497  }
498  else
499  {
500  NS_TEST_ASSERT_MSG_EQ (ipTos, 0x2, "IP TOS should have ECT set if ECN negotiation between endpoints is successful");
501  }
502  }
503  else
504  {
505  NS_TEST_ASSERT_MSG_NE (ipTos, 0x2, "IP TOS should not have ECT set if ECN negotiation between endpoints is unsuccessful");
506  }
507  }
508  }
509 }
510 
513 {
514  if (m_testcase == 5 || m_testcase == 6)
515  {
516  Ptr<TcpSocketCongestedRouter> socket = DynamicCast<TcpSocketCongestedRouter> (
517  CreateSocket (node,
520  socket->SetTestCase (m_testcase);
521  return socket;
522  }
523  else
524  {
526  }
527 }
528 
536 {
537 public:
538  TcpEcnTestSuite () : TestSuite ("tcp-ecn-test", UNIT)
539  {
540  AddTestCase (new TcpEcnTest (1, "ECN Negotiation Test : ECN incapable sender and ECN incapable receiver"),
542  AddTestCase (new TcpEcnTest (2, "ECN Negotiation Test : ECN capable sender and ECN incapable receiver"),
544  AddTestCase (new TcpEcnTest (3, "ECN Negotiation Test : ECN incapable sender and ECN capable receiver"),
546  AddTestCase (new TcpEcnTest (4, "ECN Negotiation Test : ECN capable sender and ECN capable receiver"),
548  AddTestCase (new TcpEcnTest (5, "ECE and CWR Functionality Test: ECN capable sender and ECN capable receiver"),
550  AddTestCase (new TcpEcnTest (6, "Congestion Window Reduction Test :ECN capable sender and ECN capable receiver"),
552  }
553 };
554 
556 
557 } // namespace ns3
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::Packet::ReplacePacketTag
bool ReplacePacketTag(Tag &tag)
Replace the value of a packet tag.
Definition: packet.cc:970
ns3::TcpSocketBase::m_ecnCWRSeq
TracedValue< SequenceNumber32 > m_ecnCWRSeq
Sequence number of the last sent CWR.
Definition: tcp-socket-base.h:1349
ns3::TcpEcnTest::m_receiverReceived
uint32_t m_receiverReceived
Number of segments received by the receiver.
Definition: tcp-ecn-test.cc:75
ns3::TcpSocketBase::AdvertisedWindowSize
virtual uint16_t AdvertisedWindowSize(bool scale=true) const
The amount of Rx window announced to the peer.
Definition: tcp-socket-base.cc:3394
ns3::TcpSocketCongestedRouter::m_testcase
uint8_t m_testcase
Test case type.
Definition: tcp-ecn-test.cc:102
ns3::TcpGeneralTest::SocketWho
SocketWho
Used as parameter of methods, specifies on what node the caller is interested (e.g.
Definition: tcp-general-test.h:275
ns3::TcpHeader::SetSourcePort
void SetSourcePort(uint16_t port)
Set the source port.
Definition: tcp-header.cc:89
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
ns3::TracedValue::Get
T Get(void) const
Get the underlying value.
Definition: traced-value.h:229
ns3::TcpHeader::ECE
@ ECE
ECE.
Definition: tcp-header.h:288
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
ns3::TcpSocketState::ECN_ECE_RCVD
@ ECN_ECE_RCVD
Last ACK received had ECE bit set in TCP header
Definition: tcp-socket-state.h:149
ns3::TcpHeader::SetSequenceNumber
void SetSequenceNumber(SequenceNumber32 sequenceNumber)
Set the sequence Number.
Definition: tcp-header.cc:101
ns3::TcpSocket::LAST_ACK
@ LAST_ACK
Our side has shutdown after remote has shutdown.
Definition: tcp-socket.h:75
ns3::TcpEcnTest::CreateSenderSocket
virtual Ptr< TcpSocketMsgBase > CreateSenderSocket(Ptr< Node > node)
Create and install the socket to install on the sender.
Definition: tcp-ecn-test.cc:512
ns3::Packet::GetSize
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
ns3::Simulator::Now
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::TcpGeneralTest::SENDER
@ SENDER
Sender node.
Definition: tcp-general-test.h:276
ns3::TcpSocketState::m_highTxMark
TracedValue< SequenceNumber32 > m_highTxMark
Highest seqno ever sent, regardless of ReTx.
Definition: tcp-socket-state.h:184
ns3::TcpEcnTest::m_senderReceived
uint32_t m_senderReceived
Number of segments received by the sender.
Definition: tcp-ecn-test.cc:74
ns3::TcpGeneralTest::ConfigureProperties
virtual void ConfigureProperties(void)
Change the configuration of the socket properties.
Definition: tcp-general-test.cc:115
ns3::SocketIpTosTag::GetTos
uint8_t GetTos(void) const
Get the tag's TOS.
Definition: socket.cc:791
ns3::Ipv6EndPoint::GetLocalAddress
Ipv6Address GetLocalAddress()
Get the local address.
Definition: ipv6-end-point.cc:52
ns3::TcpSocketMsgBase
Class for inserting callbacks special points of the flow of TCP sockets.
Definition: tcp-general-test.h:53
ns3::TcpGeneralTest::CreateSocket
virtual Ptr< TcpSocketMsgBase > CreateSocket(Ptr< Node > node, TypeId socketType, TypeId congControl)
Create a socket.
Definition: tcp-general-test.cc:278
ns3::TcpSocketBase::m_closeOnEmpty
bool m_closeOnEmpty
Close socket upon tx buffer emptied.
Definition: tcp-socket-base.h:1294
ns3::TcpSocketBase::m_ecnEchoSeq
TracedValue< SequenceNumber32 > m_ecnEchoSeq
Sequence number of the last received ECN Echo.
Definition: tcp-socket-base.h:1347
ns3::g_tcpECNTestSuite
static TcpEcnTestSuite g_tcpECNTestSuite
static var for test initialization
Definition: tcp-ecn-test.cc:555
ns3::TcpSocket::FIN_WAIT_1
@ FIN_WAIT_1
Our side has shutdown, waiting to complete transmission of remaining buffered data
Definition: tcp-socket.h:78
ns3::TcpEcnTest::Tx
virtual void Tx(const Ptr< const Packet > p, const TcpHeader &h, SocketWho who)
Packet transmitted down to IP layer.
Definition: tcp-ecn-test.cc:474
ns3::TcpSocketCongestedRouter::m_dataPacketSent
uint32_t m_dataPacketSent
Number of packets sent.
Definition: tcp-ecn-test.cc:101
ns3::TcpSocketBase::AddOptions
void AddOptions(TcpHeader &tcpHeader)
Add options to TcpHeader.
Definition: tcp-socket-base.cc:4085
ns3::TcpEcnTest::Rx
virtual void Rx(const Ptr< const Packet > p, const TcpHeader &h, SocketWho who)
Packet received from IP layer.
Definition: tcp-ecn-test.cc:425
ns3::TcpSocketState::m_ecnState
TracedValue< EcnState_t > m_ecnState
Current ECN State, represented as combination of EcnState values.
Definition: tcp-socket-state.h:182
ns3::TcpSocketBase::m_retxEvent
EventId m_retxEvent
Retransmission event.
Definition: tcp-socket-base.h:1246
ns3::SocketIpTtlTag::SetTtl
void SetTtl(uint8_t ttl)
Set the tag's TTL.
Definition: socket.cc:604
ns3::TcpSocketBase::ReTxTimeout
virtual void ReTxTimeout(void)
An RTO event happened.
Definition: tcp-socket-base.cc:3626
ns3::TcpSocketCongestedRouter
A TCP socket which sends certain data packets with CE flags set for tests 5 and 6.
Definition: tcp-ecn-test.cc:93
ns3::TcpSocketCongestedRouter::TcpSocketCongestedRouter
TcpSocketCongestedRouter(const TcpSocketCongestedRouter &other)
Constructor.
Definition: tcp-ecn-test.cc:114
ns3::TcpSocketBase::m_endPoint
Ipv4EndPoint * m_endPoint
the IPv4 endpoint
Definition: tcp-socket-base.h:1278
ns3::Packet::PeekPacketTag
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Definition: packet.cc:978
ns3::TcpHeader::SetAckNumber
void SetAckNumber(SequenceNumber32 ackNumber)
Set the ACK number.
Definition: tcp-header.cc:107
ns3::Simulator::Schedule
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:556
ns3::TcpSocketBase::m_tcb
Ptr< TcpSocketState > m_tcb
Congestion control information.
Definition: tcp-socket-base.h:1328
NS_TEST_ASSERT_MSG_NE
#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
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
ns3::Socket::GetIpTtl
virtual uint8_t GetIpTtl(void) const
Query the value of IP Time to Live field of this socket.
Definition: socket.cc:520
ns3::TcpSocketCongestedRouter::Fork
Ptr< TcpSocketBase > Fork(void)
Call CopyObject<> to clone me.
Definition: tcp-ecn-test.cc:380
ns3::TcpSocketState::EcnStateName
static const char *const EcnStateName[TcpSocketState::ECN_CWR_SENT+1]
Literal names of ECN states for use in log messages.
Definition: tcp-socket-state.h:162
ns3::TcpHeader::SetFlags
void SetFlags(uint8_t flags)
Set flags of the header.
Definition: tcp-header.cc:113
ns3::Socket::GetIpv6HopLimit
virtual uint8_t GetIpv6HopLimit(void) const
Query the value of IP Hop Limit field of this socket.
Definition: socket.cc:545
ns3::TcpHeader::SYN
@ SYN
SYN.
Definition: tcp-header.h:283
ns3::SocketPriorityTag::SetPriority
void SetPriority(uint8_t priority)
Set the tag's priority.
Definition: socket.cc:842
ns3::Ptr< const Packet >
ns3::TcpEcnTest::m_senderSent
uint32_t m_senderSent
Number of segments sent by the sender.
Definition: tcp-ecn-test.cc:73
ns3::TcpSocketBase::m_tcp
Ptr< TcpL4Protocol > m_tcp
the associated TCP L4 protocol
Definition: tcp-socket-base.h:1281
ns3::Ipv6EndPoint::GetPeerAddress
Ipv6Address GetPeerAddress()
Get the peer address.
Definition: ipv6-end-point.cc:72
ns3::Ipv4EndPoint::GetLocalPort
uint16_t GetLocalPort(void)
Get the local port.
Definition: ipv4-end-point.cc:67
ns3::TcpSocket::CLOSE_WAIT
@ CLOSE_WAIT
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
ns3::TcpSocket::ESTABLISHED
@ ESTABLISHED
Connection established
Definition: tcp-socket.h:71
ns3::TcpSocketMsgBase::UpdateRttHistory
virtual void UpdateRttHistory(const SequenceNumber32 &seq, uint32_t sz, bool isRetransmission)
Update the RTT history, when we send TCP segments.
Definition: tcp-general-test.cc:1119
max
#define max(a, b)
Definition: 80211b.c:43
ns3::TcpSocketBase::m_delAckEvent
EventId m_delAckEvent
Delayed ACK timeout event.
Definition: tcp-socket-base.h:1248
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
ns3::TcpSocketState::ECN_DISABLED
@ ECN_DISABLED
ECN disabled traffic
Definition: tcp-socket-state.h:145
ns3::TcpSocketBase::m_endPoint6
Ipv6EndPoint * m_endPoint6
the IPv6 endpoint
Definition: tcp-socket-base.h:1279
ns3::SocketIpv6HopLimitTag
This class implements a tag that carries the socket-specific HOPLIMIT of a packet to the IPv6 layer.
Definition: socket.h:1165
ns3::TcpEcnTest::TcpEcnTest
TcpEcnTest(uint32_t testcase, const std::string &desc)
Constructor.
Definition: tcp-ecn-test.cc:386
ns3::TcpEcnTest
checks if ECT, CWR and ECE bits are set correctly in different scenarios
Definition: tcp-ecn-test.cc:54
ns3::EventId::Cancel
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
ns3::Ipv6EndPoint::GetLocalPort
uint16_t GetLocalPort()
Get the local port.
Definition: ipv6-end-point.cc:62
ns3::TcpSocketBase::m_txBuffer
Ptr< TcpTxBuffer > m_txBuffer
Tx buffer.
Definition: tcp-socket-base.h:1288
ns3::TcpSocketBase::MarkEcnEct0
uint8_t MarkEcnEct0(uint8_t tos) const
Mark ECT(0) codepoint.
Definition: tcp-socket-base.h:462
ns3::TcpSocketState::ECN_CWR_SENT
@ ECN_CWR_SENT
Sender has reduced the congestion window, and sent a packet with CWR bit set in TCP header.
Definition: tcp-socket-state.h:150
tcp-error-model.h
ns3::TcpSocketCongestedRouter::SetTestCase
void SetTestCase(uint8_t testCase)
Set the test case type.
Definition: tcp-ecn-test.cc:151
ns3::Ipv6EndPoint::GetPeerPort
uint16_t GetPeerPort()
Get the peer port.
Definition: ipv6-end-point.cc:77
ns3::Ipv4EndPoint::GetLocalAddress
Ipv4Address GetLocalAddress(void)
Get the local address.
Definition: ipv4-end-point.cc:53
ns3::TcpGeneralTest::RECEIVER
@ RECEIVER
Receiver node.
Definition: tcp-general-test.h:277
ns3::Socket::IsManualIpv6HopLimit
bool IsManualIpv6HopLimit(void) const
Checks if the socket has a specific IPv6 Hop Limit set.
Definition: socket.cc:383
ns3::SocketIpv6TclassTag
indicates whether the socket has IPV6_TCLASS set.
Definition: socket.h:1356
ns3::TcpHeader
Header for the Transmission Control Protocol.
Definition: tcp-header.h:45
ns3::TcpEcnTestSuite::TcpEcnTestSuite
TcpEcnTestSuite()
Definition: tcp-ecn-test.cc:538
ns3::TcpSocketBase::MarkEcnCe
uint8_t MarkEcnCe(uint8_t tos) const
Mark CE codepoint.
Definition: tcp-socket-base.h:484
tcp-general-test.h
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
ns3::TcpSocketBase::m_state
TracedValue< TcpStates_t > m_state
TCP state.
Definition: tcp-socket-base.h:1291
ns3::TcpGeneralTest
General infrastructure for TCP testing.
Definition: tcp-general-test.h:257
ns3::TcpSocketState::m_rxBuffer
Ptr< TcpRxBuffer > m_rxBuffer
Rx buffer (reordering buffer)
Definition: tcp-socket-state.h:203
ns3::Packet::AddPacketTag
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:956
ns3::TestSuite
A suite of tests to run.
Definition: test.h:1344
ns3::SocketPriorityTag
indicates whether the socket has a priority set.
Definition: socket.h:1309
NS_TEST_ASSERT_MSG_EQ
#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
ns3::TcpEcnTest::m_testcase
uint32_t m_testcase
Test case type.
Definition: tcp-ecn-test.cc:76
ns3::Socket::IsManualIpv6Tclass
bool IsManualIpv6Tclass(void) const
Checks if the socket has a specific IPv6 Tclass set.
Definition: socket.cc:371
ns3::TcpSocketCongestedRouter::SendDataPacket
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,...
Definition: tcp-ecn-test.cc:157
ns3::SocketIpv6TclassTag::SetTclass
void SetTclass(uint8_t tclass)
Set the tag's Tclass.
Definition: socket.cc:900
ns3::SocketIpTosTag
indicates whether the socket has IP_TOS set.
Definition: socket.h:1263
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
ns3::TcpSocketBase::m_delAckCount
uint32_t m_delAckCount
Delayed ACK counter.
Definition: tcp-socket-base.h:1254
ns3::SocketIpTosTag::SetTos
void SetTos(uint8_t tos)
Set the tag's TOS.
Definition: socket.cc:785
ns3::TestSuite::UNIT
@ UNIT
This test suite implements a Unit Test.
Definition: test.h:1353
ns3::TcpSocketBase::m_rto
TracedValue< Time > m_rto
Retransmit timeout.
Definition: tcp-socket-base.h:1267
ns3::SocketIpTtlTag
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer.
Definition: socket.h:1117
ns3::TcpGeneralTest::m_congControlTypeId
TypeId m_congControlTypeId
Congestion control.
Definition: tcp-general-test.h:1036
ns3::Socket::GetPriority
uint8_t GetPriority(void) const
Query the priority value of this socket.
Definition: socket.cc:396
ns3::TcpHeader::CWR
@ CWR
CWR.
Definition: tcp-header.h:289
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition: log-macros-enabled.h:244
ns3::Ipv4EndPoint::GetPeerPort
uint16_t GetPeerPort(void)
Get the peer port.
Definition: ipv4-end-point.cc:81
ns3::TcpSocketCongestedRouter::TcpSocketCongestedRouter
TcpSocketCongestedRouter()
Definition: tcp-ecn-test.cc:104
ns3::TcpSocketBase::m_txTrace
TracedCallback< Ptr< const Packet >, const TcpHeader &, Ptr< const TcpSocketBase > > m_txTrace
Trace of transmitted packets.
Definition: tcp-socket-base.h:1338
ns3::TcpHeader::GetFlags
uint8_t GetFlags() const
Get the flags.
Definition: tcp-header.cc:173
ns3::TcpEcnTest::ConfigureProperties
void ConfigureProperties()
Change the configuration of the socket properties.
Definition: tcp-ecn-test.cc:397
ns3::TcpHeader::ACK
@ ACK
Ack.
Definition: tcp-header.h:286
ns3::TcpHeader::FIN
@ FIN
FIN.
Definition: tcp-header.h:282
ns3::TcpGeneralTest::SetUseEcn
void SetUseEcn(SocketWho who, TcpSocketState::UseEcn_t useEcn)
Forcefully set the ECN mode of use.
Definition: tcp-general-test.cc:971
ns3::Socket::m_boundnetdevice
Ptr< NetDevice > m_boundnetdevice
the device this socket is bound to (might be null).
Definition: socket.h:1077
ns3::TcpHeader::SetWindowSize
void SetWindowSize(uint16_t windowSize)
Set the window size.
Definition: tcp-header.cc:119
ns3::TestCase::QUICK
@ QUICK
Fast test.
Definition: test.h:1159
ns3::Ipv4EndPoint::GetPeerAddress
Ipv4Address GetPeerAddress(void)
Get the peer address.
Definition: ipv4-end-point.cc:74
ns3::TcpHeader::SetDestinationPort
void SetDestinationPort(uint16_t port)
Set the destination port.
Definition: tcp-header.cc:95
ns3::TcpSocketCongestedRouter::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: tcp-ecn-test.cc:134
ns3::Socket::NotifyDataSent
void NotifyDataSent(uint32_t size)
Notify through the callback (if set) that some data have been sent.
Definition: socket.cc:285
ns3::Socket::IsManualIpTtl
bool IsManualIpTtl(void) const
Checks if the socket has a specific IPv4 TTL set.
Definition: socket.cc:377
ns3::Socket::GetIpTos
uint8_t GetIpTos(void) const
Query the value of IP Type of Service of this socket.
Definition: socket.cc:453
ns3::TcpEcnTest::CWndTrace
virtual void CWndTrace(uint32_t oldValue, uint32_t newValue)
Tracks the congestion window changes.
Definition: tcp-ecn-test.cc:411
ns3::SequenceNumber< uint32_t, int32_t >
ns3::Socket::GetIpv6Tclass
uint8_t GetIpv6Tclass(void) const
Query the value of IPv6 Traffic Class field of this socket.
Definition: socket.cc:495
ns3::TcpEcnTest::m_cwndChangeCount
uint32_t m_cwndChangeCount
Number of times the congestion window did change.
Definition: tcp-ecn-test.cc:72
ns3::Simulator::ScheduleNow
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition: simulator.h:587
ns3::TcpSocketCongestedRouter::ReTxTimeout
virtual void ReTxTimeout()
An RTO event happened.
Definition: tcp-ecn-test.cc:145
ns3::SocketIpv6HopLimitTag::SetHopLimit
void SetHopLimit(uint8_t hopLimit)
Set the tag's Hop Limit.
Definition: socket.cc:665
ns3::Time::GetSeconds
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:380
ns3::TcpEcnTestSuite
TCP ECN TestSuite.
Definition: tcp-ecn-test.cc:536
ns3::EventId::IsExpired
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:65
ns3::TcpGeneralTest::CreateSenderSocket
virtual Ptr< TcpSocketMsgBase > CreateSenderSocket(Ptr< Node > node)
Create and install the socket to install on the sender.
Definition: tcp-general-test.cc:324
ns3::TcpSocketState::On
@ On
Enable.
Definition: tcp-socket-state.h:115