From 271ea4bc7527bb255a268cf4a2868d2421b2c5a9 Mon Sep 17 00:00:00 2001 From: Raj Bhattacharjea Date: Thu, 10 Apr 2008 15:04:47 -0400 Subject: [PATCH] Add support for TCP cwnd tracing --- src/core/config.cc | 2 +- src/core/traced-value.h | 6 ++++++ src/internet-node/tcp-socket.cc | 19 +++++++++++++++++-- src/internet-node/tcp-socket.h | 15 +++++++++------ 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/core/config.cc b/src/core/config.cc index cd47003e8..409d05557 100644 --- a/src/core/config.cc +++ b/src/core/config.cc @@ -190,7 +190,7 @@ Resolver::DoResolve (std::string path, Ptr root) { // This is a call to GetObject std::string tidString = item.substr (1, item.size () - 1); - NS_LOG_DEBUG ("GetObject="< object = root->GetObject (tid); if (object == 0) diff --git a/src/core/traced-value.h b/src/core/traced-value.h index 6210d42b1..1e45aeaec 100644 --- a/src/core/traced-value.h +++ b/src/core/traced-value.h @@ -118,6 +118,12 @@ private: TracedCallback m_cb; }; +template +std::ostream& operator << (std::ostream& os, const TracedValue& rhs) +{ + return os< bool operator == (const TracedValue &lhs, const TracedValue &rhs) { diff --git a/src/internet-node/tcp-socket.cc b/src/internet-node/tcp-socket.cc index 40a511444..58495f5bf 100644 --- a/src/internet-node/tcp-socket.cc +++ b/src/internet-node/tcp-socket.cc @@ -31,6 +31,7 @@ #include "tcp-typedefs.h" #include "ns3/simulator.h" #include "ns3/packet.h" +#include "ns3/trace-source-accessor.h" #include @@ -40,6 +41,20 @@ using namespace std; namespace ns3 { +NS_OBJECT_ENSURE_REGISTERED (TcpSocket); + +TypeId +TcpSocket::GetTypeId () +{ + static TypeId tid = TypeId("ns3::TcpSocket") + .SetParent () + .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 @@ uint32_t TcpSocket::Window () { NS_LOG_FUNCTION; NS_LOG_LOGIC ("TcpSocket::Window() "< #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 TcpHeader; class TcpSocket : public Socket { public: + static TypeId GetTypeId (void); /** * Create an unbound tcp socket. */ @@ -152,12 +155,12 @@ private: 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 m_cWnd; //Congestion window + uint32_t m_ssThresh; //Slow Start Threshold + uint32_t m_initialCWnd; //Initial cWnd value // Round trip time estimation Ptr m_rtt;