assert failed: Ipv4 AddressHelper

587 views
Skip to first unread message

chadni

unread,
Sep 21, 2014, 1:38:43 AM9/21/14
to ns-3-...@googlegroups.com

Hello,
I did install the Internet Stack in all the nodes but instead of that i m getting this error.


assert failed. cond="ipv4", msg="Ipv4AddressHelper::Assign(): NetDevice is associated with a node without IPv4 stack installed -> fail (maybe need to use InternetStackHelper?)", file=../src/internet/helper/ipv4-address-helper.cc, line=145
terminate called without an active exception
Command ['/home/Roshni/ns-allinone-3.20/ns-3.20/build/scratch/ourpaperFinal'] terminated with signal SIGABRT. Run it under a debugger to get more information (./waf --run <program> --command-template="gdb --args %s <args>"

Thank You
Chadni

my code

int main(int argc, char *argv[])
{
uint32_t nMobile = 1;
uint32_t nServer = 1;
uint32_t nWifi = 16;
    bool verbose = true;
   if (verbose)
    {
      
      LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
    }

    // enable rts cts all the time.
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("0"));
  // disable fragmentation
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
// 1. Create the nodes and hold them in a container
  NodeContainer server;
  server.Create (nServer); //create a server node
  NodeContainer smartPhone;
  smartPhone.Create (nMobile); //create a mobile node
  NodeContainer wifiApNode ;
  wifiApNode.Create(nWifi);   //create access point
  NodeContainer wifiAp;

   for(uint32_t i=0;i<nWifi;i++)
  {
    wifiAp.Add(wifiApNode.Get(i));
  }
  
  WifiHelper wifi = WifiHelper::Default ();
 
  MobilityHelper mobility;

  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 ("wifi-default");
  wifi.SetRemoteStationManager ("ns3::ArfWifiManager");

 //3. Set up MAC for AP
 mac.SetType ("ns3::ApWifiMac",
               "Ssid", SsidValue (ssid),
                 "BeaconGeneration", BooleanValue (true),
                    "BeaconInterval", TimeValue (Seconds (5)));


  NetDeviceContainer apDevice;
      apDevice = wifi.Install (phy, mac, wifiAp);  
  


 //add mobility
  
  Ptr<ListPositionAllocator> positionAlloc = CreateObject <ListPositionAllocator>();
  for (int j = 0; j < 4; ++j)
  {
    for (int i = 0; i < 4; ++i)
    {
      positionAlloc ->Add(Vector(i*100, j*100, 0)); // apn

    }
  }
   
    mobility.SetPositionAllocator (positionAlloc);
    mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
    mobility.Install (wifiAp);


// 5.Add Internet layers stack
InternetStackHelper stack; 
stack.Install (wifiAp);
  


// 6. Assign IP address to each device
 Ipv4AddressHelper ipv4;
    NS_LOG_INFO ("Assign IP Addresses.");
     ipv4.SetBase ("10.1.1.0", "255.255.255.0");

       Ipv4InterfaceContainer interface = ipv4.Assign (apDevice);
        TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
        

  Simulator::Run ();
  Simulator::Destroy ();
  return 0;


}

Tommaso Pecorella

unread,
Sep 21, 2014, 2:12:49 AM9/21/14
to ns-3-...@googlegroups.com


Do NOT post the code in the message. There's a *@#§&%$ "attach a file" function and it hasn't been made just to have a fancy header in the posting interface.

Thank you very much,

T.

Tommaso Pecorella

unread,
Sep 21, 2014, 2:41:05 AM9/21/14
to ns-3-...@googlegroups.com
Works for me. After adding the missing includes and a Simulator::Stop(Seconds(100)); of course.

T

Chaithra B.R.

unread,
May 19, 2018, 4:04:21 AM5/19/18
to ns-3-users
What are all the directives we need to add?.because even after adding all the includes I am getting the same error
Reply all
Reply to author
Forward
0 new messages