A Discrete-Event Network Simulator
API
tcp-general-test.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2015 Natale Patriciello <natale.patriciello@gmail.com>
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  */
19 #define __STDC_LIMIT_MACROS
20 #include "ns3/test.h"
21 #include "ns3/node-container.h"
22 #include "ns3/tcp-socket-base.h"
23 #include "ns3/simple-net-device-helper.h"
24 #include "ns3/ipv4-address-helper.h"
25 #include "ns3/internet-stack-helper.h"
26 #include "ns3/log.h"
27 #include "ns3/tcp-l4-protocol.h"
28 #include "../model/ipv4-end-point.h"
29 #include "../model/ipv6-end-point.h"
30 #include "tcp-general-test.h"
31 
32 namespace ns3 {
33 
34 NS_LOG_COMPONENT_DEFINE ("TcpGeneralTest");
35 
36 TcpGeneralTest::TcpGeneralTest (const std::string &desc)
37  : TestCase (desc),
38  m_congControlTypeId (TcpNewReno::GetTypeId ()),
39  m_remoteAddr (Ipv4Address::GetAny (), 4477)
40 {
41  NS_LOG_FUNCTION (this << desc);
42 }
43 
45 {
47 }
48 
49 void
51 {
52  NS_LOG_FUNCTION (this << socket);
53  Ptr<Packet> packet;
54  Address from;
55 
56  while ((packet = socket->RecvFrom (from)))
57  {
58  if (packet->GetSize () == 0)
59  { //EOF
60  break;
61  }
62  }
63 }
64 
65 void
66 TcpGeneralTest::SendPacket (Ptr<Socket> socket, uint32_t pktSize,
67  uint32_t pktCount, Time pktInterval )
68 {
69  NS_LOG_FUNCTION (this << " " << pktSize << " " << pktCount << " " <<
70  pktInterval.GetSeconds ());
71  if (pktCount > 0)
72  {
73  socket->Send (Create<Packet> (pktSize));
75  socket, pktSize, pktCount - 1, pktInterval);
76  }
77  else
78  {
79  socket->Close ();
80  }
81 }
82 
83 void
85 {
86  FinalChecks ();
87 
89  NS_LOG_INFO ("Done.");
90 }
91 
92 void
94 {
95  NS_LOG_FUNCTION (this);
96 
100  SetAppPktSize (500);
101  SetAppPktCount (10);
103  SetMTU (1500);
104 }
105 
106 void
108 {
109  NS_LOG_FUNCTION (this);
110  SetInitialCwnd (SENDER, 1);
111  SetInitialSsThresh (SENDER, UINT32_MAX);
112  SetSegmentSize (SENDER, 500);
113  SetSegmentSize (RECEIVER, 500);
114 }
115 
116 void
118 {
120 
121  NS_LOG_INFO ("Create nodes.");
123  nodes.Create (2);
124 
125  InternetStackHelper internet;
126  internet.Install (nodes);
127 
129 
131 
132  SimpleNetDeviceHelper helperChannel;
133  helperChannel.SetNetDevicePointToPointMode (true);
134 
135  NetDeviceContainer net = helperChannel.Install (nodes, channel);
136 
139 
140  Ptr<SimpleNetDevice> senderDev = DynamicCast<SimpleNetDevice> (net.Get (0));
141  Ptr<SimpleNetDevice> receiverDev = DynamicCast<SimpleNetDevice> (net.Get (1));
142 
143  senderDev->SetMtu (m_mtu);
144  senderDev->GetQueue ()->TraceConnect ("Drop", "SENDER",
146  senderDev->TraceConnect ("PhyRxDrop", "sender",
148 
149  receiverDev->SetMtu (m_mtu);
150  receiverDev->GetQueue ()->TraceConnect ("Drop", "RECEIVER",
152  receiverDev->TraceConnect ("PhyRxDrop", "RECEIVER",
154 
155  senderDev->SetReceiveErrorModel (senderEM);
156  receiverDev->SetReceiveErrorModel (receiverEM);
157 
158  Ipv4AddressHelper ipv4;
159  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
160  Ipv4InterfaceContainer i = ipv4.Assign (net);
161  Ipv4Address serverAddress = i.GetAddress (1);
162  //Ipv4Address clientAddress = i.GetAddress (0);
163 
164  NS_LOG_INFO ("Create sockets.");
165  //Receiver socket on n1
167 
168  m_receiverSocket->SetRecvCallback (MakeCallback (&TcpGeneralTest::ReceivePacket, this));
169  m_receiverSocket->SetAcceptCallback (
170  MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
172  m_receiverSocket->SetCloseCallbacks (MakeCallback (&TcpGeneralTest::NormalCloseCb, this),
175  m_receiverSocket->SetProcessedAckCb (MakeCallback (&TcpGeneralTest::ProcessedAckCb, this));
176  m_receiverSocket->SetRetransmitCb (MakeCallback (&TcpGeneralTest::RtoExpiredCb, this));
178  m_receiverSocket->SetUpdateRttHistoryCb (MakeCallback (&TcpGeneralTest::UpdateRttHistoryCb, this));
179  m_receiverSocket->TraceConnectWithoutContext ("Tx",
181  m_receiverSocket->TraceConnectWithoutContext ("Rx",
183 
185  m_receiverSocket->Bind (local);
186 
187  m_senderSocket = CreateSenderSocket (nodes.Get (0));
188  m_senderSocket->SetCloseCallbacks (MakeCallback (&TcpGeneralTest::NormalCloseCb, this),
190  m_senderSocket->SetRcvAckCb (MakeCallback (&TcpGeneralTest::RcvAckCb, this));
191  m_senderSocket->SetProcessedAckCb (MakeCallback (&TcpGeneralTest::ProcessedAckCb, this));
192  m_senderSocket->SetRetransmitCb (MakeCallback (&TcpGeneralTest::RtoExpiredCb, this));
193  m_senderSocket->SetDataSentCallback (MakeCallback (&TcpGeneralTest::DataSentCb, this));
194  m_senderSocket->SetUpdateRttHistoryCb (MakeCallback (&TcpGeneralTest::UpdateRttHistoryCb, this));
195  m_senderSocket->TraceConnectWithoutContext ("CongestionWindow",
197  m_senderSocket->TraceConnectWithoutContext ("SlowStartThreshold",
199  m_senderSocket->TraceConnectWithoutContext ("CongState",
201  m_senderSocket->TraceConnectWithoutContext ("Tx",
203  m_senderSocket->TraceConnectWithoutContext ("Rx",
205  m_senderSocket->TraceConnectWithoutContext ("RTT",
207  m_senderSocket->TraceConnectWithoutContext ("BytesInFlight",
209 
210  m_remoteAddr = InetSocketAddress (serverAddress, 4477);
211 
213 
214  m_receiverSocket->Listen ();
215  m_receiverSocket->ShutdownSend ();
216 
222 
223  NS_LOG_INFO ("Run Simulation.");
224  Simulator::Run ();
225 }
226 
227 void
229 {
230  NS_LOG_INFO (this);
231  m_senderSocket->Connect (m_remoteAddr);
232 }
233 
234 void
236 {
237  (void) from;
241 
242 }
243 
246 {
247  Ptr<SimpleChannel> ch = CreateObject <SimpleChannel> ();
248 
249  ch->SetAttribute ("Delay", TimeValue (m_propagationDelay));
250 
251  return ch;
252 }
253 
256  TypeId congControl)
257 {
258  ObjectFactory rttFactory;
259  ObjectFactory congestionAlgorithmFactory;
260  ObjectFactory socketFactory;
261 
262  rttFactory.SetTypeId (RttMeanDeviation::GetTypeId ());
263  congestionAlgorithmFactory.SetTypeId (congControl);
264  socketFactory.SetTypeId (socketType);
265 
266  Ptr<RttEstimator> rtt = rttFactory.Create<RttEstimator> ();
267  Ptr<TcpSocketMsgBase> socket = DynamicCast<TcpSocketMsgBase> (socketFactory.Create ());
268  Ptr<TcpCongestionOps> algo = congestionAlgorithmFactory.Create<TcpCongestionOps> ();
269 
270  socket->SetNode (node);
271  socket->SetTcp (node->GetObject<TcpL4Protocol> ());
272  socket->SetRtt (rtt);
273  socket->SetCongestionControlAlgorithm (algo);
274 
275  return socket;
276 }
277 
280 {
281  return 0;
282 }
283 
286 {
287  return 0;
288 }
289 
292 {
294 }
295 
298 {
300 }
301 
302 void
304 {
305  if (context.compare ("SENDER") == 0)
306  {
307  QueueDrop (SENDER);
308  }
309  else if (context.compare ("RECEIVER") == 0)
310  {
312  }
313  else
314  {
315  NS_FATAL_ERROR ("Packet dropped in a queue, but queue not recognized");
316  }
317 }
318 
319 void
321 {
322  if (context.compare ("SENDER") == 0)
323  {
324  PhyDrop (SENDER);
325  }
326  else if (context.compare ("RECEIVER") == 0)
327  {
328  PhyDrop (RECEIVER);
329  }
330  else
331  {
332  NS_FATAL_ERROR ("Packet dropped in a queue, but queue not recognized");
333  }
334 }
335 
336 void
338 {
339  if (socket->GetNode () == m_receiverSocket->GetNode ())
340  {
342  }
343  else if (socket->GetNode () == m_senderSocket->GetNode ())
344  {
346  }
347  else
348  {
349  NS_FATAL_ERROR ("Closed socket, but not recognized");
350  }
351 }
352 
353 void
355  const SequenceNumber32 & seq, uint32_t sz,
356  bool isRetransmission)
357 {
358  if (tcp->GetNode () == m_receiverSocket->GetNode ())
359  {
360  UpdatedRttHistory (seq, sz, isRetransmission, RECEIVER);
361  }
362  else if (tcp->GetNode () == m_senderSocket->GetNode ())
363  {
364  UpdatedRttHistory (seq, sz, isRetransmission, SENDER);
365  }
366  else
367  {
368  NS_FATAL_ERROR ("Closed socket, but not recognized");
369  }
370 }
371 
372 void
374  const Ptr<const TcpSocketBase> tcp)
375 {
376  if (tcp->GetNode () == m_receiverSocket->GetNode ())
377  {
378  RTOExpired (tcb, RECEIVER);
379  }
380  else if (tcp->GetNode () == m_senderSocket->GetNode ())
381  {
382  RTOExpired (tcb, SENDER);
383  }
384  else
385  {
386  NS_FATAL_ERROR ("Closed socket, but not recognized");
387  }
388 }
389 
390 void
392 {
393  if (socket->GetNode () == m_receiverSocket->GetNode ())
394  {
395  DataSent (size, RECEIVER);
396  }
397  else if (socket->GetNode () == m_senderSocket->GetNode ())
398  {
399  DataSent (size, SENDER);
400  }
401  else
402  {
403  NS_FATAL_ERROR ("Closed socket, but not recognized");
404  }
405 }
406 
407 void
409 {
410  if (socket->GetNode () == m_receiverSocket->GetNode ())
411  {
413  }
414  else if (socket->GetNode () == m_senderSocket->GetNode ())
415  {
416  ErrorClose (SENDER);
417  }
418  else
419  {
420  NS_FATAL_ERROR ("Closed socket, but not recognized");
421  }
422 }
423 
424 void
426 {
427  NS_LOG_FUNCTION (this << p << h << who);
428 }
429 
430 void
432 {
433  NS_LOG_FUNCTION (this << p << h << who);
434 }
435 
436 void
438  const Ptr<const TcpSocketBase> tcp)
439 {
440  if (tcp->GetNode () == m_receiverSocket->GetNode ())
441  {
442  RcvAck (tcp->m_tcb, h, RECEIVER);
443  }
444  else if (tcp->GetNode () == m_senderSocket->GetNode ())
445  {
446  RcvAck (tcp->m_tcb, h, SENDER);
447  }
448  else
449  {
450  NS_FATAL_ERROR ("Received ACK but socket not recognized");
451  }
452 }
453 
454 void
456  const TcpHeader &h, const Ptr<const TcpSocketBase> tcp)
457 {
458  if (tcp->GetNode () == m_receiverSocket->GetNode ())
459  {
460  Tx (p, h, RECEIVER);
461  }
462  else if (tcp->GetNode () == m_senderSocket->GetNode ())
463  {
464  Tx (p, h, SENDER);
465  }
466  else
467  {
468  NS_FATAL_ERROR ("Received ACK but socket not recognized");
469  }
470 }
471 
472 void
474  const Ptr<const TcpSocketBase> tcp)
475 {
476  if (tcp->GetNode () == m_receiverSocket->GetNode ())
477  {
478  Rx (p, h, RECEIVER);
479  }
480  else if (tcp->GetNode () == m_senderSocket->GetNode ())
481  {
482  Rx (p, h, SENDER);
483  }
484  else
485  {
486  NS_FATAL_ERROR ("Received ACK but socket not recognized");
487  }
488 }
489 
490 void
493 {
494  if (tcp->GetNode () == m_receiverSocket->GetNode ())
495  {
496  ProcessedAck (tcp->m_tcb, h, RECEIVER);
497  }
498  else if (tcp->GetNode () == m_senderSocket->GetNode ())
499  {
500  ProcessedAck (tcp->m_tcb, h, SENDER);
501  }
502  else
503  {
504  NS_FATAL_ERROR ("Received ACK but socket not recognized");
505  }
506 }
507 
508 void
510 {
511  NS_LOG_FUNCTION (this << tcp);
512 
513  m_receiverSocket = tcp;
514 }
515 
516 uint32_t
518 {
519  if (who == SENDER)
520  {
521  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_retxThresh;
522  }
523  else if (who == RECEIVER)
524  {
525  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_retxThresh;
526  }
527  else
528  {
529  NS_FATAL_ERROR ("Not defined");
530  }
531 }
532 
533 uint32_t
535 {
536  if (who == SENDER)
537  {
538  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_dupAckCount;
539  }
540  else if (who == RECEIVER)
541  {
542  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_dupAckCount;
543  }
544  else
545  {
546  NS_FATAL_ERROR ("Not defined");
547  }
548 }
549 
550 uint32_t
552 {
553  if (who == SENDER)
554  {
555  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_delAckMaxCount;
556  }
557  else if (who == RECEIVER)
558  {
559  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_delAckMaxCount;
560  }
561  else
562  {
563  NS_FATAL_ERROR ("Not defined");
564  }
565 }
566 
567 Time
569 {
570  if (who == SENDER)
571  {
572  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetDelAckTimeout ();
573  }
574  else if (who == RECEIVER)
575  {
576  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetDelAckTimeout ();
577  }
578  else
579  {
580  NS_FATAL_ERROR ("Not defined");
581  }
582 }
583 
584 uint32_t
586 {
587  if (who == SENDER)
588  {
589  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetSegSize ();
590  }
591  else if (who == RECEIVER)
592  {
593  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetSegSize ();
594  }
595  else
596  {
597  NS_FATAL_ERROR ("Not defined");
598  }
599 }
600 
603 {
604  return GetTcb (who)->m_highTxMark;
605 }
606 
607 uint32_t
609 {
610  if (who == SENDER)
611  {
612  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetInitialCwnd ();
613  }
614  else if (who == RECEIVER)
615  {
616  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetInitialCwnd ();
617  }
618  else
619  {
620  NS_FATAL_ERROR ("Not defined");
621  }
622 }
623 
624 uint32_t
626 {
627  if (who == SENDER)
628  {
629  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetInitialSSThresh ();
630  }
631  else if (who == RECEIVER)
632  {
633  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetInitialSSThresh ();
634  }
635  else
636  {
637  NS_FATAL_ERROR ("Not defined");
638  }
639 }
640 
641 Time
643 {
644  if (who == SENDER)
645  {
646  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rto.Get ();
647  }
648  else if (who == RECEIVER)
649  {
650  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rto.Get ();
651  }
652  else
653  {
654  NS_FATAL_ERROR ("Not defined");
655  }
656 }
657 
658 Time
660 {
661  if (who == SENDER)
662  {
663  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_minRto;
664  }
665  else if (who == RECEIVER)
666  {
667  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_minRto;
668  }
669  else
670  {
671  NS_FATAL_ERROR ("Not defined");
672  }
673 }
674 
675 Time
677 {
678  if (who == SENDER)
679  {
680  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_cnTimeout;
681  }
682  else if (who == RECEIVER)
683  {
684  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_cnTimeout;
685  }
686  else
687  {
688  NS_FATAL_ERROR ("Not defined");
689  }
690 }
691 
694 {
695  if (who == SENDER)
696  {
697  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rtt;
698  }
699  else if (who == RECEIVER)
700  {
701  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rtt;
702  }
703  else
704  {
705  NS_FATAL_ERROR ("Not defined");
706  }
707 }
708 
709 Time
711 {
712  if (who == SENDER)
713  {
714  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_clockGranularity;
715  }
716  else if (who == RECEIVER)
717  {
718  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_clockGranularity;
719  }
720  else
721  {
722  NS_FATAL_ERROR ("Not defined");
723  }
724 }
725 
728 {
729  if (who == SENDER)
730  {
731  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_state.Get ();
732  }
733  else if (who == RECEIVER)
734  {
735 
736  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_state.Get ();
737  }
738  else
739  {
740  NS_FATAL_ERROR ("Not defined");
741  }
742 }
743 
744 uint32_t
746 {
747  if (who == SENDER)
748  {
749  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rWnd.Get ();
750  }
751  else if (who == RECEIVER)
752  {
753 
754  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rWnd.Get ();
755  }
756  else
757  {
758  NS_FATAL_ERROR ("Not defined");
759  }
760 }
761 
762 EventId
764 {
765  if (who == SENDER)
766  {
767  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_persistEvent;
768  }
769  else if (who == RECEIVER)
770  {
771 
772  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_persistEvent;
773  }
774  else
775  {
776  NS_FATAL_ERROR ("Not defined");
777  }
778 }
779 
780 Time
782 {
783  if (who == SENDER)
784  {
785  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_persistTimeout;
786  }
787  else if (who == RECEIVER)
788  {
789 
790  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_persistTimeout;
791  }
792  else
793  {
794  NS_FATAL_ERROR ("Not defined");
795  }
796 }
797 
800 {
801  if (who == SENDER)
802  {
803  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_tcb;
804  }
805  else if (who == RECEIVER)
806  {
807 
808  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_tcb;
809  }
810  else
811  {
812  NS_FATAL_ERROR ("Not defined");
813  }
814 }
815 
818 {
819  if (who == SENDER)
820  {
821  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rxBuffer;
822  }
823  else if (who == RECEIVER)
824  {
825 
826  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rxBuffer;
827  }
828  else
829  {
830  NS_FATAL_ERROR ("Not defined");
831  }
832 }
833 
834 void
836 {
837  if (who == SENDER)
838  {
839  m_senderSocket->SetRcvBufSize (size);
840  }
841  else if (who == RECEIVER)
842  {
843  m_receiverSocket->SetRcvBufSize (size);
844  }
845  else
846  {
847  NS_FATAL_ERROR ("Not defined");
848  }
849 }
850 
851 void
852 TcpGeneralTest::SetSegmentSize (SocketWho who, uint32_t segmentSize)
853 {
854  if (who == SENDER)
855  {
856  m_senderSocket->SetSegSize (segmentSize);
857  }
858  else if (who == RECEIVER)
859  {
860  m_receiverSocket->SetSegSize (segmentSize);
861  }
862  else
863  {
864  NS_FATAL_ERROR ("Not defined");
865  }
866 }
867 
868 void
869 TcpGeneralTest::SetInitialCwnd (SocketWho who, uint32_t initialCwnd)
870 {
871  if (who == SENDER)
872  {
873  m_senderSocket->SetInitialCwnd (initialCwnd);
874  }
875  else if (who == RECEIVER)
876  {
877  m_receiverSocket->SetInitialCwnd (initialCwnd);
878  }
879  else
880  {
881  NS_FATAL_ERROR ("Not defined");
882  }
883 }
884 
885 void
886 TcpGeneralTest::SetInitialSsThresh (SocketWho who, uint32_t initialSsThresh)
887 {
888  if (who == SENDER)
889  {
890  m_senderSocket->SetInitialSSThresh (initialSsThresh);
891  }
892  else if (who == RECEIVER)
893  {
894  m_receiverSocket->SetInitialSSThresh (initialSsThresh);
895  }
896  else
897  {
898  NS_FATAL_ERROR ("Not defined");
899  }
900 }
901 
903 
904 TypeId
906 {
907  static TypeId tid = TypeId ("ns3::TcpSocketMsgBase")
909  .SetGroupName ("Internet")
910  .AddConstructor<TcpSocketMsgBase> ()
911  ;
912  return tid;
913 }
914 
917 {
918  return CopyObject<TcpSocketMsgBase> (this);
919 }
920 
921 void
923 {
924  NS_ASSERT (!cb.IsNull ());
925  m_rcvAckCb = cb;
926 }
927 
928 void
930 {
931  NS_ASSERT (!cb.IsNull ());
932  m_processedAckCb = cb;
933 }
934 
935 void
937 {
938  NS_ASSERT (!cb.IsNull ());
939  m_retrCallback = cb;
940 }
941 
942 void
944 {
946  m_rcvAckCb (packet, tcpHeader, this);
947 
948  TcpSocketBase::ReceivedAck (packet, tcpHeader);
949 
950  m_processedAckCb (packet, tcpHeader, this);
951 }
952 
953 void
955 {
957 
958  m_retrCallback (m_tcb, this);
959 }
960 
961 void
963 {
964  NS_ASSERT (!cb.IsNull ());
965  m_forkCb = cb;
966 }
967 
968 void
970 {
971  NS_ASSERT (!cb.IsNull ());
972  m_updateRttCb = cb;
973 }
974 
975 void
977  bool isRetransmission)
978 {
979  TcpSocketBase::UpdateRttHistory (seq, sz, isRetransmission);
980  if (!m_updateRttCb.IsNull ())
981  {
982  m_updateRttCb (this, seq, sz, isRetransmission);
983  }
984 }
985 
986 void
988  const Address &fromAddress, const Address &toAddress)
989 {
990  TcpSocketBase::CompleteFork (p, tcpHeader, fromAddress, toAddress);
991 
992  if (!m_forkCb.IsNull ())
993  {
994  m_forkCb (this);
995  }
996 }
997 
999 
1000 TypeId
1002 {
1003  static TypeId tid = TypeId ("ns3::TcpSocketSmallAcks")
1005  .SetGroupName ("Internet")
1006  .AddConstructor<TcpSocketSmallAcks> ()
1007  ;
1008  return tid;
1009 }
1010 
1018 void
1020 {
1021  Ptr<Packet> p = Create<Packet> ();
1022  TcpHeader header;
1023  SequenceNumber32 s = m_tcb->m_nextTxSequence;
1024 
1025  /*
1026  * Add tags for each socket option.
1027  * Note that currently the socket adds both IPv4 tag and IPv6 tag
1028  * if both options are set. Once the packet got to layer three, only
1029  * the corresponding tags will be read.
1030  */
1031  if (GetIpTos ())
1032  {
1033  SocketIpTosTag ipTosTag;
1034  ipTosTag.SetTos (GetIpTos ());
1035  p->AddPacketTag (ipTosTag);
1036  }
1037 
1038  if (IsManualIpv6Tclass ())
1039  {
1040  SocketIpv6TclassTag ipTclassTag;
1041  ipTclassTag.SetTclass (GetIpv6Tclass ());
1042  p->AddPacketTag (ipTclassTag);
1043  }
1044 
1045  if (IsManualIpTtl ())
1046  {
1047  SocketIpTtlTag ipTtlTag;
1048  ipTtlTag.SetTtl (GetIpTtl ());
1049  p->AddPacketTag (ipTtlTag);
1050  }
1051 
1052  if (IsManualIpv6HopLimit ())
1053  {
1054  SocketIpv6HopLimitTag ipHopLimitTag;
1055  ipHopLimitTag.SetHopLimit (GetIpv6HopLimit ());
1056  p->AddPacketTag (ipHopLimitTag);
1057  }
1058 
1059  if (m_endPoint == 0 && m_endPoint6 == 0)
1060  {
1061  NS_LOG_WARN ("Failed to send empty packet due to null endpoint");
1062  return;
1063  }
1064  if (flags & TcpHeader::FIN)
1065  {
1066  flags |= TcpHeader::ACK;
1067  }
1068  else if (m_state == FIN_WAIT_1 || m_state == LAST_ACK || m_state == CLOSING)
1069  {
1070  ++s;
1071  }
1072 
1073  bool hasSyn = flags & TcpHeader::SYN;
1074  bool hasFin = flags & TcpHeader::FIN;
1075  bool isAck = flags == TcpHeader::ACK;
1076 
1077  header.SetFlags (flags);
1078  header.SetSequenceNumber (s);
1079 
1080  // Actual division in small acks.
1081  if (hasSyn || hasFin)
1082  {
1083  header.SetAckNumber (m_rxBuffer->NextRxSequence ());
1084  }
1085  else
1086  {
1087  SequenceNumber32 ackSeq;
1088 
1089  ackSeq = m_lastAckedSeq + m_bytesToAck;
1090 
1091  if (m_bytesLeftToBeAcked == 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1092  {
1093  m_bytesLeftToBeAcked = m_rxBuffer->NextRxSequence ().GetValue () - 1 - m_bytesToAck;
1094  }
1095  else if (m_bytesLeftToBeAcked > 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1096  {
1098  }
1099 
1100  NS_LOG_LOGIC ("Acking up to " << ackSeq << " remaining bytes: " << m_bytesLeftToBeAcked);
1101 
1102  header.SetAckNumber (ackSeq);
1103  m_lastAckedSeq = ackSeq;
1104  }
1105 
1106  // end of division in small acks
1107 
1108  if (m_endPoint != 0)
1109  {
1110  header.SetSourcePort (m_endPoint->GetLocalPort ());
1111  header.SetDestinationPort (m_endPoint->GetPeerPort ());
1112  }
1113  else
1114  {
1115  header.SetSourcePort (m_endPoint6->GetLocalPort ());
1116  header.SetDestinationPort (m_endPoint6->GetPeerPort ());
1117  }
1118  AddOptions (header);
1119  header.SetWindowSize (AdvertisedWindowSize ());
1120 
1121  // RFC 6298, clause 2.4
1122  m_rto = Max (m_rtt->GetEstimate () + Max (m_clockGranularity, m_rtt->GetVariation () * 4), m_minRto);
1123 
1124  if (hasSyn)
1125  {
1126  if (m_synCount == 0)
1127  { // No more connection retries, give up
1128  NS_LOG_LOGIC ("Connection failed.");
1129  m_rtt->Reset (); //According to recommendation -> RFC 6298
1130  CloseAndNotify ();
1131  return;
1132  }
1133  else
1134  { // Exponential backoff of connection time out
1135  int backoffCount = 0x1 << (m_synRetries - m_synCount);
1136  m_rto = m_cnTimeout * backoffCount;
1137  m_synCount--;
1138  }
1139  }
1140  if (m_endPoint != 0)
1141  {
1142  m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (),
1144  }
1145  else
1146  {
1147  m_tcp->SendPacket (p, header, m_endPoint6->GetLocalAddress (),
1149  }
1150 
1151  m_txTrace (p, header, this);
1152 
1153  if (flags & TcpHeader::ACK)
1154  { // If sending an ACK, cancel the delay ACK as well
1155  m_delAckEvent.Cancel ();
1156  m_delAckCount = 0;
1157  }
1158  if (m_retxEvent.IsExpired () && (hasSyn || hasFin) && !isAck )
1159  { // Retransmit SYN / SYN+ACK / FIN / FIN+ACK to guard against lost
1160  NS_LOG_LOGIC ("Schedule retransmission timeout at time "
1161  << Simulator::Now ().GetSeconds () << " to expire at time "
1162  << (Simulator::Now () + m_rto.Get ()).GetSeconds ());
1164  }
1165 
1166  // send another ACK if bytes remain
1167  if (m_bytesLeftToBeAcked > 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1168  {
1169  SendEmptyPacket (flags);
1170  }
1171 }
1172 
1175 {
1176  return CopyObject<TcpSocketSmallAcks> (this);
1177 }
1178 
1179 } // namespace ns3
virtual void ProcessedAck(const Ptr< const TcpSocketState > tcb, const TcpHeader &h, SocketWho who)
Processed ack.
Ipv6Address GetLocalAddress()
Get the local address.
void SetTclass(uint8_t tclass)
Set the tag's Tclass.
Definition: socket.cc:906
tuple channel
Definition: third.py:85
Time GetMinRto(SocketWho who)
Get the minimun RTO attribute.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
virtual void DoTeardown(void)
Teardown the TCP test.
bool IsManualIpTtl(void) const
Checks if the socket has a specific IPv4 TTL set.
Definition: socket.cc:377
Time GetPersistentTimeout(SocketWho who)
Get the persistent timeout of the selected socket.
an Inet address class
static Ipv4Address GetAny(void)
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual void SendEmptyPacket(uint8_t flags)
Send empty packet, copied/pasted from TcpSocketBase.
Ptr< TcpSocketMsgBase > m_senderSocket
Pointer to sender socket.
void PhyDropCb(std::string context, Ptr< const Packet > p)
Time m_propagationDelay
Propagation delay of the channel.
virtual uint8_t GetIpTtl(void) const
Query the value of IP Time to Live field of this socket.
Definition: socket.cc:526
uint32_t GetDelAckCount(SocketWho who)
Get the number of delayed ack (if present)
void DataSentCb(Ptr< Socket > socket, uint32_t size)
uint32_t GetSegSize(SocketWho who)
Get the segment size of the node specified.
Class for inserting callbacks special points of the flow of TCP sockets.
uint8_t GetIpTos(void) const
Query the value of IP Type of Service of this socket.
Definition: socket.cc:459
This class implements a tag that carries the socket-specific HOPLIMIT of a packet to the IPv6 layer...
Definition: socket.h:1160
Ipv4EndPoint * m_endPoint
the IPv4 endpoint
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
holds a vector of std::pair of Ptr and interface index.
TcpGeneralTest(const std::string &desc)
TcpGeneralTest constructor.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:462
AckManagementCb m_rcvAckCb
uint32_t m_synRetries
Number of connection attempts.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
void SetForkCb(Callback< void, Ptr< TcpSocketMsgBase > > cb)
Set the callback invoked after the forking.
void SetCongestionControl(TypeId congControl)
Congestion control of the sender socket.
virtual void DoRun(void)
Execute the tcp test.
void NormalCloseCb(Ptr< Socket > socket)
EventId m_retxEvent
Retransmission event.
virtual void PhyDrop(SocketWho who)
Link drop.
virtual void DataSent(uint32_t size, SocketWho who)
Notifying application for sent data.
void QueueDropCb(std::string context, Ptr< const Packet > p)
virtual void ErrorClose(SocketWho who)
Socket closed with an error.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:824
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1270
virtual Ptr< TcpSocketMsgBase > CreateReceiverSocket(Ptr< Node > node)
Create and install the socket to install on the receiver.
Both sides have shutdown but we still have data we have to finish sending.
Definition: tcp-socket.h:81
virtual void FinalChecks()
Performs the (eventual) final checks through test asserts.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
static void Run(void)
Run the simulation.
Definition: simulator.cc:201
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
Ptr< TcpSocketState > m_tcb
Congestion control informations.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:903
void DoConnect()
Scheduled at 0.0, SENDER starts the connection to RECEIVER.
void SendPacket(Ptr< Socket > socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval)
Send packets to other endpoint.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
void SetAppPktSize(uint32_t pktSize)
Set app packet size.
aggregate IP/TCP/UDP functionality to existing Nodes.
virtual void CompleteFork(Ptr< Packet > p, const TcpHeader &tcpHeader, const Address &fromAddress, const Address &toAddress)
Complete a connection by forking the socket.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:792
void SetTransmitStart(Time startTime)
Set the initial time at which the application sends the first data packet.
void SetCloseCallbacks(Callback< void, Ptr< Socket > > normalClose, Callback< void, Ptr< Socket > > errorClose)
Detect socket recv() events such as graceful shutdown or error.
Definition: socket.cc:94
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:244
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
virtual void Rx(const Ptr< const Packet > p, const TcpHeader &h, SocketWho who)
Packet received from IP layer.
virtual uint8_t GetIpv6HopLimit(void) const
Query the value of IP Hop Limit field of this socket.
Definition: socket.cc:551
Time m_cnTimeout
Timeout for connection retry.
virtual void SsThreshTrace(uint32_t oldValue, uint32_t newValue)
Slow start threshold changes.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Callback< R > MakeNullCallback(void)
Definition: callback.h:1635
static TypeId GetTypeId(void)
Get the type ID.
void SetRcvAckCb(AckManagementCb cb)
Set the callback invoked when an ACK is received (at the beginning of the processing) ...
void SetTos(uint8_t tos)
Set the tag's TOS.
Definition: socket.cc:791
encapsulates test code
Definition: test.h:1147
The NewReno implementation.
virtual void ReceivedAck(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received an ACK packet.
T Get(void) const
Get the underlying value.
Definition: traced-value.h:218
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer...
Definition: socket.h:1112
virtual void Tx(const Ptr< const Packet > p, const TcpHeader &h, SocketWho who)
Packet transmitted down to IP layer.
TracedValue< TcpStates_t > m_state
TCP state.
virtual Ptr< ErrorModel > CreateSenderErrorModel()
Create and return the error model to install in the sender node.
a polymophic address class
Definition: address.h:90
uint16_t GetPeerPort()
Get the peer port.
TCP socket creation and multiplexing/demultiplexing.
uint32_t m_delAckCount
Delayed ACK counter.
tuple nodes
Definition: first.py:25
uint32_t GetRWnd(SocketWho who)
Get the rWnd of the selected socket.
virtual void Retransmit(void)
Halving cwnd and call DoRetransmit()
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:341
virtual void ReceivePacket(Ptr< Socket > socket)
Packet received.
Time GetDelAckTimeout(SocketWho who)
Get the timeout of delayed ack (if present)
SequenceNumber32 GetHighestTxMark(SocketWho who)
Get the highest tx mark of the node specified.
void ErrorCloseCb(Ptr< Socket > socket)
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1238
virtual void UpdateRttHistory(const SequenceNumber32 &seq, uint32_t sz, bool isRetransmission)
Update the RTT history, when we send TCP segments.
static void EnablePrinting(void)
Enable printing packets metadata.
Definition: packet.cc:535
void SetTtl(uint8_t ttl)
Set the tag's TTL.
Definition: socket.cc:610
AttributeValue implementation for Time.
Definition: nstime.h:957
uint32_t GetDupAckCount(SocketWho who)
Get the number of dupack received.
virtual void Retransmit(void)
Halving cwnd and call DoRetransmit()
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
uint16_t GetLocalPort()
Get the local port.
virtual uint16_t AdvertisedWindowSize(bool scale=true) const
The amount of Rx window announced to the peer.
void SetMTU(uint32_t mtu)
MTU of the bottleneck link.
virtual Ptr< TcpSocketBase > Fork(void)
Call CopyObject<> to clone me.
virtual void ConfigureProperties(void)
Change the configuration of the socket properties.
void SetSegmentSize(SocketWho who, uint32_t segmentSize)
Forcefully set the segment size.
Ipv6EndPoint * m_endPoint6
the IPv6 endpoint
Base class for all RTT Estimators.
Definition: rtt-estimator.h:43
Ipv4Address GetLocalAddress(void)
Get the local address.
holds a vector of ns3::NetDevice pointers
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:209
uint32_t m_pktCount
Count of the application packet.
Time m_interPacketInterval
Time between sending application packet.
void SetRetransmitCb(RetrCb cb)
Set the callback invoked after the processing of a retransmit timeout.
void SetInitialCwnd(SocketWho who, uint32_t initialCwnd)
Forcefully set the initial cwnd.
Time GetConnTimeout(SocketWho who)
Get the retransmission time for the SYN segments.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
bool IsManualIpv6Tclass(void) const
Checks if the socket has a specific IPv6 Tclass set.
Definition: socket.cc:371
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
Definition: socket.cc:128
A base class for implementation of a stream socket using TCP.
Ptr< RttEstimator > m_rtt
Round trip time estimator.
Ptr< TcpRxBuffer > m_rxBuffer
Rx buffer (reordering buffer)
void ProcessedAckCb(Ptr< const Packet > p, const TcpHeader &h, Ptr< const TcpSocketBase > tcp)
virtual Ptr< TcpSocketMsgBase > CreateSocket(Ptr< Node > node, TypeId socketType, TypeId congControl)
Create a socket.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:252
Ptr< TcpL4Protocol > m_tcp
the associated TCP L4 protocol
void SetHopLimit(uint8_t hopLimit)
Set the tag's Hop Limit.
Definition: socket.cc:671
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:165
virtual void RcvAck(const Ptr< const TcpSocketState > tcb, const TcpHeader &h, SocketWho who)
Received ack.
bool IsManualIpv6HopLimit(void) const
Checks if the socket has a specific IPv6 Hop Limit set.
Definition: socket.cc:383
void RxPacketCb(const Ptr< const Packet > p, const TcpHeader &h, const Ptr< const TcpSocketBase > tcp)
virtual void CompleteFork(Ptr< Packet > p, const TcpHeader &tcpHeader, const Address &fromAddress, const Address &toAddress)
Complete a connection by forking the socket.
uint32_t GetInitialCwnd(SocketWho who)
Get the initial congestion window.
virtual void AddOptions(TcpHeader &tcpHeader)
Add options to TcpHeader.
AckManagementCb m_processedAckCb
Ptr< TcpSocketMsgBase > m_receiverSocket
Pointer to receiver socket.
Time GetRto(SocketWho who)
Get the retransmission time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
virtual void QueueDrop(SocketWho who)
Drop on the queue.
Header for the Transmission Control Protocol.
Definition: tcp-header.h:44
Congestion control abstract class.
void SetNetDevicePointToPointMode(bool pointToPointMode)
SimpleNetDevice is Broadcast capable and ARP needing.
indicates whether the socket has IPV6_TCLASS set.
Definition: socket.h:1351
uint8_t GetIpv6Tclass(void) const
Query the value of IPv6 Traffic Class field of this socket.
Definition: socket.cc:501
void SetAppPktCount(uint32_t pktCount)
Set app packet count.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
uint32_t GetInitialSsThresh(SocketWho who)
Get the initial slow start threshold.
void SetAppPktInterval(Time pktInterval)
Interval between app-generated packet.
virtual Ptr< TcpSocketMsgBase > CreateSenderSocket(Ptr< Node > node)
Create and install the socket to install on the sender.
uint32_t GetReTxThreshold(SocketWho who)
Get the retransmission threshold.
static TypeId GetTypeId(void)
void ForkCb(Ptr< TcpSocketMsgBase > tcp)
Time GetClockGranularity(SocketWho who)
Get the clock granularity attribute.
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:224
Time m_minRto
minimum value of the Retransmit timeout
virtual void CongStateTrace(const TcpSocketState::TcpCongState_t oldValue, const TcpSocketState::TcpCongState_t newValue)
State on Ack state machine changes.
void SetInitialSsThresh(SocketWho who, uint32_t initialSsThresh)
Forcefully set the initial ssth.
void UpdateRttHistoryCb(Ptr< const TcpSocketBase > tcp, const SequenceNumber32 &seq, uint32_t sz, bool isRetransmission)
SocketWho
Used as parameter of methods, specifies on what node the caller is interested (e.g.
UpdateRttCallback m_updateRttCb
TcpStates_t
Names of the 11 TCP states.
Definition: tcp-socket.h:65
Instantiate subclasses of ns3::Object.
static void ScheduleWithContext(uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event with the given context.
Definition: simulator.h:1319
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
virtual void NormalClose(SocketWho who)
Socket closed normally.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ptr< RttEstimator > GetRttEstimator(SocketWho who)
Get the Rtt estimator of the socket.
Ptr< NetDevice > m_boundnetdevice
the device this socket is bound to (might be null).
Definition: socket.h:1073
uint32_t GetId(void) const
Definition: node.cc:107
TracedValue< Time > m_rto
Retransmit timeout.
An identifier for simulation events.
Definition: event-id.h:53
uint16_t GetLocalPort(void)
Get the local port.
virtual void ConfigureEnvironment(void)
Change the configuration of the evironment.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:228
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
void SetUpdateRttHistoryCb(UpdateRttCallback cb)
Set the callback invoked when we update rtt history.
Ipv6Address GetPeerAddress()
Get the peer address.
static TypeId GetTypeId(void)
Our side has shutdown, waiting to complete transmission of remaining buffered data.
Definition: tcp-socket.h:78
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
virtual Ptr< SimpleChannel > CreateChannel()
Create and return the channel installed between the two socket.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
void TxPacketCb(const Ptr< const Packet > p, const TcpHeader &h, const Ptr< const TcpSocketBase > tcp)
Ipv4Address GetPeerAddress(void)
Get the peer address.
Ptr< TcpSocketState > GetTcb(SocketWho who)
Get the TCB from selected socket.
uint32_t m_synCount
Count of remaining connection retries.
virtual void BytesInFlightTrace(uint32_t oldValue, uint32_t newValue)
Bytes in flight changes.
void RtoExpiredCb(const Ptr< const TcpSocketState > tcb, const Ptr< const TcpSocketBase > tcp)
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_mtu
MTU of the environment.
Callback< void, Ptr< TcpSocketMsgBase > > m_forkCb
virtual void UpdatedRttHistory(const SequenceNumber32 &seq, uint32_t sz, bool isRetransmission, SocketWho who)
Updated the Rtt history.
A TCP socket which sends ACKs smaller than the segment received.
virtual void RttTrace(Time oldTime, Time newTime)
Rtt changes.
EventId GetPersistentEvent(SocketWho who)
Get the persistent event of the selected socket.
virtual Ptr< ErrorModel > CreateReceiverErrorModel()
Create and return the error model to install in the receiver node.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
virtual void ReceivedAck(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received an ACK packet.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void RcvAckCb(Ptr< const Packet > p, const TcpHeader &h, Ptr< const TcpSocketBase > tcp)
void CloseAndNotify(void)
Peacefully close the socket by notifying the upper layer and deallocate end point.
SequenceNumber32 m_lastAckedSeq
InetSocketAddress m_remoteAddr
Ptr< TcpRxBuffer > GetRxBuffer(SocketWho who)
Get the Rx buffer from selected socket.
void SetRcvBufSize(SocketWho who, uint32_t size)
Forcefully set a defined size for rx buffer.
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
build a set of SimpleNetDevice objects
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
virtual void RTOExpired(const Ptr< const TcpSocketState > tcb, SocketWho who)
Rto has expired.
virtual int Close(void)=0
Close a socket.
Ptr< TcpSocketBase > Fork(void)
Call CopyObject<> to clone me.
void SetProcessedAckCb(AckManagementCb cb)
Set the callback invoked when an ACK is received and processed (at the end of the processing) ...
indicates whether the socket has IP_TOS set.
Definition: socket.h:1258
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:59
virtual void UpdateRttHistory(const SequenceNumber32 &seq, uint32_t sz, bool isRetransmission)
Update the RTT history, when we send TCP segments.
EventId m_delAckEvent
Delayed ACK timeout event.
a unique identifier for an interface.
Definition: type-id.h:58
virtual void CWndTrace(uint32_t oldValue, uint32_t newValue)
Congestion window changes.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:904
Time m_clockGranularity
Clock Granularity used in RTO calcs.
uint32_t m_pktSize
Size of the application packet.
TracedCallback< Ptr< const Packet >, const TcpHeader &, Ptr< const TcpSocketBase > > m_txTrace
Trace of transmitted packets.
TcpSocket::TcpStates_t GetTcpState(SocketWho who)
Get the state of the TCP state machine.
Time m_startTime
Data transmission time.
void HandleAccept(Ptr< Socket > socket, const Address &from)
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
void SetPropagationDelay(Time propDelay)
Propagation delay of the bottleneck link.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
TypeId m_congControlTypeId
Congestion control.