ns3::SeedManager::SetSeed (1);
stdma::StdmaHelper stdma;
stdma.SetStandard(ns3::WIFI_PHY_STANDARD_80211p_CCH);
stdma::StdmaMacHelper stdmaMac = stdma::StdmaMacHelper::Default();
ns3::Config::SetDefault ("stdma::StdmaMac::FrameDuration", ns3::TimeValue(ns3::Seconds(1.0)));
ns3::Config::SetDefault ("stdma::StdmaMac::MaximumPacketSize", ns3::UintegerValue(1000));
ns3::Config::SetDefault ("stdma::StdmaMac::ReportRate", ns3::UintegerValue(10));
ns3::Config::SetDefault ("stdma::StdmaMac::Timeout", ns3::RandomVariableValue (ns3::UniformVariable(8, 8)));
m_adaptiveDevices = stdma.Install(nodePhy,stdmaMac,m_adaptiveNodes);
m_baseDevices = stdma.Install(basePhy,stdmaMac,m_baseNodes);
m_allDevices.Add(m_baseDevices);
m_allDevices.Add(m_adaptiveDevices);
InternetStackHelper stack;
stack.Install(m_allNodes);
Ipv4AddressHelper addressAdhoc;
addressAdhoc.SetBase ("10.1.0.0", "255.255.0.0");
m_allInterfaces = addressAdhoc.Assign (m_allDevices);
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
OnOffHelper onoff1 ("ns3::UdpSocketFactory",Address (InetSocketAddress(m_allInterfaces.GetAddress(0),8080)));
onoff1.SetAttribute ("PacketSize", ns3::UintegerValue (400 - GetProtocolOverheads()));
onoff1.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"));
onoff1.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"));
//Base station Sink
TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
Ptr<Socket> sink = Socket::CreateSocket (m_baseNodes.Get(0), tid);
InetSocketAddress local = InetSocketAddress (m_allInterfaces.GetAddress(0), 8080);
//Now lets Tell all the other nodes to send packet to the sink.
for(uint32_t i=0;i<m_adaptiveNodes.GetN();i++){
ApplicationContainer temp = onoff1.Install (m_adaptiveNodes.Get (i));
temp.Start (Seconds (10));
temp.Stop (Seconds (m_totalSimTime - 15));
}