move Tcp to TcpSocketFactory
authorTom Henderson <tomh@tomh.org>
Tue, 20 May 2008 12:16:55 -0700
changeset 3132 b0b0abb911cd
parent 3131 d82336dfd269
child 3133 295e061719fc
move Tcp to TcpSocketFactory
examples/tcp-large-transfer.cc
src/helper/packet-sink-helper.cc
src/internet-node/tcp-header.h
src/internet-node/tcp-impl.cc
src/internet-node/tcp-impl.h
src/internet-node/tcp-socket-impl.cc
src/node/tcp-socket-factory.cc
src/node/tcp-socket-factory.h
src/node/tcp.cc
src/node/tcp.h
src/node/wscript
utils/print-introspected-doxygen.cc
--- a/examples/tcp-large-transfer.cc	Tue May 20 11:52:25 2008 -0700
+++ b/examples/tcp-large-transfer.cc	Tue May 20 12:16:55 2008 -0700
@@ -169,15 +169,15 @@
   uint16_t servPort = 50000;
 
   // Create a packet sink to receive these packets
-  PacketSinkHelper sink ("ns3::Tcp",
+  PacketSinkHelper sink ("ns3::TcpSocketFactory",
                          InetSocketAddress (Ipv4Address::GetAny (), servPort));
 
   ApplicationContainer apps = sink.Install (c1.Get (1));
   apps.Start (Seconds (0.0));
 
   // and generate traffic to remote sink.
-  //TypeId tid = TypeId::LookupByName ("ns3::Tcp");
-  Ptr<Socket> localSocket = Socket::CreateSocket (c0.Get (0), Tcp::GetTypeId ());
+  //TypeId tid = TypeId::LookupByName ("ns3::TcpSocketFactory");
+  Ptr<Socket> localSocket = Socket::CreateSocket (c0.Get (0), TcpSocketFactory::GetTypeId ());
   localSocket->Bind ();
   Simulator::ScheduleNow (&StartFlow, localSocket, nBytes,
                           ipInterfs.GetAddress (1), servPort);
--- a/src/helper/packet-sink-helper.cc	Tue May 20 11:52:25 2008 -0700
+++ b/src/helper/packet-sink-helper.cc	Tue May 20 12:16:55 2008 -0700
@@ -47,7 +47,7 @@
 void 
 PacketSinkHelper::SetTcpLocal (Ipv4Address ip, uint16_t port)
 {
-  m_factory.Set ("Protocol", String ("ns3::Tcp"));
+  m_factory.Set ("Protocol", String ("ns3::TcpSocketFactory"));
   m_factory.Set ("Local", Address (InetSocketAddress (ip, port)));
 }
 #endif
--- a/src/internet-node/tcp-header.h	Tue May 20 11:52:25 2008 -0700
+++ b/src/internet-node/tcp-header.h	Tue May 20 12:16:55 2008 -0700
@@ -24,7 +24,7 @@
 #include <stdint.h>
 #include "ns3/header.h"
 #include "ns3/buffer.h"
-#include "ns3/tcp.h"
+#include "ns3/tcp-socket-factory.h"
 #include "ns3/ipv4-address.h"
 #include "ns3/sequence-number.h"
 
--- a/src/internet-node/tcp-impl.cc	Tue May 20 11:52:25 2008 -0700
+++ b/src/internet-node/tcp-impl.cc	Tue May 20 12:16:55 2008 -0700
@@ -48,7 +48,7 @@
 TcpImpl::DoDispose (void)
 {
   m_tcp = 0;
-  Tcp::DoDispose ();
+  TcpSocketFactory::DoDispose ();
 }
 
 } // namespace ns3
--- a/src/internet-node/tcp-impl.h	Tue May 20 11:52:25 2008 -0700
+++ b/src/internet-node/tcp-impl.h	Tue May 20 12:16:55 2008 -0700
@@ -20,7 +20,7 @@
 #ifndef TCP_IMPL_H
 #define TCP_IMPL_H
 
-#include "ns3/tcp.h"
+#include "ns3/tcp-socket-factory.h"
 #include "ns3/ptr.h"
 
 namespace ns3 {
@@ -39,7 +39,7 @@
  * 
  * Most of the logic is in class ns3::TcpSocketImpl.
  */
-class TcpImpl : public Tcp
+class TcpImpl : public TcpSocketFactory
 {
 public:
   TcpImpl ();
--- a/src/internet-node/tcp-socket-impl.cc	Tue May 20 11:52:25 2008 -0700
+++ b/src/internet-node/tcp-socket-impl.cc	Tue May 20 12:16:55 2008 -0700
@@ -176,7 +176,7 @@
 TcpSocketImpl::SetNode (Ptr<Node> node)
 {
   m_node = node;
-  Ptr<Tcp> t = node->GetObject<Tcp> ();
+  Ptr<TcpSocketFactory> t = node->GetObject<TcpSocketFactory> ();
   m_segmentSize = t->GetDefaultSegSize ();
   m_rxWindowSize = t->GetDefaultAdvWin ();
   m_advertisedWindowSize = t->GetDefaultAdvWin ();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/node/tcp-socket-factory.cc	Tue May 20 12:16:55 2008 -0700
@@ -0,0 +1,140 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 Georgia Tech Research Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Raj Bhattacharjea <raj.b@gatech.edu>
+ */
+#include "tcp-socket-factory.h"
+#include "ns3/uinteger.h"
+#include "ns3/double.h"
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (TcpSocketFactory);
+
+TypeId
+TcpSocketFactory::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::TcpSocketFactory")
+    .SetParent<SocketFactory> ()
+    .AddAttribute ("DefaultSegmentSize",
+                   "Default TCP maximum segment size in bytes (may be adjusted based on MTU discovery)",
+                   UintegerValue (536),
+                   MakeUintegerAccessor (&TcpSocketFactory::m_defaultSegSize),
+                   MakeUintegerChecker<uint32_t> ())
+    .AddAttribute ("DefaultAdvertisedWindowSize",
+                   "Default TCP advertised window size (bytes)",
+                   UintegerValue (0xffff),
+                   MakeUintegerAccessor (&TcpSocketFactory::m_defaultAdvWin),
+                   MakeUintegerChecker<uint32_t> ())
+    .AddAttribute ("DefaultSlowStartThreshold",
+                   "Default TCP slow start threshold (bytes)",
+                   UintegerValue (0xffff),
+                   MakeUintegerAccessor (&TcpSocketFactory::m_defaultSsThresh),
+                   MakeUintegerChecker<uint32_t> ())
+    .AddAttribute ("DefaultTxBufferSize",
+                   "Default TCP maximum transmit buffer size (bytes)",
+                   UintegerValue (0xffffffffl),
+                   MakeUintegerAccessor (&TcpSocketFactory::m_defaultTxBuffer),
+                   MakeUintegerChecker<uint32_t> ())
+    .AddAttribute ("DefaultRxBufferSize",
+                   "Default TCP maximum receive buffer size (bytes)",
+                   UintegerValue (0xffffffffl),
+                   MakeUintegerAccessor (&TcpSocketFactory::m_defaultRxBuffer),
+                   MakeUintegerChecker<uint32_t> ())
+    .AddAttribute ("DefaultInitialCongestionWindowSize",
+                   "Default TCP initial congestion window size (segments)",
+                   UintegerValue (1),
+                   MakeUintegerAccessor (&TcpSocketFactory::m_defaultInitialCwnd),
+                   MakeUintegerChecker<uint32_t> ())
+    .AddAttribute ("DefaultConnTimeout",
+                   "Default TCP retransmission timeout when opening connection (seconds)",
+                   UintegerValue (3),
+                   MakeUintegerAccessor (&TcpSocketFactory::m_defaultConnTimeout),
+                   MakeUintegerChecker<uint32_t> ())
+    .AddAttribute ("DefaultConnCount",
+                   "Default number of connection attempts (SYN retransmissions) before returning failure",
+                   UintegerValue (6),
+                   MakeUintegerAccessor (&TcpSocketFactory::m_defaultConnCount),
+                   MakeUintegerChecker<uint32_t> ())
+    .AddAttribute ("DefaultDelAckTimeout",
+                   "Default timeout value for TCP delayed acks, in seconds",
+                   DoubleValue (0.2),
+                   MakeDoubleAccessor (&TcpSocketFactory::m_defaultDelAckTimeout),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("DefaultDelAckCount",
+                   "Default number of packets to wait before sending a TCP ack",
+                   UintegerValue (2),
+                   MakeUintegerAccessor (&TcpSocketFactory::m_defaultDelAckCount),
+                   MakeUintegerChecker<uint32_t> ())
+     ;
+  return tid;
+}
+
+uint32_t 
+TcpSocketFactory::GetDefaultSegSize (void) const
+{
+  return m_defaultSegSize;
+}
+uint32_t 
+TcpSocketFactory::GetDefaultAdvWin (void) const
+{
+  return m_defaultAdvWin;
+}
+uint32_t 
+TcpSocketFactory::GetDefaultSsThresh (void) const
+{
+  return m_defaultSsThresh;
+}
+uint32_t 
+TcpSocketFactory::GetDefaultTxBuffer (void) const
+{
+  return m_defaultTxBuffer;
+}
+uint32_t 
+TcpSocketFactory::GetDefaultRxBuffer (void) const
+{
+  return m_defaultRxBuffer;
+}
+uint32_t 
+TcpSocketFactory::GetDefaultInitialCwnd (void) const
+{
+  return m_defaultInitialCwnd;
+}
+uint32_t 
+TcpSocketFactory::GetDefaultConnTimeout (void) const
+{
+  return m_defaultConnTimeout;
+}
+uint32_t 
+TcpSocketFactory::GetDefaultConnCount (void) const
+{
+  return m_defaultConnCount;
+}
+
+double
+TcpSocketFactory::GetDefaultDelAckTimeout (void) const
+{
+  return m_defaultDelAckTimeout;
+}
+
+uint32_t
+TcpSocketFactory::GetDefaultDelAckCount (void) const
+{
+  return m_defaultDelAckCount;
+}
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/node/tcp-socket-factory.h	Tue May 20 12:16:55 2008 -0700
@@ -0,0 +1,78 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 Georgia Tech Research Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Raj Bhattacharjea <raj.b@gatech.edu>
+ */
+#ifndef TCP_SOCKET_FACTORY_H
+#define TCP_SOCKET_FACTORY_H
+
+#include "socket-factory.h"
+
+namespace ns3 {
+
+class Socket;
+
+/**
+ * \brief API to create TCP socket instances 
+ *
+ * This abstract class defines the API for TCP sockets.
+ * This class also holds the global default variables used to
+ * initialize newly created sockets, such as values that are
+ * set through the sysctl or proc interfaces in Linux.
+
+ * All TCP socket factory implementations must provide an implementation 
+ * of CreateSocket
+ * below, and should make use of the default values configured below.
+ * 
+ * \see TcpSocketFactoryImpl
+ *
+ */
+class TcpSocketFactory : public SocketFactory
+{
+public:
+  static TypeId GetTypeId (void);
+
+  virtual Ptr<Socket> CreateSocket (void) = 0;
+
+  uint32_t GetDefaultSegSize (void) const;
+  uint32_t GetDefaultAdvWin (void) const;
+  uint32_t GetDefaultSsThresh (void) const;
+  uint32_t GetDefaultTxBuffer (void) const;
+  uint32_t GetDefaultRxBuffer (void) const;
+  uint32_t GetDefaultInitialCwnd (void) const;
+  uint32_t GetDefaultConnTimeout (void) const;
+  uint32_t GetDefaultConnCount (void) const;
+  double   GetDefaultDelAckTimeout (void) const;
+  uint32_t GetDefaultDelAckCount (void) const;
+
+private:
+  uint32_t  m_defaultSegSize;
+  uint32_t  m_defaultAdvWin; 
+  uint32_t  m_defaultSsThresh;
+  uint32_t  m_defaultTxBuffer;
+  uint32_t  m_defaultRxBuffer;
+  uint32_t  m_defaultInitialCwnd;
+  uint32_t  m_defaultConnTimeout;
+  uint32_t  m_defaultConnCount;
+  double    m_defaultDelAckTimeout;
+  uint32_t  m_defaultDelAckCount;
+
+};
+
+} // namespace ns3
+
+#endif /* TCP_SOCKET_FACTORY_H */
--- a/src/node/tcp.cc	Tue May 20 11:52:25 2008 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 Georgia Tech Research Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Raj Bhattacharjea <raj.b@gatech.edu>
- */
-#include "tcp.h"
-#include "ns3/uinteger.h"
-#include "ns3/double.h"
-
-namespace ns3 {
-
-NS_OBJECT_ENSURE_REGISTERED (Tcp);
-
-TypeId
-Tcp::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::Tcp")
-    .SetParent<SocketFactory> ()
-    .AddAttribute ("DefaultSegmentSize",
-                   "Default TCP maximum segment size in bytes (may be adjusted based on MTU discovery)",
-                   UintegerValue (536),
-                   MakeUintegerAccessor (&Tcp::m_defaultSegSize),
-                   MakeUintegerChecker<uint32_t> ())
-    .AddAttribute ("DefaultAdvertisedWindowSize",
-                   "Default TCP advertised window size (bytes)",
-                   UintegerValue (0xffff),
-                   MakeUintegerAccessor (&Tcp::m_defaultAdvWin),
-                   MakeUintegerChecker<uint32_t> ())
-    .AddAttribute ("DefaultSlowStartThreshold",
-                   "Default TCP slow start threshold (bytes)",
-                   UintegerValue (0xffff),
-                   MakeUintegerAccessor (&Tcp::m_defaultSsThresh),
-                   MakeUintegerChecker<uint32_t> ())
-    .AddAttribute ("DefaultTxBufferSize",
-                   "Default TCP maximum transmit buffer size (bytes)",
-                   UintegerValue (0xffffffffl),
-                   MakeUintegerAccessor (&Tcp::m_defaultTxBuffer),
-                   MakeUintegerChecker<uint32_t> ())
-    .AddAttribute ("DefaultRxBufferSize",
-                   "Default TCP maximum receive buffer size (bytes)",
-                   UintegerValue (0xffffffffl),
-                   MakeUintegerAccessor (&Tcp::m_defaultRxBuffer),
-                   MakeUintegerChecker<uint32_t> ())
-    .AddAttribute ("DefaultInitialCongestionWindowSize",
-                   "Default TCP initial congestion window size (segments)",
-                   UintegerValue (1),
-                   MakeUintegerAccessor (&Tcp::m_defaultInitialCwnd),
-                   MakeUintegerChecker<uint32_t> ())
-    .AddAttribute ("DefaultConnTimeout",
-                   "Default TCP retransmission timeout when opening connection (seconds)",
-                   UintegerValue (3),
-                   MakeUintegerAccessor (&Tcp::m_defaultConnTimeout),
-                   MakeUintegerChecker<uint32_t> ())
-    .AddAttribute ("DefaultConnCount",
-                   "Default number of connection attempts (SYN retransmissions) before returning failure",
-                   UintegerValue (6),
-                   MakeUintegerAccessor (&Tcp::m_defaultConnCount),
-                   MakeUintegerChecker<uint32_t> ())
-    .AddAttribute ("DefaultDelAckTimeout",
-                   "Default timeout value for TCP delayed acks, in seconds",
-                   DoubleValue (0.2),
-                   MakeDoubleAccessor (&Tcp::m_defaultDelAckTimeout),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("DefaultDelAckCount",
-                   "Default number of packets to wait before sending a TCP ack",
-                   UintegerValue (2),
-                   MakeUintegerAccessor (&Tcp::m_defaultDelAckCount),
-                   MakeUintegerChecker<uint32_t> ())
-     ;
-  return tid;
-}
-
-uint32_t 
-Tcp::GetDefaultSegSize (void) const
-{
-  return m_defaultSegSize;
-}
-uint32_t 
-Tcp::GetDefaultAdvWin (void) const
-{
-  return m_defaultAdvWin;
-}
-uint32_t 
-Tcp::GetDefaultSsThresh (void) const
-{
-  return m_defaultSsThresh;
-}
-uint32_t 
-Tcp::GetDefaultTxBuffer (void) const
-{
-  return m_defaultTxBuffer;
-}
-uint32_t 
-Tcp::GetDefaultRxBuffer (void) const
-{
-  return m_defaultRxBuffer;
-}
-uint32_t 
-Tcp::GetDefaultInitialCwnd (void) const
-{
-  return m_defaultInitialCwnd;
-}
-uint32_t 
-Tcp::GetDefaultConnTimeout (void) const
-{
-  return m_defaultConnTimeout;
-}
-uint32_t 
-Tcp::GetDefaultConnCount (void) const
-{
-  return m_defaultConnCount;
-}
-
-double
-Tcp::GetDefaultDelAckTimeout (void) const
-{
-  return m_defaultDelAckTimeout;
-}
-
-uint32_t
-Tcp::GetDefaultDelAckCount (void) const
-{
-  return m_defaultDelAckCount;
-}
-
-} // namespace ns3
--- a/src/node/tcp.h	Tue May 20 11:52:25 2008 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 Georgia Tech Research Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Raj Bhattacharjea <raj.b@gatech.edu>
- */
-#ifndef TCP_H
-#define TCP_H
-
-#include "socket-factory.h"
-
-namespace ns3 {
-
-class Socket;
-
-/**
- * \brief API to create TCP socket instances 
- *
- * This abstract class defines the API for TCP sockets.
- * This class also holds the global default variables used to
- * initialize newly created sockets, such as values that are
- * set through the sysctl or proc interfaces in Linux.
-
- * All TCP implementations must provide an implementation of CreateSocket
- * below, and should make use of the default values configured below.
- * 
- * \see TcpImpl
- *
- */
-class Tcp : public SocketFactory
-{
-public:
-  static TypeId GetTypeId (void);
-
-  virtual Ptr<Socket> CreateSocket (void) = 0;
-
-  uint32_t GetDefaultSegSize (void) const;
-  uint32_t GetDefaultAdvWin (void) const;
-  uint32_t GetDefaultSsThresh (void) const;
-  uint32_t GetDefaultTxBuffer (void) const;
-  uint32_t GetDefaultRxBuffer (void) const;
-  uint32_t GetDefaultInitialCwnd (void) const;
-  uint32_t GetDefaultConnTimeout (void) const;
-  uint32_t GetDefaultConnCount (void) const;
-  double   GetDefaultDelAckTimeout (void) const;
-  uint32_t GetDefaultDelAckCount (void) const;
-
-private:
-  uint32_t  m_defaultSegSize;
-  uint32_t  m_defaultAdvWin; 
-  uint32_t  m_defaultSsThresh;
-  uint32_t  m_defaultTxBuffer;
-  uint32_t  m_defaultRxBuffer;
-  uint32_t  m_defaultInitialCwnd;
-  uint32_t  m_defaultConnTimeout;
-  uint32_t  m_defaultConnCount;
-  double    m_defaultDelAckTimeout;
-  uint32_t  m_defaultDelAckCount;
-
-};
-
-} // namespace ns3
-
-#endif /* TCP_H */
--- a/src/node/wscript	Tue May 20 11:52:25 2008 -0700
+++ b/src/node/wscript	Tue May 20 12:16:55 2008 -0700
@@ -27,7 +27,7 @@
         'packet-socket.cc',
         'udp-socket.cc',
         'udp-socket-factory.cc',
-        'tcp.cc',
+        'tcp-socket-factory.cc',
         'ipv4.cc',
         'application.cc',
         'simple-channel.cc',
@@ -60,7 +60,7 @@
         'packet-socket-factory.h',
         'udp-socket.h',
         'udp-socket-factory.h',
-        'tcp.h',
+        'tcp-socket-factory.h',
         'ipv4.h',
         'application.h',
         'simple-channel.h',
--- a/utils/print-introspected-doxygen.cc	Tue May 20 11:52:25 2008 -0700
+++ b/utils/print-introspected-doxygen.cc	Tue May 20 12:16:55 2008 -0700
@@ -236,7 +236,7 @@
   NodeContainer c; c.Create (1);
 
   StaticInformation info;
-  info.RecordAggregationInfo ("ns3::Node", "ns3::Tcp");
+  info.RecordAggregationInfo ("ns3::Node", "ns3::TcpSocketFactory");
   info.RecordAggregationInfo ("ns3::Node", "ns3::UdpSocketFactory");
   info.RecordAggregationInfo ("ns3::Node", "ns3::PacketSocketFactory");
   info.RecordAggregationInfo ("ns3::Node", "ns3::olsr::Agent");