Skip to main content

Creation of a New Agent in ns2 - NS2 Tutorial # 10

To create an new Agent in NS2 that describes the OTcl and C++ linkages

We know that the file is stored in the folder
~ns-2.35/pradeep/tspagent.cc

Open the file ns-2.35/Makefile.in and make an entry of your own file (in this case, it is tspagent.cc

Find a vairable inside the Makefile.in called

OBJ_CC=

and make an entry there as shown below pradeep/tspagent.o \

Save the file and open a terminal, go to the folder ~ns-2.35/ and execute the command one by one

$] ./configure
$] make

Correct any mistakes or errors in your .cc file and run the above commands.
Successful OTcl and C++ linkages....

Thank you and Stay tuned for more lectures

Next lecture will be on AODV protocol and its modification.

Refer my website nsnam.com for downloading the source code and refer my videos at

https://www.youtube.com/tspradeepkumar

Share and Subscribe.

Thank you......





Download the files here
https://drive.google.com/open?id=1kaIrYn91xl2NUNNK64cjHrEHyiSJCIiY



T S Pradeep Kumar

Comments

  1. Respected sir
    please solve this problem
    root@vikas:/usr/local/ns-allinone-2.35/ns-2.35/pardeep# make
    make: *** No targets specified and no makefile found. Stop.
    root@vikas:/usr/local/ns-allinone-2.35/ns-2.35/pardeep# cd ..
    root@vikas:/usr/local/ns-allinone-2.35/ns-2.35# make
    g++ -c -Wall -Wno-write-strings -DTCP_DELAY_BIND_ALL -DNO_TK -DTCLCL_CLASSINSTVAR -DNDEBUG -DLINUX_TCP_HEADER -DUSE_SHM -DHAVE_LIBTCLCL -DHAVE_TCLCL_H -DHAVE_LIBOTCL1_14 -DHAVE_OTCL_H -DHAVE_LIBTK8_5 -DHAVE_TK_H -DHAVE_LIBTCL8_5 -DHAVE_TCLINT_H -DHAVE_TCL_H -DHAVE_CONFIG_H -DNS_DIFFUSION -DSMAC_NO_SYNC -DCPP_NAMESPACE=std -DUSE_SINGLE_ADDRESS_SPACE -Drng_test -I. -I. -I/usr/local/ns-allinone-2.35/tclcl-1.20 -I/usr/local/ns-allinone-2.35/otcl-1.14 -I/usr/local/ns-allinone-2.35/include -I/usr/local/ns-allinone-2.35/include -I/usr/local/ns-allinone-2.35/include -I/usr/include/pcap -I./tcp -I./sctp -I./common -I./link -I./queue -I./adc -I./apps -I./mac -I./mobile -I./trace -I./routing -I./tools -I./classifier -I./mcast -I./diffusion3/lib/main -I./diffusion3/lib -I./diffusion3/lib/nr -I./diffusion3/ns -I./diffusion3/filter_core -I./asim/ -I./qs -I./diffserv -I./satellite -I./wpan -o mdart/mdart_adp.o mdart/mdart_adp.cc
    mdart/mdart_adp.cc: In member function ‘void ADP::sendDarq(nsaddr_t, int)’:
    mdart/mdart_adp.cc:108:21: error: reference to ‘hash’ is ambiguous
    nsaddr_t dstAdd_ = hash(reqId);
    ^~~~
    In file included from ./mdart/mdart.h:52:0,
    from ./mdart/mdart_adp.h:51,
    from mdart/mdart_adp.cc:47:
    ./mdart/mdart_function.h:230:17: note: candidates are: nsaddr_t hash(nsaddr_t)
    inline nsaddr_t hash(nsaddr_t id) {
    ^~~~
    In file included from /usr/include/c++/7/bits/basic_string.h:6587:0,
    from /usr/include/c++/7/string:52,
    from /usr/include/c++/7/bitset:47,
    from ./mdart/mdart_function.h:62,
    from ./mdart/mdart.h:52,
    from ./mdart/mdart_adp.h:51,
    from mdart/mdart_adp.cc:47:
    /usr/include/c++/7/bits/functional_hash.h:58:12: note: template struct std::hash
    struct hash;
    ^~~~
    mdart/mdart_adp.cc: In member function ‘void ADP::sendDaup()’:
    mdart/mdart_adp.cc:396:21: error: reference to ‘hash’ is ambiguous
    nsaddr_t dstAdd_ = hash(mdart_->id_);
    ^~~~
    In file included from ./mdart/mdart.h:52:0,
    from ./mdart/mdart_adp.h:51,
    from mdart/mdart_adp.cc:47:
    ./mdart/mdart_function.h:230:17: note: candidates are: nsaddr_t hash(nsaddr_t)
    inline nsaddr_t hash(nsaddr_t id) {
    ^~~~
    In file included from /usr/include/c++/7/bits/basic_string.h:6587:0,
    from /usr/include/c++/7/string:52,
    from /usr/include/c++/7/bitset:47,
    from ./mdart/mdart_function.h:62,
    from ./mdart/mdart.h:52,
    from ./mdart/mdart_adp.h:51,
    from mdart/mdart_adp.cc:47:
    /usr/include/c++/7/bits/functional_hash.h:58:12: note: template struct std::hash
    struct hash;
    ^~~~
    Makefile:93: recipe for target 'mdart/mdart_adp.o' failed
    make: *** [mdart/mdart_adp.o] Error 1

    ~/usr/local/ns-allinone-2.35/ns-2.35/pardeep# ls
    myown.tcl tspagent.cc tspagent.o
    ~/usr/local/ns-allinone-2.35/ns-2.35/pardeep# ns myown.tcl
    invalid command name "Agent/PRADEEP"
    while executing
    "Agent/PRADEEP create _o3 "
    invoked from within
    "catch "$className create $o $args" msg"
    invoked from within
    "if [catch "$className create $o $args" msg] {
    if [string match "__FAILED_SHADOW_OBJECT_" $msg] {
    delete $o
    return ""
    }
    global errorInfo
    error "class $..."
    (procedure "new" line 3)
    invoked from within
    "new Agent/PRADEEP"
    invoked from within
    "set xyz [new Agent/PRADEEP]"
    (file "myown.tcl" line 1)

    ReplyDelete
  2. Dear Sir, tell us how to create a UDP agent that can receive packets from the source then send the received packets to another node (the destination).
    Is there any Agent in ns2 that can do this?

    ReplyDelete
  3. Please tell me in details how can I create a new Agent that can forward to same received packet to another destination. I tried hard to do this since more than 1 year, please help me.

    ReplyDelete

Post a Comment

Popular posts from this blog

Installing ns-3.34 in Ubuntu 20.04

This post shows how to install ns 3.34 in Ubuntu 20.04 LTS Prerequisites: Fresh installation of Ubuntu Version 20.04 LTS  ns3.34 can be downloaded from here Follow the video link for complete step by step instructions on the installation.  This version fixes the compilation issues of vanet-routing-compare.cc (bug in ns3.33)  Issue the following commands after opening a terminal  $ sudo apt update $ sudo apt install g++ python3 python3-dev python-dev pkg-config sqlite3 python3-setuptools git qt5-default gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3 openmpi-bin openmpi-common openmpi-doc libopenmpi-dev autoconf cvs bzr unrar openmpi-bin openmpi-common openmpi-doc libopenmpi-dev tcpdump wireshark libxml2 libxml2-dev Unzip or untar the ns-allinone-3.34.tar.bz2 in the home folder (in my case its /home/pradeepkumar) $ cd ns-allinone-3.34/ $ ./build.py --enable-examples --enable-tests  Once the installation is completed, you may get an output show

Installation of ns3 in Windows 10 and Windows 11 OS using WSL (Windows Subsystem for Linux)

This post shows how to install ns-3.33 in Windows 10 through WSL (Windows Subsystem for Linux) This posts works for Windows 11 also (I have tested it on a Windows 11 ISO and it works the Same way as mentioned in the following post.) This post will work for ns-3.3x version. Prerequisites : Install Windows Subsystem for Linux with GUI: Please refer the following video  System Information: OS used: Windows 10 and WSL (Ubuntu 20.04) GUI: XServer for Windows NS3 Version: ns-3.33 See the following complete video on how to install ns3 in Windows 10 Step 0 : Open XLaunch Step 1 :  Open WSL using PowerShell and open it as Administrator Command:/  wsl $ xfce4-session The GUI of Ubuntu Opens within Windows 10 OS. Step 2 : Download ns3 from nsnam.org website through Mozilla Firefox browser Step 3: Open a Terminal  $ sudo apt update $ sudo apt install build-essential autoconf automake libxmu-dev python3-pygraphviz cvs mercurial bzr git cmake p7zip-full python3-matplotlib python-tk python3-dev qt5-q

Installing NS-3.32 in Ubuntu 20.04

This is about installing ns version 3.32 in Ubuntu 20.04 LTS. #ns3 #ns3 .32 #networksimulation The commands used in the video are given here. $] sudo apt update $] sudo apt install build-essential autoconf automake libxmu-dev python3-pygraphviz cvs mercurial bzr git cmake p7zip-full python3-matplotlib python-tk python3-dev qt5-qmake qt5-default gnuplot-x11 wireshark Download the ns-allinone-3.32.tar.bz2 package from nsnam.org and copy it to /home/ folder See the full video for detailed instructions Extract it either in GUI or using command $] tar jxvf ns-allinone-3.32.tar.bz2 $] cd ns-allinone-3.32/ $] ./build.py --enable-examples --enable-tests The above command will take some time to install all the packages  You can see the output as shown below ns3 To check whether ns3 installed successfully, use the following commands. $] cd ns-3.32/ $] ./waf --run hello-simulator You should get the output as Hello Simulator $] ./waf --run first This is the example from the ns-3.32/exa