question about measuring packet delivery ratio by referring wifi-example-sim.cc

55 views
Skip to first unread message

xiexi...@gmail.com

unread,
May 31, 2018, 3:35:19 AM5/31/18
to ns-3-users
I intend to collect packet delivery ratio of MANET, and write according codes by referring wifi-example-sim.cc. The program runs successfully,  however,  the output is 0!!! I have checked my program many times, but i cannot figure out what was wrong. Can anybody help in correcting it?

The following is the code in .hpp file.
 Config::ConnectWithoutContext("/NodeList/*/ApplicationList/*/$ns3::PacketSink/Rx", MakeCallback (&ReceivePacket));
   
   std::cout << "receive: " << PRecv << std::endl;   

   std::string Myexperiment = m_experiment;
   
   std::string strategy ("wifi-default");
   
   std::string input;
   {
   std::stringstream sstr;
       sstr << maxRange;
       input = sstr.str ();
   }
   
   std::string runID;
   {
std::stringstream sstr;
    sstr << maxRange;
sstr << "_";
sstr << m_run;
    runID = sstr.str ();
  }
   
   DataCollector data;
   data.DescribeRun (Myexperiment,strategy,input,runID);
   
   
   Ptr<PacketCounterCalculator> appTx = CreateObject<PacketCounterCalculator>();
   appTx->SetKey ("sender-tx-packets");
   appTx->SetContext ("nodeAll");
   Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::OnOffApplication/Tx",MakeCallback (&PacketCounterCalculator::PacketUpdate,appTx));
   data.AddDataCalculator (appTx);
   
   
   Ptr<CounterCalculator<uint32_t> > appRx =
      CreateObject<CounterCalculator<uint32_t> >();
   appRx->SetKey ("receiver-rx-packets");
   appRx->SetContext ("nodeAll");
   Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::PacketSink/Rx",
                    MakeBoundCallback (&RxCallback,
                                 appRx));
   data.AddDataCalculator (appRx);
   
   std::string format ("omnet");
   Ptr<DataOutputInterface> output = 0;
   output = CreateObject<OmnetDataOutput>();
   output->Output (data);
   output->GetFilePrefix ();
ad-hoc.h
ad-hocRun.cc
Reply all
Reply to author
Forward
0 new messages