Train agents using TCP traffic
ffrommel opened this issue · comments
Hello.
I would like to ask you if you had tried training the agents using TCP traffic. I tried to modify the installTrafficGenerator function of the scenario.h module to generate TCP traffic but I couldn't get it to work, that is, no TCP transmissions ocur. To do this I relied on the lines that were commented out on that function and on this example from NS-3: https://www.nsnam.org/doxygen/wifi-tcp_8cc_source.html.
Thank you very much for any help you can give me on this.
Regards.
Fabian.
Hi,
I'm not sure if we've tried it yet. If the problems are still persisting I can take a look whether we have something that could help in making the TCP work.
Best,
Witek
Hi Witek. Thank you very much for your answer.
I kept working on this change and managed to install the TCP source and sink applications on all nodes, however, only transmissions from 1 or 2 clients ocur, the others do not send anything.
What I did was create the function generateTcpTraffic that loads the applications to the serversApp and clientsApp variables (ApplicationContainer type) defined as global variables inside scenario.h:
void Scenario::generateTcpTraffic (double startTime, double endTime, int payloadSize, Ptr<Node> srvNode, Ptr<Node> cliNode, Ipv4Address address, int port)
{
startTimes.push_back(startTime);
endTimes.push_back(endTime);
Address localAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", localAddress);
serversApp.Add (packetSinkHelper.Install (srvNode));
OnOffHelper onoff ("ns3::TcpSocketFactory", Ipv4Address::GetAny ());
onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
onoff.SetAttribute ("PacketSize", UintegerValue (payloadSize));
onoff.SetAttribute ("DataRate", DataRateValue (DataRate ("10Mbps")));
AddressValue remoteAddress (InetSocketAddress (address, port));
onoff.SetAttribute ("Remote", remoteAddress);
clientsApp.Add (onoff.Install (cliNode));
}
Then, from the installScenario function, I go through all the clients and load the applications like this:
generateTcpTraffic(0.0, simulationTime + 2 + envStepTime*historyLength, payloadSize, this->staNodes.Get(i), this->apNode.Get(0), this->stasInterface.GetAddress(i), this->port++);
And I start the applications like this:
double min = 0.0;
double max = 1.0;
Ptr<UniformRandomVariable> fuzz = CreateObject<UniformRandomVariable>();
fuzz->SetAttribute("Min", DoubleValue(min));
fuzz->SetAttribute("Max", DoubleValue(max));
serversApp.StartWithJitter (Seconds (0.0), fuzz);
serversApp.Stop (Seconds (simulationTime + 2 + envStepTime*historyLength));
clientsApp.StartWithJitter (Seconds (0.5), fuzz);
clientsApp.Stop (Seconds (simulationTime + 2 + envStepTime*historyLength));
Finally, I modified the ScheduleNextStateRead function of the cw.cc module to print the bytes received in the AP sent by each client and the accumulated bytes:
int totalRx = 0;
int lastValue = 0;
for (int i=0 ; i < nWifi ; ++i)
{
NS_LOG_UNCOND("### [ScheduleNextStateRead] Bytes from STA " << i << ": " << DynamicCast<PacketSink>(serversApp.Get (i))->GetTotalRx ());
totalRx += DynamicCast<PacketSink> (serversApp.Get (i))->GetTotalRx ();
}
lastValue = g_rxPktNum;
g_rxPktNum += (totalRx - lastValue);
NS_LOG_UNCOND("### [ScheduleNextStateRead] Total bytes: " << g_rxPktNum);
Thank you very much for any guidance you can give me.
Regards.
Fabián.
Hello Witek.
I am pleased to tell you that I was able to get the TCP transmissions to work. To do this, I relied on this example from NS-3: https://www.nsnam.org/doxygen/tcp-bulk-send_8cc_source.html. For this reason, I close this issue.
Regards,
Fabian.