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 
186  m_senderSocket = CreateSenderSocket (nodes.Get (0));
187  m_senderSocket->SetCloseCallbacks (MakeCallback (&TcpGeneralTest::NormalCloseCb, this),
189  m_senderSocket->SetRcvAckCb (MakeCallback (&TcpGeneralTest::RcvAckCb, this));
190  m_senderSocket->SetProcessedAckCb (MakeCallback (&TcpGeneralTest::ProcessedAckCb, this));
191  m_senderSocket->SetRetransmitCb (MakeCallback (&TcpGeneralTest::RtoExpiredCb, this));
192  m_senderSocket->SetDataSentCallback (MakeCallback (&TcpGeneralTest::DataSentCb, this));
193  m_senderSocket->SetUpdateRttHistoryCb (MakeCallback (&TcpGeneralTest::UpdateRttHistoryCb, this));
194  m_senderSocket->TraceConnectWithoutContext ("CongestionWindow",
196  m_senderSocket->TraceConnectWithoutContext ("SlowStartThreshold",
198  m_senderSocket->TraceConnectWithoutContext ("CongState",
200  m_senderSocket->TraceConnectWithoutContext ("Tx",
202  m_senderSocket->TraceConnectWithoutContext ("Rx",
204  m_senderSocket->TraceConnectWithoutContext ("RTT",
206  m_senderSocket->TraceConnectWithoutContext ("BytesInFlight",
208 
209  m_remoteAddr = InetSocketAddress (serverAddress, 4477);
210 
212 
213  m_receiverSocket->Listen ();
214  m_receiverSocket->ShutdownSend ();
215 
221 
222  NS_LOG_INFO ("Run Simulation.");
223  Simulator::Run ();
224 }
225 
226 void
228 {
229  NS_LOG_INFO (this);
230  m_senderSocket->Connect (m_remoteAddr);
231 }
232 
233 void
235 {
236  (void) from;
240 
241 }
242 
245 {
246  Ptr<SimpleChannel> ch = CreateObject <SimpleChannel> ();
247 
248  ch->SetAttribute ("Delay", TimeValue (m_propagationDelay));
249 
250  return ch;
251 }
252 
255  TypeId congControl)
256 {
257  ObjectFactory rttFactory;
258  ObjectFactory congestionAlgorithmFactory;
259  ObjectFactory socketFactory;
260 
261  rttFactory.SetTypeId (RttMeanDeviation::GetTypeId ());
262  congestionAlgorithmFactory.SetTypeId (congControl);
263  socketFactory.SetTypeId (socketType);
264 
265  Ptr<RttEstimator> rtt = rttFactory.Create<RttEstimator> ();
266  Ptr<TcpSocketMsgBase> socket = DynamicCast<TcpSocketMsgBase> (socketFactory.Create ());
267  Ptr<TcpCongestionOps> algo = congestionAlgorithmFactory.Create<TcpCongestionOps> ();
268 
269  socket->SetNode (node);
270  socket->SetTcp (node->GetObject<TcpL4Protocol> ());
271  socket->SetRtt (rtt);
272  socket->SetCongestionControlAlgorithm (algo);
273 
274  return socket;
275 }
276 
279 {
280  return 0;
281 }
282 
285 {
286  return 0;
287 }
288 
291 {
293 }
294 
297 {
299 }
300 
301 void
303 {
304  if (context.compare ("SENDER") == 0)
305  {
306  QueueDrop (SENDER);
307  }
308  else if (context.compare ("RECEIVER") == 0)
309  {
311  }
312  else
313  {
314  NS_FATAL_ERROR ("Packet dropped in a queue, but queue not recognized");
315  }
316 }
317 
318 void
320 {
321  if (context.compare ("SENDER") == 0)
322  {
323  PhyDrop (SENDER);
324  }
325  else if (context.compare ("RECEIVER") == 0)
326  {
327  PhyDrop (RECEIVER);
328  }
329  else
330  {
331  NS_FATAL_ERROR ("Packet dropped in a queue, but queue not recognized");
332  }
333 }
334 
335 void
337 {
338  if (socket->GetNode () == m_receiverSocket->GetNode ())
339  {
341  }
342  else if (socket->GetNode () == m_senderSocket->GetNode ())
343  {
345  }
346  else
347  {
348  NS_FATAL_ERROR ("Closed socket, but not recognized");
349  }
350 }
351 
352 void
354  const SequenceNumber32 & seq, uint32_t sz,
355  bool isRetransmission)
356 {
357  if (tcp->GetNode () == m_receiverSocket->GetNode ())
358  {
359  UpdatedRttHistory (seq, sz, isRetransmission, RECEIVER);
360  }
361  else if (tcp->GetNode () == m_senderSocket->GetNode ())
362  {
363  UpdatedRttHistory (seq, sz, isRetransmission, SENDER);
364  }
365  else
366  {
367  NS_FATAL_ERROR ("Closed socket, but not recognized");
368  }
369 }
370 
371 void
373  const Ptr<const TcpSocketBase> tcp)
374 {
375  if (tcp->GetNode () == m_receiverSocket->GetNode ())
376  {
377  RTOExpired (tcb, RECEIVER);
378  }
379  else if (tcp->GetNode () == m_senderSocket->GetNode ())
380  {
381  RTOExpired (tcb, SENDER);
382  }
383  else
384  {
385  NS_FATAL_ERROR ("Closed socket, but not recognized");
386  }
387 }
388 
389 void
391 {
392  if (socket->GetNode () == m_receiverSocket->GetNode ())
393  {
394  DataSent (size, RECEIVER);
395  }
396  else if (socket->GetNode () == m_senderSocket->GetNode ())
397  {
398  DataSent (size, SENDER);
399  }
400  else
401  {
402  NS_FATAL_ERROR ("Closed socket, but not recognized");
403  }
404 }
405 
406 void
408 {
409  if (socket->GetNode () == m_receiverSocket->GetNode ())
410  {
412  }
413  else if (socket->GetNode () == m_senderSocket->GetNode ())
414  {
415  ErrorClose (SENDER);
416  }
417  else
418  {
419  NS_FATAL_ERROR ("Closed socket, but not recognized");
420  }
421 }
422 
423 void
425 {
426  NS_LOG_FUNCTION (this << p << h << who);
427 }
428 
429 void
431 {
432  NS_LOG_FUNCTION (this << p << h << who);
433 }
434 
435 void
437  const Ptr<const TcpSocketBase> tcp)
438 {
439  if (tcp->GetNode () == m_receiverSocket->GetNode ())
440  {
441  RcvAck (tcp->m_tcb, h, RECEIVER);
442  }
443  else if (tcp->GetNode () == m_senderSocket->GetNode ())
444  {
445  RcvAck (tcp->m_tcb, h, SENDER);
446  }
447  else
448  {
449  NS_FATAL_ERROR ("Received ACK but socket not recognized");
450  }
451 }
452 
453 void
455  const TcpHeader &h, const Ptr<const TcpSocketBase> tcp)
456 {
457  if (tcp->GetNode () == m_receiverSocket->GetNode ())
458  {
459  Tx (p, h, RECEIVER);
460  }
461  else if (tcp->GetNode () == m_senderSocket->GetNode ())
462  {
463  Tx (p, h, SENDER);
464  }
465  else
466  {
467  NS_FATAL_ERROR ("Received ACK but socket not recognized");
468  }
469 }
470 
471 void
473  const Ptr<const TcpSocketBase> tcp)
474 {
475  if (tcp->GetNode () == m_receiverSocket->GetNode ())
476  {
477  Rx (p, h, RECEIVER);
478  }
479  else if (tcp->GetNode () == m_senderSocket->GetNode ())
480  {
481  Rx (p, h, SENDER);
482  }
483  else
484  {
485  NS_FATAL_ERROR ("Received ACK but socket not recognized");
486  }
487 }
488 
489 void
492 {
493  if (tcp->GetNode () == m_receiverSocket->GetNode ())
494  {
495  ProcessedAck (tcp->m_tcb, h, RECEIVER);
496  }
497  else if (tcp->GetNode () == m_senderSocket->GetNode ())
498  {
499  ProcessedAck (tcp->m_tcb, h, SENDER);
500  }
501  else
502  {
503  NS_FATAL_ERROR ("Received ACK but socket not recognized");
504  }
505 }
506 
507 void
509 {
510  NS_LOG_FUNCTION (this << tcp);
511 
512  m_receiverSocket = tcp;
513 }
514 
515 uint32_t
517 {
518  if (who == SENDER)
519  {
520  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_retxThresh;
521  }
522  else if (who == RECEIVER)
523  {
524  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_retxThresh;
525  }
526  else
527  {
528  NS_FATAL_ERROR ("Not defined");
529  }
530 }
531 
532 uint32_t
534 {
535  if (who == SENDER)
536  {
537  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_dupAckCount;
538  }
539  else if (who == RECEIVER)
540  {
541  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_dupAckCount;
542  }
543  else
544  {
545  NS_FATAL_ERROR ("Not defined");
546  }
547 }
548 
549 uint32_t
551 {
552  if (who == SENDER)
553  {
554  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_delAckMaxCount;
555  }
556  else if (who == RECEIVER)
557  {
558  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_delAckMaxCount;
559  }
560  else
561  {
562  NS_FATAL_ERROR ("Not defined");
563  }
564 }
565 
566 Time
568 {
569  if (who == SENDER)
570  {
571  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetDelAckTimeout ();
572  }
573  else if (who == RECEIVER)
574  {
575  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetDelAckTimeout ();
576  }
577  else
578  {
579  NS_FATAL_ERROR ("Not defined");
580  }
581 }
582 
583 uint32_t
585 {
586  if (who == SENDER)
587  {
588  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetSegSize ();
589  }
590  else if (who == RECEIVER)
591  {
592  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetSegSize ();
593  }
594  else
595  {
596  NS_FATAL_ERROR ("Not defined");
597  }
598 }
599 
602 {
603  if (who == SENDER)
604  {
605  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_highTxMark;
606  }
607  else if (who == RECEIVER)
608  {
609  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_highTxMark;
610  }
611  else
612  {
613  NS_FATAL_ERROR ("Not defined");
614  }
615 }
616 
617 uint32_t
619 {
620  if (who == SENDER)
621  {
622  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetInitialCwnd ();
623  }
624  else if (who == RECEIVER)
625  {
626  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetInitialCwnd ();
627  }
628  else
629  {
630  NS_FATAL_ERROR ("Not defined");
631  }
632 }
633 
634 uint32_t
636 {
637  if (who == SENDER)
638  {
639  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetInitialSSThresh ();
640  }
641  else if (who == RECEIVER)
642  {
643  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetInitialSSThresh ();
644  }
645  else
646  {
647  NS_FATAL_ERROR ("Not defined");
648  }
649 }
650 
651 Time
653 {
654  if (who == SENDER)
655  {
656  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rto.Get ();
657  }
658  else if (who == RECEIVER)
659  {
660  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rto.Get ();
661  }
662  else
663  {
664  NS_FATAL_ERROR ("Not defined");
665  }
666 }
667 
668 Time
670 {
671  if (who == SENDER)
672  {
673  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_minRto;
674  }
675  else if (who == RECEIVER)
676  {
677  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_minRto;
678  }
679  else
680  {
681  NS_FATAL_ERROR ("Not defined");
682  }
683 }
684 
685 Time
687 {
688  if (who == SENDER)
689  {
690  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_cnTimeout;
691  }
692  else if (who == RECEIVER)
693  {
694  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_cnTimeout;
695  }
696  else
697  {
698  NS_FATAL_ERROR ("Not defined");
699  }
700 }
701 
704 {
705  if (who == SENDER)
706  {
707  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rtt;
708  }
709  else if (who == RECEIVER)
710  {
711  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rtt;
712  }
713  else
714  {
715  NS_FATAL_ERROR ("Not defined");
716  }
717 }
718 
719 Time
721 {
722  if (who == SENDER)
723  {
724  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_clockGranularity;
725  }
726  else if (who == RECEIVER)
727  {
728  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_clockGranularity;
729  }
730  else
731  {
732  NS_FATAL_ERROR ("Not defined");
733  }
734 }
735 
738 {
739  if (who == SENDER)
740  {
741  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_state.Get ();
742  }
743  else if (who == RECEIVER)
744  {
745 
746  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_state.Get ();
747  }
748  else
749  {
750  NS_FATAL_ERROR ("Not defined");
751  }
752 }
753 
754 uint32_t
756 {
757  if (who == SENDER)
758  {
759  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rWnd.Get ();
760  }
761  else if (who == RECEIVER)
762  {
763 
764  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rWnd.Get ();
765  }
766  else
767  {
768  NS_FATAL_ERROR ("Not defined");
769  }
770 }
771 
772 EventId
774 {
775  if (who == SENDER)
776  {
777  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_persistEvent;
778  }
779  else if (who == RECEIVER)
780  {
781 
782  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_persistEvent;
783  }
784  else
785  {
786  NS_FATAL_ERROR ("Not defined");
787  }
788 }
789 
790 Time
792 {
793  if (who == SENDER)
794  {
795  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_persistTimeout;
796  }
797  else if (who == RECEIVER)
798  {
799 
800  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_persistTimeout;
801  }
802  else
803  {
804  NS_FATAL_ERROR ("Not defined");
805  }
806 }
807 
810 {
811  if (who == SENDER)
812  {
813  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_tcb;
814  }
815  else if (who == RECEIVER)
816  {
817 
818  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_tcb;
819  }
820  else
821  {
822  NS_FATAL_ERROR ("Not defined");
823  }
824 }
825 
826 void
828 {
829  if (who == SENDER)
830  {
831  m_senderSocket->SetRcvBufSize (size);
832  }
833  else if (who == RECEIVER)
834  {
835  m_receiverSocket->SetRcvBufSize (size);
836  }
837  else
838  {
839  NS_FATAL_ERROR ("Not defined");
840  }
841 }
842 
843 void
844 TcpGeneralTest::SetSegmentSize (SocketWho who, uint32_t segmentSize)
845 {
846  if (who == SENDER)
847  {
848  m_senderSocket->SetSegSize (segmentSize);
849  }
850  else if (who == RECEIVER)
851  {
852  m_receiverSocket->SetSegSize (segmentSize);
853  }
854  else
855  {
856  NS_FATAL_ERROR ("Not defined");
857  }
858 }
859 
860 void
861 TcpGeneralTest::SetInitialCwnd (SocketWho who, uint32_t initialCwnd)
862 {
863  if (who == SENDER)
864  {
865  m_senderSocket->SetInitialCwnd (initialCwnd);
866  }
867  else if (who == RECEIVER)
868  {
869  m_receiverSocket->SetInitialCwnd (initialCwnd);
870  }
871  else
872  {
873  NS_FATAL_ERROR ("Not defined");
874  }
875 }
876 
877 void
878 TcpGeneralTest::SetInitialSsThresh (SocketWho who, uint32_t initialSsThresh)
879 {
880  if (who == SENDER)
881  {
882  m_senderSocket->SetInitialSSThresh (initialSsThresh);
883  }
884  else if (who == RECEIVER)
885  {
886  m_receiverSocket->SetInitialSSThresh (initialSsThresh);
887  }
888  else
889  {
890  NS_FATAL_ERROR ("Not defined");
891  }
892 }
893 
895 
896 TypeId
898 {
899  static TypeId tid = TypeId ("ns3::TcpSocketMsgBase")
901  .SetGroupName ("Internet")
902  .AddConstructor<TcpSocketMsgBase> ()
903  ;
904  return tid;
905 }
906 
909 {
910  return CopyObject<TcpSocketMsgBase> (this);
911 }
912 
913 void
915 {
916  NS_ASSERT (!cb.IsNull ());
917  m_rcvAckCb = cb;
918 }
919 
920 void
922 {
923  NS_ASSERT (!cb.IsNull ());
924  m_processedAckCb = cb;
925 }
926 
927 void
929 {
930  NS_ASSERT (!cb.IsNull ());
931  m_retrCallback = cb;
932 }
933 
934 void
936 {
938  m_rcvAckCb (packet, tcpHeader, this);
939 
940  TcpSocketBase::ReceivedAck (packet, tcpHeader);
941 
942  m_processedAckCb (packet, tcpHeader, this);
943 }
944 
945 void
947 {
949 
950  m_retrCallback (m_tcb, this);
951 }
952 
953 void
955 {
956  NS_ASSERT (!cb.IsNull ());
957  m_forkCb = cb;
958 }
959 
960 void
962 {
963  NS_ASSERT (!cb.IsNull ());
964  m_updateRttCb = cb;
965 }
966 
967 void
969  bool isRetransmission)
970 {
971  TcpSocketBase::UpdateRttHistory (seq, sz, isRetransmission);
972  if (!m_updateRttCb.IsNull ())
973  {
974  m_updateRttCb (this, seq, sz, isRetransmission);
975  }
976 }
977 
978 void
980  const Address &fromAddress, const Address &toAddress)
981 {
982  TcpSocketBase::CompleteFork (p, tcpHeader, fromAddress, toAddress);
983 
984  if (!m_forkCb.IsNull ())
985  {
986  m_forkCb (this);
987  }
988 }
989 
991 
992 TypeId
994 {
995  static TypeId tid = TypeId ("ns3::TcpSocketSmallAcks")
997  .SetGroupName ("Internet")
998  .AddConstructor<TcpSocketSmallAcks> ()
999  ;
1000  return tid;
1001 }
1002 
1010 void
1012 {
1013  Ptr<Packet> p = Create<Packet> ();
1014  TcpHeader header;
1016 
1017  /*
1018  * Add tags for each socket option.
1019  * Note that currently the socket adds both IPv4 tag and IPv6 tag
1020  * if both options are set. Once the packet got to layer three, only
1021  * the corresponding tags will be read.
1022  */
1023  if (IsManualIpTos ())
1024  {
1025  SocketIpTosTag ipTosTag;
1026  ipTosTag.SetTos (GetIpTos ());
1027  p->AddPacketTag (ipTosTag);
1028  }
1029 
1030  if (IsManualIpv6Tclass ())
1031  {
1032  SocketIpv6TclassTag ipTclassTag;
1033  ipTclassTag.SetTclass (GetIpv6Tclass ());
1034  p->AddPacketTag (ipTclassTag);
1035  }
1036 
1037  if (IsManualIpTtl ())
1038  {
1039  SocketIpTtlTag ipTtlTag;
1040  ipTtlTag.SetTtl (GetIpTtl ());
1041  p->AddPacketTag (ipTtlTag);
1042  }
1043 
1044  if (IsManualIpv6HopLimit ())
1045  {
1046  SocketIpv6HopLimitTag ipHopLimitTag;
1047  ipHopLimitTag.SetHopLimit (GetIpv6HopLimit ());
1048  p->AddPacketTag (ipHopLimitTag);
1049  }
1050 
1051  if (m_endPoint == 0 && m_endPoint6 == 0)
1052  {
1053  NS_LOG_WARN ("Failed to send empty packet due to null endpoint");
1054  return;
1055  }
1056  if (flags & TcpHeader::FIN)
1057  {
1058  flags |= TcpHeader::ACK;
1059  }
1060  else if (m_state == FIN_WAIT_1 || m_state == LAST_ACK || m_state == CLOSING)
1061  {
1062  ++s;
1063  }
1064 
1065  bool hasSyn = flags & TcpHeader::SYN;
1066  bool hasFin = flags & TcpHeader::FIN;
1067  bool isAck = flags == TcpHeader::ACK;
1068 
1069  header.SetFlags (flags);
1070  header.SetSequenceNumber (s);
1071 
1072  // Actual division in small acks.
1073  if (hasSyn || hasFin)
1074  {
1075  header.SetAckNumber (m_rxBuffer->NextRxSequence ());
1076  }
1077  else
1078  {
1079  SequenceNumber32 ackSeq;
1080 
1081  ackSeq = m_lastAckedSeq + m_bytesToAck;
1082 
1083  if (m_bytesLeftToBeAcked == 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1084  {
1085  m_bytesLeftToBeAcked = m_rxBuffer->NextRxSequence ().GetValue () - 1 - m_bytesToAck;
1086  }
1087  else if (m_bytesLeftToBeAcked > 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1088  {
1090  }
1091 
1092  NS_LOG_LOGIC ("Acking up to " << ackSeq << " remaining bytes: " << m_bytesLeftToBeAcked);
1093 
1094  header.SetAckNumber (ackSeq);
1095  m_lastAckedSeq = ackSeq;
1096  }
1097 
1098  // end of division in small acks
1099 
1100  if (m_endPoint != 0)
1101  {
1102  header.SetSourcePort (m_endPoint->GetLocalPort ());
1103  header.SetDestinationPort (m_endPoint->GetPeerPort ());
1104  }
1105  else
1106  {
1107  header.SetSourcePort (m_endPoint6->GetLocalPort ());
1108  header.SetDestinationPort (m_endPoint6->GetPeerPort ());
1109  }
1110  AddOptions (header);
1111  header.SetWindowSize (AdvertisedWindowSize ());
1112 
1113  // RFC 6298, clause 2.4
1114  m_rto = Max (m_rtt->GetEstimate () + Max (m_clockGranularity, m_rtt->GetVariation () * 4), m_minRto);
1115 
1116  if (hasSyn)
1117  {
1118  if (m_synCount == 0)
1119  { // No more connection retries, give up
1120  NS_LOG_LOGIC ("Connection failed.");
1121  m_rtt->Reset (); //According to recommendation -> RFC 6298
1122  CloseAndNotify ();
1123  return;
1124  }
1125  else
1126  { // Exponential backoff of connection time out
1127  int backoffCount = 0x1 << (m_synRetries - m_synCount);
1128  m_rto = m_cnTimeout * backoffCount;
1129  m_synCount--;
1130  }
1131  }
1132  if (m_endPoint != 0)
1133  {
1134  m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (),
1136  }
1137  else
1138  {
1139  m_tcp->SendPacket (p, header, m_endPoint6->GetLocalAddress (),
1141  }
1142 
1143  m_txTrace (p, header, this);
1144 
1145  if (flags & TcpHeader::ACK)
1146  { // If sending an ACK, cancel the delay ACK as well
1147  m_delAckEvent.Cancel ();
1148  m_delAckCount = 0;
1149  }
1150  if (m_retxEvent.IsExpired () && (hasSyn || hasFin) && !isAck )
1151  { // Retransmit SYN / SYN+ACK / FIN / FIN+ACK to guard against lost
1152  NS_LOG_LOGIC ("Schedule retransmission timeout at time "
1153  << Simulator::Now ().GetSeconds () << " to expire at time "
1154  << (Simulator::Now () + m_rto.Get ()).GetSeconds ());
1156  }
1157 
1158  // send another ACK if bytes remain
1159  if (m_bytesLeftToBeAcked > 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1160  {
1161  SendEmptyPacket (flags);
1162  }
1163 }
1164 
1167 {
1168  return CopyObject<TcpSocketSmallAcks> (this);
1169 }
1170 
1171 } // 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:854
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:383
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:471
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:404
This class implements a tag that carries the socket-specific HOPLIMIT of a packet to the IPv6 layer...
Definition: socket.h:1101
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:455
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:1258
virtual Ptr< TcpSocketMsgBase > CreateReceiverSocket(Ptr< Node > node)
Create and install the socket to install on the receiver.
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:200
#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:786
void SetTransmitStart(Time startTime)
Set the initial time at which the application sends the first data packet.
bool IsManualIpTos(void) const
Checks if the socket has a specific IPv4 ToS set.
Definition: socket.cc:371
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
Both sides have shutdown but we still have data we have to finish sending.
Definition: tcp-socket.h:80
#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:145
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:496
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:1626
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:797
TracedValue< SequenceNumber32 > m_nextTxSequence
Next seqnum to be sent (SND.NXT), ReTx pushes it back.
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:217
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer...
Definition: socket.h:1053
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()
Our side has shutdown, waiting to complete transmission of remaining buffered data.
Definition: tcp-socket.h:77
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:1216
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:616
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.
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:1480
bool IsManualIpv6Tclass(void) const
Checks if the socket has a specific IPv6 Tclass set.
Definition: socket.cc:377
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:677
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:164
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:389
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:1246
uint8_t GetIpv6Tclass(void) const
Query the value of IPv6 Traffic Class field of this socket.
Definition: socket.cc:446
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.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:223
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
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:1297
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:967
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)
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
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.
TcpStates_t
Names of the 11 TCP states.
Definition: tcp-socket.h:64
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:1199
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.
Our side has shutdown after remote has shutdown.
Definition: tcp-socket.h:74
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:826
Time m_clockGranularity
Clock Granularity used in RTO calcs.
uint32_t m_pktSize
Size of the application packet.
virtual uint16_t AdvertisedWindowSize(void) const
The amount of Rx window announced to the peer.
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.