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/queue.h"
28 #include "ns3/tcp-l4-protocol.h"
29 #include "../model/ipv4-end-point.h"
30 #include "../model/ipv6-end-point.h"
31 #include "tcp-general-test.h"
32 
33 using namespace ns3;
34 
35 NS_LOG_COMPONENT_DEFINE ("TcpGeneralTest");
36 
37 TcpGeneralTest::TcpGeneralTest (const std::string &desc)
38  : TestCase (desc),
39  m_congControlTypeId (TcpNewReno::GetTypeId ()),
40  m_remoteAddr (Ipv4Address::GetAny (), 4477)
41 {
42  NS_LOG_FUNCTION (this << desc);
43 }
44 
46 {
48 }
49 
50 void
52 {
53  NS_LOG_FUNCTION (this << socket);
54  Ptr<Packet> packet;
55  Address from;
56 
57  while ((packet = socket->RecvFrom (from)))
58  {
59  if (packet->GetSize () == 0)
60  { //EOF
61  break;
62  }
63  }
64 }
65 
66 void
67 TcpGeneralTest::SendPacket (Ptr<Socket> socket, uint32_t pktSize,
68  uint32_t pktCount, Time pktInterval )
69 {
70  NS_LOG_FUNCTION (this << " " << pktSize << " " << pktCount << " " <<
71  pktInterval.GetSeconds ());
72  if (pktCount > 0)
73  {
74  socket->Send (Create<Packet> (pktSize));
76  socket, pktSize, pktCount - 1, pktInterval);
77  }
78  else
79  {
80  socket->Close ();
81  }
82 }
83 
84 void
86 {
87  FinalChecks ();
88 
90  NS_LOG_INFO ("Done.");
91 }
92 
93 void
95 {
96  NS_LOG_FUNCTION (this);
97 
100  SetTransmitStart (Seconds (10));
101  SetAppPktSize (500);
102  SetAppPktCount (10);
104  SetMTU (1500);
105 }
106 
107 void
109 {
110  NS_LOG_FUNCTION (this);
111  SetInitialCwnd (SENDER, 1);
112  SetInitialSsThresh (SENDER, UINT32_MAX);
113  SetSegmentSize (SENDER, 500);
114  SetSegmentSize (RECEIVER, 500);
115 }
116 
117 void
119 {
121 
122  NS_LOG_INFO ("Create nodes.");
124  nodes.Create (2);
125 
126  InternetStackHelper internet;
127  internet.Install (nodes);
128 
130 
132 
133  SimpleNetDeviceHelper helperChannel;
134  helperChannel.SetNetDevicePointToPointMode (true);
135 
136  NetDeviceContainer net = helperChannel.Install (nodes, channel);
137 
140 
141  Ptr<SimpleNetDevice> senderDev = DynamicCast<SimpleNetDevice> (net.Get (0));
142  Ptr<SimpleNetDevice> receiverDev = DynamicCast<SimpleNetDevice> (net.Get (1));
143 
144  senderDev->SetMtu (m_mtu);
145  senderDev->GetQueue ()->TraceConnect ("Drop", "SENDER",
147  senderDev->TraceConnect ("PhyRxDrop", "sender",
149 
150  receiverDev->SetMtu (m_mtu);
151  receiverDev->GetQueue ()->TraceConnect ("Drop", "RECEIVER",
153  receiverDev->TraceConnect ("PhyRxDrop", "RECEIVER",
155 
156  senderDev->SetReceiveErrorModel (senderEM);
157  receiverDev->SetReceiveErrorModel (receiverEM);
158 
159  Ipv4AddressHelper ipv4;
160  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
161  Ipv4InterfaceContainer i = ipv4.Assign (net);
162  Ipv4Address serverAddress = i.GetAddress (1);
163  //Ipv4Address clientAddress = i.GetAddress (0);
164 
165  NS_LOG_INFO ("Create sockets.");
166  //Receiver socket on n1
168 
169  m_receiverSocket->SetRecvCallback (MakeCallback (&TcpGeneralTest::ReceivePacket, this));
170  m_receiverSocket->SetAcceptCallback (
171  MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
173  m_receiverSocket->SetCloseCallbacks (MakeCallback (&TcpGeneralTest::NormalCloseCb, this),
176  m_receiverSocket->SetProcessedAckCb (MakeCallback (&TcpGeneralTest::ProcessedAckCb, this));
177  m_receiverSocket->SetAfterRetransmitCb (MakeCallback (&TcpGeneralTest::AfterRetransmitCb, this));
178  m_receiverSocket->SetBeforeRetransmitCb (MakeCallback (&TcpGeneralTest::BeforeRetransmitCb, this));
180  m_receiverSocket->SetUpdateRttHistoryCb (MakeCallback (&TcpGeneralTest::UpdateRttHistoryCb, this));
181  m_receiverSocket->TraceConnectWithoutContext ("Tx",
183  m_receiverSocket->TraceConnectWithoutContext ("Rx",
185 
187  m_receiverSocket->Bind (local);
188 
189  m_senderSocket = CreateSenderSocket (nodes.Get (0));
190  m_senderSocket->SetCloseCallbacks (MakeCallback (&TcpGeneralTest::NormalCloseCb, this),
192  m_senderSocket->SetRcvAckCb (MakeCallback (&TcpGeneralTest::RcvAckCb, this));
193  m_senderSocket->SetProcessedAckCb (MakeCallback (&TcpGeneralTest::ProcessedAckCb, this));
194  m_senderSocket->SetAfterRetransmitCb (MakeCallback (&TcpGeneralTest::AfterRetransmitCb, this));
195  m_senderSocket->SetBeforeRetransmitCb (MakeCallback (&TcpGeneralTest::BeforeRetransmitCb, this));
196  m_senderSocket->SetDataSentCallback (MakeCallback (&TcpGeneralTest::DataSentCb, this));
197  m_senderSocket->SetUpdateRttHistoryCb (MakeCallback (&TcpGeneralTest::UpdateRttHistoryCb, this));
198  m_senderSocket->TraceConnectWithoutContext ("CongestionWindow",
200  m_senderSocket->TraceConnectWithoutContext ("SlowStartThreshold",
202  m_senderSocket->TraceConnectWithoutContext ("CongState",
204  m_senderSocket->TraceConnectWithoutContext ("Tx",
206  m_senderSocket->TraceConnectWithoutContext ("Rx",
208  m_senderSocket->TraceConnectWithoutContext ("RTT",
210  m_senderSocket->TraceConnectWithoutContext ("BytesInFlight",
212 
213  m_remoteAddr = InetSocketAddress (serverAddress, 4477);
214 
216 
217  m_receiverSocket->Listen ();
218  m_receiverSocket->ShutdownSend ();
219 
225 
226  NS_LOG_INFO ("Run Simulation.");
227  Simulator::Run ();
228 }
229 
230 void
232 {
233  NS_LOG_INFO (this);
234  m_senderSocket->Connect (m_remoteAddr);
235 }
236 
237 void
239 {
240  (void) from;
244 
245 }
246 
249 {
250  Ptr<SimpleChannel> ch = CreateObject <SimpleChannel> ();
251 
252  ch->SetAttribute ("Delay", TimeValue (m_propagationDelay));
253 
254  return ch;
255 }
256 
259  TypeId congControl)
260 {
261  ObjectFactory rttFactory;
262  ObjectFactory congestionAlgorithmFactory;
263  ObjectFactory socketFactory;
264 
265  rttFactory.SetTypeId (RttMeanDeviation::GetTypeId ());
266  congestionAlgorithmFactory.SetTypeId (congControl);
267  socketFactory.SetTypeId (socketType);
268 
269  Ptr<RttEstimator> rtt = rttFactory.Create<RttEstimator> ();
270  Ptr<TcpSocketMsgBase> socket = DynamicCast<TcpSocketMsgBase> (socketFactory.Create ());
271  Ptr<TcpCongestionOps> algo = congestionAlgorithmFactory.Create<TcpCongestionOps> ();
272 
273  socket->SetNode (node);
274  socket->SetTcp (node->GetObject<TcpL4Protocol> ());
275  socket->SetRtt (rtt);
276  socket->SetCongestionControlAlgorithm (algo);
277 
278  return socket;
279 }
280 
283 {
284  return 0;
285 }
286 
289 {
290  return 0;
291 }
292 
295 {
297 }
298 
301 {
303 }
304 
305 void
307 {
308  if (context.compare ("SENDER") == 0)
309  {
310  QueueDrop (SENDER);
311  }
312  else if (context.compare ("RECEIVER") == 0)
313  {
315  }
316  else
317  {
318  NS_FATAL_ERROR ("Packet dropped in a queue, but queue not recognized");
319  }
320 }
321 
322 void
324 {
325  if (context.compare ("SENDER") == 0)
326  {
327  PhyDrop (SENDER);
328  }
329  else if (context.compare ("RECEIVER") == 0)
330  {
331  PhyDrop (RECEIVER);
332  }
333  else
334  {
335  NS_FATAL_ERROR ("Packet dropped in a queue, but queue not recognized");
336  }
337 }
338 
339 void
341 {
342  if (socket->GetNode () == m_receiverSocket->GetNode ())
343  {
345  }
346  else if (socket->GetNode () == m_senderSocket->GetNode ())
347  {
349  }
350  else
351  {
352  NS_FATAL_ERROR ("Closed socket, but not recognized");
353  }
354 }
355 
356 void
358  const SequenceNumber32 & seq, uint32_t sz,
359  bool isRetransmission)
360 {
361  if (tcp->GetNode () == m_receiverSocket->GetNode ())
362  {
363  UpdatedRttHistory (seq, sz, isRetransmission, RECEIVER);
364  }
365  else if (tcp->GetNode () == m_senderSocket->GetNode ())
366  {
367  UpdatedRttHistory (seq, sz, isRetransmission, SENDER);
368  }
369  else
370  {
371  NS_FATAL_ERROR ("Closed socket, but not recognized");
372  }
373 }
374 
375 void
377  const Ptr<const TcpSocketBase> tcp)
378 {
379  if (tcp->GetNode () == m_receiverSocket->GetNode ())
380  {
381  AfterRTOExpired (tcb, RECEIVER);
382  }
383  else if (tcp->GetNode () == m_senderSocket->GetNode ())
384  {
385  AfterRTOExpired (tcb, SENDER);
386  }
387  else
388  {
389  NS_FATAL_ERROR ("Closed socket, but not recognized");
390  }
391 }
392 
393 void
395  const Ptr<const TcpSocketBase> tcp)
396 {
397  if (tcp->GetNode () == m_receiverSocket->GetNode ())
398  {
399  BeforeRTOExpired (tcb, RECEIVER);
400  }
401  else if (tcp->GetNode () == m_senderSocket->GetNode ())
402  {
403  BeforeRTOExpired (tcb, SENDER);
404  }
405  else
406  {
407  NS_FATAL_ERROR ("Closed socket, but not recognized");
408  }
409 }
410 
411 void
413 {
414  if (socket->GetNode () == m_receiverSocket->GetNode ())
415  {
416  DataSent (size, RECEIVER);
417  }
418  else if (socket->GetNode () == m_senderSocket->GetNode ())
419  {
420  DataSent (size, SENDER);
421  }
422  else
423  {
424  NS_FATAL_ERROR ("Closed socket, but not recognized");
425  }
426 }
427 
428 void
430 {
431  if (socket->GetNode () == m_receiverSocket->GetNode ())
432  {
434  }
435  else if (socket->GetNode () == m_senderSocket->GetNode ())
436  {
437  ErrorClose (SENDER);
438  }
439  else
440  {
441  NS_FATAL_ERROR ("Closed socket, but not recognized");
442  }
443 }
444 
445 void
447 {
448  NS_LOG_FUNCTION (this << p << h << who);
449 }
450 
451 void
453 {
454  NS_LOG_FUNCTION (this << p << h << who);
455 }
456 
457 void
459  const Ptr<const TcpSocketBase> tcp)
460 {
461  if (tcp->GetNode () == m_receiverSocket->GetNode ())
462  {
463  RcvAck (tcp->m_tcb, h, RECEIVER);
464  }
465  else if (tcp->GetNode () == m_senderSocket->GetNode ())
466  {
467  RcvAck (tcp->m_tcb, h, SENDER);
468  }
469  else
470  {
471  NS_FATAL_ERROR ("Received ACK but socket not recognized");
472  }
473 }
474 
475 void
477  const TcpHeader &h, const Ptr<const TcpSocketBase> tcp)
478 {
479  if (tcp->GetNode () == m_receiverSocket->GetNode ())
480  {
481  Tx (p, h, RECEIVER);
482  }
483  else if (tcp->GetNode () == m_senderSocket->GetNode ())
484  {
485  Tx (p, h, SENDER);
486  }
487  else
488  {
489  NS_FATAL_ERROR ("Received ACK but socket not recognized");
490  }
491 }
492 
493 void
495  const Ptr<const TcpSocketBase> tcp)
496 {
497  if (tcp->GetNode () == m_receiverSocket->GetNode ())
498  {
499  Rx (p, h, RECEIVER);
500  }
501  else if (tcp->GetNode () == m_senderSocket->GetNode ())
502  {
503  Rx (p, h, SENDER);
504  }
505  else
506  {
507  NS_FATAL_ERROR ("Received ACK but socket not recognized");
508  }
509 }
510 
511 void
514 {
515  if (tcp->GetNode () == m_receiverSocket->GetNode ())
516  {
517  ProcessedAck (tcp->m_tcb, h, RECEIVER);
518  }
519  else if (tcp->GetNode () == m_senderSocket->GetNode ())
520  {
521  ProcessedAck (tcp->m_tcb, h, SENDER);
522  }
523  else
524  {
525  NS_FATAL_ERROR ("Received ACK but socket not recognized");
526  }
527 }
528 
529 void
531 {
532  NS_LOG_FUNCTION (this << tcp);
533 
534  m_receiverSocket = tcp;
535 }
536 
537 uint32_t
539 {
540  if (who == SENDER)
541  {
542  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_retxThresh;
543  }
544  else if (who == RECEIVER)
545  {
546  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_retxThresh;
547  }
548  else
549  {
550  NS_FATAL_ERROR ("Not defined");
551  }
552 }
553 
554 uint32_t
556 {
557  if (who == SENDER)
558  {
559  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_dupAckCount;
560  }
561  else if (who == RECEIVER)
562  {
563  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_dupAckCount;
564  }
565  else
566  {
567  NS_FATAL_ERROR ("Not defined");
568  }
569 }
570 
571 uint32_t
573 {
574  if (who == SENDER)
575  {
576  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_delAckMaxCount;
577  }
578  else if (who == RECEIVER)
579  {
580  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_delAckMaxCount;
581  }
582  else
583  {
584  NS_FATAL_ERROR ("Not defined");
585  }
586 }
587 
588 Time
590 {
591  if (who == SENDER)
592  {
593  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetDelAckTimeout ();
594  }
595  else if (who == RECEIVER)
596  {
597  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetDelAckTimeout ();
598  }
599  else
600  {
601  NS_FATAL_ERROR ("Not defined");
602  }
603 }
604 
605 uint32_t
607 {
608  if (who == SENDER)
609  {
610  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetSegSize ();
611  }
612  else if (who == RECEIVER)
613  {
614  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetSegSize ();
615  }
616  else
617  {
618  NS_FATAL_ERROR ("Not defined");
619  }
620 }
621 
624 {
625  return GetTcb (who)->m_highTxMark;
626 }
627 
628 uint32_t
630 {
631  if (who == SENDER)
632  {
633  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetInitialCwnd ();
634  }
635  else if (who == RECEIVER)
636  {
637  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetInitialCwnd ();
638  }
639  else
640  {
641  NS_FATAL_ERROR ("Not defined");
642  }
643 }
644 
645 uint32_t
647 {
648  if (who == SENDER)
649  {
650  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetInitialSSThresh ();
651  }
652  else if (who == RECEIVER)
653  {
654  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetInitialSSThresh ();
655  }
656  else
657  {
658  NS_FATAL_ERROR ("Not defined");
659  }
660 }
661 
662 Time
664 {
665  if (who == SENDER)
666  {
667  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rto.Get ();
668  }
669  else if (who == RECEIVER)
670  {
671  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rto.Get ();
672  }
673  else
674  {
675  NS_FATAL_ERROR ("Not defined");
676  }
677 }
678 
679 Time
681 {
682  if (who == SENDER)
683  {
684  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_minRto;
685  }
686  else if (who == RECEIVER)
687  {
688  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_minRto;
689  }
690  else
691  {
692  NS_FATAL_ERROR ("Not defined");
693  }
694 }
695 
696 Time
698 {
699  if (who == SENDER)
700  {
701  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_cnTimeout;
702  }
703  else if (who == RECEIVER)
704  {
705  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_cnTimeout;
706  }
707  else
708  {
709  NS_FATAL_ERROR ("Not defined");
710  }
711 }
712 
715 {
716  if (who == SENDER)
717  {
718  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rtt;
719  }
720  else if (who == RECEIVER)
721  {
722  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rtt;
723  }
724  else
725  {
726  NS_FATAL_ERROR ("Not defined");
727  }
728 }
729 
730 Time
732 {
733  if (who == SENDER)
734  {
735  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_clockGranularity;
736  }
737  else if (who == RECEIVER)
738  {
739  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_clockGranularity;
740  }
741  else
742  {
743  NS_FATAL_ERROR ("Not defined");
744  }
745 }
746 
749 {
750  if (who == SENDER)
751  {
752  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_state.Get ();
753  }
754  else if (who == RECEIVER)
755  {
756 
757  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_state.Get ();
758  }
759  else
760  {
761  NS_FATAL_ERROR ("Not defined");
762  }
763 }
764 
765 uint32_t
767 {
768  if (who == SENDER)
769  {
770  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rWnd.Get ();
771  }
772  else if (who == RECEIVER)
773  {
774 
775  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rWnd.Get ();
776  }
777  else
778  {
779  NS_FATAL_ERROR ("Not defined");
780  }
781 }
782 
783 EventId
785 {
786  if (who == SENDER)
787  {
788  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_persistEvent;
789  }
790  else if (who == RECEIVER)
791  {
792 
793  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_persistEvent;
794  }
795  else
796  {
797  NS_FATAL_ERROR ("Not defined");
798  }
799 }
800 
801 Time
803 {
804  if (who == SENDER)
805  {
806  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_persistTimeout;
807  }
808  else if (who == RECEIVER)
809  {
810 
811  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_persistTimeout;
812  }
813  else
814  {
815  NS_FATAL_ERROR ("Not defined");
816  }
817 }
818 
821 {
822  if (who == SENDER)
823  {
824  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_tcb;
825  }
826  else if (who == RECEIVER)
827  {
828 
829  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_tcb;
830  }
831  else
832  {
833  NS_FATAL_ERROR ("Not defined");
834  }
835 }
836 
839 {
840  if (who == SENDER)
841  {
842  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rxBuffer;
843  }
844  else if (who == RECEIVER)
845  {
846 
847  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rxBuffer;
848  }
849  else
850  {
851  NS_FATAL_ERROR ("Not defined");
852  }
853 }
854 
855 void
857 {
858  if (who == SENDER)
859  {
860  m_senderSocket->SetRcvBufSize (size);
861  }
862  else if (who == RECEIVER)
863  {
864  m_receiverSocket->SetRcvBufSize (size);
865  }
866  else
867  {
868  NS_FATAL_ERROR ("Not defined");
869  }
870 }
871 
872 void
873 TcpGeneralTest::SetSegmentSize (SocketWho who, uint32_t segmentSize)
874 {
875  if (who == SENDER)
876  {
877  m_senderSocket->SetSegSize (segmentSize);
878  }
879  else if (who == RECEIVER)
880  {
881  m_receiverSocket->SetSegSize (segmentSize);
882  }
883  else
884  {
885  NS_FATAL_ERROR ("Not defined");
886  }
887 }
888 
889 void
890 TcpGeneralTest::SetInitialCwnd (SocketWho who, uint32_t initialCwnd)
891 {
892  if (who == SENDER)
893  {
894  m_senderSocket->SetInitialCwnd (initialCwnd);
895  }
896  else if (who == RECEIVER)
897  {
898  m_receiverSocket->SetInitialCwnd (initialCwnd);
899  }
900  else
901  {
902  NS_FATAL_ERROR ("Not defined");
903  }
904 }
905 
906 void
907 TcpGeneralTest::SetInitialSsThresh (SocketWho who, uint32_t initialSsThresh)
908 {
909  if (who == SENDER)
910  {
911  m_senderSocket->SetInitialSSThresh (initialSsThresh);
912  }
913  else if (who == RECEIVER)
914  {
915  m_receiverSocket->SetInitialSSThresh (initialSsThresh);
916  }
917  else
918  {
919  NS_FATAL_ERROR ("Not defined");
920  }
921 }
922 
924 
925 TypeId
927 {
928  static TypeId tid = TypeId ("ns3::TcpSocketMsgBase")
930  .SetGroupName ("Internet")
931  .AddConstructor<TcpSocketMsgBase> ()
932  ;
933  return tid;
934 }
935 
938 {
939  return CopyObject<TcpSocketMsgBase> (this);
940 }
941 
942 void
944 {
945  NS_ASSERT (!cb.IsNull ());
946  m_rcvAckCb = cb;
947 }
948 
949 void
951 {
952  NS_ASSERT (!cb.IsNull ());
953  m_processedAckCb = cb;
954 }
955 
956 void
958 {
959  NS_ASSERT (!cb.IsNull ());
960  m_afterRetrCallback = cb;
961 }
962 
963 void
965 {
966  NS_ASSERT (!cb.IsNull ());
968 }
969 
970 void
972 {
974  m_rcvAckCb (packet, tcpHeader, this);
975 
976  TcpSocketBase::ReceivedAck (packet, tcpHeader);
977 
978  m_processedAckCb (packet, tcpHeader, this);
979 }
980 
981 void
983 {
984  m_beforeRetrCallback (m_tcb, this);
986  m_afterRetrCallback (m_tcb, this);
987 }
988 
989 void
991 {
992  NS_ASSERT (!cb.IsNull ());
993  m_forkCb = cb;
994 }
995 
996 void
998 {
999  NS_ASSERT (!cb.IsNull ());
1000  m_updateRttCb = cb;
1001 }
1002 
1003 void
1005  bool isRetransmission)
1006 {
1007  TcpSocketBase::UpdateRttHistory (seq, sz, isRetransmission);
1008  if (!m_updateRttCb.IsNull ())
1009  {
1010  m_updateRttCb (this, seq, sz, isRetransmission);
1011  }
1012 }
1013 
1014 void
1016  const Address &fromAddress, const Address &toAddress)
1017 {
1018  TcpSocketBase::CompleteFork (p, tcpHeader, fromAddress, toAddress);
1019 
1020  if (!m_forkCb.IsNull ())
1021  {
1022  m_forkCb (this);
1023  }
1024 }
1025 
1027 
1028 TypeId
1030 {
1031  static TypeId tid = TypeId ("ns3::TcpSocketSmallAcks")
1033  .SetGroupName ("Internet")
1034  .AddConstructor<TcpSocketSmallAcks> ()
1035  ;
1036  return tid;
1037 }
1038 
1039 /*
1040  * Send empty packet, copied/pasted from TcpSocketBase
1041  *
1042  * The rationale for copying/pasting is that we need to edit a little the
1043  * code inside. Since there isn't a well-defined division of duties,
1044  * we are forced to do this.
1045  */
1046 void
1048 {
1049  Ptr<Packet> p = Create<Packet> ();
1050  TcpHeader header;
1052 
1053  /*
1054  * Add tags for each socket option.
1055  * Note that currently the socket adds both IPv4 tag and IPv6 tag
1056  * if both options are set. Once the packet got to layer three, only
1057  * the corresponding tags will be read.
1058  */
1059  if (GetIpTos ())
1060  {
1061  SocketIpTosTag ipTosTag;
1062  ipTosTag.SetTos (GetIpTos ());
1063  p->AddPacketTag (ipTosTag);
1064  }
1065 
1066  if (IsManualIpv6Tclass ())
1067  {
1068  SocketIpv6TclassTag ipTclassTag;
1069  ipTclassTag.SetTclass (GetIpv6Tclass ());
1070  p->AddPacketTag (ipTclassTag);
1071  }
1072 
1073  if (IsManualIpTtl ())
1074  {
1075  SocketIpTtlTag ipTtlTag;
1076  ipTtlTag.SetTtl (GetIpTtl ());
1077  p->AddPacketTag (ipTtlTag);
1078  }
1079 
1080  if (IsManualIpv6HopLimit ())
1081  {
1082  SocketIpv6HopLimitTag ipHopLimitTag;
1083  ipHopLimitTag.SetHopLimit (GetIpv6HopLimit ());
1084  p->AddPacketTag (ipHopLimitTag);
1085  }
1086 
1087  if (m_endPoint == 0 && m_endPoint6 == 0)
1088  {
1089  NS_LOG_WARN ("Failed to send empty packet due to null endpoint");
1090  return;
1091  }
1092  if (flags & TcpHeader::FIN)
1093  {
1094  flags |= TcpHeader::ACK;
1095  }
1096  else if (m_state == FIN_WAIT_1 || m_state == LAST_ACK || m_state == CLOSING)
1097  {
1098  ++s;
1099  }
1100 
1101  bool hasSyn = flags & TcpHeader::SYN;
1102  bool hasFin = flags & TcpHeader::FIN;
1103  bool isAck = flags == TcpHeader::ACK;
1104 
1105  header.SetFlags (flags);
1106  header.SetSequenceNumber (s);
1107 
1108  // Actual division in small acks.
1109  if (hasSyn || hasFin)
1110  {
1111  header.SetAckNumber (m_rxBuffer->NextRxSequence ());
1112  }
1113  else
1114  {
1115  SequenceNumber32 ackSeq;
1116 
1117  ackSeq = m_lastAckedSeq + m_bytesToAck;
1118 
1119  if (m_bytesLeftToBeAcked == 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1120  {
1121  m_bytesLeftToBeAcked = m_rxBuffer->NextRxSequence ().GetValue () - 1 - m_bytesToAck;
1122  }
1123  else if (m_bytesLeftToBeAcked > 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1124  {
1126  }
1127 
1128  NS_LOG_LOGIC ("Acking up to " << ackSeq << " remaining bytes: " << m_bytesLeftToBeAcked);
1129 
1130  header.SetAckNumber (ackSeq);
1131  m_lastAckedSeq = ackSeq;
1132  }
1133 
1134  // end of division in small acks
1135 
1136  if (m_endPoint != 0)
1137  {
1138  header.SetSourcePort (m_endPoint->GetLocalPort ());
1139  header.SetDestinationPort (m_endPoint->GetPeerPort ());
1140  }
1141  else
1142  {
1143  header.SetSourcePort (m_endPoint6->GetLocalPort ());
1144  header.SetDestinationPort (m_endPoint6->GetPeerPort ());
1145  }
1146  AddOptions (header);
1147  header.SetWindowSize (AdvertisedWindowSize ());
1148 
1149  // RFC 6298, clause 2.4
1150  m_rto = Max (m_rtt->GetEstimate () + Max (m_clockGranularity, m_rtt->GetVariation () * 4), m_minRto);
1151 
1152  if (hasSyn)
1153  {
1154  if (m_synCount == 0)
1155  { // No more connection retries, give up
1156  NS_LOG_LOGIC ("Connection failed.");
1157  m_rtt->Reset (); //According to recommendation -> RFC 6298
1158  CloseAndNotify ();
1159  return;
1160  }
1161  else
1162  { // Exponential backoff of connection time out
1163  int backoffCount = 0x1 << (m_synRetries - m_synCount);
1164  m_rto = m_cnTimeout * backoffCount;
1165  m_synCount--;
1166  }
1167  }
1168  if (m_endPoint != 0)
1169  {
1170  m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (),
1172  }
1173  else
1174  {
1175  m_tcp->SendPacket (p, header, m_endPoint6->GetLocalAddress (),
1177  }
1178 
1179  m_txTrace (p, header, this);
1180 
1181  if (flags & TcpHeader::ACK)
1182  { // If sending an ACK, cancel the delay ACK as well
1183  m_delAckEvent.Cancel ();
1184  m_delAckCount = 0;
1185  }
1186  if (m_retxEvent.IsExpired () && (hasSyn || hasFin) && !isAck )
1187  { // Retransmit SYN / SYN+ACK / FIN / FIN+ACK to guard against lost
1188  NS_LOG_LOGIC ("Schedule retransmission timeout at time "
1189  << Simulator::Now ().GetSeconds () << " to expire at time "
1190  << (Simulator::Now () + m_rto.Get ()).GetSeconds ());
1192  }
1193 
1194  // send another ACK if bytes remain
1195  if (m_bytesLeftToBeAcked > 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1196  {
1197  SendEmptyPacket (flags);
1198  }
1199 }
1200 
1203 {
1204  return CopyObject<TcpSocketSmallAcks> (this);
1205 }
1206 
virtual void ProcessedAck(const Ptr< const TcpSocketState > tcb, const TcpHeader &h, SocketWho who)
Processed ack.
void TxPacketCb(const Ptr< const Packet > p, const TcpHeader &h, const Ptr< const TcpSocketBase > tcp)
Tx packet Callback.
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
virtual void Rx(const Ptr< const Packet > p, const TcpHeader &h, SocketWho who)
Packet received from IP layer.
uint32_t GetReTxThreshold(SocketWho who)
Get the retransmission threshold.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
bool IsManualIpTtl(void) const
Checks if the socket has a specific IPv4 TTL set.
Definition: socket.cc:377
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 "...
Ptr< TcpSocketMsgBase > m_senderSocket
Pointer to sender socket.
void SetSegmentSize(SocketWho who, uint32_t segmentSize)
Forcefully set the segment size.
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
RetrCb m_afterRetrCallback
After retransmission callback.
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:1159
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:45
holds a vector of std::pair of Ptr and interface index.
virtual void DoTeardown(void)
Teardown the TCP test.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:459
void SetProcessedAckCb(AckManagementCb cb)
Set the callback invoked when an ACK is received and processed (at the end of the processing) ...
AckManagementCb m_rcvAckCb
Receive ACK callback.
uint32_t m_synRetries
Number of connection attempts.
virtual Ptr< ErrorModel > CreateReceiverErrorModel()
Create and return the error model to install in the receiver node.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
uint32_t GetRWnd(SocketWho who)
Get the rWnd of the selected socket.
void SetCongestionControl(TypeId congControl)
Congestion control of the sender 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 DoConnect()
Scheduled at 0.0, SENDER starts the connection to RECEIVER.
virtual void ErrorClose(SocketWho who)
Socket closed with an error.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:814
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1270
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:226
#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:1001
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.
void ErrorCloseCb(Ptr< Socket > socket)
Error Close Callback.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:796
virtual void Tx(const Ptr< const Packet > p, const TcpHeader &h, SocketWho who)
Packet transmitted down to IP layer.
void SetTransmitStart(Time startTime)
Set the initial time at which the application sends the first data packet.
void ForkCb(Ptr< TcpSocketMsgBase > tcp)
Fork Callback.
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:277
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
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.
Time GetMinRto(SocketWho who)
Get the minimun RTO attribute.
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 SetTos(uint8_t tos)
Set the tag's TOS.
Definition: socket.cc:791
encapsulates test code
Definition: test.h:1155
The NewReno implementation.
virtual void ReceivedAck(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received an ACK packet.
virtual void ConfigureProperties(void)
Change the configuration of the socket properties.
uint32_t GetDelAckCount(SocketWho who)
Get the number of delayed ack (if present)
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:1111
TracedValue< TcpStates_t > m_state
TCP state.
virtual void ReceivedAck(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received an ACK packet.
void SetAfterRetransmitCb(RetrCb cb)
Set the callback invoked after the processing of a retransmit timeout.
virtual Ptr< ErrorModel > CreateSenderErrorModel()
Create and return the error model to install in the sender node.
void UpdateRttHistoryCb(Ptr< const TcpSocketBase > tcp, const SequenceNumber32 &seq, uint32_t sz, bool isRetransmission)
Update RTT with new data.
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.
SequenceNumber32 GetHighestTxMark(SocketWho who)
Get the highest tx mark of the node specified.
void SetUpdateRttHistoryCb(UpdateRttCallback cb)
Set the callback invoked when we update rtt history.
tuple nodes
Definition: first.py:25
virtual Ptr< TcpSocketBase > Fork(void)
Call CopyObject<> to clone me.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:341
void BeforeRetransmitCb(const Ptr< const TcpSocketState > tcb, const Ptr< const TcpSocketBase > tcp)
Invoked before a retransmit event.
virtual void SendEmptyPacket(uint8_t flags)
Send a empty packet that carries a flag, e.g., ACK.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1375
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:534
void SetForkCb(Callback< void, Ptr< TcpSocketMsgBase > > cb)
Set the callback invoked after the forking.
void SetTtl(uint8_t ttl)
Set the tag's TTL.
Definition: socket.cc:610
AttributeValue implementation for Time.
Definition: nstime.h:1055
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.
TcpSocket::TcpStates_t GetTcpState(SocketWho who)
Get the state of the TCP state machine.
void SetMTU(uint32_t mtu)
MTU of the bottleneck link.
virtual bool SetMtu(const uint16_t mtu)
SocketWho
Used as parameter of methods, specifies on what node the caller is interested (e.g.
Ipv6EndPoint * m_endPoint6
the IPv6 endpoint
uint32_t GetInitialSsThresh(SocketWho who)
Get the initial slow start threshold.
static TypeId GetTypeId(void)
Get the type ID.
Base class for all RTT Estimators.
Definition: rtt-estimator.h:43
virtual void ReceivePacket(Ptr< Socket > socket)
Packet received.
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 down to tcp socket.
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.
void SetInitialSsThresh(SocketWho who, uint32_t initialSsThresh)
Forcefully set the initial ssth.
Ptr< TcpRxBuffer > m_rxBuffer
Rx buffer (reordering buffer)
Ptr< TcpSocketState > GetTcb(SocketWho who)
Get the TCB from selected socket.
Ptr< TcpL4Protocol > m_tcp
the associated TCP L4 protocol
void SetHopLimit(uint8_t hopLimit)
Set the tag's Hop Limit.
Definition: socket.cc:671
void DataSentCb(Ptr< Socket > socket, uint32_t size)
Data sent Callback.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:190
virtual Ptr< SimpleChannel > CreateChannel()
Create and return the channel installed between the two socket.
virtual void RcvAck(const Ptr< const TcpSocketState > tcb, const TcpHeader &h, SocketWho who)
Received ack.
void ProcessedAckCb(Ptr< const Packet > p, const TcpHeader &h, Ptr< const TcpSocketBase > tcp)
ACK processed Callback.
bool IsManualIpv6HopLimit(void) const
Checks if the socket has a specific IPv6 Hop Limit set.
Definition: socket.cc:383
virtual Ptr< TcpSocketMsgBase > CreateSocket(Ptr< Node > node, TypeId socketType, TypeId congControl)
Create a socket.
virtual void UpdateRttHistory(const SequenceNumber32 &seq, uint32_t sz, bool isRetransmission)
Update the RTT history, when we send TCP segments.
virtual void CompleteFork(Ptr< Packet > p, const TcpHeader &tcpHeader, const Address &fromAddress, const Address &toAddress)
Complete a connection by forking the socket.
static TypeId GetTypeId(void)
Get the type ID.
void AddOptions(TcpHeader &tcpHeader)
Add options to TcpHeader.
AckManagementCb m_processedAckCb
Processed ACK callback.
Ptr< TcpSocketMsgBase > m_receiverSocket
Pointer to receiver socket.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Time GetClockGranularity(SocketWho who)
Get the clock granularity attribute.
keep track of a set of node pointers.
uint32_t GetSegSize(SocketWho who)
Get the segment size of the node specified.
virtual void QueueDrop(SocketWho who)
Drop on the queue.
Header for the Transmission Control Protocol.
Definition: tcp-header.h:44
Congestion control abstract class.
uint32_t GetDupAckCount(SocketWho who)
Get the number of dupack received.
void HandleAccept(Ptr< Socket > socket, const Address &from)
Handle an accept connection.
void SetNetDevicePointToPointMode(bool pointToPointMode)
SimpleNetDevice is Broadcast capable and ARP needing.
void NormalCloseCb(Ptr< Socket > socket)
Normal Close Callback.
indicates whether the socket has IPV6_TCLASS set.
Definition: socket.h:1350
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...
void SetAppPktInterval(Time pktInterval)
Interval between app-generated packet.
EventId GetPersistentEvent(SocketWho who)
Get the persistent event of the selected socket.
TcpGeneralTest(const std::string &desc)
TcpGeneralTest constructor.
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the SimpleNetDevice.
void SetRcvBufSize(SocketWho who, uint32_t size)
Forcefully set a defined size for rx buffer.
Ptr< Queue< Packet > > GetQueue(void) const
Get a copy of the attached Queue.
Our side has shutdown after remote has shutdown.
Definition: tcp-socket.h:75
virtual Ptr< TcpSocketMsgBase > CreateReceiverSocket(Ptr< Node > node)
Create and install the socket to install on the receiver.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
virtual void ReTxTimeout(void)
An RTO event happened.
Time GetDelAckTimeout(SocketWho who)
Get the timeout of delayed ack (if present)
virtual void ReTxTimeout(void)
An RTO event happened.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
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.
virtual void ConfigureEnvironment(void)
Change the configuration of the evironment.
virtual void CompleteFork(Ptr< Packet > p, const TcpHeader &tcpHeader, const Address &fromAddress, const Address &toAddress)
Complete a connection by forking the socket.
UpdateRttCallback m_updateRttCb
Update RTT callback.
TcpStates_t
Names of the 11 TCP states.
Definition: tcp-socket.h:65
virtual Ptr< TcpSocketMsgBase > CreateSenderSocket(Ptr< Node > node)
Create and install the socket to install on the sender.
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:1469
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< NetDevice > m_boundnetdevice
the device this socket is bound to (might be null).
Definition: socket.h:1072
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.
void PhyDropCb(std::string context, Ptr< const Packet > p)
Drop at Phy layer Callback.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:261
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
Ipv6Address GetPeerAddress()
Get the peer address.
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.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:993
uint32_t GetInitialCwnd(SocketWho who)
Get the initial congestion window.
Ipv4Address GetPeerAddress(void)
Get the peer address.
void AfterRetransmitCb(const Ptr< const TcpSocketState > tcb, const Ptr< const TcpSocketBase > tcp)
Invoked after a retransmit event.
uint32_t m_synCount
Count of remaining connection retries.
void SetInitialCwnd(SocketWho who, uint32_t initialCwnd)
Forcefully set the initial cwnd.
virtual void BytesInFlightTrace(uint32_t oldValue, uint32_t newValue)
Bytes in flight changes.
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
void SendPacket(Ptr< Socket > socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval)
Send packets to other endpoint.
uint32_t m_mtu
MTU of the environment.
Callback< void, Ptr< TcpSocketMsgBase > > m_forkCb
Fork callback.
virtual void UpdatedRttHistory(const SequenceNumber32 &seq, uint32_t sz, bool isRetransmission, SocketWho who)
Updated the Rtt history.
TracedValue< SequenceNumber32 > m_highTxMark
Highest seqno ever sent, regardless of ReTx.
RetrCb m_beforeRetrCallback
Before retransmission callback.
bool TraceConnect(std::string name, std::string context, const CallbackBase &cb)
Connect a TraceSource to a Callback with a context.
Definition: object-base.cc:306
A TCP socket which sends ACKs smaller than the segment received.
Ptr< TcpSocketBase > Fork(void)
Call CopyObject<> to clone me.
virtual void RttTrace(Time oldTime, Time newTime)
Rtt changes.
Ptr< TcpRxBuffer > GetRxBuffer(SocketWho who)
Get the Rx buffer from selected socket.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void QueueDropCb(std::string context, Ptr< const Packet > p)
Queue Drop Callback.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
uint32_t m_bytesLeftToBeAcked
Number of bytes to be ACKed left.
Time GetPersistentTimeout(SocketWho who)
Get the persistent timeout of the selected socket.
void CloseAndNotify(void)
Peacefully close the socket by notifying the upper layer and deallocate end point.
SequenceNumber32 m_lastAckedSeq
Last sequence number ACKed.
void SetRcvAckCb(AckManagementCb cb)
Set the callback invoked when an ACK is received (at the beginning of the processing) ...
InetSocketAddress m_remoteAddr
Remote peer address.
virtual Ptr< Node > GetNode(void) const
Return the node this socket is associated with.
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.
void RxPacketCb(const Ptr< const Packet > p, const TcpHeader &h, const Ptr< const TcpSocketBase > tcp)
Rx packet Callback.
build a set of SimpleNetDevice objects
Time GetConnTimeout(SocketWho who)
Get the retransmission time for the SYN segments.
virtual void BeforeRTOExpired(const Ptr< const TcpSocketState > tcb, SocketWho who)
Rto has expired.
void SetBeforeRetransmitCb(RetrCb cb)
Set the callback invoked before the processing of a retransmit timeout.
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
virtual int Close(void)=0
Close a socket.
uint32_t m_bytesToAck
Number of bytes to be ACKed.
indicates whether the socket has IP_TOS set.
Definition: socket.h:1257
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:59
EventId m_delAckEvent
Delayed ACK timeout event.
Ptr< RttEstimator > GetRttEstimator(SocketWho who)
Get the Rtt estimator of the socket.
a unique identifier for an interface.
Definition: type-id.h:58
virtual void CWndTrace(uint32_t oldValue, uint32_t newValue)
Tracks the congestion window changes.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:914
Time m_clockGranularity
Clock Granularity used in RTO calcs.
virtual void DoRun(void)
Execute the tcp test.
uint32_t m_pktSize
Size of the application packet.
void RcvAckCb(Ptr< const Packet > p, const TcpHeader &h, Ptr< const TcpSocketBase > tcp)
Receive ACK Callback.
TracedCallback< Ptr< const Packet >, const TcpHeader &, Ptr< const TcpSocketBase > > m_txTrace
Trace of transmitted packets.
Time m_startTime
Data transmission time.
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.
virtual void AfterRTOExpired(const Ptr< const TcpSocketState > tcb, SocketWho who)
Rto has expired.
TracedValue< SequenceNumber32 > m_nextTxSequence
Next seqnum to be sent (SND.NXT), ReTx pushes it back.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
TypeId m_congControlTypeId
Congestion control.
Time GetRto(SocketWho who)
Get the retransmission time.