SlideShare uma empresa Scribd logo
1 de 20
Baixar para ler offline
Introduction to NS2
T S Pradeep Kumar
VIT Chennai
http://www.nsnam.com
http://www.pradeepkumar.org
pradeepkumarts@gmail.com
1
2
✤Linux Vs Windows
✤Network Simulation
✤Introduction to NS2
✤NS2 Architecture
✤OTCL
Overview
• Verss
Use Linux
Because….
✤Support has been stopped beyond
NS-2.27 in windows
✤Package Configuration is tedious in
windows
✤Use NS2 at your own risk in windows
✤Also now the recent architecture of
windows8x family is experiencing lot
of difficulties in tuning cygwin or
mingw.
3
Ò Linux for NS2
✕You may use any distributions like Ubuntu, Fedora, Linux
Mint, RHEL/CentOS, etc.
É Know basic commands (ls, chmod, tar, rpm, make, gedit, vi,
pwd, passwd, echo, cd, etc)
É Know the directory structure and shell prompt in linux and NS2
É Understand Path variables setting, Installation of packages and
dependencies for corresponding distribution.
4
Basic Linux Commands
✤ ls – to list the directory contents
✤ chmod – changing the mode of the file
✤ tar – tape archive (to compress or decompress)
✤ rpm – a type of installation file for linux
✤ make – to compile or recompile in linux
✤ gedit or vi – editors (similar like notepad)
✤ pwd - present working directory
✤ passwd – to change the user passwd
✤ echo – to echo to the screen
✤ cd – change directory
✤ mkdir – to create a directory
5
TS PRADEEP KUMAR
6
✤ To run the install file within the directory scope
✤ $prompt] ./install
✤ To run the install file in global scope is
✤ $prompt] install
Linux basics
TS PRADEEP KUMAR
✤ Approaches
✤ Experiment
✤ Put all network Devices and measure the results/performance
✤ Pros - realistic
✤ Cons - Expensive/Sometime impossible
✤ Mathematical model
✤ Model devices using a graph model
✤ Insight
✤ Need to make assumptions
✤ Simulation
✤ Use programming to represent devices
✤ Easy and can be easily verified
✤ Not much insight, need to make assumptions
Network Simulation
7
TS PRADEEP KUMAR
A B C
✤ Network Simulation
✤ Event Driven
✤ Every event provide a reference to the next event (Example: using
pointer)
✤ Simulation finishes
✤ When there are no more events
✤ At pre-specified time
8
Network Simulation
TS PRADEEP KUMAR
✤ NS is a discrete event simulator
✤ It provides support for
✤ Simulation of TCP
✤ Routing
✤ Huge number of protocols ranging from wired to wireless
networks
✤ Supports the addition of new entities like agent, packet,
application, queue, protocol, routing, etc.
9
About NS2
TS PRADEEP KUMAR
✤ NS2 is not a polished or a finished product
✤ Errors/Bugs are being discovered and corrected.
✤ Users of ns are requested to verify that the results are
not invalidated by bugs.
10
About NS2
TS PRADEEP KUMAR
✤ Network Simulator 2 is an event driven Simulator
✤ It consists of
✤ C++ (Internally)
✤ OTCL (User Interface)
✤ TclCL (Interface between C++ and OTCL)
11
NS2 Architecture
TS PRADEEP KUMAR
12
NS2 Architecture
TS PRADEEP KUMAR
13
NS2 Architecture
14
✤ NS is a OTCL interpreter with network simulation
object libraries
✤ Relation between TCL & OTCL is similar to C & C++
✤ To run a Tcl File and animation file
✤ ns filename.tcl (or) tclsh filename.tcl
✤ nam filename.nam
15
OTCL
# Create a class call "mom" and add a member function call "greet"
Class mom
mom instproc greet {} {
$self instvar age_
puts "$age_ years old mom say:
How are you doing?"
}
16
OTCL Example
# Create a child class of "mom" called "kid" and overide
the member function "greet"
Class kid -superclass mom
kid instproc greet {} {
$self instvar age_
puts "$age_ years old kid say:
What's up, dude?"
}
17
OTCL Example
✤ # Create a mom and a kid object set each age
✤ set a [new mom]
✤ $a set age_ 45
✤ set b [new kid]
✤ $b set age_ 15
✤ # Calling member function "greet" of each object
✤ $a greet
✤ $b greet
18
OTCL Example
To run the above file
✤ Open an Editor preferably gedit or Text Editor in Linux
✤ Type the program
✤ Mom Class
✤ Kid Class
✤ creation of object of both classes
✤ Run the File using
✤ ns momkid.tcl
19
01
Questions?????

