Amit Soni wrote:
> 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
> 
> 

Amit,
I'll cross-post this to ns-3-users list as well; please do any
follow-ups on the ns-3-users list only.

I had a quick look at your script tonight.  First thing that I did was
to try to localize the problem.  I swapped out the Wifi configuration
for a Csma configuration, to see whether the traffic generators were
behaving OK:

   CsmaHelper csma;
   csma.SetChannelAttribute ("DataRate", DataRateValue (5000000));
   csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
   staDevs = csma.Install (stas);

and then further below, I changed it to use Csma tracing helpers:
   //WifiHelper::EnableAsciiAll(ascii);
   CsmaHelper::EnableAsciiAll(ascii);

This produced a lot of UDP data, so it seems like the problem is in the
Wifi configuration or is a result of using WiFi (perhaps packet losses).

Next, I turned on full logging for the original file you posted, which I
called halting.cc and which I placed in the scratch/ directory:

export NS_LOG="*"
./waf --run scratch/halting

This produced voluminous output that I didn't feel like wading through,
so I turned off verbose logging:

export NS_LOG=""

I instead turned on a few selected log components as follows:

export NS_LOG="AdhocWifiMac:MacLow:NetDevice:ArpL3Protocol"

and reran the script, and this snippet was in the log trace:

508192000ns MacLow:StartTransmission(): 00:00:00:00:00:03 startTx
size=64, to=ff:ff:ff:ff:ff:ff, listener=0x638690^M508192000ns
MacLow:SendDataPacket(0x6381c0)^M
508192000ns MacLow:ForwardDown(0x6381c0, 0x6426a0, 0x638308,
wifia-6mbs)^M508192000ns MacLow:ForwardDown(): 00:00:00:00:00:03 send
DATA, to=ff:ff:ff:ff:ff:ff, size=64, mode=wifia-6mbs, duration=0ns,
seq=0x0^M
508304016ns MacLow:ReceiveError(0x6370d0, 0x642220, 0.999963)^M
508304016ns MacLow:ReceiveError(): 00:00:00:00:00:02 rx failed ^M
508304033ns MacLow:ReceiveOk(0x6392b0, 0x642400, 3395.41, wifia-6mbs, 0)^M
508304033ns MacLow:ReceiveOk(): 00:00:00:00:00:04 duration/id=0ns^M
508304033ns MacLow:ReceiveOk(): 00:00:00:00:00:04 rx broadcast
from=00:00:00:00:00:01^M
508304033ns AdhocWifiMac:ForwardUp(): received size=36,
from=00:00:00:00:00:01^M
508304033ns ArpL3Protocol:Receive()^M
508304033ns ArpL3Protocol:FindCache()^M
508304033ns ArpL3Protocol:Receive(): ARP: received request node=3, got
request from 10.1.1.1 for address 10.1.1.2; we have address
10.1.1.4^M508304033ns ArpL3Protocol:Receive(): node=3, got request from
10.1.1.1 for unknown address 10.1.1.2 -- drop^M


so, it seems that there are two ARP requests being sent, one from
10.1.1.1 to 10.1.1.2 that is received on node 3 (which discards it), and
one from 10.1.1.3 to 10.1.1.4 that is not received by anyone.

Looking at the subsequent arp behavior, both transmitting nodes are in
"wate reply" state

516384000ns ArpL3Protocol:Lookup()^M516384000ns ArpL3Protocol:Lookup():
node=0, wait reply for 10.1.1.2 valid -- drop previous
516384000ns ArpL3Protocol:Lookup()^M516384000ns ArpL3Protocol:Lookup():
node=2, wait reply for 10.1.1.4 valid -- drop previous
...

then move to "dead entry" state a while later, and stay there for the
rest of the simulation:

1524000000ns ArpL3Protocol:Lookup(): node=0, dead entry for 10.1.1.2
valid -- drop
1524000000ns ArpL3Protocol:Lookup()
1524000000ns ArpL3Protocol:Lookup(): node=2, dead entry for 10.1.1.4
valid -- drop


A quick scan of the arp-l3-protocol.cc implementation seems to suggest
that there is no capability to retransmit ARP requests, so maybe this is
a bug that needs confirmed or filing.

So, my initial take on this is:
1) the initial wireless transmissions are failing to reach intended nodes
2) arp is not retrying

I will try to look again tomorrow,
Tom


Reply via email to