GIDForums  

Go Back   GIDForums > Computer Forums > Computer Software Forum - Linux
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 24-Feb-2007, 01:21
kunalsinha10 kunalsinha10 is offline
New Member
 
Join Date: Feb 2007
Posts: 6
kunalsinha10 is on a distinguished road

How to run a c++ program in ns2 in linux


I have installed ns-allinone2.30 successfully in my pc(m using Red Hat).Can u please tell me how to run a c++ program after the installation of ns2.I want to run a c++ program on tcp ,but not able to do it.If possible please send the replies in my mail also.
My mail ids are: kunalsinha10@rediffmail.com or
kunalsinha10@yahoo.co.in
  #2  
Old 24-Feb-2007, 11:36
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 6,153
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: How to run a c++ program in ns2 in linux


Quote:
Originally Posted by kunalsinha10
I have installed ns-allinone2.30 successfully in my pc(m using Red Hat).Can u please tell me how to run a c++ program after the installation of ns2.I want to run a c++ program on tcp ,but not able to do it.


If you mean that you want to simulate a c++ program that, somehow, involves tcp, then:

I would start by going through a tutorial on ns. Look on the web for more information. You might start here:

Mark Greis's Tutorial for ns

Somewhere around chapter VII there is a C++ example.

You should have the ns manual on-line or printed out for your reference as you go through the tutorial.

The ns Manual

If you have specific questions, then tell us what you tried what you expected and what didn't work.

Regards,

Dave
  #3  
Old 25-Feb-2007, 11:52
kunalsinha10 kunalsinha10 is offline
New Member
 
Join Date: Feb 2007
Posts: 6
kunalsinha10 is on a distinguished road

Re: How to run a c++ program in ns2 in linux


Thanks for ur reply,I looked into the e-book u told me to.Actually I wanted to know the commands to run the c++ program on ns2 in linux(Red Hat),like in c we can start a program by writing "vi a.c" and then compile it using "cc a.c" and then run it using "./a.out".
In the same way please tell me how to run the c++ program on ns2 in linux(Red Hat).
  #4  
Old 25-Feb-2007, 12:35
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 6,153
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: How to run a c++ program in ns2 in linux


Quote:
Originally Posted by kunalsinha10
Actually I wanted to know the commands to run the c++ program on ns2 in linux(Red Hat),like in c we can start a program by writing "vi a.c" and then compile it using "cc a.c" and then run it using "./a.out".
In the same way please tell me how to run the c++ program on ns2 in linux(Red Hat).


In general, to compile and run a c++ program from a command line on a Linux system with compilers installed in the usual place:


Suppose I have a file named "test.cpp" Here's how I do it (assuming that '$ ' is the bash shell command-line prompt):


$ g++ -Wall -W -pedantic test.cpp -o test
$ ./test


The first line compiles the file and tells the compiler to be very verbose with warning messages (that is what "-Wall -W -pedantic" tells it).

Instead of letting it use the default executable file name, "a.out", I find it much more desirable to tell it to call the output file something that is meaningful with respect to the source file name (that is what the "-o" tells it).

If there are any error messages, the executable output file will not be created. If there are any warning messages, then I do whatever is necessary to get rid of them.

Then, and only then, do I try to execute the program.

After the program is tested as much as you care to do, then, as far as I know, you can execute the program from a prompt within ns.

% ./test


Regards,

Dave
  #5  
Old 01-Mar-2007, 04:34
kunalsinha10 kunalsinha10 is offline
New Member
 
Join Date: Feb 2007
Posts: 6
kunalsinha10 is on a distinguished road

Re: How to run a c++ program in ns2 in linux


Please tell me how to compile and run this program.note:It does not have main()

[example code removed]
Last edited by admin : 13-Mar-2007 at 06:24. Reason: Please surround your C++ code with [cpp] ... [/cpp]
  #6  
Old 01-Mar-2007, 04:39
kunalsinha10 kunalsinha10 is offline
New Member
 
Join Date: Feb 2007
Posts: 6
kunalsinha10 is on a distinguished road

Re: How to run a c++ program in ns2 in linux


I am attaching a program.Please tell me how to compile and run the program on ns2.Note:It does not have main().
Last edited by admin : 13-Mar-2007 at 06:22. Reason: Removed file as requested
  #7  
Old 01-Mar-2007, 19:16
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 6,153
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: How to run a c++ program in ns2 in linux


Quote:
Originally Posted by kunalsinha10
I am attaching a program.Please tell me how to compile and run the program on ns2.Note:It does not have main().

You can't just compile a separate bunch of c++. You have to recompile the entire ns program with your new new stuff in it. There is an example in chapter 7 of the tutorial that I previously recommended. (There are other references on the web if you poke around a little.)

Mark Greis's Tutorial for ns


Regards,

Dave
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
BOOKEEPING program, HELP!! yabud C Programming Language 10 17-Nov-2006 03:48
How to read particular memory location ? realnapster C Programming Language 10 10-May-2006 09:11
How to make Linux shell calls in a C++ program salmaz8347 C++ Forum 3 14-Oct-2005 06:59
[TUTORIAL] Calling an external program in C (Linux) dsmith C Programming Language 4 22-Apr-2005 13:30
Call a C program through Linux shell script nuwandee C Programming Language 3 29-Mar-2004 21:54

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 08:08.


vBulletin, Copyright © 2000 - 2014, Jelsoft Enterprises Ltd.