Results 1 to 6 of 6

Thread: c++ ns3 simulator compiling error

Threaded View

  1. #1
    Join Date
    Nov 2012

    c++ ns3 simulator compiling error

    Hello. I am trying to compile the code below using the command line. The error I get is:

    one.cpp:8:29: fatal error: ns3/core-module.h: No such file or directory compilation terminated.
    This how I am compiling:

    g++ -o one one.cpp
    Can someone please explain how to compile this code through the command line?

    Note: When I try to compile using Geany it compiles fine.


     * UdpEchoClient     UdpEchoServer
     *      n0 -------------- n1
     *         point-to-point
    #include <ns3/core-module.h>
    #include <ns3/network-module.h>
    #include <ns3/internet-module.h>
    #include <ns3/point-to-point-module.h>
    #include <ns3/applications-module.h>
    using namespace ns3;
    int main ()
      LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
      LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
      NodeContainer nodes;
      nodes.Create (2);
      PointToPointHelper pointToPoint;
      pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
      pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
      NetDeviceContainer devices;
      devices = pointToPoint.Install (nodes);
      InternetStackHelper stack;
      stack.Install (nodes);
      Ipv4AddressHelper address;
      address.SetBase ("", "");
      Ipv4InterfaceContainer interfaces;
      interfaces = address.Assign (devices);
      UdpEchoServerHelper echoServer (9);
      ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));
      serverApps.Start (Seconds (1.0));
      serverApps.Stop (Seconds (10.0));
      UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9);
      echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
      echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
      echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
      ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));
      clientApps.Start (Seconds (2.0));
      clientApps.Stop (Seconds (10.0));
      Simulator::Run ();
      Simulator::Destroy ();
      return 0;
    Last edited by binaryperson; April 18th, 2013 at 12:52 AM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts