Why too many packet loss in Wifi

1,194 views
Skip to first unread message

Vijay

unread,
Oct 2, 2013, 5:41:07 PM10/2/13
to ns-3-...@googlegroups.com
From AP->STA, I am losing 50% of the packets. However from STA->AP, every packet is received.

Flow 1 (10.1.3.1 -> 10.1.3.3)
  Tx Bytes:   268176
  Rx Bytes:   267572
  Goodput: 0.408282 Mbps
  Packet Loss Ratio: 0.225225 %
  mean Delay: 0.817473 ms
  mean Jitter: 0.260213 ms
  mean Hop count: 1
Flow 2 (10.1.3.3 -> 10.1.3.1)
  Tx Bytes:   268176
  Rx Bytes:   134692
  Goodput: 0.205524 Mbps
  Packet Loss Ratio: 49.7748 %
  mean Delay: 15.5464 ms
  mean Jitter: 4.68896 ms
  mean Hop count: 1


The code is as below:

#include "ns3/core-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/wifi-module.h"
#include "ns3/mobility-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
#include "ns3/flow-monitor-module.h"

// Default Network Topology
//
//   Wifi 10.1.3.0
//           AP
//  *    *    *  
//  |    |    |      
// n0   n1   n2  

using namespace ns3;

NS_LOG_COMPONENT_DEFINE ("ThirdScriptExample");

int
main (int argc, char *argv[])
{

  CommandLine cmd;

  cmd.Parse (argc,argv);

  NodeContainer wifiStaNodes;
  wifiStaNodes.Create (2);
  NodeContainer wifiApNode;
  wifiApNode.Create(1);

  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
  phy.SetChannel (channel.Create ());

  WifiHelper wifi = WifiHelper::Default ();
  wifi.SetRemoteStationManager ("ns3::AarfWifiManager");

  NqosWifiMacHelper mac = NqosWifiMacHelper::Default ();

  Ssid ssid = Ssid ("ns-3-ssid");
  mac.SetType ("ns3::StaWifiMac",
               "Ssid", SsidValue (ssid),
               "ActiveProbing", BooleanValue (false));

  NetDeviceContainer staDevices;
  staDevices = wifi.Install (phy, mac, wifiStaNodes);

  mac.SetType ("ns3::ApWifiMac",
               "Ssid", SsidValue (ssid));

  NetDeviceContainer apDevices;
  apDevices = wifi.Install (phy, mac, wifiApNode);

  MobilityHelper mobility;

  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::RandomWalk2dMobilityModel",
                             "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
  mobility.Install (wifiStaNodes);

  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
  mobility.Install (wifiApNode);

  InternetStackHelper stack;
  stack.Install (wifiStaNodes);
  stack.Install (wifiApNode);

  Ipv4AddressHelper address;

  address.SetBase ("10.1.3.0", "255.255.255.0");
  Ipv4InterfaceContainer Interfaces;
  Interfaces.Add (address.Assign (staDevices));
  Interfaces.Add (address.Assign (apDevices));

  ApplicationContainer clientApps, serverApps;
  OnOffHelper dlClient ("ns3::UdpSocketFactory",Address(InetSocketAddress (Interfaces.GetAddress(2), 9)));
  dlClient.SetConstantRate (DataRate ("1024Kb/s"), 576);
  clientApps.Add (dlClient.Install (wifiStaNodes.Get(0)));

  OnOffHelper ulClient ("ns3::UdpSocketFactory",Address(InetSocketAddress (Interfaces.GetAddress(0), 9)));
  ulClient.SetConstantRate (DataRate ("1024Kb/s"), 576);
  clientApps.Add (ulClient.Install (wifiApNode.Get(0)));
   
  // 7.Creating Sink

  PacketSinkHelper sink ("ns3::UdpSocketFactory",InetSocketAddress (Ipv4Address::GetAny (), 9));
  serverApps.Add (sink.Install (wifiApNode.Get(0)));
  PacketSinkHelper sink1 ("ns3::UdpSocketFactory",InetSocketAddress (Ipv4Address::GetAny (), 9));
  serverApps.Add (sink1.Install (wifiStaNodes.Get(0)));
  serverApps.Start (Seconds (0.0));
  clientApps.Start (Seconds (0.0));

  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();

  FlowMonitorHelper flowmon=FlowMonitorHelper();
  Ptr<FlowMonitor> monitor;
  monitor = flowmon.Install(wifiStaNodes);
  monitor = flowmon.Install(wifiApNode);
 
  Simulator::Stop (Seconds (2.0));

  Simulator::Run ();

  monitor->CheckForLostPackets ();
  Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmon.GetClassifier ());
  std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats ();
  for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i = stats.begin (); i != stats.end (); ++i)
  {
    Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow (i->first);
    std::cout << "Flow " << i->first << " (" << t.sourceAddress << " -> " << t.destinationAddress << ")\n";
    std::cout << "  Tx Bytes:   " << i->second.txBytes << "\n";
    std::cout << "  Rx Bytes:   " << i->second.rxBytes << "\n";
    std::cout << "  Goodput: " << i->second.rxBytes * 8.0 / 5.0 / (1024*1024) << " Mbps\n";
    std::cout << "  Packet Loss Ratio: " << (i->second.txPackets - i->second.rxPackets)*100/(double)i->second.txPackets << " %\n";
    //std::cout << "  Packet Dropped: " << i->second.packetsDropped  << "%\n";
    std::cout << "  mean Delay: " << i->second.delaySum.GetSeconds()*1000/i->second.rxPackets << " ms\n";
    std::cout << "  mean Jitter: " << i->second.jitterSum.GetSeconds()*1000/(i->second.rxPackets - 1) << " ms\n";
    std::cout << "  mean Hop count: " << 1 + i->second.timesForwarded/(double)i->second.rxPackets << "\n";
  }

  Simulator::Destroy ();
  return 0;
}



