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 "ns3/tcp-header.h"
32 #include "ns3/tcp-tx-buffer.h"
33 #include "ns3/tcp-rx-buffer.h"
34 #include "ns3/rtt-estimator.h"
35 
36 #include "tcp-general-test.h"
37 
38 using namespace ns3;
39 
40 NS_LOG_COMPONENT_DEFINE ("TcpGeneralTest");
41 
42 TcpGeneralTest::TcpGeneralTest (const std::string &desc)
43  : TestCase (desc),
44  m_congControlTypeId (TcpNewReno::GetTypeId ()),
45  m_recoveryTypeId (TcpClassicRecovery::GetTypeId ()),
46  m_remoteAddr (Ipv4Address::GetAny (), 4477)
47 {
48  NS_LOG_FUNCTION (this << desc);
49 }
50 
52 {
54 }
55 
56 void
58 {
59  NS_LOG_FUNCTION (this << socket);
60  Ptr<Packet> packet;
61  Address from;
62 
63  while ((packet = socket->RecvFrom (from)))
64  {
65  if (packet->GetSize () == 0)
66  { //EOF
67  break;
68  }
69  }
70 }
71 
72 void
73 TcpGeneralTest::SendPacket (Ptr<Socket> socket, uint32_t pktSize,
74  uint32_t pktCount, Time pktInterval )
75 {
76  NS_LOG_FUNCTION (this << " " << pktSize << " " << pktCount << " " <<
77  pktInterval.GetSeconds ());
78  if (pktCount > 0)
79  {
80  socket->Send (Create<Packet> (pktSize));
82  socket, pktSize, pktCount - 1, pktInterval);
83  }
84  else
85  {
86  socket->Close ();
87  }
88 }
89 
90 void
92 {
93  FinalChecks ();
94 
96  NS_LOG_INFO ("Done.");
97 }
98 
99 void
101 {
102  NS_LOG_FUNCTION (this);
103 
107  SetTransmitStart (Seconds (10));
108  SetAppPktSize (500);
109  SetAppPktCount (10);
111  SetMTU (1500);
112 }
113 
114 void
116 {
117  NS_LOG_FUNCTION (this);
118  SetInitialCwnd (SENDER, 1);
119  SetInitialSsThresh (SENDER, UINT32_MAX);
120  SetSegmentSize (SENDER, 500);
121  SetSegmentSize (RECEIVER, 500);
122 }
123 
124 void
126 {
128 
129  NS_LOG_INFO ("Create nodes.");
131  nodes.Create (2);
132 
133  InternetStackHelper internet;
134  internet.Install (nodes);
135 
137 
139 
140  SimpleNetDeviceHelper helperChannel;
141  helperChannel.SetNetDevicePointToPointMode (true);
142 
143  NetDeviceContainer net = helperChannel.Install (nodes, channel);
144 
147 
148  Ptr<SimpleNetDevice> senderDev = DynamicCast<SimpleNetDevice> (net.Get (0));
149  Ptr<SimpleNetDevice> receiverDev = DynamicCast<SimpleNetDevice> (net.Get (1));
150 
151  senderDev->SetMtu (m_mtu);
152  senderDev->GetQueue ()->TraceConnect ("Drop", "SENDER",
154  senderDev->TraceConnect ("PhyRxDrop", "sender",
156 
157  receiverDev->SetMtu (m_mtu);
158  receiverDev->GetQueue ()->TraceConnect ("Drop", "RECEIVER",
160  receiverDev->TraceConnect ("PhyRxDrop", "RECEIVER",
162 
163  senderDev->SetReceiveErrorModel (senderEM);
164  receiverDev->SetReceiveErrorModel (receiverEM);
165 
166  Ipv4AddressHelper ipv4;
167  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
168  Ipv4InterfaceContainer i = ipv4.Assign (net);
169  Ipv4Address serverAddress = i.GetAddress (1);
170  //Ipv4Address clientAddress = i.GetAddress (0);
171 
172  NS_LOG_INFO ("Create sockets.");
173  //Receiver socket on n1
175 
176  m_receiverSocket->SetRecvCallback (MakeCallback (&TcpGeneralTest::ReceivePacket, this));
177  m_receiverSocket->SetAcceptCallback (
178  MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
180  m_receiverSocket->SetCloseCallbacks (MakeCallback (&TcpGeneralTest::NormalCloseCb, this),
183  m_receiverSocket->SetProcessedAckCb (MakeCallback (&TcpGeneralTest::ProcessedAckCb, this));
184  m_receiverSocket->SetAfterRetransmitCb (MakeCallback (&TcpGeneralTest::AfterRetransmitCb, this));
185  m_receiverSocket->SetBeforeRetransmitCb (MakeCallback (&TcpGeneralTest::BeforeRetransmitCb, this));
187  m_receiverSocket->SetUpdateRttHistoryCb (MakeCallback (&TcpGeneralTest::UpdateRttHistoryCb, this));
188  m_receiverSocket->TraceConnectWithoutContext ("Tx",
190  m_receiverSocket->TraceConnectWithoutContext ("Rx",
192 
194  m_receiverSocket->Bind (local);
195 
197  m_senderSocket->SetCloseCallbacks (MakeCallback (&TcpGeneralTest::NormalCloseCb, this),
199  m_senderSocket->SetRcvAckCb (MakeCallback (&TcpGeneralTest::RcvAckCb, this));
200  m_senderSocket->SetProcessedAckCb (MakeCallback (&TcpGeneralTest::ProcessedAckCb, this));
201  m_senderSocket->SetAfterRetransmitCb (MakeCallback (&TcpGeneralTest::AfterRetransmitCb, this));
202  m_senderSocket->SetBeforeRetransmitCb (MakeCallback (&TcpGeneralTest::BeforeRetransmitCb, this));
203  m_senderSocket->SetDataSentCallback (MakeCallback (&TcpGeneralTest::DataSentCb, this));
204  m_senderSocket->SetUpdateRttHistoryCb (MakeCallback (&TcpGeneralTest::UpdateRttHistoryCb, this));
205  m_senderSocket->TraceConnectWithoutContext ("CongestionWindow",
207  m_senderSocket->TraceConnectWithoutContext ("CongestionWindowInflated",
209  m_senderSocket->TraceConnectWithoutContext ("SlowStartThreshold",
211  m_senderSocket->TraceConnectWithoutContext ("CongState",
213  m_senderSocket->TraceConnectWithoutContext ("Tx",
215  m_senderSocket->TraceConnectWithoutContext ("Rx",
217  m_senderSocket->TraceConnectWithoutContext ("RTT",
219  m_senderSocket->TraceConnectWithoutContext ("BytesInFlight",
221  m_senderSocket->TraceConnectWithoutContext ("RTO",
223  m_senderSocket->TraceConnectWithoutContext ("NextTxSequence",
225  m_senderSocket->TraceConnectWithoutContext ("HighestSequence",
227 
228 
229  m_remoteAddr = InetSocketAddress (serverAddress, 4477);
230 
232 
233  m_receiverSocket->Listen ();
234  m_receiverSocket->ShutdownSend ();
235 
238  Simulator::ScheduleWithContext (nodes.Get (0)->GetId (),
241 
242  NS_LOG_INFO ("Run Simulation.");
243  Simulator::Run ();
244 }
245 
246 void
248 {
249  NS_LOG_INFO (this);
250  m_senderSocket->Connect (m_remoteAddr);
251 }
252 
253 void
255 {
256  (void) from;
260 
261 }
262 
265 {
266  Ptr<SimpleChannel> ch = CreateObject <SimpleChannel> ();
267 
268  ch->SetAttribute ("Delay", TimeValue (m_propagationDelay));
269 
270  return ch;
271 }
272 
275  TypeId congControl)
276 {
277  return CreateSocket (node, socketType, congControl, m_recoveryTypeId);
278 }
279 
282  TypeId congControl, TypeId recoveryAlgorithm)
283 {
284  ObjectFactory rttFactory;
285  ObjectFactory congestionAlgorithmFactory;
286  ObjectFactory recoveryAlgorithmFactory;
287  ObjectFactory socketFactory;
288 
289  rttFactory.SetTypeId (RttMeanDeviation::GetTypeId ());
290  congestionAlgorithmFactory.SetTypeId (congControl);
291  recoveryAlgorithmFactory.SetTypeId (recoveryAlgorithm);
292  socketFactory.SetTypeId (socketType);
293 
294  Ptr<RttEstimator> rtt = rttFactory.Create<RttEstimator> ();
295  Ptr<TcpSocketMsgBase> socket = DynamicCast<TcpSocketMsgBase> (socketFactory.Create ());
296  Ptr<TcpCongestionOps> algo = congestionAlgorithmFactory.Create<TcpCongestionOps> ();
297  Ptr<TcpRecoveryOps> recovery = recoveryAlgorithmFactory.Create<TcpRecoveryOps> ();
298 
299  socket->SetNode (node);
300  socket->SetTcp (node->GetObject<TcpL4Protocol> ());
301  socket->SetRtt (rtt);
302  socket->SetCongestionControlAlgorithm (algo);
303  socket->SetRecoveryAlgorithm (recovery);
304  return socket;
305 }
306 
309 {
310  return nullptr;
311 }
312 
315 {
316  return nullptr;
317 }
318 
321 {
323 }
324 
327 {
329 }
330 
331 void
333 {
334  if (context.compare ("SENDER") == 0)
335  {
336  QueueDrop (SENDER);
337  }
338  else if (context.compare ("RECEIVER") == 0)
339  {
341  }
342  else
343  {
344  NS_FATAL_ERROR ("Packet dropped in a queue, but queue not recognized");
345  }
346 }
347 
348 void
350 {
351  NS_UNUSED (p);
352  if (context.compare ("SENDER") == 0)
353  {
354  PhyDrop (SENDER);
355  }
356  else if (context.compare ("RECEIVER") == 0)
357  {
358  PhyDrop (RECEIVER);
359  }
360  else
361  {
362  NS_FATAL_ERROR ("Packet dropped in a queue, but queue not recognized");
363  }
364 }
365 
366 void
368 {
369  if (socket->GetNode () == m_receiverSocket->GetNode ())
370  {
372  }
373  else if (socket->GetNode () == m_senderSocket->GetNode ())
374  {
376  }
377  else
378  {
379  NS_FATAL_ERROR ("Closed socket, but not recognized");
380  }
381 }
382 
383 void
385  const SequenceNumber32 & seq, uint32_t sz,
386  bool isRetransmission)
387 {
388  if (tcp->GetNode () == m_receiverSocket->GetNode ())
389  {
390  UpdatedRttHistory (seq, sz, isRetransmission, RECEIVER);
391  }
392  else if (tcp->GetNode () == m_senderSocket->GetNode ())
393  {
394  UpdatedRttHistory (seq, sz, isRetransmission, SENDER);
395  }
396  else
397  {
398  NS_FATAL_ERROR ("Closed socket, but not recognized");
399  }
400 }
401 
402 void
404  const Ptr<const TcpSocketBase> tcp)
405 {
406  if (tcp->GetNode () == m_receiverSocket->GetNode ())
407  {
408  AfterRTOExpired (tcb, RECEIVER);
409  }
410  else if (tcp->GetNode () == m_senderSocket->GetNode ())
411  {
412  AfterRTOExpired (tcb, SENDER);
413  }
414  else
415  {
416  NS_FATAL_ERROR ("Closed socket, but not recognized");
417  }
418 }
419 
420 void
422  const Ptr<const TcpSocketBase> tcp)
423 {
424  if (tcp->GetNode () == m_receiverSocket->GetNode ())
425  {
426  BeforeRTOExpired (tcb, RECEIVER);
427  }
428  else if (tcp->GetNode () == m_senderSocket->GetNode ())
429  {
430  BeforeRTOExpired (tcb, SENDER);
431  }
432  else
433  {
434  NS_FATAL_ERROR ("Closed socket, but not recognized");
435  }
436 }
437 
438 void
440 {
441  if (socket->GetNode () == m_receiverSocket->GetNode ())
442  {
443  DataSent (size, RECEIVER);
444  }
445  else if (socket->GetNode () == m_senderSocket->GetNode ())
446  {
447  DataSent (size, SENDER);
448  }
449  else
450  {
451  NS_FATAL_ERROR ("Closed socket, but not recognized");
452  }
453 }
454 
455 void
457 {
458  if (socket->GetNode () == m_receiverSocket->GetNode ())
459  {
461  }
462  else if (socket->GetNode () == m_senderSocket->GetNode ())
463  {
464  ErrorClose (SENDER);
465  }
466  else
467  {
468  NS_FATAL_ERROR ("Closed socket, but not recognized");
469  }
470 }
471 
472 void
474 {
475  NS_LOG_FUNCTION (this << p << h << who);
476 }
477 
478 void
480 {
481  NS_LOG_FUNCTION (this << p << h << who);
482 }
483 
484 void
486  const Ptr<const TcpSocketBase> tcp)
487 {
488  if (tcp->GetNode () == m_receiverSocket->GetNode ())
489  {
490  RcvAck (tcp->m_tcb, h, RECEIVER);
491  }
492  else if (tcp->GetNode () == m_senderSocket->GetNode ())
493  {
494  RcvAck (tcp->m_tcb, h, SENDER);
495  }
496  else
497  {
498  NS_FATAL_ERROR ("Received ACK but socket not recognized");
499  }
500 }
501 
502 void
504  const TcpHeader &h, const Ptr<const TcpSocketBase> tcp)
505 {
506  if (tcp->GetNode () == m_receiverSocket->GetNode ())
507  {
508  Tx (p, h, RECEIVER);
509  }
510  else if (tcp->GetNode () == m_senderSocket->GetNode ())
511  {
512  Tx (p, h, SENDER);
513  }
514  else
515  {
516  NS_FATAL_ERROR ("Received ACK but socket not recognized");
517  }
518 }
519 
520 void
522  const Ptr<const TcpSocketBase> tcp)
523 {
524  if (tcp->GetNode () == m_receiverSocket->GetNode ())
525  {
526  Rx (p, h, RECEIVER);
527  }
528  else if (tcp->GetNode () == m_senderSocket->GetNode ())
529  {
530  Rx (p, h, SENDER);
531  }
532  else
533  {
534  NS_FATAL_ERROR ("Received ACK but socket not recognized");
535  }
536 }
537 
538 void
541 {
542  if (tcp->GetNode () == m_receiverSocket->GetNode ())
543  {
544  ProcessedAck (tcp->m_tcb, h, RECEIVER);
545  }
546  else if (tcp->GetNode () == m_senderSocket->GetNode ())
547  {
548  ProcessedAck (tcp->m_tcb, h, SENDER);
549  }
550  else
551  {
552  NS_FATAL_ERROR ("Received ACK but socket not recognized");
553  }
554 }
555 
556 void
558 {
559  NS_LOG_FUNCTION (this << tcp);
560 
561  m_receiverSocket = tcp;
562 }
563 
564 uint32_t
566 {
567  if (who == SENDER)
568  {
569  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_retxThresh;
570  }
571  else if (who == RECEIVER)
572  {
573  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_retxThresh;
574  }
575  else
576  {
577  NS_FATAL_ERROR ("Not defined");
578  }
579 }
580 
581 uint32_t
583 {
584  if (who == SENDER)
585  {
586  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_dupAckCount;
587  }
588  else if (who == RECEIVER)
589  {
590  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_dupAckCount;
591  }
592  else
593  {
594  NS_FATAL_ERROR ("Not defined");
595  }
596 }
597 
598 uint32_t
600 {
601  if (who == SENDER)
602  {
603  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_delAckMaxCount;
604  }
605  else if (who == RECEIVER)
606  {
607  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_delAckMaxCount;
608  }
609  else
610  {
611  NS_FATAL_ERROR ("Not defined");
612  }
613 }
614 
615 Time
617 {
618  if (who == SENDER)
619  {
620  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetDelAckTimeout ();
621  }
622  else if (who == RECEIVER)
623  {
624  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetDelAckTimeout ();
625  }
626  else
627  {
628  NS_FATAL_ERROR ("Not defined");
629  }
630 }
631 
632 uint32_t
634 {
635  if (who == SENDER)
636  {
637  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetSegSize ();
638  }
639  else if (who == RECEIVER)
640  {
641  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetSegSize ();
642  }
643  else
644  {
645  NS_FATAL_ERROR ("Not defined");
646  }
647 }
648 
651 {
652  return GetTcb (who)->m_highTxMark;
653 }
654 
655 uint32_t
657 {
658  if (who == SENDER)
659  {
660  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetInitialCwnd ();
661  }
662  else if (who == RECEIVER)
663  {
664  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetInitialCwnd ();
665  }
666  else
667  {
668  NS_FATAL_ERROR ("Not defined");
669  }
670 }
671 
672 uint32_t
674 {
675  if (who == SENDER)
676  {
677  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetInitialSSThresh ();
678  }
679  else if (who == RECEIVER)
680  {
681  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetInitialSSThresh ();
682  }
683  else
684  {
685  NS_FATAL_ERROR ("Not defined");
686  }
687 }
688 
689 Time
691 {
692  if (who == SENDER)
693  {
694  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rto.Get ();
695  }
696  else if (who == RECEIVER)
697  {
698  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rto.Get ();
699  }
700  else
701  {
702  NS_FATAL_ERROR ("Not defined");
703  }
704 }
705 
706 Time
708 {
709  if (who == SENDER)
710  {
711  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_minRto;
712  }
713  else if (who == RECEIVER)
714  {
715  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_minRto;
716  }
717  else
718  {
719  NS_FATAL_ERROR ("Not defined");
720  }
721 }
722 
723 Time
725 {
726  if (who == SENDER)
727  {
728  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_cnTimeout;
729  }
730  else if (who == RECEIVER)
731  {
732  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_cnTimeout;
733  }
734  else
735  {
736  NS_FATAL_ERROR ("Not defined");
737  }
738 }
739 
742 {
743  if (who == SENDER)
744  {
745  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rtt;
746  }
747  else if (who == RECEIVER)
748  {
749  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rtt;
750  }
751  else
752  {
753  NS_FATAL_ERROR ("Not defined");
754  }
755 }
756 
757 Time
759 {
760  if (who == SENDER)
761  {
762  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_clockGranularity;
763  }
764  else if (who == RECEIVER)
765  {
766  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_clockGranularity;
767  }
768  else
769  {
770  NS_FATAL_ERROR ("Not defined");
771  }
772 }
773 
776 {
777  if (who == SENDER)
778  {
779  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_state.Get ();
780  }
781  else if (who == RECEIVER)
782  {
783 
784  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_state.Get ();
785  }
786  else
787  {
788  NS_FATAL_ERROR ("Not defined");
789  }
790 }
791 
792 uint32_t
794 {
795  if (who == SENDER)
796  {
797  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rWnd.Get ();
798  }
799  else if (who == RECEIVER)
800  {
801 
802  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rWnd.Get ();
803  }
804  else
805  {
806  NS_FATAL_ERROR ("Not defined");
807  }
808 }
809 
810 EventId
812 {
813  if (who == SENDER)
814  {
815  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_persistEvent;
816  }
817  else if (who == RECEIVER)
818  {
819 
820  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_persistEvent;
821  }
822  else
823  {
824  NS_FATAL_ERROR ("Not defined");
825  }
826 }
827 
828 Time
830 {
831  if (who == SENDER)
832  {
833  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_persistTimeout;
834  }
835  else if (who == RECEIVER)
836  {
837 
838  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_persistTimeout;
839  }
840  else
841  {
842  NS_FATAL_ERROR ("Not defined");
843  }
844 }
845 
848 {
849  if (who == SENDER)
850  {
851  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_tcb;
852  }
853  else if (who == RECEIVER)
854  {
855 
856  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_tcb;
857  }
858  else
859  {
860  NS_FATAL_ERROR ("Not defined");
861  }
862 }
863 
866 {
867  if (who == SENDER)
868  {
869  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rxBuffer;
870  }
871  else if (who == RECEIVER)
872  {
873 
874  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rxBuffer;
875  }
876  else
877  {
878  NS_FATAL_ERROR ("Not defined");
879  }
880 }
881 
884  {
885  if (who == SENDER)
886  {
887  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_txBuffer;
888  }
889  else if (who == RECEIVER)
890  {
891  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_txBuffer;
892  }
893  else
894  {
895  NS_FATAL_ERROR ("Not defined");
896  }
897  }
898 
899 
900 void
902 {
903  if (who == SENDER)
904  {
905  m_senderSocket->SetRcvBufSize (size);
906  }
907  else if (who == RECEIVER)
908  {
909  m_receiverSocket->SetRcvBufSize (size);
910  }
911  else
912  {
913  NS_FATAL_ERROR ("Not defined");
914  }
915 }
916 
917 void
918 TcpGeneralTest::SetSegmentSize (SocketWho who, uint32_t segmentSize)
919 {
920  if (who == SENDER)
921  {
922  m_senderSocket->SetSegSize (segmentSize);
923  }
924  else if (who == RECEIVER)
925  {
926  m_receiverSocket->SetSegSize (segmentSize);
927  }
928  else
929  {
930  NS_FATAL_ERROR ("Not defined");
931  }
932 }
933 
934 void
935 TcpGeneralTest::SetInitialCwnd (SocketWho who, uint32_t initialCwnd)
936 {
937  if (who == SENDER)
938  {
939  m_senderSocket->SetInitialCwnd (initialCwnd);
940  }
941  else if (who == RECEIVER)
942  {
943  m_receiverSocket->SetInitialCwnd (initialCwnd);
944  }
945  else
946  {
947  NS_FATAL_ERROR ("Not defined");
948  }
949 }
950 void
952 {
953  if (who == SENDER)
954  {
955  m_senderSocket->SetEcn (ecnMode);
956  }
957  else if (who == RECEIVER)
958  {
959  m_receiverSocket->SetEcn (ecnMode);
960  }
961  else
962  {
963  NS_FATAL_ERROR ("Not defined");
964  }
965 }
966 
967 void
968 TcpGeneralTest::SetInitialSsThresh (SocketWho who, uint32_t initialSsThresh)
969 {
970  if (who == SENDER)
971  {
972  m_senderSocket->SetInitialSSThresh (initialSsThresh);
973  }
974  else if (who == RECEIVER)
975  {
976  m_receiverSocket->SetInitialSSThresh (initialSsThresh);
977  }
978  else
979  {
980  NS_FATAL_ERROR ("Not defined");
981  }
982 }
983 
985 
986 TypeId
988 {
989  static TypeId tid = TypeId ("ns3::TcpSocketMsgBase")
991  .SetGroupName ("Internet")
992  .AddConstructor<TcpSocketMsgBase> ()
993  ;
994  return tid;
995 }
996 
999 {
1000  return CopyObject<TcpSocketMsgBase> (this);
1001 }
1002 
1003 void
1005 {
1006  NS_ASSERT (!cb.IsNull ());
1007  m_rcvAckCb = cb;
1008 }
1009 
1010 void
1012 {
1013  NS_ASSERT (!cb.IsNull ());
1014  m_processedAckCb = cb;
1015 }
1016 
1017 void
1019 {
1020  NS_ASSERT (!cb.IsNull ());
1021  m_afterRetrCallback = cb;
1022 }
1023 
1024 void
1026 {
1027  NS_ASSERT (!cb.IsNull ());
1028  m_beforeRetrCallback = cb;
1029 }
1030 
1031 void
1033 {
1035  m_rcvAckCb (packet, tcpHeader, this);
1036 
1037  TcpSocketBase::ReceivedAck (packet, tcpHeader);
1038 
1039  m_processedAckCb (packet, tcpHeader, this);
1040 }
1041 
1042 void
1044 {
1045  m_beforeRetrCallback (m_tcb, this);
1047  m_afterRetrCallback (m_tcb, this);
1048 }
1049 
1050 void
1052 {
1053  NS_ASSERT (!cb.IsNull ());
1054  m_forkCb = cb;
1055 }
1056 
1057 void
1059 {
1060  NS_ASSERT (!cb.IsNull ());
1061  m_updateRttCb = cb;
1062 }
1063 
1064 void
1066  bool isRetransmission)
1067 {
1068  TcpSocketBase::UpdateRttHistory (seq, sz, isRetransmission);
1069  if (!m_updateRttCb.IsNull ())
1070  {
1071  m_updateRttCb (this, seq, sz, isRetransmission);
1072  }
1073 }
1074 
1075 void
1077  const Address &fromAddress, const Address &toAddress)
1078 {
1079  TcpSocketBase::CompleteFork (p, tcpHeader, fromAddress, toAddress);
1080 
1081  if (!m_forkCb.IsNull ())
1082  {
1083  m_forkCb (this);
1084  }
1085 }
1086 
1088 
1089 TypeId
1091 {
1092  static TypeId tid = TypeId ("ns3::TcpSocketSmallAcks")
1094  .SetGroupName ("Internet")
1095  .AddConstructor<TcpSocketSmallAcks> ()
1096  ;
1097  return tid;
1098 }
1099 
1100 /*
1101  * Send empty packet, copied/pasted from TcpSocketBase
1102  *
1103  * The rationale for copying/pasting is that we need to edit a little the
1104  * code inside. Since there isn't a well-defined division of duties,
1105  * we are forced to do this.
1106  */
1107 void
1109 {
1110  Ptr<Packet> p = Create<Packet> ();
1111  TcpHeader header;
1113 
1114  /*
1115  * Add tags for each socket option.
1116  * Note that currently the socket adds both IPv4 tag and IPv6 tag
1117  * if both options are set. Once the packet got to layer three, only
1118  * the corresponding tags will be read.
1119  */
1120  if (GetIpTos ())
1121  {
1122  SocketIpTosTag ipTosTag;
1123  ipTosTag.SetTos (GetIpTos ());
1124  p->AddPacketTag (ipTosTag);
1125  }
1126 
1127  if (IsManualIpv6Tclass ())
1128  {
1129  SocketIpv6TclassTag ipTclassTag;
1130  ipTclassTag.SetTclass (GetIpv6Tclass ());
1131  p->AddPacketTag (ipTclassTag);
1132  }
1133 
1134  if (IsManualIpTtl ())
1135  {
1136  SocketIpTtlTag ipTtlTag;
1137  ipTtlTag.SetTtl (GetIpTtl ());
1138  p->AddPacketTag (ipTtlTag);
1139  }
1140 
1141  if (IsManualIpv6HopLimit ())
1142  {
1143  SocketIpv6HopLimitTag ipHopLimitTag;
1144  ipHopLimitTag.SetHopLimit (GetIpv6HopLimit ());
1145  p->AddPacketTag (ipHopLimitTag);
1146  }
1147 
1148  if (m_endPoint == nullptr && m_endPoint6 == nullptr)
1149  {
1150  NS_LOG_WARN ("Failed to send empty packet due to null endpoint");
1151  return;
1152  }
1153  if (flags & TcpHeader::FIN)
1154  {
1155  flags |= TcpHeader::ACK;
1156  }
1157  else if (m_state == FIN_WAIT_1 || m_state == LAST_ACK || m_state == CLOSING)
1158  {
1159  ++s;
1160  }
1161 
1162  bool hasSyn = flags & TcpHeader::SYN;
1163  bool hasFin = flags & TcpHeader::FIN;
1164  bool isAck = flags == TcpHeader::ACK;
1165 
1166  header.SetFlags (flags);
1167  header.SetSequenceNumber (s);
1168 
1169  // Actual division in small acks.
1170  if (hasSyn || hasFin)
1171  {
1172  header.SetAckNumber (m_rxBuffer->NextRxSequence ());
1173  }
1174  else
1175  {
1176  SequenceNumber32 ackSeq;
1177 
1178  ackSeq = m_lastAckedSeq + m_bytesToAck;
1179 
1180  if (m_bytesLeftToBeAcked == 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1181  {
1182  m_bytesLeftToBeAcked = m_rxBuffer->NextRxSequence ().GetValue () - 1 - m_bytesToAck;
1183  }
1184  else if (m_bytesLeftToBeAcked > 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1185  {
1187  }
1188 
1189  NS_LOG_LOGIC ("Acking up to " << ackSeq << " remaining bytes: " << m_bytesLeftToBeAcked);
1190 
1191  header.SetAckNumber (ackSeq);
1192  m_lastAckedSeq = ackSeq;
1193  }
1194 
1195  // end of division in small acks
1196 
1197  if (m_endPoint != nullptr)
1198  {
1199  header.SetSourcePort (m_endPoint->GetLocalPort ());
1200  header.SetDestinationPort (m_endPoint->GetPeerPort ());
1201  }
1202  else
1203  {
1204  header.SetSourcePort (m_endPoint6->GetLocalPort ());
1205  header.SetDestinationPort (m_endPoint6->GetPeerPort ());
1206  }
1207  AddOptions (header);
1208  header.SetWindowSize (AdvertisedWindowSize ());
1209 
1210  // RFC 6298, clause 2.4
1211  m_rto = Max (m_rtt->GetEstimate () + Max (m_clockGranularity, m_rtt->GetVariation () * 4), m_minRto);
1212 
1213  if (hasSyn)
1214  {
1215  if (m_synCount == 0)
1216  { // No more connection retries, give up
1217  NS_LOG_LOGIC ("Connection failed.");
1218  m_rtt->Reset (); //According to recommendation -> RFC 6298
1219  CloseAndNotify ();
1220  return;
1221  }
1222  else
1223  { // Exponential backoff of connection time out
1224  int backoffCount = 0x1 << (m_synRetries - m_synCount);
1225  m_rto = m_cnTimeout * backoffCount;
1226  m_synCount--;
1227  }
1228  }
1229  if (m_endPoint != nullptr)
1230  {
1231  m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (),
1233  }
1234  else
1235  {
1236  m_tcp->SendPacket (p, header, m_endPoint6->GetLocalAddress (),
1238  }
1239 
1240  m_txTrace (p, header, this);
1241 
1242  if (flags & TcpHeader::ACK)
1243  { // If sending an ACK, cancel the delay ACK as well
1244  m_delAckEvent.Cancel ();
1245  m_delAckCount = 0;
1246  }
1247  if (m_retxEvent.IsExpired () && (hasSyn || hasFin) && !isAck )
1248  { // Retransmit SYN / SYN+ACK / FIN / FIN+ACK to guard against lost
1249  NS_LOG_LOGIC ("Schedule retransmission timeout at time "
1250  << Simulator::Now ().GetSeconds () << " to expire at time "
1251  << (Simulator::Now () + m_rto.Get ()).GetSeconds ());
1253  }
1254 
1255  // send another ACK if bytes remain
1256  if (m_bytesLeftToBeAcked > 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1257  {
1258  SendEmptyPacket (flags);
1259  }
1260 }
1261 
1264 {
1265  return CopyObject<TcpSocketSmallAcks> (this);
1266 }
1267 
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&#39;s Tclass.
Definition: socket.cc:900
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.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
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.
RetrCb m_afterRetrCallback
After retransmission callback.
Class for inserting callbacks special points of the flow of TCP sockets.
This class implements a tag that carries the socket-specific HOPLIMIT of a packet to the IPv6 layer...
Definition: socket.h:1163
Ipv4EndPoint * m_endPoint
the IPv4 endpoint
#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<Ipv4> and interface index.
virtual void DoTeardown(void)
Teardown the TCP test.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
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.
uint32_t GetRWnd(SocketWho who)
Get the rWnd of the selected socket.
void SetCongestionControl(TypeId congControl)
Congestion control of the sender socket.
void SetRecoveryAlgorithm(TypeId reccovery)
recovery algorithm 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.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:355
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:170
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:204
Ptr< TcpSocketState > m_tcb
Congestion control information.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1070
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.
#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:280
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
Time m_cnTimeout
Timeout for connection retry.
Time GetMinRto(SocketWho who)
Get the minimum RTO attribute.
recovery abstract class
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&#39;s TOS.
Definition: socket.cc:785
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)
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer...
Definition: socket.h:1115
virtual void CWndInflTrace(uint32_t oldValue, uint32_t newValue)
Tracks the inflated congestion window changes.
TracedValue< TcpStates_t > m_state
TCP state.
virtual void ReceivedAck(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received an ACK packet.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:59
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.
channel
Definition: third.py:85
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.
virtual uint8_t GetIpTtl(void) const
Query the value of IP Time to Live field of this socket.
Definition: socket.cc:520
void SetUpdateRttHistoryCb(UpdateRttCallback cb)
Set the callback invoked when we update rtt history.
virtual Ptr< TcpSocketBase > Fork(void)
Call CopyObject<> to clone me.
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.
TypeId m_recoveryTypeId
Recovery.
nodes
Definition: first.py:25
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1389
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&#39;s TTL.
Definition: socket.cc:604
AttributeValue implementation for Time.
Definition: nstime.h:1124
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
uint16_t GetLocalPort()
Get the local port.
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)
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
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&#39;s Hop Limit.
Definition: socket.cc:665
void DataSentCb(Ptr< Socket > socket, uint32_t size)
Data sent Callback.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:134
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.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:459
void ProcessedAckCb(Ptr< const Packet > p, const TcpHeader &h, Ptr< const TcpSocketBase > tcp)
ACK processed Callback.
virtual Ptr< TcpSocketMsgBase > CreateSocket(Ptr< Node > node, TypeId socketType, TypeId congControl)
Create a socket.
void SetEcn(SocketWho who, TcpSocketBase::EcnMode_t ecnMode)
Forcefully set the ecn mode on.
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.
bool IsManualIpv6Tclass(void) const
Checks if the socket has a specific IPv6 Tclass set.
Definition: socket.cc:371
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:1354
void SetAppPktCount(uint32_t pktCount)
Set app packet count.
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.
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:193
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 environment.
uint8_t GetIpv6Tclass(void) const
Query the value of IPv6 Traffic Class field of this socket.
Definition: socket.cc:495
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
bool IsManualIpv6HopLimit(void) const
Checks if the socket has a specific IPv6 Hop Limit set.
Definition: socket.cc:383
virtual void CompleteFork(Ptr< Packet > p, const TcpHeader &tcpHeader, const Address &fromAddress, const Address &toAddress)
Complete a connection by forking the socket.
SocketWho
Used as parameter of methods, specifies on what node the caller is interested (e.g.
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:1483
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:1076
TracedValue< Time > m_rto
Retransmit timeout.
An identifier for simulation events.
Definition: event-id.h:53
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:863
uint16_t GetLocalPort(void)
Get the local port.
void PhyDropCb(std::string context, Ptr< const Packet > p)
Drop at Phy layer Callback.
virtual uint16_t AdvertisedWindowSize(bool scale=true) const
The amount of Rx window announced to the peer.
virtual uint8_t GetIpv6HopLimit(void) const
Query the value of IP Hop Limit field of this socket.
Definition: socket.cc:545
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:264
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
T Get(void) const
Get the underlying value.
Definition: traced-value.h:218
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1062
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.
The Classic recovery implementation.
uint32_t m_bytesLeftToBeAcked
Number of bytes to be ACKed left.
Time GetPersistentTimeout(SocketWho who)
Get the persistent timeout of the selected socket.
Ptr< TcpTxBuffer > GetTxBuffer(SocketWho who)
Get the Tx buffer from 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< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
virtual Ptr< Node > GetNode(void) const
Return the node this socket is associated with.
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.
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1270
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
uint32_t m_bytesToAck
Number of bytes to be ACKed.
indicates whether the socket has IP_TOS set.
Definition: socket.h:1261
bool IsManualIpTtl(void) const
Checks if the socket has a specific IPv4 TTL set.
Definition: socket.cc:377
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
uint8_t GetIpTos(void) const
Query the value of IP Type of Service of this socket.
Definition: socket.cc:453
Ptr< Queue< Packet > > GetQueue(void) const
Get a copy of the attached Queue.
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:915
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.
TypeId m_congControlTypeId
Congestion control.
Time GetRto(SocketWho who)
Get the retransmission time.