Add support for TCP cwnd tracing
authorRaj Bhattacharjea <raj.b@gatech.edu>
Thu Apr 10 15:04:47 2008 -0400 (22 months ago)
changeset 2903ea31499ecbfb
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
     1.1 --- a/src/core/config.cc	Thu Apr 10 13:16:43 2008 -0700
     1.2 +++ b/src/core/config.cc	Thu Apr 10 15:04:47 2008 -0400
     1.3 @@ -190,7 +190,7 @@
     1.4      {
     1.5        // This is a call to GetObject
     1.6        std::string tidString = item.substr (1, item.size () - 1);
     1.7 -      NS_LOG_DEBUG ("GetObject="<<tidString<<"on path="<<GetResolvedPath (""));
     1.8 +      NS_LOG_DEBUG ("GetObject="<<tidString<<" on path="<<GetResolvedPath (""));
     1.9        TypeId tid = TypeId::LookupByName (tidString);
    1.10        Ptr<Object> object = root->GetObject<Object> (tid);
    1.11        if (object == 0)
     2.1 --- a/src/core/traced-value.h	Thu Apr 10 13:16:43 2008 -0700
     2.2 +++ b/src/core/traced-value.h	Thu Apr 10 15:04:47 2008 -0400
     2.3 @@ -118,6 +118,12 @@
     2.4    TracedCallback<T,T> m_cb;
     2.5  };
     2.6  
     2.7 +template <typename T>
     2.8 +std::ostream& operator << (std::ostream& os, const TracedValue<T>& rhs)
     2.9 +{
    2.10 +  return os<<rhs.Get();
    2.11 +}
    2.12 +
    2.13  template <typename T, typename U>
    2.14  bool operator == (const TracedValue<T> &lhs, const TracedValue<U> &rhs)
    2.15  {
     3.1 --- a/src/internet-node/tcp-socket.cc	Thu Apr 10 13:16:43 2008 -0700
     3.2 +++ b/src/internet-node/tcp-socket.cc	Thu Apr 10 15:04:47 2008 -0400
     3.3 @@ -31,6 +31,7 @@
     3.4  #include "tcp-typedefs.h"
     3.5  #include "ns3/simulator.h"
     3.6  #include "ns3/packet.h"
     3.7 +#include "ns3/trace-source-accessor.h"
     3.8  
     3.9  #include <algorithm>
    3.10  
    3.11 @@ -40,6 +41,20 @@
    3.12  
    3.13  namespace ns3 {
    3.14  
    3.15 +NS_OBJECT_ENSURE_REGISTERED (TcpSocket);
    3.16 +
    3.17 +TypeId
    3.18 +TcpSocket::GetTypeId ()
    3.19 +{
    3.20 +  static TypeId tid = TypeId("ns3::TcpSocket")
    3.21 +    .SetParent<Socket> ()
    3.22 +    .AddTraceSource ("CongestionWindow",
    3.23 +                     "The TCP connection's congestion window",
    3.24 +                     MakeTraceSourceAccessor (&TcpSocket::m_cWnd))
    3.25 +    ;
    3.26 +  return tid;
    3.27 +}
    3.28 +
    3.29    TcpSocket::TcpSocket ()
    3.30    : m_skipRetxResched (false),
    3.31      m_dupAckCount (0),
    3.32 @@ -899,7 +914,7 @@
    3.33  {
    3.34    NS_LOG_FUNCTION;
    3.35    NS_LOG_LOGIC ("TcpSocket::Window() "<<this);
    3.36 -  return std::min (m_rxWindowSize, m_cWnd);
    3.37 +  return std::min (m_rxWindowSize, m_cWnd.Get());
    3.38  }
    3.39  
    3.40  uint32_t  TcpSocket::AvailableWindow ()
    3.41 @@ -1120,7 +1135,7 @@
    3.42      }
    3.43    else
    3.44      { // Congestion avoidance mode, adjust by (ackBytes*segSize) / cWnd
    3.45 -      double adder =  ((double) m_segmentSize * m_segmentSize) / m_cWnd;
    3.46 +      double adder =  ((double) m_segmentSize * m_segmentSize) / m_cWnd.Get();
    3.47        if (adder < 1.0) 
    3.48          {
    3.49            adder = 1.0;
     4.1 --- a/src/internet-node/tcp-socket.h	Thu Apr 10 13:16:43 2008 -0700
     4.2 +++ b/src/internet-node/tcp-socket.h	Thu Apr 10 15:04:47 2008 -0400
     4.3 @@ -22,6 +22,7 @@
     4.4  
     4.5  #include <stdint.h>
     4.6  #include "ns3/callback.h"
     4.7 +#include "ns3/traced-value.h"
     4.8  #include "ns3/socket.h"
     4.9  #include "ns3/ptr.h"
    4.10  #include "ns3/ipv4-address.h"
    4.11 @@ -31,6 +32,7 @@
    4.12  #include "sequence-number.h"
    4.13  #include "rtt-estimator.h"
    4.14  
    4.15 +
    4.16  namespace ns3 {
    4.17  
    4.18  class Ipv4EndPoint;
    4.19 @@ -42,6 +44,7 @@
    4.20  class TcpSocket : public Socket
    4.21  {
    4.22  public:
    4.23 +  static TypeId GetTypeId (void);
    4.24    /**
    4.25     * Create an unbound tcp socket.
    4.26     */
    4.27 @@ -152,12 +155,12 @@
    4.28    SequenceNumber m_firstPendingSequence;
    4.29  
    4.30    // Window management
    4.31 -  uint32_t          m_segmentSize;                     // SegmentSize
    4.32 -  uint32_t          m_rxWindowSize;
    4.33 -  uint32_t          m_advertisedWindowSize;            // Window to advertise to peer
    4.34 -  uint32_t          m_cWnd;            // Congestion window
    4.35 -  uint32_t          m_ssThresh;                     // Slow Start Threshold
    4.36 -  uint32_t          m_initialCWnd;     // Initial (and reset) value for cWnd
    4.37 +  uint32_t                       m_segmentSize;          //SegmentSize
    4.38 +  uint32_t                       m_rxWindowSize;
    4.39 +  uint32_t                       m_advertisedWindowSize; //Window to advertise
    4.40 +  TracedValue<uint32_t>          m_cWnd;                 //Congestion window
    4.41 +  uint32_t                       m_ssThresh;             //Slow Start Threshold
    4.42 +  uint32_t                       m_initialCWnd;          //Initial cWnd value
    4.43  
    4.44    // Round trip time estimation
    4.45    Ptr<RttEstimator> m_rtt;