CWND Trace for Multiple Nodes

308 views
Skip to first unread message

Shahrukh Khan Kasi

unread,
Sep 21, 2019, 10:12:51 PM9/21/19
to ns-3-users
Hi,

I am trying to store the values of congestion window size for multiple nodes in TcpVariantsComparison simulations. However, when I run the code for multiple clients, the congestion window is only traced for the last node. I have attached the code snippet below, if anyone knows the probable solution to this problem, please share.



static Ptr<OutputStreamWrapper> cWndStream;
static uint32_t cWndValue;

static void
CwndTracer (uint32_t oldval, uint32_t newval)
{
  *cWndStream->GetStream () << Simulator::Now ().GetSeconds () << " " << newval << std::endl;
  cWndValue = newval
}
    
static void
TraceCwnd (uint32_t nodeid, std::string cwnd_tr_file_name)
{
  AsciiTraceHelper ascii;
  cWndStream = ascii.CreateFileStream (cwnd_tr_file_name.c_str ());
  std::ostringstream stream;
  stream << "/NodeList/" << nodeid << "/$ns3::TcpL4Protocol/SocketList/*/CongestionWindow";
  std::cout << stream.str() << std::endl;
  Config::ConnectWithoutContext (stream.str(), MakeCallback (&CwndTracer));
}

int main (int argc, char *argv[])
{
for (uint32_t nodeid = 0; nodeid < 3; ++nodeid)
{
Simulator::Schedule (Seconds (0.00001), &TraceCwnd, nodeid, prefix_file_name + "-cwnd" + std::to_string(nodeid) + ".data");
}
}


Tom Henderson

unread,
Sep 21, 2019, 11:46:35 PM9/21/19
to ns-3-...@googlegroups.com
Have you checked that all of the sockets of interest are created by time
10 microseconds (when you are trying to connect)?
> --
> Posting to this group should follow these guidelines
> https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
> ---
> You received this message because you are subscribed to the Google
> Groups "ns-3-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ns-3-users+...@googlegroups.com
> <mailto:ns-3-users+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ns-3-users/7c70e845-18f2-441d-bf7c-fa8f65818c73%40googlegroups.com
> <https://groups.google.com/d/msgid/ns-3-users/7c70e845-18f2-441d-bf7c-fa8f65818c73%40googlegroups.com?utm_medium=email&utm_source=footer>.

Shahrukh Khan Kasi

unread,
Sep 22, 2019, 10:24:44 AM9/22/19
to ns-3-users
When I change the connect time from 10 microseconds to 0.1 seconds, I still get the cwnd trace for the last node only.

Tom Henderson

unread,
Sep 22, 2019, 11:00:00 AM9/22/19
to ns-3-...@googlegroups.com, Shahrukh Khan Kasi
On 9/22/19 7:24 AM, Shahrukh Khan Kasi wrote:
> When I change the connect time from 10 microseconds to 0.1 seconds, I
> still get the cwnd trace for the last node only.

Usually there are two possibilities for this:
1) the traced object doesn't exist for some reason
2) the trace exists but is not properly connected due to an incorrect
path specifier

In your case, you start with a working example
(tcp-variants-comparison.cc) so it is less likely to be 2).

To debug this, I probably would take steps such as the following (either
logging, described below, or similar steps using gdb):

1) find where in the code that this trace is triggered. In this case,
it is tcp-socket-base.cc:4140

void
TcpSocketBase::UpdateCwnd (uint32_t oldValue, uint32_t newValue)
{
m_cWndTrace (oldValue, newValue);
}

I notice that there isn't a log output on this method. Temporarily add one:

void
TcpSocketBase::UpdateCwnd (uint32_t oldValue, uint32_t newValue)
{
NS_LOG_DEBUG ("UpdateCwnd");
m_cWndTrace (oldValue, newValue);
}

rebuild and now run your program like this:

$ NS_LOG="TcpSocketBase" ./waf --run tcp-variants-comparison > log.out 2>&1

Because of the extra context information passed to the log output, you
will see lines in the log.out file like this:

+0.045288399s 2 [node 2] TcpSocketBase:UpdateCwnd(): [DEBUG] UpdateCwnd

+0.090576798s 1 [node 1] TcpSocketBase:UpdateCwnd(): [DEBUG] UpdateCwnd

Now, in your case, you expect to see nodes 0 through 3. Do you see
these UpdateCwnd calls for those nodes in your log trace? If so, you
probably have some problem in connecting to the trace, and I would
double check (again using the log) the times that these sockets are
being instantiated. If not, then the tracing hooks may be fine but your
program is not doing what you think it should be doing.