Mais conteúdo relacionado

Mais procurados

security in wireless sensor networks
security in wireless sensor networkssecurity in wireless sensor networks
security in wireless sensor networks
Vishnu Kudumula
 
Security in mobile ad hoc networks
Security in mobile ad hoc networksSecurity in mobile ad hoc networks
Security in mobile ad hoc networks
Piyush Mittal
 
Lecture 23 27. quality of services in ad hoc wireless networks
Lecture 23 27. quality of services in ad hoc wireless networksLecture 23 27. quality of services in ad hoc wireless networks
Lecture 23 27. quality of services in ad hoc wireless networks
Chandra Meena
 
Security in wireless sensor networks
Security in wireless sensor networksSecurity in wireless sensor networks
Security in wireless sensor networks
Piyush Mittal
 

Mais procurados (20)

Firewalls
FirewallsFirewalls
Firewalls
 
security in wireless sensor networks
security in wireless sensor networkssecurity in wireless sensor networks
security in wireless sensor networks
 
Security in mobile ad hoc networks
Security in mobile ad hoc networksSecurity in mobile ad hoc networks
Security in mobile ad hoc networks
 
Data aggregation in wireless sensor networks
Data aggregation in wireless sensor networksData aggregation in wireless sensor networks
Data aggregation in wireless sensor networks
 
Routing protocols for ad hoc wireless networks
Routing protocols for ad hoc wireless networks Routing protocols for ad hoc wireless networks
Routing protocols for ad hoc wireless networks
 
Multiple Access Protocal
Multiple Access ProtocalMultiple Access Protocal
Multiple Access Protocal
 
Lecture 23 27. quality of services in ad hoc wireless networks
Lecture 23 27. quality of services in ad hoc wireless networksLecture 23 27. quality of services in ad hoc wireless networks
Lecture 23 27. quality of services in ad hoc wireless networks
 
ISSUES IN AD HOC WIRELESS NETWORKS
ISSUES IN  AD HOC WIRELESS  NETWORKS ISSUES IN  AD HOC WIRELESS  NETWORKS
ISSUES IN AD HOC WIRELESS NETWORKS
 
WSN NETWORK -MAC PROTOCOLS - Low Duty Cycle Protocols And Wakeup Concepts – ...
WSN NETWORK -MAC PROTOCOLS - Low Duty Cycle Protocols And Wakeup Concepts –  ...WSN NETWORK -MAC PROTOCOLS - Low Duty Cycle Protocols And Wakeup Concepts –  ...
WSN NETWORK -MAC PROTOCOLS - Low Duty Cycle Protocols And Wakeup Concepts – ...
 
QoS (quality of service)
QoS (quality of service)QoS (quality of service)
QoS (quality of service)
 
IP Security
IP SecurityIP Security
IP Security
 
Chap 12 tcp
Chap 12 tcpChap 12 tcp
Chap 12 tcp
 
Mac protocols
Mac protocolsMac protocols
Mac protocols
 
Firewall Design and Implementation
Firewall Design and ImplementationFirewall Design and Implementation
Firewall Design and Implementation
 
TCP congestion control
TCP congestion controlTCP congestion control
TCP congestion control
 
WSN-IEEE 802.15.4 -MAC Protocol
WSN-IEEE 802.15.4 -MAC ProtocolWSN-IEEE 802.15.4 -MAC Protocol
WSN-IEEE 802.15.4 -MAC Protocol
 
Go back-n protocol
Go back-n protocolGo back-n protocol
Go back-n protocol
 
