Add support for TCP cwnd tracing
authorRaj Bhattacharjea <raj.b@gatech.edu>
Thu, 10 Apr 2008 15:04:47 -0400
changeset 2903 ea31499ecbfb
parent 2902 9c2cfada5e72
child 2904 413ef952ea19
Add support for TCP cwnd tracing
src/core/config.cc
src/core/traced-value.h
src/internet-node/tcp-socket.cc
src/internet-node/tcp-socket.h
--- a/src/core/config.cc	Thu Apr 10 13:16:43 2008 -0700
+++ b/src/core/config.cc	Thu Apr 10 15:04:47 2008 -0400
@@ -190,7 +190,7 @@
     {
       // This is a call to GetObject
       std::string tidString = item.substr (1, item.size () - 1);
-      NS_LOG_DEBUG ("GetObject="<<tidString<<"on path="<<GetResolvedPath (""));
+      NS_LOG_DEBUG ("GetObject="<<tidString<<" on path="<<GetResolvedPath (""));
       TypeId tid = TypeId::LookupByName (tidString);
       Ptr<Object> object = root->GetObject<Object> (tid);
       if (object == 0)
--- a/src/core/traced-value.h	Thu Apr 10 13:16:43 2008 -0700
+++ b/src/core/traced-value.h	Thu Apr 10 15:04:47 2008 -0400
@@ -118,6 +118,12 @@
   TracedCallback<T,T> m_cb;
 };
 
+template <typename T>
+std::ostream& operator << (std::ostream& os, const TracedValue<T>& rhs)
+{
+  return os<<rhs.Get();
+}
+
 template <typename T, typename U>
 bool operator == (const TracedValue<T> &lhs, const TracedValue<U> &rhs)
 {
--- a/src/internet-node/tcp-socket.cc	Thu Apr 10 13:16:43 2008 -0700
+++ b/src/internet-node/tcp-socket.cc	Thu Apr 10 15:04:47 2008 -0400
@@ -31,6 +31,7 @@
 #include "tcp-typedefs.h"
 #include "ns3/simulator.h"
 #include "ns3/packet.h"
+#include "ns3/trace-source-accessor.h"
 
 #include <algorithm>
 
@@ -40,6 +41,20 @@
 
 namespace ns3 {
 
+NS_OBJECT_ENSURE_REGISTERED (TcpSocket);
+
+TypeId
+TcpSocket::GetTypeId ()
+{
+  static TypeId tid = TypeId("ns3::TcpSocket")
+    .SetParent<Socket> ()
+    .AddTraceSource ("CongestionWindow",
+                     "The TCP connection's congestion window",
+                     MakeTraceSourceAccessor (&TcpSocket::m_cWnd))
+    ;
+  return tid;
+}
+
   TcpSocket::TcpSocket ()
   : m_skipRetxResched (false),
     m_dupAckCount (0),
@@ -899,7 +914,7 @@
 {
   NS_LOG_FUNCTION;
   NS_LOG_LOGIC ("TcpSocket::Window() "<<this);
-  return std::min (m_rxWindowSize, m_cWnd);
+  return std::min (m_rxWindowSize, m_cWnd.Get());
 }
 
 uint32_t  TcpSocket::AvailableWindow ()
@@ -1120,7 +1135,7 @@
     }
   else
     { // Congestion avoidance mode, adjust by (ackBytes*segSize) / cWnd
-      double adder =  ((double) m_segmentSize * m_segmentSize) / m_cWnd;
+      double adder =  ((double) m_segmentSize * m_segmentSize) / m_cWnd.Get();
       if (adder < 1.0) 
         {
           adder = 1.0;
--- a/src/internet-node/tcp-socket.h	Thu Apr 10 13:16:43 2008 -0700
+++ b/src/internet-node/tcp-socket.h	Thu Apr 10 15:04:47 2008 -0400
@@ -22,6 +22,7 @@
 
 #include <stdint.h>
 #include "ns3/callback.h"
+#include "ns3/traced-value.h"
 #include "ns3/socket.h"
 #include "ns3/ptr.h"
 #include "ns3/ipv4-address.h"
@@ -31,6 +32,7 @@
 #include "sequence-number.h"
 #include "rtt-estimator.h"
 
+
 namespace ns3 {
 
 class Ipv4EndPoint;
@@ -42,6 +44,7 @@
 class TcpSocket : public Socket
 {
 public:
+  static TypeId GetTypeId (void);
   /**
    * Create an unbound tcp socket.
    */
@@ -152,12 +155,12 @@
   SequenceNumber m_firstPendingSequence;
 
   // Window management
-  uint32_t          m_segmentSize;                     // SegmentSize
-  uint32_t          m_rxWindowSize;
-  uint32_t          m_advertisedWindowSize;            // Window to advertise to peer
-  uint32_t          m_cWnd;            // Congestion window
-  uint32_t          m_ssThresh;                     // Slow Start Threshold
-  uint32_t          m_initialCWnd;     // Initial (and reset) value for cWnd
+  uint32_t                       m_segmentSize;          //SegmentSize
+  uint32_t                       m_rxWindowSize;
+  uint32_t                       m_advertisedWindowSize; //Window to advertise
+  TracedValue<uint32_t>          m_cWnd;                 //Congestion window
+  uint32_t                       m_ssThresh;             //Slow Start Threshold
+  uint32_t                       m_initialCWnd;          //Initial cWnd value
 
   // Round trip time estimation
   Ptr<RttEstimator> m_rtt;