Anybody know what can be the reason for losing so many packets. I reduced data rate to 256 kbps, then also it is losing 50% packets.

Konstantinos

unread,
Oct 2, 2013, 5:46:32 PM10/2/13
to ns-3-...@googlegroups.com
I think that the problem might be similar to the one discussed here 

Try to 'jitter' the starting of the client apps.

Regards,
K.

On Wednesday, October 2, 2013 10:41:07 PM UTC+1, Vijay wrote:
From AP->STA, I am losing 50% of the packets. However from STA->AP, every packet is received.

Flow 1 (10.1.3.1 -> 10.1.3.3)
  Tx Bytes:   268176
  Rx Bytes:   267572
  Goodput: 0.408282 Mbps
  Packet Loss Ratio: 0.225225 %
  mean Delay: 0.817473 ms
  mean Jitter: 0.260213 ms
  mean Hop count: 1
Flow 2 (10.1.3.3 -> 10.1.3.1)
  Tx Bytes:   268176
  Rx Bytes:   134692
  Goodput: 0.205524 Mbps
  Packet Loss Ratio: 49.7748 %
  mean Delay: 15.5464 ms
  mean Jitter: 4.68896 ms
  mean Hop count: 1



Shashi Ranjan

unread,
Oct 2, 2013, 6:17:37 PM10/2/13
to ns-3-...@googlegroups.com
Thanks a lot Konstantinos,

you saved me. But I don't understand why its' happening. Are packet colliding?

Initially I thought may be its because of the queue length. But then when I increased the simulation time to 60 sec, packets starts receiving with packet loss = 1.5 %.

I am very curious what is actually happening ?

Thanks again



--
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/_8dGE2uYvQ0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/groups/opt_out.

Shashi Ranjan

unread,
Oct 2, 2013, 7:20:06 PM10/2/13
to ns-3-...@googlegroups.com
Dear Konstantinos,

Sorry to say the problem still exists. Now I have 4 STAs with different distance ( max = 60m). But I am losing lots of packets ( upto 96%). Also delay is also too high (upto 678ms). I have done as you suggested.

I am getting following results. Node 1 is th AP.

