SlideShare a Scribd company logo
1 of 20
Network simulator 2 T S PRADEEP KUMAR url : http://www.pradeepkumar.org Email: tspembedded@gmail.com Social : http://www.facebook.com/tspradeep
Overview	 Installation of NS2 Introduction to OTCL/C++ Recompiling NS2 Modification Adding a new module
Linux for Ns2 Linux Use of Linux is recommended Fedora (10, 12) If DVD Version- no need of additional package installation Install all the packages (if default installation selected, then additional packages have to be installed) Ubuntu (9.04, 9.10, 10.04, 10.10) Additional packages to be installed, there may be GCC Issues, xgraph and NAM issues Red Hat Enterprise Linux 5 (RHEL5) 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/ns-build.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”
Basic architecture of ns2
Directory structure of ns2
OTCL Verses C++ 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 TCLCL Consists of Six main classes Tcl(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(intargc, 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 intTSPAgent::command(intargc, 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 quot;Message From TSPPrivFuncquot;"); tcl.evalf("puts quot;     tsp_var1 = %dquot;", tsp_var1); tcl.evalf("puts quot;     tsp_var2 = %fquot;", tsp_var2); }
Simple Agent to Test #name it as .tcl file # Create TSPAgent set myagent [new Agent/TSPAgentOtcl] # Set configurable parameters of TSPAgent $myagent set tsp_var1_otcl 2 $myagent set tsp_var2_otcl 3.14 # Give a command to TSPAgent $myagent call-tsp-priv-fun
Case study – 2 – Multimedia over udp to build a multimedia application that runs over a UDP connection,  five rate media scaling by changing encoding and transmission policy pairs associated with scale parameter values.
Case study – 2 – Multimedia over udp Based on 5 rate 0 	0.3mb 1	0.6mb 2	0.9mb 3	1.2mb 4	1.5mb Packetsize 	1000 Random	false
Case study – 2 – Multimedia over udp When connection established, Sender/receiver agree on 5 different sets of encoding and transmission policy pairs. Sender sends with scale 0 but changes the transmission rates according to the value that the receiver notifies. The receiver is responsible for monitoring the network congestion and determine the scale factor. If congestion, then the receiver reduces the scale factor.
Where to modify ~ns-2.34 is the folder where all the cc modules are located
Where to modify
Thank you!!!

More Related Content

What's hot

What's hot (20)

TCP/IP 3-way Handshake
TCP/IP 3-way Handshake TCP/IP 3-way Handshake
TCP/IP 3-way Handshake
 
Ec8004 wireless networks unit 1 watm
Ec8004 wireless networks unit 1 watmEc8004 wireless networks unit 1 watm
Ec8004 wireless networks unit 1 watm
 
the transport layer
the transport layerthe transport layer
the transport layer
 
Tutorial ns 3-tutorial-slides
Tutorial ns 3-tutorial-slidesTutorial ns 3-tutorial-slides
Tutorial ns 3-tutorial-slides
 
Mobile IP
Mobile IPMobile IP
Mobile IP
 
Computer Network - Network Layer
Computer Network - Network LayerComputer Network - Network Layer
Computer Network - Network Layer
 
Transport Layer Services : Multiplexing And Demultiplexing
Transport Layer Services : Multiplexing And DemultiplexingTransport Layer Services : Multiplexing And Demultiplexing
Transport Layer Services : Multiplexing And Demultiplexing
 
Socket programming or network programming
Socket programming or network programmingSocket programming or network programming
Socket programming or network programming
 
Building Topology in NS3
Building Topology in NS3Building Topology in NS3
Building Topology in NS3
 
Flow Control
Flow ControlFlow Control
Flow Control
 
ns-3 Tutorial
ns-3 Tutorialns-3 Tutorial
ns-3 Tutorial
 
Ch 20 UNICAST ROUTING SECTION 2
Ch 20   UNICAST ROUTING  SECTION  2Ch 20   UNICAST ROUTING  SECTION  2
Ch 20 UNICAST ROUTING SECTION 2
 
Lan architecture
Lan architectureLan architecture
Lan architecture
 
Bgp protocol
Bgp protocolBgp protocol
Bgp protocol
 
Transport layer protocol
Transport layer protocolTransport layer protocol
Transport layer protocol
 
Transmission Control Protocol (TCP)
Transmission Control Protocol (TCP)Transmission Control Protocol (TCP)
Transmission Control Protocol (TCP)
 
Socket programming using C
Socket programming using CSocket programming using C
Socket programming using C
 
Leach & Pegasis
Leach & PegasisLeach & Pegasis
Leach & Pegasis
 
AODV routing protocol
AODV routing protocolAODV routing protocol
AODV routing protocol
 
GO BACK N PROTOCOL
GO BACK N PROTOCOLGO BACK N PROTOCOL
GO BACK N PROTOCOL
 

Viewers also liked

Simulation and Performance Analysis of AODV using NS-2.34
Simulation and Performance Analysis of AODV using NS-2.34Simulation and Performance Analysis of AODV using NS-2.34
Simulation and Performance Analysis of AODV using NS-2.34
Shaikhul Islam Chowdhury
 
Use of NS-2 to Simulate MANET Routing Algorithms
Use of NS-2 to Simulate MANET Routing AlgorithmsUse of NS-2 to Simulate MANET Routing Algorithms
Use of NS-2 to Simulate MANET Routing Algorithms
Giancarlo Romeo
 
NS2: Binding C++ and OTcl variables
NS2: Binding C++ and OTcl variablesNS2: Binding C++ and OTcl variables
NS2: Binding C++ and OTcl variables
Teerawat Issariyakul
 
NS-2 Tutorial
NS-2 TutorialNS-2 Tutorial
NS-2 Tutorial
code453
 

Viewers also liked (20)

Session 1 introduction to ns2
Session 1   introduction to ns2Session 1   introduction to ns2
Session 1 introduction to ns2
 
Introduction to NS2 - Cont..
Introduction to NS2 - Cont..Introduction to NS2 - Cont..
Introduction to NS2 - Cont..
 
TinyOS 2.1 Tutorial: TOSSIM
TinyOS 2.1 Tutorial: TOSSIMTinyOS 2.1 Tutorial: TOSSIM
TinyOS 2.1 Tutorial: TOSSIM
 
Intoduction to TinyOS, nesC and TOSSIM
Intoduction to TinyOS, nesC and TOSSIMIntoduction to TinyOS, nesC and TOSSIM
Intoduction to TinyOS, nesC and TOSSIM
 
Simulation and Performance Analysis of AODV using NS-2.34
Simulation and Performance Analysis of AODV using NS-2.34Simulation and Performance Analysis of AODV using NS-2.34
Simulation and Performance Analysis of AODV using NS-2.34
 
Wireless Sensor Network Simulators: A Survey and Comparisons
Wireless Sensor Network Simulators: A Survey and ComparisonsWireless Sensor Network Simulators: A Survey and Comparisons
Wireless Sensor Network Simulators: A Survey and Comparisons
 
Begineers for Qualnet
Begineers for QualnetBegineers for Qualnet
Begineers for Qualnet
 
Introduction to Qualnet
Introduction to QualnetIntroduction to Qualnet
Introduction to Qualnet
 
Introduction to Qualnet
Introduction to Qualnet Introduction to Qualnet
Introduction to Qualnet
 
Ns2
Ns2Ns2
Ns2
 
NS2: Events and Handlers
NS2: Events and HandlersNS2: Events and Handlers
NS2: Events and Handlers
 
NS2--Event Scheduler
NS2--Event SchedulerNS2--Event Scheduler
NS2--Event Scheduler
 
Use of NS-2 to Simulate MANET Routing Algorithms
Use of NS-2 to Simulate MANET Routing AlgorithmsUse of NS-2 to Simulate MANET Routing Algorithms
Use of NS-2 to Simulate MANET Routing Algorithms
 
NS2: Binding C++ and OTcl variables
NS2: Binding C++ and OTcl variablesNS2: Binding C++ and OTcl variables
NS2: Binding C++ and OTcl variables
 
Basic Packet Forwarding in NS2
Basic Packet Forwarding in NS2Basic Packet Forwarding in NS2
Basic Packet Forwarding in NS2
 
Ns2
Ns2Ns2
Ns2
 
Ns2programs
Ns2programsNs2programs
Ns2programs
 
Manet ns2
Manet ns2Manet ns2
Manet ns2
 
Protocol implementation on NS2
Protocol implementation on NS2Protocol implementation on NS2
Protocol implementation on NS2
 
NS-2 Tutorial
NS-2 TutorialNS-2 Tutorial
NS-2 Tutorial
 

Similar to Network simulator 2

Easy distributed load test with Tsung
Easy distributed load test with TsungEasy distributed load test with Tsung
Easy distributed load test with Tsung
Ngoc Dao
 
Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2
Max Kleiner
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
Abed Bukhari
 
httplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docxhttplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docx
adampcarr67227
 
Eff Plsql
Eff PlsqlEff Plsql
Eff Plsql
afa reg
 
20100712-OTcl Command -- Getting Started
20100712-OTcl Command -- Getting Started20100712-OTcl Command -- Getting Started
20100712-OTcl Command -- Getting Started
Teerawat Issariyakul
 
Shell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdfShell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdf
clarityvision
 

Similar to Network simulator 2 (20)

OTcl and C++ linkages in NS2
OTcl and C++ linkages in NS2OTcl and C++ linkages in NS2
OTcl and C++ linkages in NS2
 
Extending ns
Extending nsExtending ns
Extending ns
 
Easy distributed load test with Tsung
Easy distributed load test with TsungEasy distributed load test with Tsung
Easy distributed load test with Tsung
 
Installation of NS2 and Congestion Control
Installation of NS2 and Congestion ControlInstallation of NS2 and Congestion Control
Installation of NS2 and Congestion Control
 
srgoc
srgocsrgoc
srgoc
 
Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
 
httplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docxhttplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docx
 
Eff Plsql
Eff PlsqlEff Plsql
Eff Plsql
 
Ns2: Introduction - Part I
Ns2: Introduction - Part INs2: Introduction - Part I
Ns2: Introduction - Part I
 
Summary of C++17 features
Summary of C++17 featuresSummary of C++17 features
Summary of C++17 features
 
CODEsign 2015
CODEsign 2015CODEsign 2015
CODEsign 2015
 
Microkernel Development
Microkernel DevelopmentMicrokernel Development
Microkernel Development
 
TechTalk - Dotnet
TechTalk - DotnetTechTalk - Dotnet
TechTalk - Dotnet
 
Ns network simulator
Ns network simulatorNs network simulator
Ns network simulator
 
Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)
 
20100712-OTcl Command -- Getting Started
20100712-OTcl Command -- Getting Started20100712-OTcl Command -- Getting Started
20100712-OTcl Command -- Getting Started
 
Shell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdfShell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdf
 
Creating Lazy stream in CSharp
Creating Lazy stream in CSharpCreating Lazy stream in CSharp
Creating Lazy stream in CSharp
 
Thrfit从入门到精通
Thrfit从入门到精通Thrfit从入门到精通
Thrfit从入门到精通
 

More from Pradeep Kumar TS

More from Pradeep Kumar TS (20)

Digital Portfolio and Footprint
Digital Portfolio and FootprintDigital Portfolio and Footprint
Digital Portfolio and Footprint
 
Open book Examination
Open book ExaminationOpen book Examination
Open book Examination
 
Software Define Networking (SDN)
Software Define Networking (SDN)Software Define Networking (SDN)
Software Define Networking (SDN)
 
What next - Career Enhancement of Graduates
What next - Career Enhancement of GraduatesWhat next - Career Enhancement of Graduates
What next - Career Enhancement of Graduates
 
Protothreads
ProtothreadsProtothreads
Protothreads
 
6LoWPAN
6LoWPAN 6LoWPAN
6LoWPAN
 
Software Defined Networks
Software Defined NetworksSoftware Defined Networks
Software Defined Networks
 
Higher Order Thinking - Question paper setting
Higher Order Thinking - Question paper settingHigher Order Thinking - Question paper setting
Higher Order Thinking - Question paper setting
 
IoT Communication Protocols
IoT Communication ProtocolsIoT Communication Protocols
IoT Communication Protocols
 
IoT Applications
IoT ApplicationsIoT Applications
IoT Applications
 
RPL - Routing Protocol for Low Power and Lossy Networks
RPL - Routing Protocol for Low Power and Lossy NetworksRPL - Routing Protocol for Low Power and Lossy Networks
RPL - Routing Protocol for Low Power and Lossy Networks
 
Mannasim for NS2
Mannasim for NS2Mannasim for NS2
Mannasim for NS2
 
Recompiling network simulator 2
Recompiling network simulator 2Recompiling network simulator 2
Recompiling network simulator 2
 
Wired and Wireless Examples in ns2
Wired and Wireless Examples in ns2Wired and Wireless Examples in ns2
Wired and Wireless Examples in ns2
 
Installation of ns2
Installation of ns2Installation of ns2
Installation of ns2
 
Software Defined Networking - 1
Software Defined Networking - 1Software Defined Networking - 1
Software Defined Networking - 1
 
Software Defined Networking - 2
Software Defined Networking - 2Software Defined Networking - 2
Software Defined Networking - 2
 
Software Defined Networking - 3
Software Defined Networking - 3Software Defined Networking - 3
Software Defined Networking - 3
 
Tracing and awk in ns2
Tracing and awk in ns2Tracing and awk in ns2
Tracing and awk in ns2
 
Virtual classrooms and labs using Big Blue Button
Virtual classrooms and labs using Big Blue ButtonVirtual classrooms and labs using Big Blue Button
Virtual classrooms and labs using Big Blue Button
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Network simulator 2

  • 1. Network simulator 2 T S PRADEEP KUMAR url : http://www.pradeepkumar.org Email: tspembedded@gmail.com Social : http://www.facebook.com/tspradeep
  • 2. Overview Installation of NS2 Introduction to OTCL/C++ Recompiling NS2 Modification Adding a new module
  • 3. Linux for Ns2 Linux Use of Linux is recommended Fedora (10, 12) If DVD Version- no need of additional package installation Install all the packages (if default installation selected, then additional packages have to be installed) Ubuntu (9.04, 9.10, 10.04, 10.10) Additional packages to be installed, there may be GCC Issues, xgraph and NAM issues Red Hat Enterprise Linux 5 (RHEL5) 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
  • 4. Installation of ns2 Download from http://isi.edu/nsnam/ns/ns-build.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”
  • 7. OTCL Verses C++ 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)
  • 8. TclCL TCLCL Consists of Six main classes Tcl(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)
  • 9. 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.
  • 10. Simple Agent class TSPAgent : public Agent { public: TSPAgent(); protected: int command(intargc, const char*const* argv); private: int tsp_var1; double tsp_var2; void TSPPrivFunc(void); };
  • 11. 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); }
  • 12. Simple Agent intTSPAgent::command(intargc, 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)); }
  • 13. Simple Agent void TSPAgent::TSPPrivFunc(void) { Tcl& tcl = Tcl::instance(); tcl.eval("puts quot;Message From TSPPrivFuncquot;"); tcl.evalf("puts quot; tsp_var1 = %dquot;", tsp_var1); tcl.evalf("puts quot; tsp_var2 = %fquot;", tsp_var2); }
  • 14. Simple Agent to Test #name it as .tcl file # Create TSPAgent set myagent [new Agent/TSPAgentOtcl] # Set configurable parameters of TSPAgent $myagent set tsp_var1_otcl 2 $myagent set tsp_var2_otcl 3.14 # Give a command to TSPAgent $myagent call-tsp-priv-fun
  • 15. Case study – 2 – Multimedia over udp to build a multimedia application that runs over a UDP connection, five rate media scaling by changing encoding and transmission policy pairs associated with scale parameter values.
  • 16. Case study – 2 – Multimedia over udp Based on 5 rate 0 0.3mb 1 0.6mb 2 0.9mb 3 1.2mb 4 1.5mb Packetsize 1000 Random false
  • 17. Case study – 2 – Multimedia over udp When connection established, Sender/receiver agree on 5 different sets of encoding and transmission policy pairs. Sender sends with scale 0 but changes the transmission rates according to the value that the receiver notifies. The receiver is responsible for monitoring the network congestion and determine the scale factor. If congestion, then the receiver reduces the scale factor.
  • 18. Where to modify ~ns-2.34 is the folder where all the cc modules are located