Successfully reported this slideshow.

Including Your Modules into NS 2

14,238 views

Published on

Published in: Education, Technology

Including Your Modules into NS 2

  1. 1. Including Your Modules into NS 2 by Teerawat Issariyakul http://www.ns2ultimate.com March 2010 http://www.ns2ultimate.com
  2. 2. Assumptions and Objectives <ul><li>You have developed NS2 modules in one or more of the following 3 file types: </li></ul><ul><li>What you would like to do is to incorporate these files into NS2 </li></ul>http://www.ns2ultimate.com File type Example C++ file myfile.cc Header file myfile.h Tcl file myfile.tcl
  3. 3. Key step <ul><li>Go to your ns home directory (e.g., nsallinone-2.35-RC3/ns-2.35 ). </li></ul><ul><li>Look for a file called “ Makefile ”. </li></ul><ul><li>Use your favorite editor to edit the file (I will explain the details in the next slides). </li></ul><ul><li>Run “ make ” at the command prompt under your ns home directory. </li></ul><ul><li>You’re done. You should be able to invoke your new modules defined in .cc , .h , and .tcl from the NS prompt. </li></ul>http://www.ns2ultimate.com
  4. 4. Modifying Makefile <ul><li>There are three places in Makefile you will have to modify </li></ul><ul><ul><li>OBJ_CC </li></ul></ul><ul><ul><li>NS_TCL_LIB </li></ul></ul><ul><ul><li>INCLUDE </li></ul></ul><ul><li>Suppose your new module are </li></ul><ul><ul><li>Stored in files myfile.h , myfile.cc , and myfile.tcl </li></ul></ul><ul><ul><li>Stored under directory nsallinone-2.35-RC3/ns-2.35/myDir </li></ul></ul>http://www.ns2ultimate.com
  5. 5. 1. C++ Modules <ul><li>Add </li></ul><ul><li>“ myDir/myfile.o ” </li></ul><ul><li>to any line following this line </li></ul><ul><li>OBJ_CC = </li></ul><ul><li>Note: </li></ul><ul><ul><li>The extension must be “ .o ”, not “ .cc ” nor “. h ” </li></ul></ul><ul><ul><li>“ . o ” is an object file obtained by compiling “. cc ” and “. h ” </li></ul></ul>
  6. 6. 1. C++ Modules: Example http://www.ns2ultimate.com
  7. 7. 2. Tcl Modules <ul><li>Add </li></ul><ul><li>“ myDir/myfile.tcl ” </li></ul><ul><li>to any line following this line </li></ul><ul><li>NS_TCL_LIB = </li></ul>
  8. 8. <ul><li>Add </li></ul><ul><li>“ -I./myDir ” </li></ul><ul><li>to any line following this line </li></ul><ul><li>INCLUDES = </li></ul><ul><li>This will include myDir into the compiling path. So that you don’t need to type the full path every time. </li></ul>3. Including Directory (Optional)
  9. 9. Final step <ul><li>Just run “ make ” at the command prompt </li></ul><ul><li>Done!! </li></ul>
  10. 10. For more information about 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

×