MULTIPLE CHOICE QUESTIONS WITH ANSWERS ON WIRELESS SENSOR NETWORKS
MULTIPLE CHOICE QUESTIONS WITH ANSWERS ON WIRELESS SENSOR NETWORKSMULTIPLE CHOICE QUESTIONS WITH ANSWERS ON WIRELESS SENSOR NETWORKS
MULTIPLE CHOICE QUESTIONS WITH ANSWERS ON WIRELESS SENSOR NETWORKS
 
Computer network switching
Computer network switchingComputer network switching
Computer network switching
 
Security in wireless sensor networks
Security in wireless sensor networksSecurity in wireless sensor networks
Security in wireless sensor networks
 

Semelhante a Introduction to ns2

Cassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & Python
Cassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & PythonCassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & Python
Cassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & Python
DataStax Academy
 
study-of-network-simulator.pdf
study-of-network-simulator.pdfstudy-of-network-simulator.pdf
study-of-network-simulator.pdf
Jayaprasanna4
 
NS2-tutorial.ppt
NS2-tutorial.pptNS2-tutorial.ppt
NS2-tutorial.ppt
Wajath
 

Semelhante a Introduction to ns2 (20)

Session 1 introduction to ns2
Session 1   introduction to ns2Session 1   introduction to ns2
Session 1 introduction to ns2
 
Tut hemant ns2
Tut hemant ns2Tut hemant ns2
Tut hemant ns2
 
Ns fundamentals 1
Ns fundamentals 1Ns fundamentals 1
Ns fundamentals 1
 
Network Simulator Tutorial
Network Simulator TutorialNetwork Simulator Tutorial
Network Simulator Tutorial
 
Ns2
Ns2Ns2
Ns2
 
MySQL up and running 30 minutes.pdf
MySQL up and running 30 minutes.pdfMySQL up and running 30 minutes.pdf
MySQL up and running 30 minutes.pdf
 
Cassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & Python
Cassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & PythonCassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & Python
Cassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & Python
 
Network simulator 2 a simulation tool for linux
Network simulator 2 a simulation tool for linuxNetwork simulator 2 a simulation tool for linux
Network simulator 2 a simulation tool for linux
 
Ns2pre
Ns2preNs2pre
Ns2pre
 
Venkat ns2
Venkat ns2Venkat ns2
Venkat ns2
 
New Jersey Red Hat Users Group Presentation: Provisioning anywhere
New Jersey Red Hat Users Group Presentation: Provisioning anywhereNew Jersey Red Hat Users Group Presentation: Provisioning anywhere
New Jersey Red Hat Users Group Presentation: Provisioning anywhere
 
Nsby examples
Nsby examplesNsby examples
Nsby examples
 
Docker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12xDocker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12x
 
Sge
SgeSge
Sge
 
study-of-network-simulator.pdf
study-of-network-simulator.pdfstudy-of-network-simulator.pdf
study-of-network-simulator.pdf
 
Introduction to ns2
Introduction to ns2Introduction to ns2
Introduction to ns2
 
Systemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveSystemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to love
 
Introduction to NS2 - Cont..
Introduction to NS2 - Cont..Introduction to NS2 - Cont..
Introduction to NS2 - Cont..
 
NS2-tutorial.ppt
NS2-tutorial.pptNS2-tutorial.ppt
NS2-tutorial.ppt
 
1 session installation
1 session installation1 session installation
1 session installation
 

Mais de Pradeep Kumar TS

Mais de 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
 
OTcl and C++ linkages in NS2
OTcl and C++ linkages in NS2OTcl and C++ linkages in NS2
OTcl and C++ linkages in NS2
 
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
 

Último

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
anilsa9823
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Último (20)

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 

