//*
//server app and install,dlport = 80
PacketSinkHelper dlPacketSinkHelper ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dlPort));
PacketSinkHelper dlPacketSinkHelper_2 ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dlPort));
serverApps.Add(dlPacketSinkHelper.Install (remoteHost));
serverApps.Add(dlPacketSinkHelper_2.Install (otherNode));
//*
// traffic A, mechost is an fake IP, just a target to send packet
OnOffHelper UEappToSendtoMEC ("ns3::UdpSocketFactory", Address ());
UEappToSendtoMEC.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
UEappToSendtoMEC.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
AddressValue mecAddress (InetSocketAddress (Ipv4Address(mechost), dlPort));
UEappToSendtoMEC.SetAttribute ("Remote", mecAddress);
UEappToSendtoMEC.SetAttribute ("DataRate", DataRateValue (DataRate("20kb/s")));
UEappToSendtoMEC.SetAttribute ("PacketSize", UintegerValue (75));
UEappToSendtoMEC.SetAttribute ("MaxBytes", UintegerValue (0));
//*
// traffic B
OnOffHelper UEappToSendtoCentral ("ns3::TcpSocketFactory", Address ());
UEappToSendtoCentral.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
UEappToSendtoCentral.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
AddressValue remoteAddress (InetSocketAddress (remoteHostAddr, CentralPort));
UEappToSendtoCentral.SetAttribute ("Remote", remoteAddress);
UEappToSendtoCentral.SetAttribute ("DataRate", DataRateValue (DataRate("20kb/s")));
UEappToSendtoCentral.SetAttribute ("PacketSize", UintegerValue (75));
UEappToSendtoCentral.SetAttribute ("MaxBytes", UintegerValue (0));
//*
//traffic C
OnOffHelper UEappBkTraffic ("ns3::UdpSocketFactory", Address ());
UEappBkTraffic.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
UEappBkTraffic.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
AddressValue otherForBkAddress (InetSocketAddress (otherAddr, dlPort));
UEappBkTraffic.SetAttribute ("Remote", otherForBkAddress);
UEappBkTraffic.SetAttribute ("DataRate", DataRateValue (DataRate("70kb/s")));
UEappBkTraffic.SetAttribute ("PacketSize", UintegerValue (100));
UEappBkTraffic.SetAttribute ("MaxBytes", UintegerValue (0));
//*
//Traffic A and B install (All UE)
for(uint32_t i=0; i<GameUeNum; i++){
clientApps.Add(UEappToSendtoMEC.Install (ueNodes.Get(i)));
clientApps.Add(UEappToSendtoCentral.Install (ueNodes.Get(i)));
}
//*
//Traffic C install
for(uint32_t i =0 ; i<UeBackGroundList.size();i++){
uint16_t UeIndex = UeBackGroundList[i];
Ptr<Node> TempNode = ueNodes.Get(UeIndex);
clientApps.Add (UEappBkTraffic.Install (TempNode));
}
//*
//App time setting
serverApps.Start (Seconds (0.1));
clientApps.Start (Seconds (0.5));
clientApps.Stop (Seconds (simTime-1));
serverApps.Stop (Seconds (simTime-0.5));