Network simulator 2


Published on

Published in: Technology
1 Comment
  • sir it is very useful
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Network simulator 2

  1. 1. Network simulator 2<br />T S PRADEEP KUMAR<br />url :<br />Email:<br />Social :<br />
  2. 2. Overview <br />Installation of NS2<br />Introduction to OTCL/C++<br />Recompiling NS2<br />Modification<br />Adding a new module<br />
  3. 3. Linux for Ns2<br />Linux<br />Use of Linux is recommended<br />Fedora (10, 12)<br />If DVD Version- no need of additional package installation<br />Install all the packages (if default installation selected, then additional packages have to be installed)<br />Ubuntu (9.04, 9.10, 10.04, 10.10)<br />Additional packages to be installed, there may be GCC Issues, xgraph and NAM issues<br />Red Hat Enterprise Linux 5 (RHEL5)<br />Cent OS is the alternative for RHEL<br />Basic commands (ls, chmod, tar, rpm, make, gedit, vi, pwd, passwd, echo, cd, etc)<br />Directory structure and shell prompt<br />Path variables setting, Installation of packages and dependencies<br />
  4. 4. Installation of ns2<br />Download from<br />Copy the file under /home/pradeep(if your username is “abcdef” then home folder will be /home/abcdef)<br />Extract it using “tar zxvf ns-allinone-2.34.tar.gz”<br />“cd ns-allinone-2.34”<br />“./install “ (if any errors, please correct it)<br />Setting of paths in “.bash_profile”or “.bashrc”<br />
  5. 5. Basic architecture of ns2<br />
  6. 6. Directory structure of ns2<br />
  7. 7. OTCL Verses C++<br />OTCL<br />Interpreted Hierarchy<br />Faster to interpret, slow to run<br />Preferable for beginners<br />C++<br />Used when dealing with a packet, agent or a protocol<br />Compiled Hierarchy<br />Slow to compile, faster to execute<br />The interface between OTCL and C++ is TclCL (available as a folder in ~ns-allinone-2.34/tclcl-xxx)<br />
  8. 8. TclCL<br />TCLCL Consists of Six main classes<br />Tcl(Methods to access the interpreted hierarchy)<br />InstVar(binds member variable in both hierarchies together<br />TclObject (base class of all simulation objects)<br />TclClass(maps class of IH to class of CH)<br />TclCommand(global access to CH from IH)<br />EmbeddedTcl (translates OTCL Script to C++ Code)<br />
  9. 9. TclCL<br />Each class have various member functions that are used to get compiled<br />As a case study, lets start how to create a simple agent.<br />
  10. 10. Simple Agent<br />class TSPAgent : public Agent {<br />public:<br />TSPAgent();<br />protected:<br />int command(intargc, const char*const* argv);<br />private:<br />int tsp_var1;<br /> double tsp_var2;<br /> void TSPPrivFunc(void);<br />};<br />
  11. 11. Simple Agent<br />static class TSPAgentClass : public TclClass {<br />public:<br />TSPAgentClass() : TclClass("Agent/TSPAgentOtcl") {}<br />TclObject* create(int, const char*const*) {<br /> return(new TSPAgent());<br /> }<br />} class_tsp_agent;<br />TSPAgent::TSPAgent() : Agent(PT_UDP) {<br /> bind("tsp_var1_otcl", &tsp_var1);<br /> bind("tsp_var2_otcl", &tsp_var2);<br />}<br />
  12. 12. Simple Agent<br />intTSPAgent::command(intargc, const char*const* argv) {<br /> if(argc == 2) {<br /> if(strcmp(argv[1], "call-tsp-priv-func") == 0) {<br />TSPPrivFunc();<br /> return(TCL_OK);<br /> }<br /> }<br /> return(Agent::command(argc, argv));<br />}<br />
  13. 13. Simple Agent<br />void TSPAgent::TSPPrivFunc(void) {<br />Tcl& tcl = Tcl::instance();<br />tcl.eval("puts "Message From TSPPrivFunc"");<br />tcl.evalf("puts " tsp_var1 = %d"", tsp_var1);<br />tcl.evalf("puts " tsp_var2 = %f"", tsp_var2);<br />}<br />
  14. 14. Simple Agent to Test<br />#name it as .tcl file<br /># Create TSPAgent<br />set myagent [new Agent/TSPAgentOtcl]<br /># Set configurable parameters of TSPAgent<br />$myagent set tsp_var1_otcl 2<br />$myagent set tsp_var2_otcl 3.14<br /># Give a command to TSPAgent<br />$myagent call-tsp-priv-fun<br />
  15. 15. Case study – 2 – Multimedia over udp<br />to build a multimedia application that runs over a UDP connection, <br />five rate media scaling<br />by changing encoding and transmission policy pairs associated with scale parameter values. <br />
  16. 16. Case study – 2 – Multimedia over udp<br />Based on 5 rate<br />0 0.3mb<br />1 0.6mb<br />2 0.9mb<br />3 1.2mb<br />4 1.5mb<br />Packetsize 1000<br />Random false<br />
  17. 17. Case study – 2 – Multimedia over udp<br />When connection established, Sender/receiver agree on 5 different sets of encoding and transmission policy pairs.<br />Sender sends with scale 0 but changes the transmission rates according to the value that the receiver notifies.<br />The receiver is responsible for monitoring the network congestion and determine the scale factor. If congestion, then the receiver reduces the scale factor.<br />
  18. 18. Where to modify<br />~ns-2.34 is the folder where all the cc modules are located<br />
  19. 19. Where to modify<br />
  20. 20. Thank you!!!<br />