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
#define max(a, b)
Definition: 80211b.c:43
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:65
uint16_t GetPeerPort(void)
Get the peer port.
Ipv4Address GetPeerAddress(void)
Get the peer address.
uint16_t GetLocalPort(void)
Get the local port.
Ipv4Address GetLocalAddress(void)
Get the local address.
Ipv6Address GetLocalAddress()
Get the local address.
uint16_t GetLocalPort()
Get the local port.
Ipv6Address GetPeerAddress()
Get the peer address.
uint16_t GetPeerPort()
Get the peer port.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:956
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Definition: packet.cc:978
bool ReplacePacketTag(Tag &tag)
Replace the value of a packet tag.
Definition: packet.cc:970
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:856
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:556
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition: simulator.h:587
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
bool IsManualIpv6HopLimit(void) const
Checks if the socket has a specific IPv6 Hop Limit set.
Definition: socket.cc:383
uint8_t GetIpv6Tclass(void) const
Query the value of IPv6 Traffic Class field of this socket.
Definition: socket.cc:495
uint8_t GetPriority(void) const
Query the priority value of this socket.
Definition: socket.cc:396
bool IsManualIpTtl(void) const
Checks if the socket has a specific IPv4 TTL set.
Definition: socket.cc:377
Ptr< NetDevice > m_boundnetdevice
the device this socket is bound to (might be null).
Definition: socket.h:1077
virtual uint8_t GetIpTtl(void) const
Query the value of IP Time to Live field of this socket.
Definition: socket.cc:520
virtual uint8_t GetIpv6HopLimit(void) const
Query the value of IP Hop Limit field of this socket.
Definition: socket.cc:545
bool IsManualIpv6Tclass(void) const
Checks if the socket has a specific IPv6 Tclass set.
Definition: socket.cc:371
void NotifyDataSent(uint32_t size)
Notify through the callback (if set) that some data have been sent.
Definition: socket.cc:285
uint8_t GetIpTos(void) const
Query the value of IP Type of Service of this socket.
Definition: socket.cc:453
indicates whether the socket has IP_TOS set.
Definition: socket.h:1263
void SetTos(uint8_t tos)
Set the tag's TOS.
Definition: socket.cc:785
uint8_t GetTos(void) const
Get the tag's TOS.
Definition: socket.cc:791
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer.
Definition: socket.h:1117
void SetTtl(uint8_t ttl)
Set the tag's TTL.
Definition: socket.cc:604
This class implements a tag that carries the socket-specific HOPLIMIT of a packet to the IPv6 layer.
Definition: socket.h:1165
void SetHopLimit(uint8_t hopLimit)
Set the tag's Hop Limit.
Definition: socket.cc:665
indicates whether the socket has IPV6_TCLASS set.
Definition: socket.h:1356
void SetTclass(uint8_t tclass)
Set the tag's Tclass.
Definition: socket.cc:900
indicates whether the socket has a priority set.
Definition: socket.h:1309
void SetPriority(uint8_t priority)
Set the tag's priority.
Definition: socket.cc:842
checks if ECT, CWR and ECE bits are set correctly in different scenarios
Definition: tcp-ecn-test.cc:54
virtual void Rx(const Ptr< const Packet > p, const TcpHeader &h, SocketWho who)
Packet received from IP layer.
uint32_t m_senderSent
Number of segments sent by the sender.
Definition: tcp-ecn-test.cc:73
virtual void Tx(const Ptr< const Packet > p, const TcpHeader &h, SocketWho who)
Packet transmitted down to IP layer.
void ConfigureProperties()
Change the configuration of the socket properties.
virtual void CWndTrace(uint32_t oldValue, uint32_t newValue)
TcpEcnTest(uint32_t testcase, const std::string &desc)
Constructor.
uint32_t m_cwndChangeCount
Number of times the congestion window did change.
Definition: tcp-ecn-test.cc:72
uint32_t m_senderReceived
Number of segments received by the sender.
Definition: tcp-ecn-test.cc:74
virtual Ptr< TcpSocketMsgBase > CreateSenderSocket(Ptr< Node > node)
Create and install the socket to install on the sender.
uint32_t m_receiverReceived
Number of segments received by the receiver.
Definition: tcp-ecn-test.cc:75
uint32_t m_testcase
Test case type.
Definition: tcp-ecn-test.cc:76
TCP ECN TestSuite.
General infrastructure for TCP testing.
virtual Ptr< TcpSocketMsgBase > CreateSenderSocket(Ptr< Node > node)
Create and install the socket to install on the sender.
SocketWho
Used as parameter of methods, specifies on what node the caller is interested (e.g.
@ RECEIVER
Receiver node.
virtual void ConfigureProperties(void)
Change the configuration of the socket properties.
virtual Ptr< TcpSocketMsgBase > CreateSocket(Ptr< Node > node, TypeId socketType, TypeId congControl)
Create a socket.
void SetUseEcn(SocketWho who, TcpSocketState::UseEcn_t useEcn)
Forcefully set the ECN mode of use.
TypeId m_congControlTypeId
Congestion control.
Header for the Transmission Control Protocol.
Definition: tcp-header.h:45
void SetDestinationPort(uint16_t port)
Set the destination port.
Definition: tcp-header.cc:95
void SetSequenceNumber(SequenceNumber32 sequenceNumber)
Set the sequence Number.
Definition: tcp-header.cc:101
void SetFlags(uint8_t flags)
Set flags of the header.
Definition: tcp-header.cc:113
void SetWindowSize(uint16_t windowSize)
Set the window size.
Definition: tcp-header.cc:119
void SetSourcePort(uint16_t port)
Set the source port.
Definition: tcp-header.cc:89
void SetAckNumber(SequenceNumber32 ackNumber)
Set the ACK number.
Definition: tcp-header.cc:107
uint8_t GetFlags() const
Get the flags.
Definition: tcp-header.cc:173
TracedCallback< Ptr< const Packet >, const TcpHeader &, Ptr< const TcpSocketBase > > m_txTrace
Trace of transmitted packets.
Ptr< TcpL4Protocol > m_tcp
the associated TCP L4 protocol
Ptr< TcpSocketState > m_tcb
Congestion control information.
bool m_closeOnEmpty
Close socket upon tx buffer emptied.
TracedValue< Time > m_rto
Retransmit timeout.
Ptr< TcpTxBuffer > m_txBuffer
Tx buffer.
EventId m_delAckEvent
Delayed ACK timeout event.
void AddOptions(TcpHeader &tcpHeader)
Add options to TcpHeader.
TracedValue< TcpStates_t > m_state
TCP state.
uint8_t MarkEcnEct0(uint8_t tos) const
Mark ECT(0) codepoint.
virtual void ReTxTimeout(void)
An RTO event happened.
EventId m_retxEvent
Retransmission event.
TracedValue< SequenceNumber32 > m_ecnCWRSeq
Sequence number of the last sent CWR.
uint32_t m_delAckCount
Delayed ACK counter.
Ipv4EndPoint * m_endPoint
the IPv4 endpoint
uint8_t MarkEcnCe(uint8_t tos) const
Mark CE codepoint.
virtual uint16_t AdvertisedWindowSize(bool scale=true) const
The amount of Rx window announced to the peer.
Ipv6EndPoint * m_endPoint6
the IPv6 endpoint
TracedValue< SequenceNumber32 > m_ecnEchoSeq
Sequence number of the last received ECN Echo.
A TCP socket which sends certain data packets with CE flags set for tests 5 and 6.
Definition: tcp-ecn-test.cc:93
static TypeId GetTypeId(void)
Get the type ID.
uint32_t m_dataPacketSent
Number of packets sent.
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,...
Ptr< TcpSocketBase > Fork(void)
Call CopyObject<> to clone me.
uint8_t m_testcase
Test case type.
virtual void ReTxTimeout()
An RTO event happened.
TcpSocketCongestedRouter(const TcpSocketCongestedRouter &other)
Constructor.
void SetTestCase(uint8_t testCase)
Set the test case type.
Class for inserting callbacks special points of the flow of TCP sockets.
virtual void UpdateRttHistory(const SequenceNumber32 &seq, uint32_t sz, bool isRetransmission)
Update the RTT history, when we send TCP segments.
TracedValue< SequenceNumber32 > m_highTxMark
Highest seqno ever sent, regardless of ReTx.
@ ECN_CWR_SENT
Sender has reduced the congestion window, and sent a packet with CWR bit set in TCP header.
@ ECN_DISABLED
ECN disabled traffic
@ ECN_ECE_RCVD
Last ACK received had ECE bit set in TCP header
Ptr< TcpRxBuffer > m_rxBuffer
Rx buffer (reordering buffer)
static const char *const EcnStateName[TcpSocketState::ECN_CWR_SENT+1]
Literal names of ECN states for use in log messages.
TracedValue< EcnState_t > m_ecnState
Current ECN State, represented as combination of EcnState values.
@ QUICK
Fast test.
Definition: test.h:999
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
A suite of tests to run.
Definition: test.h:1188
@ UNIT
This test suite implements a Unit Test.
Definition: test.h:1197
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:379
T Get(void) const
Get the underlying value.
Definition: traced-value.h:232
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
@ ESTABLISHED
Connection established
Definition: tcp-socket.h:71
@ 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
@ FIN_WAIT_1
Our side has shutdown, waiting to complete transmission of remaining buffered data
Definition: tcp-socket.h:78
@ LAST_ACK
Our side has shutdown after remote has shutdown.
Definition: tcp-socket.h:75
#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:141
#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:542
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static TcpEcnTestSuite g_tcpECNTestSuite
static var for test initialization