Trace throughput with several ueNodes.

34 views
Skip to first unread message

Jesus Fdez Rguez

unread,
Jun 14, 2020, 1:21:39 AM6/14/20
to ns-3-users
Hi,

I need to trace the throughput experimented by each node in my network. It was easy with one node (receivedNodes was set as global variable). But with an unfixed number of ue nodes I cant declare it global. I have tried with an struct to save the received packets by each node but it is always 0 inside the throughput function.

struct NodeInfo
{
  uint32_t node;
  uint32_t byteCounter;
  uint32_t oldByteCounter;
  Ptr<Socket> ns3Socket;
};

static void ReceivePacket (struct NodeInfo info[], std::string path, Ptr<const Packet> packet, const Address &from )
 {
   std::string nodeid = path.substr(2, path.size() - 3);
   nodeid = nodeid.substr(nodeid.find("/") + 1);
   nodeid = nodeid.substr(0, nodeid.find("/"));
   info[std::stoi(nodeid)].byteCounter += packet->GetSize ();
   NS_LOG_UNCOND(" Bytes received by node " << nodeid << " : " << info[std::stoi(nodeid)].byteCounter);
}

 void
 Throughput(bool firstWrite, Time binSize, std::string fileName, typeNodeInfo *info)
 {
   std::ofstream output;
   output.open (fileName.c_str (), std::ofstream::app);
   double  throughput = (info->byteCounter - info->oldByteCounter)*8/binSize.GetSeconds ()/1024/1024;
   output << Simulator::Now().GetSeconds() << " " << throughput << std::endl;
   info->oldByteCounter = info->byteCounter;
   Simulator::Schedule (binSize, &Throughput, firstWrite, binSize, fileName, info);
 }


And in the mainI call the functions like..
Simulator::Schedule (Seconds(transientDuration), &Throughput, firstWrite, binSize, fileName, &nodeInfo[u]);
Config::Connect("/NodeList/*/ApplicationList/0/$ns3::PacketSink/Rx", MakeBoundCallback (&ReceivePacket, nodeInfo));

The &ReceivedPacket works fine but the receivedpackets by each node is not accesible from the main. ¿ any idea to tace the Throughput propertly?

Reply all
Reply to author
Forward
0 new messages