- Tom
> > an email to ns-3-...@googlegroups.com <javascript:>
> > <mailto:ns-3-users+...@googlegroups.com <javascript:>>.
> <https://groups.google.com/d/msgid/ns-3-users/7c70e845-18f2-441d-bf7c-fa8f65818c73%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/ns-3-users/7c70e845-18f2-441d-bf7c-fa8f65818c73%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> Posting to this group should follow these guidelines
> https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
> ---
> You received this message because you are subscribed to the Google
> Groups "ns-3-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ns-3-users+...@googlegroups.com
> <mailto:ns-3-users+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ns-3-users/355cc801-5dea-41e7-9e72-d421f4c5b28d%40googlegroups.com
> <https://groups.google.com/d/msgid/ns-3-users/355cc801-5dea-41e7-9e72-d421f4c5b28d%40googlegroups.com?utm_medium=email&utm_source=footer>.

Shahrukh Khan Kasi

unread,
Sep 22, 2019, 12:03:50 PM9/22/19
to ns-3-users
log.out contains calls to UpdateCwnd for node 2, 3, 4 and 5 but no calls to UpdateCwnd from node 0 and 1. The source nodes are 0, 1 and 2 so UpdateCwnd should have been called for the nodes 0 and 1 as well. Please find the attached log.out file here: https://drive.google.com/open?id=1VFTeYy6H-syaeeY9TRPQqse9quzlvvgR

I also did a detailed search in ns-3-users google group and other platforms about tracing Cwnd for multiple nodes (or sockets) in NS-3. Many people have reported the issue and tried working on it but I couldn't find any resolution to the issue.

Shahrukh
>      > <mailto:ns-3-users+unsub...@googlegroups.com <javascript:>>.
>      > To view this discussion on the web visit
>      >
>     https://groups.google.com/d/msgid/ns-3-users/7c70e845-18f2-441d-bf7c-fa8f65818c73%40googlegroups.com
>     <https://groups.google.com/d/msgid/ns-3-users/7c70e845-18f2-441d-bf7c-fa8f65818c73%40googlegroups.com>
>
>      >
>     <https://groups.google.com/d/msgid/ns-3-users/7c70e845-18f2-441d-bf7c-fa8f65818c73%40googlegroups.com?utm_medium=email&utm_source=footer
>     <https://groups.google.com/d/msgid/ns-3-users/7c70e845-18f2-441d-bf7c-fa8f65818c73%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> Posting to this group should follow these guidelines
> https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
> ---
> You received this message because you are subscribed to the Google
> Groups "ns-3-users" group.
> To unsubscribe from this group and stop receiving emails from it, send

Tom Henderson

unread,
Sep 22, 2019, 12:21:37 PM9/22/19
to ns-3-...@googlegroups.com, Shahrukh Khan Kasi
On 9/22/19 9:03 AM, Shahrukh Khan Kasi wrote:
> log.out contains calls to UpdateCwnd for node 2, 3, 4 and 5 but no calls
> to UpdateCwnd from node 0 and 1. The source nodes are 0, 1 and 2 so
> UpdateCwnd should have been called for the nodes 0 and 1 as well. Please
> find the attached log.out file here:
> https://drive.google.com/open?id=1VFTeYy6H-syaeeY9TRPQqse9quzlvvgR.

Are you sure that nodes 0 and 1 in this revised topology are TCP
endpoints? These will be the first two nodes created in the scenario.

>
> I also did a detailed search in ns-3-users google group and other
> platforms about tracing Cwnd for multiple nodes (or sockets) in NS-3.
> Many people have reported the issue and tried working on it but I
> couldn't find any resolution to the issue.

If you are sure of your node numbering, and still think there is an
error, please share your program and we can have a look.

- Tom

Shahrukh Khan Kasi

unread,
Sep 22, 2019, 1:54:39 PM9/22/19
to ns-3-users
I am not sure if the nodes 0 and 1 are TCP endpoints. But even when I trace the results for nodes 2, 3 and 4, only node 4 statistics are traced and files for other node traces are empty. I have made slight modifications to the TCP with reinforcement learning repository (https://github.com/tkn-tub/ns3-gym/blob/master/scratch/rl-tcp/sim.cc) to obtain the statistics for CWND, RTT, etc. Please find the code in the attachments.
sim.cc

Patrick Hughes

unread,
Mar 4, 2020, 12:47:47 PM3/4/20
to ns-3-users
Was any solution ever found to why those traces didn't work. I have a very similar problem and debug output shows the TcpSockets exist.

Thank you.
Reply all
Reply to author
Forward
0 new messages