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  m_senderSocket->TraceConnectWithoutContext ("RTO",
214  m_senderSocket->TraceConnectWithoutContext ("NextTxSequence",
216  m_senderSocket->TraceConnectWithoutContext ("HighestSequence",
218 
219 
220  m_remoteAddr = InetSocketAddress (serverAddress, 4477);
221 
223 
224  m_receiverSocket->Listen ();
225  m_receiverSocket->ShutdownSend ();
226 
232 
233  NS_LOG_INFO ("Run Simulation.");
234  Simulator::Run ();
235 }
236 
237 void
239 {
240  NS_LOG_INFO (this);
241  m_senderSocket->Connect (m_remoteAddr);
242 }
243 
244 void
246 {
247  (void) from;
251 
252 }
253 
256 {
257  Ptr<SimpleChannel> ch = CreateObject <SimpleChannel> ();
258 
259  ch->SetAttribute ("Delay", TimeValue (m_propagationDelay));
260 
261  return ch;
262 }
263 
266  TypeId congControl)
267 {
268  ObjectFactory rttFactory;
269  ObjectFactory congestionAlgorithmFactory;
270  ObjectFactory socketFactory;
271 
272  rttFactory.SetTypeId (RttMeanDeviation::GetTypeId ());
273  congestionAlgorithmFactory.SetTypeId (congControl);
274  socketFactory.SetTypeId (socketType);
275 
276  Ptr<RttEstimator> rtt = rttFactory.Create<RttEstimator> ();
277  Ptr<TcpSocketMsgBase> socket = DynamicCast<TcpSocketMsgBase> (socketFactory.Create ());
278  Ptr<TcpCongestionOps> algo = congestionAlgorithmFactory.Create<TcpCongestionOps> ();
279 
280  socket->SetNode (node);
281  socket->SetTcp (node->GetObject<TcpL4Protocol> ());
282  socket->SetRtt (rtt);
283  socket->SetCongestionControlAlgorithm (algo);
284 
285  return socket;
286 }
287 
290 {
291  return nullptr;
292 }
293 
296 {
297  return nullptr;
298 }
299 
302 {
304 }
305 
308 {
310 }
311 
312 void
314 {
315  if (context.compare ("SENDER") == 0)
316  {
317  QueueDrop (SENDER);
318  }
319  else if (context.compare ("RECEIVER") == 0)
320  {
322  }
323  else
324  {
325  NS_FATAL_ERROR ("Packet dropped in a queue, but queue not recognized");
326  }
327 }
328 
329 void
331 {
332  NS_UNUSED (p);
333  if (context.compare ("SENDER") == 0)
334  {
335  PhyDrop (SENDER);
336  }
337  else if (context.compare ("RECEIVER") == 0)
338  {
339  PhyDrop (RECEIVER);
340  }
341  else
342  {
343  NS_FATAL_ERROR ("Packet dropped in a queue, but queue not recognized");
344  }
345 }
346 
347 void
349 {
350  if (socket->GetNode () == m_receiverSocket->GetNode ())
351  {
353  }
354  else if (socket->GetNode () == m_senderSocket->GetNode ())
355  {
357  }
358  else
359  {
360  NS_FATAL_ERROR ("Closed socket, but not recognized");
361  }
362 }
363 
364 void
366  const SequenceNumber32 & seq, uint32_t sz,
367  bool isRetransmission)
368 {
369  if (tcp->GetNode () == m_receiverSocket->GetNode ())
370  {
371  UpdatedRttHistory (seq, sz, isRetransmission, RECEIVER);
372  }
373  else if (tcp->GetNode () == m_senderSocket->GetNode ())
374  {
375  UpdatedRttHistory (seq, sz, isRetransmission, SENDER);
376  }
377  else
378  {
379  NS_FATAL_ERROR ("Closed socket, but not recognized");
380  }
381 }
382 
383 void
385  const Ptr<const TcpSocketBase> tcp)
386 {
387  if (tcp->GetNode () == m_receiverSocket->GetNode ())
388  {
389  AfterRTOExpired (tcb, RECEIVER);
390  }
391  else if (tcp->GetNode () == m_senderSocket->GetNode ())
392  {
393  AfterRTOExpired (tcb, SENDER);
394  }
395  else
396  {
397  NS_FATAL_ERROR ("Closed socket, but not recognized");
398  }
399 }
400 
401 void
403  const Ptr<const TcpSocketBase> tcp)
404 {
405  if (tcp->GetNode () == m_receiverSocket->GetNode ())
406  {
407  BeforeRTOExpired (tcb, RECEIVER);
408  }
409  else if (tcp->GetNode () == m_senderSocket->GetNode ())
410  {
411  BeforeRTOExpired (tcb, SENDER);
412  }
413  else
414  {
415  NS_FATAL_ERROR ("Closed socket, but not recognized");
416  }
417 }
418 
419 void
421 {
422  if (socket->GetNode () == m_receiverSocket->GetNode ())
423  {
424  DataSent (size, RECEIVER);
425  }
426  else if (socket->GetNode () == m_senderSocket->GetNode ())
427  {
428  DataSent (size, SENDER);
429  }
430  else
431  {
432  NS_FATAL_ERROR ("Closed socket, but not recognized");
433  }
434 }
435 
436 void
438 {
439  if (socket->GetNode () == m_receiverSocket->GetNode ())
440  {
442  }
443  else if (socket->GetNode () == m_senderSocket->GetNode ())
444  {
445  ErrorClose (SENDER);
446  }
447  else
448  {
449  NS_FATAL_ERROR ("Closed socket, but not recognized");
450  }
451 }
452 
453 void
455 {
456  NS_LOG_FUNCTION (this << p << h << who);
457 }
458 
459 void
461 {
462  NS_LOG_FUNCTION (this << p << h << who);
463 }
464 
465 void
467  const Ptr<const TcpSocketBase> tcp)
468 {
469  if (tcp->GetNode () == m_receiverSocket->GetNode ())
470  {
471  RcvAck (tcp->m_tcb, h, RECEIVER);
472  }
473  else if (tcp->GetNode () == m_senderSocket->GetNode ())
474  {
475  RcvAck (tcp->m_tcb, h, SENDER);
476  }
477  else
478  {
479  NS_FATAL_ERROR ("Received ACK but socket not recognized");
480  }
481 }
482 
483 void
485  const TcpHeader &h, const Ptr<const TcpSocketBase> tcp)
486 {
487  if (tcp->GetNode () == m_receiverSocket->GetNode ())
488  {
489  Tx (p, h, RECEIVER);
490  }
491  else if (tcp->GetNode () == m_senderSocket->GetNode ())
492  {
493  Tx (p, h, SENDER);
494  }
495  else
496  {
497  NS_FATAL_ERROR ("Received ACK but socket not recognized");
498  }
499 }
500 
501 void
503  const Ptr<const TcpSocketBase> tcp)
504 {
505  if (tcp->GetNode () == m_receiverSocket->GetNode ())
506  {
507  Rx (p, h, RECEIVER);
508  }
509  else if (tcp->GetNode () == m_senderSocket->GetNode ())
510  {
511  Rx (p, h, SENDER);
512  }
513  else
514  {
515  NS_FATAL_ERROR ("Received ACK but socket not recognized");
516  }
517 }
518 
519 void
522 {
523  if (tcp->GetNode () == m_receiverSocket->GetNode ())
524  {
525  ProcessedAck (tcp->m_tcb, h, RECEIVER);
526  }
527  else if (tcp->GetNode () == m_senderSocket->GetNode ())
528  {
529  ProcessedAck (tcp->m_tcb, h, SENDER);
530  }
531  else
532  {
533  NS_FATAL_ERROR ("Received ACK but socket not recognized");
534  }
535 }
536 
537 void
539 {
540  NS_LOG_FUNCTION (this << tcp);
541 
542  m_receiverSocket = tcp;
543 }
544 
545 uint32_t
547 {
548  if (who == SENDER)
549  {
550  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_retxThresh;
551  }
552  else if (who == RECEIVER)
553  {
554  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_retxThresh;
555  }
556  else
557  {
558  NS_FATAL_ERROR ("Not defined");
559  }
560 }
561 
562 uint32_t
564 {
565  if (who == SENDER)
566  {
567  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_dupAckCount;
568  }
569  else if (who == RECEIVER)
570  {
571  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_dupAckCount;
572  }
573  else
574  {
575  NS_FATAL_ERROR ("Not defined");
576  }
577 }
578 
579 uint32_t
581 {
582  if (who == SENDER)
583  {
584  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_delAckMaxCount;
585  }
586  else if (who == RECEIVER)
587  {
588  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_delAckMaxCount;
589  }
590  else
591  {
592  NS_FATAL_ERROR ("Not defined");
593  }
594 }
595 
596 Time
598 {
599  if (who == SENDER)
600  {
601  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetDelAckTimeout ();
602  }
603  else if (who == RECEIVER)
604  {
605  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetDelAckTimeout ();
606  }
607  else
608  {
609  NS_FATAL_ERROR ("Not defined");
610  }
611 }
612 
613 uint32_t
615 {
616  if (who == SENDER)
617  {
618  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetSegSize ();
619  }
620  else if (who == RECEIVER)
621  {
622  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetSegSize ();
623  }
624  else
625  {
626  NS_FATAL_ERROR ("Not defined");
627  }
628 }
629 
632 {
633  return GetTcb (who)->m_highTxMark;
634 }
635 
636 uint32_t
638 {
639  if (who == SENDER)
640  {
641  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetInitialCwnd ();
642  }
643  else if (who == RECEIVER)
644  {
645  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetInitialCwnd ();
646  }
647  else
648  {
649  NS_FATAL_ERROR ("Not defined");
650  }
651 }
652 
653 uint32_t
655 {
656  if (who == SENDER)
657  {
658  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetInitialSSThresh ();
659  }
660  else if (who == RECEIVER)
661  {
662  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetInitialSSThresh ();
663  }
664  else
665  {
666  NS_FATAL_ERROR ("Not defined");
667  }
668 }
669 
670 Time
672 {
673  if (who == SENDER)
674  {
675  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rto.Get ();
676  }
677  else if (who == RECEIVER)
678  {
679  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rto.Get ();
680  }
681  else
682  {
683  NS_FATAL_ERROR ("Not defined");
684  }
685 }
686 
687 Time
689 {
690  if (who == SENDER)
691  {
692  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_minRto;
693  }
694  else if (who == RECEIVER)
695  {
696  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_minRto;
697  }
698  else
699  {
700  NS_FATAL_ERROR ("Not defined");
701  }
702 }
703 
704 Time
706 {
707  if (who == SENDER)
708  {
709  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_cnTimeout;
710  }
711  else if (who == RECEIVER)
712  {
713  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_cnTimeout;
714  }
715  else
716  {
717  NS_FATAL_ERROR ("Not defined");
718  }
719 }
720 
723 {
724  if (who == SENDER)
725  {
726  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rtt;
727  }
728  else if (who == RECEIVER)
729  {
730  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rtt;
731  }
732  else
733  {
734  NS_FATAL_ERROR ("Not defined");
735  }
736 }
737 
738 Time
740 {
741  if (who == SENDER)
742  {
743  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_clockGranularity;
744  }
745  else if (who == RECEIVER)
746  {
747  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_clockGranularity;
748  }
749  else
750  {
751  NS_FATAL_ERROR ("Not defined");
752  }
753 }
754 
757 {
758  if (who == SENDER)
759  {
760  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_state.Get ();
761  }
762  else if (who == RECEIVER)
763  {
764 
765  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_state.Get ();
766  }
767  else
768  {
769  NS_FATAL_ERROR ("Not defined");
770  }
771 }
772 
773 uint32_t
775 {
776  if (who == SENDER)
777  {
778  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rWnd.Get ();
779  }
780  else if (who == RECEIVER)
781  {
782 
783  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rWnd.Get ();
784  }
785  else
786  {
787  NS_FATAL_ERROR ("Not defined");
788  }
789 }
790 
791 EventId
793 {
794  if (who == SENDER)
795  {
796  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_persistEvent;
797  }
798  else if (who == RECEIVER)
799  {
800 
801  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_persistEvent;
802  }
803  else
804  {
805  NS_FATAL_ERROR ("Not defined");
806  }
807 }
808 
809 Time
811 {
812  if (who == SENDER)
813  {
814  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_persistTimeout;
815  }
816  else if (who == RECEIVER)
817  {
818 
819  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_persistTimeout;
820  }
821  else
822  {
823  NS_FATAL_ERROR ("Not defined");
824  }
825 }
826 
829 {
830  if (who == SENDER)
831  {
832  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_tcb;
833  }
834  else if (who == RECEIVER)
835  {
836 
837  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_tcb;
838  }
839  else
840  {
841  NS_FATAL_ERROR ("Not defined");
842  }
843 }
844 
847 {
848  if (who == SENDER)
849  {
850  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rxBuffer;
851  }
852  else if (who == RECEIVER)
853  {
854 
855  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rxBuffer;
856  }
857  else
858  {
859  NS_FATAL_ERROR ("Not defined");
860  }
861 }
862 
863 void
865 {
866  if (who == SENDER)
867  {
868  m_senderSocket->SetRcvBufSize (size);
869  }
870  else if (who == RECEIVER)
871  {
872  m_receiverSocket->SetRcvBufSize (size);
873  }
874  else
875  {
876  NS_FATAL_ERROR ("Not defined");
877  }
878 }
879 
880 void
881 TcpGeneralTest::SetSegmentSize (SocketWho who, uint32_t segmentSize)
882 {
883  if (who == SENDER)
884  {
885  m_senderSocket->SetSegSize (segmentSize);
886  }
887  else if (who == RECEIVER)
888  {
889  m_receiverSocket->SetSegSize (segmentSize);
890  }
891  else
892  {
893  NS_FATAL_ERROR ("Not defined");
894  }
895 }
896 
897 void
898 TcpGeneralTest::SetInitialCwnd (SocketWho who, uint32_t initialCwnd)
899 {
900  if (who == SENDER)
901  {
902  m_senderSocket->SetInitialCwnd (initialCwnd);
903  }
904  else if (who == RECEIVER)
905  {
906  m_receiverSocket->SetInitialCwnd (initialCwnd);
907  }
908  else
909  {
910  NS_FATAL_ERROR ("Not defined");
911  }
912 }
913 
914 void
915 TcpGeneralTest::SetInitialSsThresh (SocketWho who, uint32_t initialSsThresh)
916 {
917  if (who == SENDER)
918  {
919  m_senderSocket->SetInitialSSThresh (initialSsThresh);
920  }
921  else if (who == RECEIVER)
922  {
923  m_receiverSocket->SetInitialSSThresh (initialSsThresh);
924  }
925  else
926  {
927  NS_FATAL_ERROR ("Not defined");
928  }
929 }
930 
932 
933 TypeId
935 {
936  static TypeId tid = TypeId ("ns3::TcpSocketMsgBase")
938  .SetGroupName ("Internet")
939  .AddConstructor<TcpSocketMsgBase> ()
940  ;
941  return tid;
942 }
943 
946 {
947  return CopyObject<TcpSocketMsgBase> (this);
948 }
949 
950 void
952 {
953  NS_ASSERT (!cb.IsNull ());
954  m_rcvAckCb = cb;
955 }
956 
957 void
959 {
960  NS_ASSERT (!cb.IsNull ());
961  m_processedAckCb = cb;
962 }
963 
964 void
966 {
967  NS_ASSERT (!cb.IsNull ());
968  m_afterRetrCallback = cb;
969 }
970 
971 void
973 {
974  NS_ASSERT (!cb.IsNull ());
976 }
977 
978 void
980 {
982  m_rcvAckCb (packet, tcpHeader, this);
983 
984  TcpSocketBase::ReceivedAck (packet, tcpHeader);
985 
986  m_processedAckCb (packet, tcpHeader, this);
987 }
988 
989 void
991 {
992  m_beforeRetrCallback (m_tcb, this);
994  m_afterRetrCallback (m_tcb, this);
995 }
996 
997 void
999 {
1000  NS_ASSERT (!cb.IsNull ());
1001  m_forkCb = cb;
1002 }
1003 
1004 void
1006 {
1007  NS_ASSERT (!cb.IsNull ());
1008  m_updateRttCb = cb;
1009 }
1010 
1011 void
1013  bool isRetransmission)
1014 {
1015  TcpSocketBase::UpdateRttHistory (seq, sz, isRetransmission);
1016  if (!m_updateRttCb.IsNull ())
1017  {
1018  m_updateRttCb (this, seq, sz, isRetransmission);
1019  }
1020 }
1021 
1022 void
1024  const Address &fromAddress, const Address &toAddress)
1025 {
1026  TcpSocketBase::CompleteFork (p, tcpHeader, fromAddress, toAddress);
1027 
1028  if (!m_forkCb.IsNull ())
1029  {
1030  m_forkCb (this);
1031  }
1032 }
1033 
1035 
1036 TypeId
1038 {
1039  static TypeId tid = TypeId ("ns3::TcpSocketSmallAcks")
1041  .SetGroupName ("Internet")
1042  .AddConstructor<TcpSocketSmallAcks> ()
1043  ;
1044  return tid;
1045 }
1046 
1047 /*
1048  * Send empty packet, copied/pasted from TcpSocketBase
1049  *
1050  * The rationale for copying/pasting is that we need to edit a little the
1051  * code inside. Since there isn't a well-defined division of duties,
1052  * we are forced to do this.
1053  */
1054 void
1056 {
1057  Ptr<Packet> p = Create<Packet> ();
1058  TcpHeader header;
1060 
1061  /*
1062  * Add tags for each socket option.
1063  * Note that currently the socket adds both IPv4 tag and IPv6 tag
1064  * if both options are set. Once the packet got to layer three, only
1065  * the corresponding tags will be read.
1066  */
1067  if (GetIpTos ())
1068  {
1069  SocketIpTosTag ipTosTag;
1070  ipTosTag.SetTos (GetIpTos ());
1071  p->AddPacketTag (ipTosTag);
1072  }
1073 
1074  if (IsManualIpv6Tclass ())
1075  {
1076  SocketIpv6TclassTag ipTclassTag;
1077  ipTclassTag.SetTclass (GetIpv6Tclass ());
1078  p->AddPacketTag (ipTclassTag);
1079  }
1080 
1081  if (IsManualIpTtl ())
1082  {
1083  SocketIpTtlTag ipTtlTag;
1084  ipTtlTag.SetTtl (GetIpTtl ());
1085  p->AddPacketTag (ipTtlTag);
1086  }
1087 
1088  if (IsManualIpv6HopLimit ())
1089  {
1090  SocketIpv6HopLimitTag ipHopLimitTag;
1091  ipHopLimitTag.SetHopLimit (GetIpv6HopLimit ());
1092  p->AddPacketTag (ipHopLimitTag);
1093  }
1094 
1095  if (m_endPoint == nullptr && m_endPoint6 == nullptr)
1096  {
1097  NS_LOG_WARN ("Failed to send empty packet due to null endpoint");
1098  return;
1099  }
1100  if (flags & TcpHeader::FIN)
1101  {
1102  flags |= TcpHeader::ACK;
1103  }
1104  else if (m_state == FIN_WAIT_1 || m_state == LAST_ACK || m_state == CLOSING)
1105  {
1106  ++s;
1107  }
1108 
1109  bool hasSyn = flags & TcpHeader::SYN;
1110  bool hasFin = flags & TcpHeader::FIN;
1111  bool isAck = flags == TcpHeader::ACK;
1112 
1113  header.SetFlags (flags);
1114  header.SetSequenceNumber (s);
1115 
1116  // Actual division in small acks.
1117  if (hasSyn || hasFin)
1118  {
1119  header.SetAckNumber (m_rxBuffer->NextRxSequence ());
1120  }
1121  else
1122  {
1123  SequenceNumber32 ackSeq;
1124 
1125  ackSeq = m_lastAckedSeq + m_bytesToAck;
1126 
1127  if (m_bytesLeftToBeAcked == 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1128  {
1129  m_bytesLeftToBeAcked = m_rxBuffer->NextRxSequence ().GetValue () - 1 - m_bytesToAck;
1130  }
1131  else if (m_bytesLeftToBeAcked > 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1132  {
1134  }
1135 
1136  NS_LOG_LOGIC ("Acking up to " << ackSeq << " remaining bytes: " << m_bytesLeftToBeAcked);
1137 
1138  header.SetAckNumber (ackSeq);
1139  m_lastAckedSeq = ackSeq;
1140  }
1141 
1142  // end of division in small acks
1143 
1144  if (m_endPoint != nullptr)
1145  {
1146  header.SetSourcePort (m_endPoint->GetLocalPort ());
1147  header.SetDestinationPort (m_endPoint->GetPeerPort ());
1148  }
1149  else
1150  {
1151  header.SetSourcePort (m_endPoint6->GetLocalPort ());
1152  header.SetDestinationPort (m_endPoint6->GetPeerPort ());
1153  }
1154  AddOptions (header);
1155  header.SetWindowSize (AdvertisedWindowSize ());
1156 
1157  // RFC 6298, clause 2.4
1158  m_rto = Max (m_rtt->GetEstimate () + Max (m_clockGranularity, m_rtt->GetVariation () * 4), m_minRto);
1159 
1160  if (hasSyn)
1161  {
1162  if (m_synCount == 0)
1163  { // No more connection retries, give up
1164  NS_LOG_LOGIC ("Connection failed.");
1165  m_rtt->Reset (); //According to recommendation -> RFC 6298
1166  CloseAndNotify ();
1167  return;
1168  }
1169  else
1170  { // Exponential backoff of connection time out
1171  int backoffCount = 0x1 << (m_synRetries - m_synCount);
1172  m_rto = m_cnTimeout * backoffCount;
1173  m_synCount--;
1174  }
1175  }
1176  if (m_endPoint != nullptr)
1177  {
1178  m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (),
1180  }
1181  else
1182  {
1183  m_tcp->SendPacket (p, header, m_endPoint6->GetLocalAddress (),
1185  }
1186 
1187  m_txTrace (p, header, this);
1188 
1189  if (flags & TcpHeader::ACK)
1190  { // If sending an ACK, cancel the delay ACK as well
1191  m_delAckEvent.Cancel ();
1192  m_delAckCount = 0;
1193  }
1194  if (m_retxEvent.IsExpired () && (hasSyn || hasFin) && !isAck )
1195  { // Retransmit SYN / SYN+ACK / FIN / FIN+ACK to guard against lost
1196  NS_LOG_LOGIC ("Schedule retransmission timeout at time "
1197  << Simulator::Now ().GetSeconds () << " to expire at time "
1198  << (Simulator::Now () + m_rto.Get ()).GetSeconds ());
1200  }
1201 
1202  // send another ACK if bytes remain
1203  if (m_bytesLeftToBeAcked > 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1204  {
1205  SendEmptyPacket (flags);
1206  }
1207 }
1208 
1211 {
1212  return CopyObject<TcpSocketSmallAcks> (this);
1213 }
1214 
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.
virtual void RtoTrace(Time oldValue, Time newValue)
RTO changes.
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:852
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:1015
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:821
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
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:355
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:572
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:1069
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
virtual void NextTxSeqTrace(SequenceNumber32 oldValue, SequenceNumber32 newValue)
Next tx seq changes.
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:1007
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.
virtual void HighestTxSeqTrace(SequenceNumber32 oldValue, SequenceNumber32 newValue)
Highest tx seq changes.
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.