Professional Documents
Culture Documents
OVERVIEW
Installation of NS2 Introduction to OTCL/C++ Recompiling NS2
Modification Adding
a new module
Linux
If DVD Version- no need of additional package installation Install all the packages (if default installation selected, then additional packages have to be installed) Additional packages to be installed, there may be GCC Issues, xgraph and NAM issues Cent OS is the alternative for RHEL
Basic commands (ls, chmod, tar, rpm, make, gedit, vi, pwd, passwd, echo, cd, etc) Directory structure and shell prompt Path variables setting, Installation of packages and dependencies
INSTALLATION OF NS2
Download from http://isi.edu/nsnam/ns/nsbuild.html#allinone Copy the file under /home/pradeep (if your username is abcdef then home folder will be /home/abcdef) Extract it using tar zxvf ns-allinone-2.34.tar.gz cd ns-allinone-2.34 ./install (if any errors, please correct it) Setting of paths in .bash_profile or .bashrc
OTCL
Interpreted Hierarchy Faster to interpret, slow to run Preferable for beginners
C++
Used when dealing with a packet, agent or a protocol Compiled Hierarchy Slow to compile, faster to execute
The interface between OTCL and C++ is TclCL (available as a folder in ~ns-allinone-2.34/tclcl-xxx)
TCLCL
(Methods to access the interpreted hierarchy) InstVar (binds member variable in both hierarchies together TclObject (base class of all simulation objects) TclClass (maps class of IH to class of CH) TclCommand (global access to CH from IH) EmbeddedTcl (translates OTCL Script to C++ Code)
TCLCL
Each class have various member functions that are used to get compiled As a case study, lets start how to create a simple agent.
SIMPLE AGENT
class TSPAgent : public Agent { public: TSPAgent(); protected: int command(int argc, const char*const* argv); private: int tsp_var1; double tsp_var2; void TSPPrivFunc(void); };
SIMPLE AGENT
static class TSPAgentClass : public TclClass { public: TSPAgentClass() : TclClass("Agent/TSPAgentOtcl") {} TclObject* create(int, const char*const*) { return(new TSPAgent()); } } class_tsp_agent; TSPAgent::TSPAgent() : Agent(PT_UDP) { bind("tsp_var1_otcl", &tsp_var1); bind("tsp_var2_otcl", &tsp_var2); }
SIMPLE AGENT
int TSPAgent::command(int argc, const char*const* argv) { if(argc == 2) { if(strcmp(argv[1], "call-tsp-priv-func") == 0) { TSPPrivFunc(); return(TCL_OK); } } return(Agent::command(argc, argv)); }
SIMPLE AGENT
void TSPAgent::TSPPrivFunc(void) { Tcl& tcl = Tcl::instance(); tcl.eval("puts \"Message From TSPPrivFunc\""); tcl.evalf("puts \" tsp_var1 = %d\"", tsp_var1); tcl.evalf("puts \" tsp_var2 = %f\"", tsp_var2); }
Based on 5 rate
0
WHERE TO MODIFY
WHERE TO MODIFY
Topic MPLS Adding a new Queue Adding a new application Sensors Examples (more than 100) Where to modify ~ns-2.34/mpls ~ns-2.34/queue/*.cc and *.h ~ns-2.34/apps/app.h ~ns-2.34/sensor-net (still to be developed) ~ns-2.34/tcl/ex/ What not lot more in NS2
THANK YOU!!!