Need help finding number of transmitted packets/ PDR

15 views
Skip to first unread message

Aamina Binte Khurram

unread,
Jul 20, 2024, 8:09:03 PM (2 days ago) Jul 20
to ns-3-users
Hello,.

I'm working with ns3-mmwave, and the millicar module specifically. I need to calculate the packet delivery ratio. For this, I wanted to record the number of transmitted packets and have been trying to figure out a way to you a trace for this but have been unsuccessful. I understand this might be a novice's question but I am completely at a loss right now.

The existing code traces just received packets by the server:
UdpEchoServerHelper server (port);
  ApplicationContainer echoApps = server.Install (n.Get (1));
  echoApps.Start (Seconds (0.0));

  AsciiTraceHelper asciiTraceHelper;
  Ptr<OutputStreamWrapper> stream = asciiTraceHelper.CreateFileStream ("simple-one-stats.txt");
  echoApps.Get(0)->TraceConnectWithoutContext ("Rx", MakeBoundCallback (&Rx, stream));

  UdpClientHelper client (n.Get (1)->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal (), port);
  ApplicationContainer apps = client.Install (n.Get (0));

Thank you for your patience, any help would be appreciated.

Tommaso Pecorella

unread,
Jul 20, 2024, 10:29:19 PM (2 days ago) Jul 20
to ns-3-users
Depending on the sending application you might have a "Tx" trace. "UdpClient" has it.

Aamina Binte Khurram

unread,
Jul 21, 2024, 7:33:03 PM (12 hours ago) Jul 21
to ns-3-users
Thank you for your reply Tommaso. Printing the instance type of the application says it is a UdpClient, but for some reason, the Tx trace doesn't seem to be working.
  UdpClientHelper client (n.Get (1)->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal (), port);
  ApplicationContainer apps = client.Install (n.Get (0));
  std::cout << apps.Get(0)->GetInstanceTypeId ().GetName () << std::endl;
  // Connecting the callback to the UdpClient's Tx trace source
  apps.Get (0)->TraceConnectWithoutContext ("Tx", MakeCallback (&Tx));

And this is the Tx function:
static void Tx (Ptr<const Packet> p)
{
 std::cout << "Tx function called" << std::endl;
 g_txPackets++;
}

It is not called. Any ideas on what I might be missing?

Aamina Binte Khurram

unread,
2:35 AM (5 hours ago) 2:35 AM
to ns-3-users
I used the UdpClient's GetTotalTx() method instead. Seems to be working!

Thanks for helping me out!
Reply all
Reply to author
Forward
0 new messages