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 
882 void
884 {
885  if (who == SENDER)
886  {
887  m_senderSocket->SetRcvBufSize (size);
888  }
889  else if (who == RECEIVER)
890  {
891  m_receiverSocket->SetRcvBufSize (size);
892  }
893  else
894  {
895  NS_FATAL_ERROR ("Not defined");
896  }
897 }
898 
899 void
900 TcpGeneralTest::SetSegmentSize (SocketWho who, uint32_t segmentSize)
901 {
902  if (who == SENDER)
903  {
904  m_senderSocket->SetSegSize (segmentSize);
905  }
906  else if (who == RECEIVER)
907  {
908  m_receiverSocket->SetSegSize (segmentSize);
909  }
910  else
911  {
912  NS_FATAL_ERROR ("Not defined");
913  }
914 }
915 
916 void
917 TcpGeneralTest::SetInitialCwnd (SocketWho who, uint32_t initialCwnd)
918 {
919  if (who == SENDER)
920  {
921  m_senderSocket->SetInitialCwnd (initialCwnd);
922  }
923  else if (who == RECEIVER)
924  {
925  m_receiverSocket->SetInitialCwnd (initialCwnd);
926  }
927  else
928  {
929  NS_FATAL_ERROR ("Not defined");
930  }
931 }
932 void
934 {
935  if (who == SENDER)
936  {
937  m_senderSocket->SetEcn (ecnMode);
938  }
939  else if (who == RECEIVER)
940  {
941  m_receiverSocket->SetEcn (ecnMode);
942  }
943  else
944  {
945  NS_FATAL_ERROR ("Not defined");
946  }
947 }
948 
949 void
950 TcpGeneralTest::SetInitialSsThresh (SocketWho who, uint32_t initialSsThresh)
951 {
952  if (who == SENDER)
953  {
954  m_senderSocket->SetInitialSSThresh (initialSsThresh);
955  }
956  else if (who == RECEIVER)
957  {
958  m_receiverSocket->SetInitialSSThresh (initialSsThresh);
959  }
960  else
961  {
962  NS_FATAL_ERROR ("Not defined");
963  }
964 }
965 
967 
968 TypeId
970 {
971  static TypeId tid = TypeId ("ns3::TcpSocketMsgBase")
973  .SetGroupName ("Internet")
974  .AddConstructor<TcpSocketMsgBase> ()
975  ;
976  return tid;
977 }
978 
981 {
982  return CopyObject<TcpSocketMsgBase> (this);
983 }
984 
985 void
987 {
988  NS_ASSERT (!cb.IsNull ());
989  m_rcvAckCb = cb;
990 }
991 
992 void
994 {
995  NS_ASSERT (!cb.IsNull ());
996  m_processedAckCb = cb;
997 }
998 
999 void
1001 {
1002  NS_ASSERT (!cb.IsNull ());
1003  m_afterRetrCallback = cb;
1004 }
1005 
1006 void
1008 {
1009  NS_ASSERT (!cb.IsNull ());
1010  m_beforeRetrCallback = cb;
1011 }
1012 
1013 void
1015 {
1017  m_rcvAckCb (packet, tcpHeader, this);
1018 
1019  TcpSocketBase::ReceivedAck (packet, tcpHeader);
1020 
1021  m_processedAckCb (packet, tcpHeader, this);
1022 }
1023 
1024 void
1026 {
1027  m_beforeRetrCallback (m_tcb, this);
1029  m_afterRetrCallback (m_tcb, this);
1030 }
1031 
1032 void
1034 {
1035  NS_ASSERT (!cb.IsNull ());
1036  m_forkCb = cb;
1037 }
1038 
1039 void
1041 {
1042  NS_ASSERT (!cb.IsNull ());
1043  m_updateRttCb = cb;
1044 }
1045 
1046 void
1048  bool isRetransmission)
1049 {
1050  TcpSocketBase::UpdateRttHistory (seq, sz, isRetransmission);
1051  if (!m_updateRttCb.IsNull ())
1052  {
1053  m_updateRttCb (this, seq, sz, isRetransmission);
1054  }
1055 }
1056 
1057 void
1059  const Address &fromAddress, const Address &toAddress)
1060 {
1061  TcpSocketBase::CompleteFork (p, tcpHeader, fromAddress, toAddress);
1062 
1063  if (!m_forkCb.IsNull ())
1064  {
1065  m_forkCb (this);
1066  }
1067 }
1068 
1070 
1071 TypeId
1073 {
1074  static TypeId tid = TypeId ("ns3::TcpSocketSmallAcks")
1076  .SetGroupName ("Internet")
1077  .AddConstructor<TcpSocketSmallAcks> ()
1078  ;
1079  return tid;
1080 }
1081 
1082 /*
1083  * Send empty packet, copied/pasted from TcpSocketBase
1084  *
1085  * The rationale for copying/pasting is that we need to edit a little the
1086  * code inside. Since there isn't a well-defined division of duties,
1087  * we are forced to do this.
1088  */
1089 void
1091 {
1092  Ptr<Packet> p = Create<Packet> ();
1093  TcpHeader header;
1095 
1096  /*
1097  * Add tags for each socket option.
1098  * Note that currently the socket adds both IPv4 tag and IPv6 tag
1099  * if both options are set. Once the packet got to layer three, only
1100  * the corresponding tags will be read.
1101  */
1102  if (GetIpTos ())
1103  {
1104  SocketIpTosTag ipTosTag;
1105  ipTosTag.SetTos (GetIpTos ());
1106  p->AddPacketTag (ipTosTag);
1107  }
1108 
1109  if (IsManualIpv6Tclass ())
1110  {
1111  SocketIpv6TclassTag ipTclassTag;
1112  ipTclassTag.SetTclass (GetIpv6Tclass ());
1113  p->AddPacketTag (ipTclassTag);
1114  }
1115 
1116  if (IsManualIpTtl ())
1117  {
1118  SocketIpTtlTag ipTtlTag;
1119  ipTtlTag.SetTtl (GetIpTtl ());
1120  p->AddPacketTag (ipTtlTag);
1121  }
1122 
1123  if (IsManualIpv6HopLimit ())
1124  {
1125  SocketIpv6HopLimitTag ipHopLimitTag;
1126  ipHopLimitTag.SetHopLimit (GetIpv6HopLimit ());
1127  p->AddPacketTag (ipHopLimitTag);
1128  }
1129 
1130  if (m_endPoint == nullptr && m_endPoint6 == nullptr)
1131  {
1132  NS_LOG_WARN ("Failed to send empty packet due to null endpoint");
1133  return;
1134  }
1135  if (flags & TcpHeader::FIN)
1136  {
1137  flags |= TcpHeader::ACK;
1138  }
1139  else if (m_state == FIN_WAIT_1 || m_state == LAST_ACK || m_state == CLOSING)
1140  {
1141  ++s;
1142  }
1143 
1144  bool hasSyn = flags & TcpHeader::SYN;
1145  bool hasFin = flags & TcpHeader::FIN;
1146  bool isAck = flags == TcpHeader::ACK;
1147 
1148  header.SetFlags (flags);
1149  header.SetSequenceNumber (s);
1150 
1151  // Actual division in small acks.
1152  if (hasSyn || hasFin)
1153  {
1154  header.SetAckNumber (m_rxBuffer->NextRxSequence ());
1155  }
1156  else
1157  {
1158  SequenceNumber32 ackSeq;
1159 
1160  ackSeq = m_lastAckedSeq + m_bytesToAck;
1161 
1162  if (m_bytesLeftToBeAcked == 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1163  {
1164  m_bytesLeftToBeAcked = m_rxBuffer->NextRxSequence ().GetValue () - 1 - m_bytesToAck;
1165  }
1166  else if (m_bytesLeftToBeAcked > 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1167  {
1169  }
1170 
1171  NS_LOG_LOGIC ("Acking up to " << ackSeq << " remaining bytes: " << m_bytesLeftToBeAcked);
1172 
1173  header.SetAckNumber (ackSeq);
1174  m_lastAckedSeq = ackSeq;
1175  }
1176 
1177  // end of division in small acks
1178 
1179  if (m_endPoint != nullptr)
1180  {
1181  header.SetSourcePort (m_endPoint->GetLocalPort ());
1182  header.SetDestinationPort (m_endPoint->GetPeerPort ());
1183  }
1184  else
1185  {
1186  header.SetSourcePort (m_endPoint6->GetLocalPort ());
1187  header.SetDestinationPort (m_endPoint6->GetPeerPort ());
1188  }
1189  AddOptions (header);
1190  header.SetWindowSize (AdvertisedWindowSize ());
1191 
1192  // RFC 6298, clause 2.4
1193  m_rto = Max (m_rtt->GetEstimate () + Max (m_clockGranularity, m_rtt->GetVariation () * 4), m_minRto);
1194 
1195  if (hasSyn)
1196  {
1197  if (m_synCount == 0)
1198  { // No more connection retries, give up
1199  NS_LOG_LOGIC ("Connection failed.");
1200  m_rtt->Reset (); //According to recommendation -> RFC 6298
1201  CloseAndNotify ();
1202  return;
1203  }
1204  else
1205  { // Exponential backoff of connection time out
1206  int backoffCount = 0x1 << (m_synRetries - m_synCount);
1207  m_rto = m_cnTimeout * backoffCount;
1208  m_synCount--;
1209  }
1210  }
1211  if (m_endPoint != nullptr)
1212  {
1213  m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (),
1215  }
1216  else
1217  {
1218  m_tcp->SendPacket (p, header, m_endPoint6->GetLocalAddress (),
1220  }
1221 
1222  m_txTrace (p, header, this);
1223 
1224  if (flags & TcpHeader::ACK)
1225  { // If sending an ACK, cancel the delay ACK as well
1226  m_delAckEvent.Cancel ();
1227  m_delAckCount = 0;
1228  }
1229  if (m_retxEvent.IsExpired () && (hasSyn || hasFin) && !isAck )
1230  { // Retransmit SYN / SYN+ACK / FIN / FIN+ACK to guard against lost
1231  NS_LOG_LOGIC ("Schedule retransmission timeout at time "
1232  << Simulator::Now ().GetSeconds () << " to expire at time "
1233  << (Simulator::Now () + m_rto.Get ()).GetSeconds ());
1235  }
1236 
1237  // send another ACK if bytes remain
1238  if (m_bytesLeftToBeAcked > 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1239  {
1240  SendEmptyPacket (flags);
1241  }
1242 }
1243 
1246 {
1247  return CopyObject<TcpSocketSmallAcks> (this);
1248 }
1249 
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:831
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:226
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
Ptr< TcpSocketState > m_tcb
Congestion control information.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1022
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:278
#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:1381
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:1076
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: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.
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: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 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:1475
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:852
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:262
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:1014
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.
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.