Hello ns users, I am simulating a small Adhoc-wifi network of 4 nodes in ns3. Two nodes are OnOff sources and other two of them are OnOff sinks. I am starting two source nodes at the same time. The problem I am facing is that, after ARP request the simulation just halts, not even a single data packet is sent. Following is my script:
#include <iostream> #include <fstream> #include "ns3/core-module.h" #include "ns3/common-module.h" #include "ns3/node-module.h" #include "ns3/helper-module.h" #include "ns3/mobility-module.h" #include "ns3/contrib-module.h" #include "ns3/wifi-module.h" using namespace ns3; int main (int argc, char *argv[]) { Packet::EnableMetadata (); Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("0")); // enable rts cts all the time. WifiHelper wifi; MobilityHelper mobility; NodeContainer stas; NetDeviceContainer staDevs; InternetStackHelper stack; stas.Create (4); Ptr<WifiChannel> channel = CreateObject<WifiChannel> (); channel->SetPropagationDelayModel (CreateObject<ConstantSpeedPropagationDelayModel> ()); Ptr<LogDistancePropagationLossModel> log = CreateObject<LogDistancePropagationLossModel> (); log->SetReferenceModel (CreateObject<FriisPropagationLossModel> ()); channel->SetPropagationLossModel (log); wifi.SetPhy ("ns3::WifiPhy"); wifi.SetRemoteStationManager ("ns3::ArfWifiManager"); wifi.SetMac ("ns3::AdhocWifiMac"); mobility.SetPositionAllocator ("ns3::GridPositionAllocator", "MinX", DoubleValue (0.0), "MinY", DoubleValue (0.0), "DeltaX", DoubleValue (5.0), "DeltaY", DoubleValue (10.0), "GridWidth", UintegerValue (3), "LayoutType", StringValue ("RowFirst")); mobility.SetMobilityModel ("ns3::StaticMobilityModel"); mobility.Install (stas); staDevs = wifi.Install (stas, channel); stack.Install (stas); Ipv4AddressHelper ipv; ipv.SetBase ("10.1.1.0", "255.255.255.0"); Ipv4InterfaceContainer ipvcontain = ipv.Assign (staDevs); OnOffHelper onoff1 ("ns3::UdpSocketFactory", InetSocketAddress (ipvcontain.GetAddress (1), 9)); onoff1.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (10))); onoff1.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); ApplicationContainer apps1 = onoff1.Install (stas.Get (0)); apps1.Start (Seconds (0.5)); apps1.Stop (Seconds (10.0)); PacketSinkHelper sink ("ns3::UdpSocketFactory", Address (InetSocketAddress (Ipv4Address::GetAny (), 9))); sink.Install (stas.Get (1)); onoff1.SetAttribute ("Remote", AddressValue (InetSocketAddress (ipvcontain.GetAddress (3), 9))); ApplicationContainer apps2 = onoff1.Install (stas.Get (2)); sink.Install (stas.Get (3)); apps2.Start(Seconds (0.5)); apps2.Stop (Seconds (10.0)); std::ofstream ascii("out.tr"); WifiHelper::EnableAsciiAll(ascii); Simulator::Stop (Seconds (10.0)); Simulator::Run (); Simulator::Destroy (); return 0; } Following is content of out.tr after simulation: + 508192000ns /NodeList/0/DeviceList/0/$ns3::WifiNetDevice/Phy/Tx ns3::WifiMacHeader (DATA ToDS=0, FromDS=0, MoreFrag=0, Retry=0, MoreData=0 Duration/ID=0usDA=ff:ff:ff:ff:ff:ff, SA=00:00:00:00:00:01, BSSID=ff:ff:ff:ff:ff:ff, FragNumber=0, SeqNumber=0) ns3::LlcSnapHeader (type 0x806) ns3::ArpHeader (request source mac: 00-06-00:00:00:00:00:01 source ipv4: 10.1.1.1 dest ipv4: 10.1.1.2) ns3::WifiMacTrailer () + 508192000ns /NodeList/2/DeviceList/0/$ns3::WifiNetDevice/Phy/Tx ns3::WifiMacHeader (DATA ToDS=0, FromDS=0, MoreFrag=0, Retry=0, MoreData=0 Duration/ID=0usDA=ff:ff:ff:ff:ff:ff, SA=00:00:00:00:00:03, BSSID=ff:ff:ff:ff:ff:ff, FragNumber=0, SeqNumber=0) ns3::LlcSnapHeader (type 0x806) ns3::ArpHeader (request source mac: 00-06-00:00:00:00:00:03 source ipv4: 10.1.1.3 dest ipv4: 10.1.1.4) ns3::WifiMacTrailer () r 508304033ns /NodeList/3/DeviceList/0/$ns3::WifiNetDevice/Phy/RxOk ns3::WifiMacHeader (DATA ToDS=0, FromDS=0, MoreFrag=0, Retry=0, MoreData=0 Duration/ID=0usDA=ff:ff:ff:ff:ff:ff, SA=00:00:00:00:00:01, BSSID=ff:ff:ff:ff:ff:ff, FragNumber=0, SeqNumber=0) ns3::LlcSnapHeader (type 0x806) ns3::ArpHeader (request source mac: 00-06-00:00:00:00:00:01 source ipv4: 10.1.1.1 dest ipv4: 10.1.1.2) ns3::WifiMacTrailer () It appears that the ARP request does collide (I dont' know why?) since the node 3 is receiveing the ARP request sent by node 0 for node 2. But simulation doesn't carry on. This is the whole trace file that I have shown. Please help me in simulating more than 1 application in wifi ns3 because any example does not show us how to do so. Any help would be greatly appreciated. Thank you, BR, Amit Soni