/*-------------------------- Setup Wifi nodes --------------------------*/
// The below set of helpers will help us to put together the wifi NICs we want
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();
Ptr<YansWifiChannel> channel = wifiChannel.Create ();
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); //
wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel"); //
YansWifiPhyHelper wifiPhy; // corrected, eliminating Default method
wifiPhy.SetChannel (channel);
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11);
wifiPhy.Set ("TxPowerStart", DoubleValue(32));
wifiPhy.Set ("TxPowerEnd", DoubleValue(32));
wifiPhy.Set ("TxGain", DoubleValue(12));
wifiPhy.Set ("RxGain", DoubleValue(12));
wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue(-61.8));
wifiPhy.Set ("CcaMode1Threshold", DoubleValue(-64.8));
NqosWaveMacHelper wifi80211pMac = NqosWaveMacHelper::Default ();
Wifi80211pHelper wifi80211p = Wifi80211pHelper::Default ();
wifi80211p.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode",StringValue (phyMode),
"ControlMode",StringValue (phyMode));
NetDeviceContainer adhocDevices = wifi80211p.Install (wifiPhy, wifi80211pMac, adhocNodes);
uint16_t controlPort = 3999;
ApplicationContainer controlApps;
for (uint32_t u = 0; u < adhocNodes.GetN(); ++u) {
//!< Initial TDMA UE synchronization Function
double tdmaStart = (u+1)*minimumTdmaSlot;
Ptr<GaussMarkovMobilityModel> mobilityModel = adhocNodes.Get(u)->GetObject<GaussMarkovMobilityModel>(); // changed to GaussMarkovMobilityModel
V2vControlClientHelper ueClient("ns3::UdpSocketFactory", Address(InetSocketAddress(Ipv4Address::GetBroadcast(), controlPort)),
"ns3::UdpSocketFactory",InetSocketAddress(Ipv4Address::GetAny(), controlPort),
mobilityModel, tdmaStart, nWifis, minimumTdmaSlot, clusterTimeMetric);
ueClient.SetAttribute ("IncidentWindow", DoubleValue(incidentWindow));
controlApps.Add(ueClient.Install(adhocNodes.Get(u)));
}
controlApps.Start (Seconds(0.1));
controlApps.Stop (Seconds(simTime-0.1));
// scenario 10 nodes sends packets to 10 nodes
OnOffHelper onoff1("ns3::UdpSocketFactory", Address());
onoff1.SetAttribute("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=1.0]"));
onoff1.SetAttribute("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=0.0]"));
for (int i = 0; i < nSinks; i++)
{
Ptr<Socket> sink = SetupPacketReceive(adhocInterfaces.GetAddress(i), adhocNodes.Get(i)); // changed 0 to i
AddressValue remoteAddress(InetSocketAddress(adhocInterfaces.GetAddress(i), port));
onoff1.SetAttribute("Remote", remoteAddress);
Ptr<UniformRandomVariable> var = CreateObject<UniformRandomVariable>();
ApplicationContainer temp = onoff1.Install(adhocNodes.Get(i + nSinks));
temp.Start(Seconds(var->GetValue(20.0, 21.0)));
temp.Stop(Seconds(simTime));
}
Simulator::Stop(Seconds(simTime));
Simulator::Run();