Introduction to ns2

  • 1. Introduction to NS2 T S Pradeep Kumar VIT Chennai http://www.nsnam.com http://www.pradeepkumar.org pradeepkumarts@gmail.com 1
  • 2. 2 ✤Linux Vs Windows ✤Network Simulation ✤Introduction to NS2 ✤NS2 Architecture ✤OTCL Overview
  • 3. • Verss Use Linux Because…. ✤Support has been stopped beyond NS-2.27 in windows ✤Package Configuration is tedious in windows ✤Use NS2 at your own risk in windows ✤Also now the recent architecture of windows8x family is experiencing lot of difficulties in tuning cygwin or mingw. 3
  • 4. Ò Linux for NS2 ✕You may use any distributions like Ubuntu, Fedora, Linux Mint, RHEL/CentOS, etc. É Know basic commands (ls, chmod, tar, rpm, make, gedit, vi, pwd, passwd, echo, cd, etc) É Know the directory structure and shell prompt in linux and NS2 É Understand Path variables setting, Installation of packages and dependencies for corresponding distribution. 4
  • 5. Basic Linux Commands ✤ ls – to list the directory contents ✤ chmod – changing the mode of the file ✤ tar – tape archive (to compress or decompress) ✤ rpm – a type of installation file for linux ✤ make – to compile or recompile in linux ✤ gedit or vi – editors (similar like notepad) ✤ pwd - present working directory ✤ passwd – to change the user passwd ✤ echo – to echo to the screen ✤ cd – change directory ✤ mkdir – to create a directory 5
  • 6. TS PRADEEP KUMAR 6 ✤ To run the install file within the directory scope ✤ $prompt] ./install ✤ To run the install file in global scope is ✤ $prompt] install Linux basics
  • 7. TS PRADEEP KUMAR ✤ Approaches ✤ Experiment ✤ Put all network Devices and measure the results/performance ✤ Pros - realistic ✤ Cons - Expensive/Sometime impossible ✤ Mathematical model ✤ Model devices using a graph model ✤ Insight ✤ Need to make assumptions ✤ Simulation ✤ Use programming to represent devices ✤ Easy and can be easily verified ✤ Not much insight, need to make assumptions Network Simulation 7
  • 8. TS PRADEEP KUMAR A B C ✤ Network Simulation ✤ Event Driven ✤ Every event provide a reference to the next event (Example: using pointer) ✤ Simulation finishes ✤ When there are no more events ✤ At pre-specified time 8 Network Simulation
  • 9. TS PRADEEP KUMAR ✤ NS is a discrete event simulator ✤ It provides support for ✤ Simulation of TCP ✤ Routing ✤ Huge number of protocols ranging from wired to wireless networks ✤ Supports the addition of new entities like agent, packet, application, queue, protocol, routing, etc. 9 About NS2
  • 10. TS PRADEEP KUMAR ✤ NS2 is not a polished or a finished product ✤ Errors/Bugs are being discovered and corrected. ✤ Users of ns are requested to verify that the results are not invalidated by bugs. 10 About NS2
  • 11. TS PRADEEP KUMAR ✤ Network Simulator 2 is an event driven Simulator ✤ It consists of ✤ C++ (Internally) ✤ OTCL (User Interface) ✤ TclCL (Interface between C++ and OTCL) 11 NS2 Architecture
  • 12. TS PRADEEP KUMAR 12 NS2 Architecture
  • 13. TS PRADEEP KUMAR 13 NS2 Architecture
  • 14. 14
  • 15. ✤ NS is a OTCL interpreter with network simulation object libraries ✤ Relation between TCL & OTCL is similar to C & C++ ✤ To run a Tcl File and animation file ✤ ns filename.tcl (or) tclsh filename.tcl ✤ nam filename.nam 15 OTCL
  • 16. # Create a class call "mom" and add a member function call "greet" Class mom mom instproc greet {} { $self instvar age_ puts "$age_ years old mom say: How are you doing?" } 16 OTCL Example
  • 17. # Create a child class of "mom" called "kid" and overide the member function "greet" Class kid -superclass mom kid instproc greet {} { $self instvar age_ puts "$age_ years old kid say: What's up, dude?" } 17 OTCL Example
  • 18. ✤ # Create a mom and a kid object set each age ✤ set a [new mom] ✤ $a set age_ 45 ✤ set b [new kid] ✤ $b set age_ 15 ✤ # Calling member function "greet" of each object ✤ $a greet ✤ $b greet 18 OTCL Example
  • 19. To run the above file ✤ Open an Editor preferably gedit or Text Editor in Linux ✤ Type the program ✤ Mom Class ✤ Kid Class ✤ creation of object of both classes ✤ Run the File using ✤ ns momkid.tcl 19