[ndnSIM] How to use hijacker in ndnSIM?

Alex Afanasyev alexander.afanasyev at ucla.edu
Tue Feb 26 09:03:50 PST 2013


Hi Chengyu,

scratch/ folder in NS-3 has a specific logic programmed into it, so you need to be careful by placing files into it.  Each  scratch/*.cc file is treated as a complete simulation scenario (i.e., need to contain main() function).  In your case neither custom-app.c nor hijacker.cc has (and they definitely should not have) main function, so the compiler is telling you that.

There is another logic of scratch/ folder that you can use and it should work in your case.   If you create a directory under scratch/  (like scratch/ndn-scenario) and put all .cc and .h file in there, then ./waf will think that you're compiling only one ndn-scenario and will compile all files together (exactly one main function should be present in all .cc files under this folder).

Hope it helps,
Alex

On Feb 26, 2013, at 12:38 AM, Chengyu Fan <chengyu at cs.colostate.edu> wrote:

> Alex,
> 
> Thanks for the quick reply. After I modify the wscript file to include hijacker.cc , it works.
> 
> More questions in lines.
> 
> On Tue, Feb 26, 2013 at 12:47 AM, Alex Afanasyev <alexander.afanasyev at ucla.edu> wrote:
> Hi Chengyu,
> 
> You would need to modify wscript file to include hijacker.cc in your scenario.   You can checkout an example in examples/wscript for "ndn-simple-with-custom-app".
>  
> At the same time, I would encourage you and everybody else against writing scenarios by modifying ndnSIM or NS-3.  My personal recommendation is to use a modular way, using for example the template https://github.com/cawka/ndnSIM-scenario-template.   If you simply copy hijacker.cc to extensions folder and copy your modified version of ndn-tree-app-delay-trace (alongside with topology files), it should compile and work.
> 
> 
> Now I try to use files "ndn-simple-with-custom-app.cc", "custom-app.h", "custom-app.cc", "hijacker.cc", and "hijacker.h" in directory "scratch".
> They work in the examples, so I think they should work in the scratch directory.
> 
> In addition, I also add two lines to include custom-app.h and hijacker.h in ndn-simple-with-custom-app.cc:
> #include "custom-app.h"
> #include "hijacker.h"
> 
> However, when I run the command "./waf --run=scratch/ndn-simple-with-custom-app", it gives me a lot of "relocation" error message:
> 
> ==================================
> ./waf --run=scratch/ndn-simple-with-custom-app
> Waf: Entering directory `/home/chengyu/ndnSIM/ns-3/build'
> [ 820/1989] cxx: scratch/ndn-simple-with-custom-app.cc -> build/scratch/ndn-simple-with-custom-app.cc.3.o
> [1715/1989] cxx: scratch/hijacker.cc -> build/scratch/hijacker.cc.2.o
> [1962/1989] cxxprogram: build/scratch/ndn-simple-with-custom-app.cc.3.o -> build/scratch/ndn-simple-with-custom-app
> [1963/1989] cxxprogram: build/scratch/hijacker.cc.2.o -> build/scratch/hijacker
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 13
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 13
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 13
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 2
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 2
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 12
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 13
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 13
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 13
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 13
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 13
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 13
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 13
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 13
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 13
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 20 has invalid symbol index 13
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 21 has invalid symbol index 13
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 22 has invalid symbol index 21
> /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crt1.o: In function `_start':
> (.text+0x18): undefined reference to `main'
> collect2: ld returned 1 exit status
> Waf: Leaving directory `/home/chengyu/ndnSIM/ns-3/build'
> Build failed
>  -> task in 'hijacker' failed (exit status 1): 
> 	{task 146488780: cxxprogram hijacker.cc.2.o -> hijacker}
> ['/usr/bin/g++', '-pthread', '-pthread', '-Wl,-Bsymbolic-functions', '-Wl,-z,relro', 'scratch/hijacker.cc.2.o', '-o', '/home/chengyu/ndnSIM/ns-3/build/scratch/hijacker', '-Wl,-Bstatic', '-Wl,-Bdynamic', '-Wl,--no-as-needed', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-L/usr/local/lib', '-L/usr/lib', '-lns3-dev-test-debug', '-lns3-dev-csma-layout-debug', '-lns3-dev-point-to-point-layout-debug', '-lns3-dev-netanim-debug', '-lns3-dev-lte-debug', '-lns3-dev-spectrum-debug', '-lns3-dev-antenna-debug', '-lns3-dev-aodv-debug', '-lns3-dev-dsdv-debug', '-lns3-dev-dsr-debug', '-lns3-dev-mesh-debug', '-lns3-dev-olsr-debug', '-lns3-dev-csma-debug', '-lns3-dev-wimax-debug', '-lns3-dev-applications-debug', '-lns3-dev-virtual-net-device-debug', '-lns3-dev-uan-debug', '-lns3-dev-energy-debug', '-lns3-dev-flow-monitor-debug', '-lns3-dev-ndnSIM-debug', '-lns3-dev-visualizer-debug', '-lns3-dev-nix-vector-routing-debug', '-lns3-dev-tap-bridge-debug', '-lns3-dev-internet-debug', '-lns3-dev-bridge-debug', '-lns3-dev-point-to-point-debug', '-lns3-dev-mpi-debug', '-lns3-dev-wifi-debug', '-lns3-dev-buildings-debug', '-lns3-dev-propagation-debug', '-lns3-dev-mobility-debug', '-lns3-dev-config-store-debug', '-lns3-dev-tools-debug', '-lns3-dev-stats-debug', '-lns3-dev-emu-debug', '-lns3-dev-topology-read-debug', '-lns3-dev-network-debug', '-lns3-dev-core-debug', '-lrt', '-lgsl', '-lgslcblas', '-lm', '-lgtk-x11-2.0', '-lgdk-x11-2.0', '-latk-1.0', '-lgio-2.0', '-lpangoft2-1.0', '-lpangocairo-1.0', '-lgdk_pixbuf-2.0', '-lcairo', '-lpango-1.0', '-lfreetype', '-lfontconfig', '-lgobject-2.0', '-lglib-2.0', '-lxml2', '-lsqlite3', '-lboost_iostreams', '-lpython2.7']
> 
> ====================================================
>  
> Let us know if you still in trouble with hijacker (either with or without modular way).
> 
> ---
> Alex
> 
> 
> On Feb 25, 2013, at 11:14 PM, Chengyu Fan <chengyu at cs.colostate.edu> wrote:
> 
>>> Hi~
>>> 
>>> I want to use the custom app "hijacker" in ndnSIM, so I modify the code of ndn-tree-app-delay-tracer.cc.
>>> 
>>> Basically I replace codes:
>>>   ndn::AppHelper producerHelper ("ns3::ndn::Producer");
>>>   producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));  
>>> 
>>> using: 
>>>   ndn::AppHelper producerHelper ("Hijacker");
>>> 
>>> 
>>> However, when I run ndn-tree-app-delay-trace, it prompts the error messages:
>>> 
>>> assert failed. cond="uid != 0", msg="Assert in TypeId::LookupByName: Hijacker not found", file=../src/core/model/type-id.cc, line=419
>>> terminate called without an active exception
>>> 
>>> Command ['/home/chengyu/ndnSIM/ns-3/build/src/ndnSIM/examples/ns3-dev-ndn-tree-app-delay-tracer-debug', '100'] terminated with signal SIGIOT. Run it under a debugger to get more information (./waf --run <program> --command-template="gdb --args %s <args>").
>>> 
>>> Does anybody know what the problem is?
>>> 
>>> Thanks,
>>> Chengyu
>> _______________________________________________
>> ndnSIM mailing list
>> ndnSIM at lists.cs.ucla.edu
>> http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim
> 
> 
> _______________________________________________
> ndnSIM mailing list
> ndnSIM at lists.cs.ucla.edu
> http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20130226/76c362b3/attachment.html>


More information about the ndnSIM mailing list