The error is given below:
memran@Ubuntu-VM:~/tarballs/ns-allinone-3.29/ns-3.29$ ./waf --run examples/tutorial/first
Waf: Entering directory `/home/memran/tarballs/ns-allinone-3.29/ns-3.29/build'
[2516/2732] Compiling examples/tutorial/first.cc
[2692/2732] Linking build/examples/tutorial/ns3.29-first-debug
examples/tutorial/first.cc.2.o: In function `main':
/home/memran/tarballs/ns-allinone-3.29/ns-3.29/build/../examples/tutorial/first.cc:102: undefined reference to `ns3::AnimationInterface::AnimationInterface(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/home/memran/tarballs/ns-allinone-3.29/ns-3.29/build/../examples/tutorial/first.cc:103: undefined reference to `ns3::AnimationInterface::SetConstantPosition(ns3::Ptr<ns3::Node>, double, double, double)'
/home/memran/tarballs/ns-allinone-3.29/ns-3.29/build/../examples/tutorial/first.cc:104: undefined reference to `ns3::AnimationInterface::SetConstantPosition(ns3::Ptr<ns3::Node>, double, double, double)'
/home/memran/tarballs/ns-allinone-3.29/ns-3.29/build/../examples/tutorial/first.cc:102: undefined reference to `ns3::AnimationInterface::~AnimationInterface()'
/home/memran/tarballs/ns-allinone-3.29/ns-3.29/build/../examples/tutorial/first.cc:102: undefined reference to `ns3::AnimationInterface::~AnimationInterface()'
collect2: error: ld returned 1 exit status
Waf: Leaving directory `/home/memran/tarballs/ns-allinone-3.29/ns-3.29/build'
Build failed
-> task in 'first' failed with exit status 1 (run with -v to display more information)
memran@Ubuntu-VM:~/tarballs/ns-allinone-3.29/ns-3.29$
The first.cc code is given below:
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#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"
#include "ns3/netanim-module.h"
//define a namespace
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("FirstScriptExample");
int
main (int argc, char *argv[])
{
//CommandLine is a class cmd is an object and Parse is a function
CommandLine cmd;
cmd.Parse (argc, argv);
//Take Logs
Time::SetResolution (Time::NS);
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
//Take n number of computer in this example, means creating two nodes one client and the other is server
//like this(Cient--------Server) with a link and then assign these nodes the IP addresses later below
//NodeContainer is a class, nodes is an object and Create is a function in that function, 2 is the parameter.
NodeContainer nodes;
nodes.Create (2); //nodes.Get(0), nodes.Get(1) to access 1st and 2nd nodes we will use below these methods/function
//Choose your technology to communicate means create a point to point link between the above two created nodes client and server
//PointToPointHelper is a class which has an object pointToPoint
//and further uses the two methods of that class which are SetDeviceAttribute method to set the datarate attribute value of this link
//and SetChannelAttribute method to set the delay attribute value on this point to point link
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
//Till here only the link is created having 5Mbps Datarate and 2ms of delay but yet the node are not connected together using this link
// 5Mbps Datarate
// A------------------B Network IP Address is 10.1.1.0 and subnet mask is 255.255.255.0
// 10.1.1.1 2ms delay 10.1.1.2
// Client ----------> Server
// port 49153 port 9
// Client <---------- Server
//Install technology on computers means the above created link will now connect the two devices
//NetDeviceContainer is a class, devices is an object for this class, pointToPoint is an object of PointToPointHelper class which uses the
//its function install and passes the nodes object of the NodeContainer class as an argument in the Install function call as a result a
//point to point link between these two devices or nodes will be created
NetDeviceContainer devices;
devices = pointToPoint.Install (nodes);
//Asking to follow rules for communication
InternetStackHelper stack;
stack.Install (nodes);
//Ipv4AddressHelper is a class and address is an object which Assigns or sets the Network IP address and Subnet Mask to communicate
//SetBase is a method or function which sets the network address parameter of this class
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer interfaces;
interfaces = address.Assign (devices);
//Create a x type of server on port x, actually UdpEchoServerHelper is a class which creates a server which listens on port 9
//with object echoServer
UdpEchoServerHelper echoServer (9);
//Install server on a node then Start and Stop the server
//ApplicationContainer is a class which uses the object serverApps to install the server application on the echoServer
//as node 1 which is 2nd node
ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
//Create x type of client and set its attributes
UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9);
echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
//Install the client application on a node then start and stop the client application
ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));
AnimationInterface anim ("anim1.xml");
anim.SetConstantPosition(nodes.Get(0), 1.0, 2.0);
anim.SetConstantPosition(nodes.Get(1), 2.0, 3.0);
//Run the simulation by calling two functions of the Simulator class Run and Destroy
Simulator::Run ();
Simulator::Destroy ();
return 0;
}