src/internet-stack/tcp-reno.cc
changeset 6697 6f1114f669ff
parent 6694 a814f37d15bf
--- a/src/internet-stack/tcp-reno.cc	Fri Dec 17 21:07:57 2010 -0800
+++ b/src/internet-stack/tcp-reno.cc	Sun Dec 19 21:57:21 2010 -0800
@@ -67,16 +67,22 @@
 {
 }
 
-void
-TcpReno::SetNode (Ptr<Node> node)
+/** We initialize m_cWnd from this function, after attributes initialized */
+int
+TcpReno::Listen (void)
 {
-  TcpSocketBase::SetNode (node);
-  /*
-   * Initialize congestion window, default to 1 MSS (RFC2001, sec.1) and must
-   * not be larger than 2 MSS (RFC2581, sec.3.1). Both m_initiaCWnd and
-   * m_segmentSize are set by the attribute system in ns3::TcpSocket.
-   */
-  m_cWnd = m_initialCWnd * m_segmentSize;
+  NS_LOG_FUNCTION (this);
+  InitializeCwnd ();
+  return TcpSocketBase::Listen ();
+}
+
+/** We initialize m_cWnd from this function, after attributes initialized */
+int
+TcpReno::Connect (const Address & address)
+{
+  NS_LOG_FUNCTION (this << address);
+  InitializeCwnd ();
+  return TcpSocketBase::Connect (address);
 }
 
 /** Limit the size of in-flight data by cwnd and receiver's rxwin */
@@ -180,7 +186,6 @@
 {
   NS_ABORT_MSG_UNLESS (m_state == CLOSED, "TcpReno::SetSegSize() cannot change segment size after connection started.");
   m_segmentSize = size;
-  m_cWnd = m_initialCWnd * m_segmentSize;
 }
 
 void
@@ -200,7 +205,6 @@
 {
   NS_ABORT_MSG_UNLESS (m_state == CLOSED, "TcpReno::SetInitialCwnd() cannot change initial cwnd after connection started.");
   m_initialCWnd = cwnd;
-  m_cWnd = m_initialCWnd * m_segmentSize;
 }
 
 uint32_t
@@ -209,4 +213,15 @@
   return m_initialCWnd;
 }
 
+void 
+TcpReno::InitializeCwnd (void)
+{
+  /*
+   * Initialize congestion window, default to 1 MSS (RFC2001, sec.1) and must
+   * not be larger than 2 MSS (RFC2581, sec.3.1). Both m_initiaCWnd and
+   * m_segmentSize are set by the attribute system in ns3::TcpSocket.
+   */
+  m_cWnd = m_initialCWnd * m_segmentSize;
+}
+
 } // namespace ns3