Source    Target    nTxPDUs    TxBytes    nRxPDUs    RxBytes    Goodput    PktLoss    Delay    Jitter
2    1    221    133484    35    21140    165.156    84.163    403.576    23.074
3    1    221    133484    68    41072    320.875    69.231    329.122    10.341
4    1    221    133484    26    15704    122.688    88.235    311.777    33.816
5    1    221    133484    35    21140    165.156    84.163    440.580    22.262
1    2    216    130464    12    7248    56.625    94.444    454.022    64.184
1    3    216    130464    12    7248    56.625    94.444    483.859    69.606
1    4    216    130464    9    5436    42.469    95.833    678.647    48.631
1    5    216    130464    12    7248    56.625    94.444    521.133    67.795



The relevant part of code is:

  uint16_t dlPort;
  uint16_t ulPort;
  ApplicationContainer clientApps, serverApps;
  Ptr<UniformRandomVariable> startTimeSeconds = CreateObject<UniformRandomVariable> ();
  startTimeSeconds->SetAttribute ("Min", DoubleValue (0.0));
  startTimeSeconds->SetAttribute ("Max", DoubleValue (0.1));
  Ptr<UniformRandomVariable> deltaTimeSeconds = CreateObject<UniformRandomVariable> ();
  deltaTimeSeconds->SetAttribute ("Min", DoubleValue (0.0));
  deltaTimeSeconds->SetAttribute ("Max", DoubleValue (0.01));
  if (enableWifi)
  {
    dlPort = 3333;
    ulPort = 2000;
    for (uint32_t u = 0; u < wifiStaNodes.GetN (); ++u)
    {
       ++ulPort;      
       Ipv4Address wifistaaddr = wifiIpIface.GetAddress(u);
       Ipv4Address apaddr = ApIpIfaces.GetAddress(0);  
       PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory", Address (InetSocketAddress (wifistaaddr, dlPort))); 
       PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory", Address (InetSocketAddress (apaddr, ulPort)));
       serverApps.Add (dlPacketSinkHelper.Install (wifiStaNodes.Get(u)));
       serverApps.Add (ulPacketSinkHelper.Install (wifiap));

       OnOffHelper dlClient ("ns3::UdpSocketFactory", Address (InetSocketAddress (wifistaaddr, dlPort))); 
       dlClient.SetConstantRate (DataRate ("1000Kb/s"), 576);

       OnOffHelper ulClient ("ns3::UdpSocketFactory", Address (InetSocketAddress (apaddr, ulPort)));

       ulClient.SetConstantRate (DataRate ("1024Kb/s"), 576);
  
       clientApps.Add (dlClient.Install (wifiap));
       clientApps.Add (ulClient.Install (wifiStaNodes.Get(u)));

       Time startTime = Seconds (startTimeSeconds->GetValue ()); // Will start at different time
       Time deltaTime = Seconds (deltaTimeSeconds->GetValue ()); // Will start at different time
       std::cout << startTime << deltaTime << std::endl;
      
       serverApps.Start (startTime);
       clientApps.Start (startTime + deltaTime);
    }
  }


Can u suggest what is happening?

vicente angelo de sousa junior

unread,
Jun 8, 2015, 6:21:56 AM6/8/15
to ns-3-...@googlegroups.com
Hi Shashi Ranjan,

Can you find a solution for this issue?

BR

Vicente Sousa

Sebastien Deronne

unread,
Jun 8, 2015, 7:27:46 AM6/8/15
to ns-3-...@googlegroups.com

I think as Konstantinos that you should use random or at least different starts for your applications.
You can also try to use different run/seed and check the results. What I expect is that you may obtain sometimes the opposite scenario for some run/seed, and sometimes you may get more fairness.

IMO the key problem is the queue policy that is being used (FIFO). In order to fully fix this bug, we would need to implement new queue policies (SFQ? others?). I know some work were ongoing on this aspect, but I have no clue what is their current status.

babrah dusenge

unread,
Oct 16, 2016, 3:28:52 PM10/16/16
to ns-3-users
Reply all
Reply to author
Forward
0 new messages