Including Your Modules into NS 2

10
Including Your Modules Including Your Modules into NS 2 into NS 2 by Teerawat Issariyakul http://www.ns2ultimate.com March 2010 http://www.ns2ultimate.com 1

description

Including Your Modules into NS 2. by Teerawat Issariyakul http://www.ns2ultimate.com March 2010. Assumptions and Objectives. You have developed NS2 modules in one or more of the following 3 file types: What you would like to do is to incorporate these files into NS2. Key step. - PowerPoint PPT Presentation

Transcript of Including Your Modules into NS 2

Page 1: Including Your Modules into NS 2

Including Your Modules into Including Your Modules into NS 2NS 2

by Teerawat Issariyakul

http://www.ns2ultimate.com

March 2010

http://www.ns2ultimate.com 1

Page 2: Including Your Modules into NS 2

Assumptions and Assumptions and ObjectivesObjectivesYou have developed NS2 modules in

one or more of the following 3 file types:

What you would like to do is to incorporate these files into NS2

http://www.ns2ultimate.com 2

File type Example

C++ file myfile.cc

Header file myfile.h

Tcl file myfile.tcl

Page 3: Including Your Modules into NS 2

Key stepKey step1. Go to your ns home directory

(e.g., nsallinone-2.35-RC3/ns-2.35).2. Look for a file called “Makefile”.3. Use your favorite editor to edit the

file (I will explain the details in the next slides).

4. Run “make” at the command prompt under your ns home directory.

5. You’re done. You should be able to invoke your new modules defined in .cc, .h, and .tcl from the NS prompt.

http://www.ns2ultimate.com 3

Page 4: Including Your Modules into NS 2

Modifying MakefileModifying MakefileThere are three places in Makefile

you will have to modify◦ OBJ_CC

◦ NS_TCL_LIB

◦ INCLUDE

Suppose your new module are ◦Stored in files myfile.h, myfile.cc, and myfile.tcl

◦Stored under directory nsallinone-2.35-RC3/ns-2.35/myDir

http://www.ns2ultimate.com 4

Page 5: Including Your Modules into NS 2

1. C++ Modules1. C++ ModulesAdd

“myDir/myfile.o \” to any line following this line

OBJ_CC = \

Note: ◦The extension must be “.o”, not

“.cc” nor “.h”◦“.o” is an object file obtained by

compiling “.cc” and “.h”

Page 6: Including Your Modules into NS 2

1. C++ Modules: 1. C++ Modules: ExampleExample

http://www.ns2ultimate.com 6

Page 7: Including Your Modules into NS 2

2. Tcl Modules2. Tcl ModulesAdd

“myDir/myfile.tcl \” to any line following this line

NS_TCL_LIB = \

Page 8: Including Your Modules into NS 2

Add

“-I./myDir \”

to any line following this line

INCLUDES = \

This will include myDir into the compiling path. So

that you don’t need to type the full path every time.

3. Including Directory 3. Including Directory (Optional)(Optional)

Page 9: Including Your Modules into NS 2

Final stepFinal stepJust run “ make ” at the command

prompt

Done!!

Page 10: Including Your Modules into NS 2

For more information For more information about NS 2about NS 2

Please see chapter 2 in this book from Springer

T. Issaraiyakul and E. Hossain, “Introduction to Network Simulator NS2”, Springer 2009 http://www.ns2ultimate.com 10