Add support for TCP cwnd tracing

This commit is contained in:
Raj Bhattacharjea
2008-04-10 15:04:47 -04:00
parent e7c2292d7b
commit 271ea4bc75
4 changed files with 33 additions and 9 deletions

View File

@@ -190,7 +190,7 @@ Resolver::DoResolve (std::string path, Ptr<Object> root)
{
// 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)

View File

@@ -118,6 +118,12 @@ private:
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)
{

View File

@@ -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 @@ using namespace std;
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 @@ uint32_t TcpSocket::Window ()
{
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 @@ void TcpSocket::NewAck (SequenceNumber seq)
}
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;

View File

@@ -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 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<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;