Как отследить CWND из ApplicationContainer, который создается из OnOffHelper - PullRequest
0 голосов
/ 25 апреля 2020

Я использовал следующий сегмент кода для создания Приемника и Передатчика (который взят из wifi-tcp. cc)

   /* Install TCP Receiver on the access point */
   PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", InetSocketAddress (staInterface2.GetAddress (0), 9));
   ApplicationContainer sinkApp = sinkHelper.Install (staWifiNode2);
   sink = StaticCast<PacketSink> (sinkApp.Get (0));

   /* Install TCP/UDP Transmitter on the station */
   OnOffHelper server ("ns3::TcpSocketFactory", (InetSocketAddress (staInterface2.GetAddress (0), 9)));
   server.SetAttribute ("PacketSize", UintegerValue (payloadSize));
   server.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
   server.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
   server.SetAttribute ("DataRate", DataRateValue (DataRate (dataRate)));
   ApplicationContainer serverApp = server.Install (staWifiNode);

Что я хочу сделать, это отследить cwnd в serverApp. Я пробовал следующий код, но он не работает на нс 3.30.

   AsciiTraceHelper asciiTraceHelper;
   Ptr<OutputStreamWrapper> stream = asciiTraceHelper.CreateFileStream ("emtp-low-frequency-transfer.cwnd");

   Simulator::Schedule (Seconds (0.5)+NanoSeconds (1.0), 
        &MyEventHandller, firstNetworkNodes.Get(0)->GetApplication(0), stream);
 static void 
 CwndTracer (Ptr<OutputStreamWrapper> stream, uint32_t oldval, uint32_t newval)
 {
   // NS_LOG_INFO ("Moving cwnd from " << oldval << " to " << newval);
   NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << "\t" << newval);
   *stream->GetStream () << Simulator::Now ().GetSeconds () << "\t" << oldval << "\t" << newval << std::endl;
 }

 void 
 MyEventHandller (Ptr<Application> app, Ptr<OutputStreamWrapper> stream)
 {
   // get socket according to each application helper.
   // for OnOffHelper, the application object is "OnOffApplication".
   // for more information about this, ref. Doxygen documentation system,
   // and check the class list, select "ns::Application", looking at the
   // Inheritance diagram for "ns::Application:".

   Ptr<Socket> src_socket  = app->GetObject<OnOffApplication>()->GetSocket();

   // ref. Doxygen documentation system, chesk the list of all trace sources
   // at "modules"->"C++ Constructs Used by All Modules"->"Debugging"->
   // "the list of all trace sources".
   src_socket->TraceConnectWithoutContext("CongestionWindow", 
        MakeBoundCallback(&CwndTracer, stream));
 }

следующее для создания узлов

   NodeContainer firstNetworkNodes;
   firstNetworkNodes.Create (2);

   NodeContainer secondNetworkNodes;
   secondNetworkNodes.Create (2);

   NodeContainer middleNetworkNodes;
   middleNetworkNodes.Add (firstNetworkNodes.Get (1));
   middleNetworkNodes.Add (secondNetworkNodes.Get (0));

В этом случае, что возможно способ распечатать cwnd ??

...