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  m_senderSocket->m_rateOps->TraceConnectWithoutContext ("TcpRateUpdated",
229  m_senderSocket->m_rateOps->TraceConnectWithoutContext ("TcpRateSampleUpdated",
231 
232 
233  m_remoteAddr = InetSocketAddress (serverAddress, 4477);
234 
236 
237  m_receiverSocket->Listen ();
238  m_receiverSocket->ShutdownSend ();
239 
242  Simulator::ScheduleWithContext (nodes.Get (0)->GetId (),
245 
246  NS_LOG_INFO ("Run Simulation.");
247  Simulator::Run ();
248 }
249 
250 void
252 {
253  NS_LOG_INFO (this);
254  m_senderSocket->Connect (m_remoteAddr);
255 }
256 
257 void
259 {
260  (void) from;
264 
265 }
266 
269 {
270  Ptr<SimpleChannel> ch = CreateObject <SimpleChannel> ();
271 
272  ch->SetAttribute ("Delay", TimeValue (m_propagationDelay));
273 
274  return ch;
275 }
276 
279  TypeId congControl)
280 {
281  return CreateSocket (node, socketType, congControl, m_recoveryTypeId);
282 }
283 
286  TypeId congControl, TypeId recoveryAlgorithm)
287 {
288  ObjectFactory rttFactory;
289  ObjectFactory congestionAlgorithmFactory;
290  ObjectFactory recoveryAlgorithmFactory;
291  ObjectFactory socketFactory;
292 
293  rttFactory.SetTypeId (RttMeanDeviation::GetTypeId ());
294  congestionAlgorithmFactory.SetTypeId (congControl);
295  recoveryAlgorithmFactory.SetTypeId (recoveryAlgorithm);
296  socketFactory.SetTypeId (socketType);
297 
298  Ptr<RttEstimator> rtt = rttFactory.Create<RttEstimator> ();
299  Ptr<TcpSocketMsgBase> socket = DynamicCast<TcpSocketMsgBase> (socketFactory.Create ());
300  Ptr<TcpCongestionOps> algo = congestionAlgorithmFactory.Create<TcpCongestionOps> ();
301  Ptr<TcpRecoveryOps> recovery = recoveryAlgorithmFactory.Create<TcpRecoveryOps> ();
302 
303  socket->SetNode (node);
304  socket->SetTcp (node->GetObject<TcpL4Protocol> ());
305  socket->SetRtt (rtt);
306  socket->SetCongestionControlAlgorithm (algo);
307  socket->SetRecoveryAlgorithm (recovery);
308  return socket;
309 }
310 
313 {
314  return nullptr;
315 }
316 
319 {
320  return nullptr;
321 }
322 
325 {
327 }
328 
331 {
333 }
334 
335 void
337 {
338  if (context.compare ("SENDER") == 0)
339  {
340  QueueDrop (SENDER);
341  }
342  else if (context.compare ("RECEIVER") == 0)
343  {
345  }
346  else
347  {
348  NS_FATAL_ERROR ("Packet dropped in a queue, but queue not recognized");
349  }
350 }
351 
352 void
354 {
355  NS_UNUSED (p);
356  if (context.compare ("SENDER") == 0)
357  {
358  PhyDrop (SENDER);
359  }
360  else if (context.compare ("RECEIVER") == 0)
361  {
362  PhyDrop (RECEIVER);
363  }
364  else
365  {
366  NS_FATAL_ERROR ("Packet dropped in a queue, but queue not recognized");
367  }
368 }
369 
370 void
372 {
373  if (socket->GetNode () == m_receiverSocket->GetNode ())
374  {
376  }
377  else if (socket->GetNode () == m_senderSocket->GetNode ())
378  {
380  }
381  else
382  {
383  NS_FATAL_ERROR ("Closed socket, but not recognized");
384  }
385 }
386 
387 void
389  const SequenceNumber32 & seq, uint32_t sz,
390  bool isRetransmission)
391 {
392  if (tcp->GetNode () == m_receiverSocket->GetNode ())
393  {
394  UpdatedRttHistory (seq, sz, isRetransmission, RECEIVER);
395  }
396  else if (tcp->GetNode () == m_senderSocket->GetNode ())
397  {
398  UpdatedRttHistory (seq, sz, isRetransmission, SENDER);
399  }
400  else
401  {
402  NS_FATAL_ERROR ("Closed socket, but not recognized");
403  }
404 }
405 
406 void
408  const Ptr<const TcpSocketBase> tcp)
409 {
410  if (tcp->GetNode () == m_receiverSocket->GetNode ())
411  {
412  AfterRTOExpired (tcb, RECEIVER);
413  }
414  else if (tcp->GetNode () == m_senderSocket->GetNode ())
415  {
416  AfterRTOExpired (tcb, SENDER);
417  }
418  else
419  {
420  NS_FATAL_ERROR ("Closed socket, but not recognized");
421  }
422 }
423 
424 void
426  const Ptr<const TcpSocketBase> tcp)
427 {
428  if (tcp->GetNode () == m_receiverSocket->GetNode ())
429  {
430  BeforeRTOExpired (tcb, RECEIVER);
431  }
432  else if (tcp->GetNode () == m_senderSocket->GetNode ())
433  {
434  BeforeRTOExpired (tcb, SENDER);
435  }
436  else
437  {
438  NS_FATAL_ERROR ("Closed socket, but not recognized");
439  }
440 }
441 
442 void
444 {
445  if (socket->GetNode () == m_receiverSocket->GetNode ())
446  {
447  DataSent (size, RECEIVER);
448  }
449  else if (socket->GetNode () == m_senderSocket->GetNode ())
450  {
451  DataSent (size, SENDER);
452  }
453  else
454  {
455  NS_FATAL_ERROR ("Closed socket, but not recognized");
456  }
457 }
458 
459 void
461 {
462  if (socket->GetNode () == m_receiverSocket->GetNode ())
463  {
465  }
466  else if (socket->GetNode () == m_senderSocket->GetNode ())
467  {
468  ErrorClose (SENDER);
469  }
470  else
471  {
472  NS_FATAL_ERROR ("Closed socket, but not recognized");
473  }
474 }
475 
476 void
478 {
479  NS_LOG_FUNCTION (this << p << h << who);
480 }
481 
482 void
484 {
485  NS_LOG_FUNCTION (this << p << h << who);
486 }
487 
488 void
490  const Ptr<const TcpSocketBase> tcp)
491 {
492  if (tcp->GetNode () == m_receiverSocket->GetNode ())
493  {
494  RcvAck (tcp->m_tcb, h, RECEIVER);
495  }
496  else if (tcp->GetNode () == m_senderSocket->GetNode ())
497  {
498  RcvAck (tcp->m_tcb, h, SENDER);
499  }
500  else
501  {
502  NS_FATAL_ERROR ("Received ACK but socket not recognized");
503  }
504 }
505 
506 void
508  const TcpHeader &h, const Ptr<const TcpSocketBase> tcp)
509 {
510  if (tcp->GetNode () == m_receiverSocket->GetNode ())
511  {
512  Tx (p, h, RECEIVER);
513  }
514  else if (tcp->GetNode () == m_senderSocket->GetNode ())
515  {
516  Tx (p, h, SENDER);
517  }
518  else
519  {
520  NS_FATAL_ERROR ("Received ACK but socket not recognized");
521  }
522 }
523 
524 void
526  const Ptr<const TcpSocketBase> tcp)
527 {
528  if (tcp->GetNode () == m_receiverSocket->GetNode ())
529  {
530  Rx (p, h, RECEIVER);
531  }
532  else if (tcp->GetNode () == m_senderSocket->GetNode ())
533  {
534  Rx (p, h, SENDER);
535  }
536  else
537  {
538  NS_FATAL_ERROR ("Received ACK but socket not recognized");
539  }
540 }
541 
542 void
545 {
546  if (tcp->GetNode () == m_receiverSocket->GetNode ())
547  {
548  ProcessedAck (tcp->m_tcb, h, RECEIVER);
549  }
550  else if (tcp->GetNode () == m_senderSocket->GetNode ())
551  {
552  ProcessedAck (tcp->m_tcb, h, SENDER);
553  }
554  else
555  {
556  NS_FATAL_ERROR ("Received ACK but socket not recognized");
557  }
558 }
559 
560 void
562 {
563  NS_LOG_FUNCTION (this << tcp);
564 
565  m_receiverSocket = tcp;
566 }
567 
568 uint32_t
570 {
571  if (who == SENDER)
572  {
573  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_retxThresh;
574  }
575  else if (who == RECEIVER)
576  {
577  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_retxThresh;
578  }
579  else
580  {
581  NS_FATAL_ERROR ("Not defined");
582  }
583 }
584 
585 uint32_t
587 {
588  if (who == SENDER)
589  {
590  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_dupAckCount;
591  }
592  else if (who == RECEIVER)
593  {
594  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_dupAckCount;
595  }
596  else
597  {
598  NS_FATAL_ERROR ("Not defined");
599  }
600 }
601 
602 uint32_t
604 {
605  if (who == SENDER)
606  {
607  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_delAckMaxCount;
608  }
609  else if (who == RECEIVER)
610  {
611  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_delAckMaxCount;
612  }
613  else
614  {
615  NS_FATAL_ERROR ("Not defined");
616  }
617 }
618 
619 Time
621 {
622  if (who == SENDER)
623  {
624  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetDelAckTimeout ();
625  }
626  else if (who == RECEIVER)
627  {
628  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetDelAckTimeout ();
629  }
630  else
631  {
632  NS_FATAL_ERROR ("Not defined");
633  }
634 }
635 
636 uint32_t
638 {
639  if (who == SENDER)
640  {
641  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetSegSize ();
642  }
643  else if (who == RECEIVER)
644  {
645  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetSegSize ();
646  }
647  else
648  {
649  NS_FATAL_ERROR ("Not defined");
650  }
651 }
652 
655 {
656  return GetTcb (who)->m_highTxMark;
657 }
658 
659 uint32_t
661 {
662  if (who == SENDER)
663  {
664  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetInitialCwnd ();
665  }
666  else if (who == RECEIVER)
667  {
668  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetInitialCwnd ();
669  }
670  else
671  {
672  NS_FATAL_ERROR ("Not defined");
673  }
674 }
675 
676 uint32_t
678 {
679  if (who == SENDER)
680  {
681  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->GetInitialSSThresh ();
682  }
683  else if (who == RECEIVER)
684  {
685  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->GetInitialSSThresh ();
686  }
687  else
688  {
689  NS_FATAL_ERROR ("Not defined");
690  }
691 }
692 
693 Time
695 {
696  if (who == SENDER)
697  {
698  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rto.Get ();
699  }
700  else if (who == RECEIVER)
701  {
702  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rto.Get ();
703  }
704  else
705  {
706  NS_FATAL_ERROR ("Not defined");
707  }
708 }
709 
710 Time
712 {
713  if (who == SENDER)
714  {
715  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_minRto;
716  }
717  else if (who == RECEIVER)
718  {
719  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_minRto;
720  }
721  else
722  {
723  NS_FATAL_ERROR ("Not defined");
724  }
725 }
726 
727 Time
729 {
730  if (who == SENDER)
731  {
732  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_cnTimeout;
733  }
734  else if (who == RECEIVER)
735  {
736  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_cnTimeout;
737  }
738  else
739  {
740  NS_FATAL_ERROR ("Not defined");
741  }
742 }
743 
746 {
747  if (who == SENDER)
748  {
749  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rtt;
750  }
751  else if (who == RECEIVER)
752  {
753  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rtt;
754  }
755  else
756  {
757  NS_FATAL_ERROR ("Not defined");
758  }
759 }
760 
761 Time
763 {
764  if (who == SENDER)
765  {
766  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_clockGranularity;
767  }
768  else if (who == RECEIVER)
769  {
770  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_clockGranularity;
771  }
772  else
773  {
774  NS_FATAL_ERROR ("Not defined");
775  }
776 }
777 
780 {
781  if (who == SENDER)
782  {
783  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_state.Get ();
784  }
785  else if (who == RECEIVER)
786  {
787 
788  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_state.Get ();
789  }
790  else
791  {
792  NS_FATAL_ERROR ("Not defined");
793  }
794 }
795 
796 uint32_t
798 {
799  if (who == SENDER)
800  {
801  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rWnd.Get ();
802  }
803  else if (who == RECEIVER)
804  {
805 
806  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rWnd.Get ();
807  }
808  else
809  {
810  NS_FATAL_ERROR ("Not defined");
811  }
812 }
813 
814 EventId
816 {
817  if (who == SENDER)
818  {
819  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_persistEvent;
820  }
821  else if (who == RECEIVER)
822  {
823 
824  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_persistEvent;
825  }
826  else
827  {
828  NS_FATAL_ERROR ("Not defined");
829  }
830 }
831 
832 Time
834 {
835  if (who == SENDER)
836  {
837  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_persistTimeout;
838  }
839  else if (who == RECEIVER)
840  {
841 
842  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_persistTimeout;
843  }
844  else
845  {
846  NS_FATAL_ERROR ("Not defined");
847  }
848 }
849 
852 {
853  if (who == SENDER)
854  {
855  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_tcb;
856  }
857  else if (who == RECEIVER)
858  {
859 
860  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_tcb;
861  }
862  else
863  {
864  NS_FATAL_ERROR ("Not defined");
865  }
866 }
867 
870 {
871  if (who == SENDER)
872  {
873  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_rxBuffer;
874  }
875  else if (who == RECEIVER)
876  {
877 
878  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_rxBuffer;
879  }
880  else
881  {
882  NS_FATAL_ERROR ("Not defined");
883  }
884 }
885 
888  {
889  if (who == SENDER)
890  {
891  return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_txBuffer;
892  }
893  else if (who == RECEIVER)
894  {
895  return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_txBuffer;
896  }
897  else
898  {
899  NS_FATAL_ERROR ("Not defined");
900  }
901  }
902 
903 
904 void
906 {
907  if (who == SENDER)
908  {
909  m_senderSocket->SetRcvBufSize (size);
910  }
911  else if (who == RECEIVER)
912  {
913  m_receiverSocket->SetRcvBufSize (size);
914  }
915  else
916  {
917  NS_FATAL_ERROR ("Not defined");
918  }
919 }
920 
921 void
922 TcpGeneralTest::SetSegmentSize (SocketWho who, uint32_t segmentSize)
923 {
924  if (who == SENDER)
925  {
926  m_senderSocket->SetSegSize (segmentSize);
927  }
928  else if (who == RECEIVER)
929  {
930  m_receiverSocket->SetSegSize (segmentSize);
931  }
932  else
933  {
934  NS_FATAL_ERROR ("Not defined");
935  }
936 }
937 
938 void
939 TcpGeneralTest::SetInitialCwnd (SocketWho who, uint32_t initialCwnd)
940 {
941  if (who == SENDER)
942  {
943  m_senderSocket->SetInitialCwnd (initialCwnd);
944  }
945  else if (who == RECEIVER)
946  {
947  m_receiverSocket->SetInitialCwnd (initialCwnd);
948  }
949  else
950  {
951  NS_FATAL_ERROR ("Not defined");
952  }
953 }
954 void
956 {
957  if (who == SENDER)
958  {
959  m_senderSocket->SetEcn (ecnMode);
960  }
961  else if (who == RECEIVER)
962  {
963  m_receiverSocket->SetEcn (ecnMode);
964  }
965  else
966  {
967  NS_FATAL_ERROR ("Not defined");
968  }
969 }
970 
971 void
972 TcpGeneralTest::SetInitialSsThresh (SocketWho who, uint32_t initialSsThresh)
973 {
974  if (who == SENDER)
975  {
976  m_senderSocket->SetInitialSSThresh (initialSsThresh);
977  }
978  else if (who == RECEIVER)
979  {
980  m_receiverSocket->SetInitialSSThresh (initialSsThresh);
981  }
982  else
983  {
984  NS_FATAL_ERROR ("Not defined");
985  }
986 }
987 
989 
990 TypeId
992 {
993  static TypeId tid = TypeId ("ns3::TcpSocketMsgBase")
995  .SetGroupName ("Internet")
996  .AddConstructor<TcpSocketMsgBase> ()
997  ;
998  return tid;
999 }
1000 
1003 {
1004  return CopyObject<TcpSocketMsgBase> (this);
1005 }
1006 
1007 void
1009 {
1010  NS_ASSERT (!cb.IsNull ());
1011  m_rcvAckCb = cb;
1012 }
1013 
1014 void
1016 {
1017  NS_ASSERT (!cb.IsNull ());
1018  m_processedAckCb = cb;
1019 }
1020 
1021 void
1023 {
1024  NS_ASSERT (!cb.IsNull ());
1025  m_afterRetrCallback = cb;
1026 }
1027 
1028 void
1030 {
1031  NS_ASSERT (!cb.IsNull ());
1032  m_beforeRetrCallback = cb;
1033 }
1034 
1035 void
1037 {
1039  m_rcvAckCb (packet, tcpHeader, this);
1040 
1041  TcpSocketBase::ReceivedAck (packet, tcpHeader);
1042 
1043  m_processedAckCb (packet, tcpHeader, this);
1044 }
1045 
1046 void
1048 {
1049  m_beforeRetrCallback (m_tcb, this);
1051  m_afterRetrCallback (m_tcb, this);
1052 }
1053 
1054 void
1056 {
1057  NS_ASSERT (!cb.IsNull ());
1058  m_forkCb = cb;
1059 }
1060 
1061 void
1063 {
1064  NS_ASSERT (!cb.IsNull ());
1065  m_updateRttCb = cb;
1066 }
1067 
1068 void
1070  bool isRetransmission)
1071 {
1072  TcpSocketBase::UpdateRttHistory (seq, sz, isRetransmission);
1073  if (!m_updateRttCb.IsNull ())
1074  {
1075  m_updateRttCb (this, seq, sz, isRetransmission);
1076  }
1077 }
1078 
1079 void
1081  const Address &fromAddress, const Address &toAddress)
1082 {
1083  TcpSocketBase::CompleteFork (p, tcpHeader, fromAddress, toAddress);
1084 
1085  if (!m_forkCb.IsNull ())
1086  {
1087  m_forkCb (this);
1088  }
1089 }
1090 
1092 
1093 TypeId
1095 {
1096  static TypeId tid = TypeId ("ns3::TcpSocketSmallAcks")
1098  .SetGroupName ("Internet")
1099  .AddConstructor<TcpSocketSmallAcks> ()
1100  ;
1101  return tid;
1102 }
1103 
1104 /*
1105  * Send empty packet, copied/pasted from TcpSocketBase
1106  *
1107  * The rationale for copying/pasting is that we need to edit a little the
1108  * code inside. Since there isn't a well-defined division of duties,
1109  * we are forced to do this.
1110  */
1111 void
1113 {
1114  Ptr<Packet> p = Create<Packet> ();
1115  TcpHeader header;
1117 
1118  /*
1119  * Add tags for each socket option.
1120  * Note that currently the socket adds both IPv4 tag and IPv6 tag
1121  * if both options are set. Once the packet got to layer three, only
1122  * the corresponding tags will be read.
1123  */
1124  if (GetIpTos ())
1125  {
1126  SocketIpTosTag ipTosTag;
1127  ipTosTag.SetTos (GetIpTos ());
1128  p->AddPacketTag (ipTosTag);
1129  }
1130 
1131  if (IsManualIpv6Tclass ())
1132  {
1133  SocketIpv6TclassTag ipTclassTag;
1134  ipTclassTag.SetTclass (GetIpv6Tclass ());
1135  p->AddPacketTag (ipTclassTag);
1136  }
1137 
1138  if (IsManualIpTtl ())
1139  {
1140  SocketIpTtlTag ipTtlTag;
1141  ipTtlTag.SetTtl (GetIpTtl ());
1142  p->AddPacketTag (ipTtlTag);
1143  }
1144 
1145  if (IsManualIpv6HopLimit ())
1146  {
1147  SocketIpv6HopLimitTag ipHopLimitTag;
1148  ipHopLimitTag.SetHopLimit (GetIpv6HopLimit ());
1149  p->AddPacketTag (ipHopLimitTag);
1150  }
1151 
1152  if (m_endPoint == nullptr && m_endPoint6 == nullptr)
1153  {
1154  NS_LOG_WARN ("Failed to send empty packet due to null endpoint");
1155  return;
1156  }
1157  if (flags & TcpHeader::FIN)
1158  {
1159  flags |= TcpHeader::ACK;
1160  }
1161  else if (m_state == FIN_WAIT_1 || m_state == LAST_ACK || m_state == CLOSING)
1162  {
1163  ++s;
1164  }
1165 
1166  bool hasSyn = flags & TcpHeader::SYN;
1167  bool hasFin = flags & TcpHeader::FIN;
1168  bool isAck = flags == TcpHeader::ACK;
1169 
1170  header.SetFlags (flags);
1171  header.SetSequenceNumber (s);
1172 
1173  // Actual division in small acks.
1174  if (hasSyn || hasFin)
1175  {
1176  header.SetAckNumber (m_rxBuffer->NextRxSequence ());
1177  }
1178  else
1179  {
1180  SequenceNumber32 ackSeq;
1181 
1182  ackSeq = m_lastAckedSeq + m_bytesToAck;
1183 
1184  if (m_bytesLeftToBeAcked == 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1185  {
1186  m_bytesLeftToBeAcked = m_rxBuffer->NextRxSequence ().GetValue () - 1 - m_bytesToAck;
1187  }
1188  else if (m_bytesLeftToBeAcked > 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1189  {
1191  }
1192 
1193  NS_LOG_LOGIC ("Acking up to " << ackSeq << " remaining bytes: " << m_bytesLeftToBeAcked);
1194 
1195  header.SetAckNumber (ackSeq);
1196  m_lastAckedSeq = ackSeq;
1197  }
1198 
1199  // end of division in small acks
1200 
1201  if (m_endPoint != nullptr)
1202  {
1203  header.SetSourcePort (m_endPoint->GetLocalPort ());
1204  header.SetDestinationPort (m_endPoint->GetPeerPort ());
1205  }
1206  else
1207  {
1208  header.SetSourcePort (m_endPoint6->GetLocalPort ());
1209  header.SetDestinationPort (m_endPoint6->GetPeerPort ());
1210  }
1211  AddOptions (header);
1212  header.SetWindowSize (AdvertisedWindowSize ());
1213 
1214  // RFC 6298, clause 2.4
1215  m_rto = Max (m_rtt->GetEstimate () + Max (m_clockGranularity, m_rtt->GetVariation () * 4), m_minRto);
1216 
1217  if (hasSyn)
1218  {
1219  if (m_synCount == 0)
1220  { // No more connection retries, give up
1221  NS_LOG_LOGIC ("Connection failed.");
1222  m_rtt->Reset (); //According to recommendation -> RFC 6298
1223  CloseAndNotify ();
1224  return;
1225  }
1226  else
1227  { // Exponential backoff of connection time out
1228  int backoffCount = 0x1 << (m_synRetries - m_synCount);
1229  m_rto = m_cnTimeout * backoffCount;
1230  m_synCount--;
1231  }
1232  }
1233  if (m_endPoint != nullptr)
1234  {
1235  m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (),
1237  }
1238  else
1239  {
1240  m_tcp->SendPacket (p, header, m_endPoint6->GetLocalAddress (),
1242  }
1243 
1244  m_txTrace (p, header, this);
1245 
1246  if (flags & TcpHeader::ACK)
1247  { // If sending an ACK, cancel the delay ACK as well
1248  m_delAckEvent.Cancel ();
1249  m_delAckCount = 0;
1250  }
1251  if (m_retxEvent.IsExpired () && (hasSyn || hasFin) && !isAck )
1252  { // Retransmit SYN / SYN+ACK / FIN / FIN+ACK to guard against lost
1253  NS_LOG_LOGIC ("Schedule retransmission timeout at time "
1254  << Simulator::Now ().GetSeconds () << " to expire at time "
1255  << (Simulator::Now () + m_rto.Get ()).GetSeconds ());
1257  }
1258 
1259  // send another ACK if bytes remain
1260  if (m_bytesLeftToBeAcked > 0 && m_rxBuffer->NextRxSequence () > m_lastAckedSeq)
1261  {
1262  SendEmptyPacket (flags);
1263  }
1264 }
1265 
1268 {
1269  return CopyObject<TcpSocketSmallAcks> (this);
1270 }
1271 
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:92
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.
virtual void RateSampleUpdatedTrace(const TcpRateLinux::TcpRateSample &sample)
Track the rate sample value of TcpRateLinux.
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")
virtual void RateUpdatedTrace(const TcpRateLinux::TcpRateConnection &rate)
Track the rate value of TcpRateLinux.
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.