SIGSEGV while using ns3::RateErrorModel in 802.11g

485 views
Skip to first unread message

Carlos Cordero

unread,
May 10, 2014, 1:55:24 PM5/10/14
to ns-3-...@googlegroups.com
Hi all!

I have this small program to test error models. I'm using 802.11g, but when I add wifiPhy.SetErrorRateModel ("ns3::RateErrorModel");  I get SIGSEGV when receiving a packet. Is there a problem with my code or a known bug or something?

The code:

/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */

#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/internet-module.h"
#include "ns3/netanim-module.h"
#include "ns3/v4ping-helper.h"
#include "ns3/olsr-helper.h"
#include "ns3/flow-monitor-helper.h"
#include "ns3/ipv4-flow-classifier.h"
#include "ns3/flow-monitor.h"

using namespace ns3;

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

  std::string errorModelType = "ns3::RateErrorModel";

  ns3::PacketMetadata::Enable ();
  NS_LOG_COMPONENT_DEFINE ("TesisBase");
  LogComponentEnable ("V4Ping", LOG_LEVEL_DEBUG);
  LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_DEBUG);
//  LogComponentEnable ("YansWifiChannel", LOG_LEVEL_DEBUG);
  LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_LOGIC);
//  LogComponentEnableAll (LOG_LEVEL_LOGIC);


// Variable definition (all generic variables starts with "m_")
  int m_distAP = 65; // Distance between access nodes and mesh (mts)
  int m_totalTime = 500; // Time to simulate (segs)
  double m_rss = 90; //82.397 in 11g for ~50% packet loss @ 65 mts using ErpOfdm18Mbps
  std::string m_animFile = "resultados/prueba.xml"; // File for .xml
  std::string m_routeFile = "resultados/prueba-route.xml"; // File for .xml routing
  std::string m_statsFile = "resultados/prueba-sta"; // Prefix for statistics output files
  std::string m_flowmonFile = "resultados/prueba.flowmon"; // File for flowmon output

// Node container creation (all node containers starts with "nc_")
  NodeContainer nc_all; // Contains every node (starting with internet node, access nodes and then mesh nodes
  nc_all.Create (2);

// Set YansWifiChannel
  WifiHelper wifi;
  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
  wifi.SetStandard (WIFI_PHY_STANDARD_80211g);
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
                                "DataMode",StringValue ("ErpOfdmRate18Mbps"));
  wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
  wifiPhy.Set ("TxGain", DoubleValue (m_rss));
  wifiPhy.Set ("RxGain", DoubleValue (0));

  Config::SetDefault ("ns3::RateErrorModel::ErrorRate", DoubleValue (0.0001));
  Config::SetDefault ("ns3::RateErrorModel::ErrorUnit", StringValue ("ERROR_UNIT_PACKET"));
  wifiPhy.SetErrorRateModel ("ns3::RateErrorModel");

//  wifiPhy.SetErrorRateModel ("ns3::NistErrorRateModel");
/*  wifiPhy.SetErrorRateModel ("ns3::YansErrorRateModel",
                             "ErrorRate", DoubleValue (0.001),
                             "ErrorUnit", StringValue ("ERROR_UNIT_PACKET"));*/
  wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel");
  wifiMac.SetType ("ns3::AdhocWifiMac");
  wifiPhy.SetChannel (wifiChannel.Create ());
  NetDeviceContainer de_all = wifi.Install (wifiPhy, wifiMac, nc_all);

// Set startup positions for nodes
  MobilityHelper mobilityMesh; //Position mesh nodes
  mobilityMesh.SetPositionAllocator ("ns3::GridPositionAllocator",
                                    "MinX", DoubleValue (0),
                                    "MinY", DoubleValue (0),
                                    "DeltaX", DoubleValue (m_distAP),
                                    "DeltaY", DoubleValue (m_distAP),
                                    "GridWidth", UintegerValue (5),
                                    "LayoutType", StringValue ("RowFirst"));
  mobilityMesh.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
  mobilityMesh.Install (nc_all);

  InternetStackHelper internetStack;
  internetStack.Install (nc_all);

  Ipv4AddressHelper addrMesh;
  addrMesh.SetBase ("10.0.0.0", "255.255.255.0");
  Ipv4InterfaceContainer if_all = addrMesh.Assign (de_all);

// Install applications
  uint16_t port = 9;  // well-known echo port number
  UdpEchoServerHelper server (port);
  ApplicationContainer apps = server.Install (nc_all);
  apps.Start (Seconds (1.0));
  apps.Stop (Seconds (10.0));

  Address serverAddress = Address(if_all.GetAddress (0));
  uint32_t packetSize = 1024;
  uint32_t maxPacketCount = 10;
  UdpEchoClientHelper client (serverAddress, port);
  client.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
  client.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
  client.SetAttribute ("PacketSize", UintegerValue (packetSize));
  apps = client.Install (nc_all.Get (1));
  apps.Start (Seconds (2.0));
  apps.Stop (Seconds (10.0));

/////PING FOR TESTS
  V4PingHelper ping1 (if_all.GetAddress (0));
  ping1.SetAttribute ("Verbose", BooleanValue (true));
  ping1.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
  ApplicationContainer appPingInternet1 = ping1.Install (nc_all.Get (1));
  appPingInternet1.Start (Seconds (0));
  appPingInternet1.Stop (Seconds (m_totalTime - 1));
/////END PING FOR TESTS


// Sets animation configs and create .xml file for NetAnim
  AnimationInterface::SetNodeDescription (nc_all.Get (0), "0-Internet");
  AnimationInterface::SetNodeDescription (nc_all.Get (1), "1-AP");
  AnimationInterface anim (m_animFile);
  anim.EnablePacketMetadata(true);
  anim.EnableIpv4RouteTracking (m_routeFile, Seconds (0), Seconds (m_totalTime), Seconds (0.25));

// Run the simulation
  Simulator::Run ();
  Simulator::Stop (Seconds (m_totalTime));
  Simulator::Destroy ();
  return 0;
}

Carlos Cordero

unread,
May 10, 2014, 10:13:19 PM5/10/14
to ns-3-...@googlegroups.com
More info over this:

Debugging with gdb show this:

YansWifiPhy:EndReceive(0x8096440, 0x80928c8, 0x8096650)

Program received signal SIGSEGV, Segmentation fault.
0xb6124f2e in ns3::InterferenceHelper::CalculateChunkSuccessRate (
    this=0x8096530, snir=39.621321353057375, duration=..., mode=...)
    at ../src/wifi/model/interference-helper.cc:265

265      double csr = m_errorRateModel->GetChunkSuccessRate (mode, snir, (uint32_t)nbits);

And... then it dies

David Bravo

unread,
May 11, 2014, 2:31:24 AM5/11/14
to ns-3-...@googlegroups.com
virtual double ns3::ErrorRateModel::GetChunkSuccessRate -> A pure virtual method that must be implemented in the subclass.

You should use a subclass of ErrorRateModel, it is:
  • NistErrorRateModel, or
  • YansErrorRateModel

Bill Szybki

unread,
Sep 1, 2023, 10:25:12 AM9/1/23
to ns-3-users
Hi,
have you solved the problem? Can you show this code fragment?

Reply all
Reply to author
Forward
0 new messages