Question about the relationship between first.cc and myfirst.cc in tutorail

212 views
Skip to first unread message

James Ryan

unread,
Nov 4, 2015, 1:56:42 AM11/4/15
to ns-3-users
I'm new to ns3 and below are my questions.

My environment:
ubuntu 15.04
install by ns-allinone-3.24.tar.bz2 and following tutorial

Question: 
1.1
I just followed the tutorial and have run myfirst.cc. It gave right output. Then accidentally, I found that a syntax error in examples/tutorial/first.cc makes the build of scratch/myfirst.cc fail!

1.2
I tried to comment out all the staff in main() except "return 0;" in examples/tutorial/first.cc, then I execute ./waf and ./waf --run scratch/myfirst. Everything goes well as the code in scratch/myfirst.cc.

1.3 Then I went further to delete examples/tutorial/first.cc, run ./waf and get the following error:

Waf: Entering directory `/home/hong/Desktop/Software/ns3/bake/source/ns-3.24/build'
Waf: Leaving directory `/home/hong/Desktop/Software/ns3/bake/source/ns-3.24/build'
source not found: 'first.cc' in bld(use=['ns3-core', 'ns3-point-to-point', 'ns3-internet', 'ns3-applications'], features=['cxx', 'cxxprogram'], idx=2, meths=['process_rule', 'process_source', 'apply_link', 'process_use', 'propagate_uselib_vars', 'apply_incpaths', 'collect_compilation_db_tasks', 'create_task_macapp', 'create_task_macplist', 'install_boost', 'set_full_paths_hpux', 'set_macosx_deployment_target'], prec=defaultdict(<type 'list'>, {}), _name='first', posted=True, source='first.cc', ns3_module_dependencies=['ns3-core', 'ns3-point-to-point', 'ns3-internet', 'ns3-applications'], mappings={}, path=/home/hong/Desktop/Software/ns3/bake/source/ns-3.24/examples/tutorial, includes='#', is_ns3_program=True, target='ns3.24.1-first-debug') in /home/hong/Desktop/Software/ns3/bake/source/ns-3.24/examples/tutorial

So, from 1.1 and 1.3, examples/tutorial/first.cc influence the result of scratch/myfirst.cc; however, from 1.2, there seems to be no such influence.
I read the tutorial from start to Chap.5 carefully, but get no clue. Could you please tell me the relationship between these two?

2.
I'm sure I'm using ns3.24 and the tutorial is for ns3.24. But the my file organization is different from that in tutorial.
The biggest difference is that in tutorial it's `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build' while in my case it's `/home/hong/Desktop/Software/ns3/bake/source/ns-3.24/build'. There is no folder named repos or ns-3-dev in my all computer!

Thank you for your time and I'm looking for your reply.

Konstantinos

unread,
Nov 4, 2015, 4:24:21 AM11/4/15
to ns-3-users
Hi,

- Regarding the errors you get due to the /examples/tutorial/first.cc:
If while you configured ns-3, you enabled the examples (i.e. ./waf configure --enable-examples), then any file in /examples or /src/<module-name>/examples will be compiled. If there is any syntax or other compile error, the compiler will complain. It does not mean that you if you run scratch/myfirst only that file has to be correct. Everything has to be right.

By deleting the contents of the file in (1.2) you cleared the error. It does not mean that the program runs at it supposes to run, but the compiler does not complain for an error.
However, by deleting the file it self in (1.3) the compiler will complain because it hasn't found that file. There is a wscript file (similar to makefile if you are familiar) that tells the compiler which files it has to compile. One of them is /tutorial/first.cc and it can't find it, hence the error. 


- Regarding the organisation, I would say it is the same. You have used BAKE to download/build NS-3 and that's totally valid, while the author of the tutorial for that part used other methods (most probably because BAKE was not available at the time).
Anything behind the ns-3-<release> is just where the ns-3 is saved. For the author it was /home/craigdo/repos/ns-3-allinone/, for you is /home/hong/Desktop/Software/ns3/bake/source 
The author used the ns-3-dev release, you have used ns-3-24 release. 
The organisation is the same!

Just a note here: When you study (any) tutorial do not just blindly copy paste and expect to see precisely the same output. You have to understand what should be the same (i.e. the output when you run an experiment) but for example there might be some differences like above (where the file is stored, what time the simulation took place, etc).

Regards,
K.

James Ryan

unread,
Nov 4, 2015, 6:18:27 AM11/4/15
to ns-3-users
Dear K,

I really appreciate your answer.
Your answer really helps me a lot right now and future work!

Thank you!
Best wishes
Reply all
Reply to author
Forward
0 new messages