Its all about Network Simulations, Internet of Things, Sensor Networks, Programming, etc

Network Simulator 2

Network Simulator 3

Post Page Advertisement [Top]

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

3 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

Bottom Ad [Post Page]