SlideShare a Scribd company logo
1 of 54
Introduction to NS2
-Network Simulator-
Contents
Overview
How to Install
OTCL – The User Language
Event Scheduler
Packet
Simulation Example
Overview
What is NS2?
- Event driven network simulator
- Developed at UC Berkely
- Implements network protocols
1) TCP, UDP
2) Traffic source mechanism: FTP, TELNET, Web, CBR and VBR
3) Router Queue management mechanism: Drop Tail, RED, CBQ
4) Routing Algorithm: Dijkstra, and etc…
5) Multicasting, Mac layer protocols for LAN
Overview
Background on the ns Simulator
- based on two languages( an object-oriented
simulator (C++), and OTcl (object-oriented Tcl)
interpreter.
- has rich library of network and protocol object
- Compiled C++ hierarchy gives efficiency in
simulation and faster execution times.
- With OTcl script provided by user, a network
topology is simulated.
Overview
Ns2 is event simulator where the advance of
time depends on the timing of events which are
maintained by a scheduler.
Event – an object in C++ hierarchy.
unique ID, Scheduled time,
pointer to an object
Scheduler – maintains ordered data structure
with the events to be executed and fires them
one by one, invoking the handler of the event.
How to Install
-Window XP-
Go to Website:
http://nsnam.isi.edu/nsnam/index.php/Running_Ns_and_Nam_Under_Windows_9x/2000/XP_Using_Cygwin
Read “Requirements and Installation Tips”
Carefully.
Download cygwin.exe from http://www.cygwin.com/
Click the “cygwin.exe”
How to Install
 Cygwin Installation
How to Install
How to Install
 Select browse for “cygwin” file( I selected as “default”)
How to Install
 Local package directory (I recommend c:cygwin).
How to Install
 Select to Install all ( I recommend it)
 You can select “install”, “default”, “uninstall”, “install”, and “reinstall” behind the first
line “all”. If you select “install”, then all sub items will be automatically selected.
Otherwise you may lose some items.
How to Install
 Select download site
How to Install
Installing
How to Install
 Finishing Installing
How to Install
NS2 Installation
Download ns-allinone-2.29.2.tar.gz from
Website and Save it to the c:/cygwin
/usr/local
Unpack it: tar xvfz ns-allinone-
2.29.2.tar.gz
Click on desktop icon “cygwin”
How to Install
How to Install
 Type “cd ..” to go to the upper folder(“cd” must be low case. And
there is one space between “d” and “.”)
 Type “cd ..” again.
How to Install
 “cd usr”, go to folder “usr”
 “cd local”, go to folder “local”
How to Install
 Find “install.exe”
How to Install
 Start to run the installation “./install”
How to Install
 Installing
How to Install
 Installing
How to Install
 Configure system variables and library paths
 After finishing installing, following window appears
How to Install
 Configure system variables
 Go to “My computer” and click “view system information”
How to Install
 Go to “advanced” Tab and Click “Environmental variables”
How to Install
How to Install
 Highlight “path” which is “system variable” box and press the “Edit”
button.
How to Install
How to Install
Add the following path separated with “;”
make sure to not change the existing path.
/usr/local/ns-allinone-2.29.2/bin
/usr/local/ns-allinone-2.29.2/tcl8.4.11/unix
/usr/local/ns-allinone-2.29.2/tk8.4.11/unix
How to Install
Go to cygwin and type the following
content
Export LD_LIBRARY_PATH=/usr/local/ns-
allinone-2.29/otcl-1.11
Export LD_LIBRARY_PATH=/usr/local/ns-
allinone-2.29/lib
Export TCL_LIBRARY_PATH=/usr/local/ns-
allinone-2.29/tcl8.4.11/library
How to Install
OTcl – The User Language
NS2 is basically an OTcl interpreter with network
simulation object libraries
Very simple syntax and easy integration with
other languages.
Characteristics:
- fast development
- provide graphic interface
- compatible with many platforms
- flexible for integration
- easy to use
- free
OTcl – The User Language
Example
OTcl – The User Language
Proc: define a procedure, followed by an
procedure name and arguments
Set: assign a value to a variable
[expr …]: to make the interpreter calculate
the value of expression within the bracket
To assign to variable x the value that
variable a has, then write “set x $a”.
Put: prints out
OTcl – The User Language
Event Scheduler
 Main users of an event scheduler are network components that
simulate packet-handling delay or that need time
Event Scheduler
Two different types of event schedulers
- real time: for emulation which allow the
simulator to interact with a real network
- non-real time: three implementations are
available (Heap, List, Calendar). The
default is set as Calendar
Event Scheduler
 Example
. . .
set ns [new Simulator]
$ns use-scheduler Heap
. . .
. . .
set ns [new Simulator]
$ns use-scheduler Heap
$ns at 300.5 "complete_sim"
. . .
proc complete_sim {} {
. . .
}
Packet
NS2 packet is composed of a stack of
headers and optional dataspace.
Packet format is initialized when a
Simulator object is created. So, a network
object can access any header in the stack
of a packet it processes using
corresponding offset value.
Packet
Simple Simulation Implement
Simple Simulation Implement
Simple Simulation Implement
Click on desktop icon “cygwin”
Make sure to put the exe files under
C:cygwinusrlocal
Do the following steps to execute
example.
Simple Simulation Implement
Simple Simulation Implement
 However you will fail to run the “ns-simple.tcl” with the displayed
notice. This is because you did not open “XWin” yet
Simple Simulation Implement
 Open “Xwin” from “C:cygwinusrX11R6bin”. If everything is fine,
you will then get the following figures.
Simple Simulation Implement
 Yet you may get the following warning messages:
Simple Simulation Implement
 That means some components missed. You can then copy these
files from “C:cygwinbin” to “C:cygwinusrX11R6bin”
 After you open X11, you may still can not run “ns-simple.tcl”
Simple Simulation Implement
The following command can solve this
issue
export DISPLAY=:0.0
Simple Simulation Implement
Simple Simulation Implement
 Run “ns-simple.tcl”
Simple Simulation Implement
 DONE !!!
Simple Simulation Implement
Thank You….

More Related Content

What's hot

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
 
Network emulator
Network emulatorNetwork emulator
Network emulator
jeromy fu
 

What's hot (20)

Ns2
Ns2Ns2
Ns2
 
Ns2
Ns2Ns2
Ns2
 
Working with NS2
Working with NS2Working with NS2
Working with NS2
 
Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
 
Ns2
Ns2Ns2
Ns2
 
Ns2 introduction 2
Ns2 introduction 2Ns2 introduction 2
Ns2 introduction 2
 
Ns 2 Network Simulator An Introduction
Ns 2 Network Simulator An IntroductionNs 2 Network Simulator An Introduction
Ns 2 Network Simulator An Introduction
 
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
 
Ns network simulator
Ns network simulatorNs network simulator
Ns network simulator
 
Network Simulation
Network SimulationNetwork Simulation
Network Simulation
 
Protocol implementation on NS2
Protocol implementation on NS2Protocol implementation on NS2
Protocol implementation on NS2
 
Venkat ns2
Venkat ns2Venkat ns2
Venkat ns2
 
Introduction to ns2
Introduction to ns2Introduction to ns2
Introduction to ns2
 
Ns2pre
Ns2preNs2pre
Ns2pre
 
Ns fundamentals 1
Ns fundamentals 1Ns fundamentals 1
Ns fundamentals 1
 
Ns2
Ns2Ns2
Ns2
 
Extending ns
Extending nsExtending ns
Extending ns
 
Network emulator
Network emulatorNetwork emulator
Network emulator
 
[232]mist 고성능 iot 스트림 처리 시스템
[232]mist 고성능 iot 스트림 처리 시스템[232]mist 고성능 iot 스트림 처리 시스템
[232]mist 고성능 iot 스트림 처리 시스템
 
Tc basics
Tc basicsTc basics
Tc basics
 

Viewers also liked

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
 

Viewers also liked (20)

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
 
ADO Controls - Database Usage from Exploring MS Visual Basic 6.0 Book
ADO Controls - Database Usage from Exploring MS Visual Basic 6.0 BookADO Controls - Database Usage from Exploring MS Visual Basic 6.0 Book
ADO Controls - Database Usage from Exploring MS Visual Basic 6.0 Book
 
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
 
Scheduler performance in manycore architecture
Scheduler performance in manycore architectureScheduler performance in manycore architecture
Scheduler performance in manycore architecture
 
SIMULATIVE ANALYSIS OF CHANNEL AND QoS AWARE SCHEDULER TO ENHANCE THE CAPACIT...
SIMULATIVE ANALYSIS OF CHANNEL AND QoS AWARE SCHEDULER TO ENHANCE THE CAPACIT...SIMULATIVE ANALYSIS OF CHANNEL AND QoS AWARE SCHEDULER TO ENHANCE THE CAPACIT...
SIMULATIVE ANALYSIS OF CHANNEL AND QoS AWARE SCHEDULER TO ENHANCE THE CAPACIT...
 
Tr ns802 11
Tr ns802 11Tr ns802 11
Tr ns802 11
 
LCU13: Discussion on ODP – Fastpath networking applications on manycore SoCs
LCU13: Discussion on ODP – Fastpath networking applications on manycore SoCsLCU13: Discussion on ODP – Fastpath networking applications on manycore SoCs
LCU13: Discussion on ODP – Fastpath networking applications on manycore SoCs
 
Introduction to Project Development using Visual Basic
Introduction to Project Development using Visual BasicIntroduction to Project Development using Visual Basic
Introduction to Project Development using Visual Basic
 
LTE Schedulers – A Definitive Approach
LTE Schedulers – A Definitive Approach LTE Schedulers – A Definitive Approach
LTE Schedulers – A Definitive Approach
 
ADO CONTROLS - Database usage
ADO CONTROLS - Database usageADO CONTROLS - Database usage
ADO CONTROLS - Database usage
 
enodeb sw to dual core
enodeb sw to dual coreenodeb sw to dual core
enodeb sw to dual core
 
NS2: Events and Handlers
NS2: Events and HandlersNS2: Events and Handlers
NS2: Events and Handlers
 
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--Event Scheduler
NS2--Event SchedulerNS2--Event Scheduler
NS2--Event Scheduler
 
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
 

Similar to Introduction to NS2 - Cont..

Survey of open source cloud architectures
Survey of open source cloud architecturesSurvey of open source cloud architectures
Survey of open source cloud architectures
abhinav vedanbhatla
 
NS2-tutorial.ppt
NS2-tutorial.pptNS2-tutorial.ppt
NS2-tutorial.ppt
Wajath
 
study-of-network-simulator.pdf
study-of-network-simulator.pdfstudy-of-network-simulator.pdf
study-of-network-simulator.pdf
Jayaprasanna4
 

Similar to Introduction to NS2 - Cont.. (20)

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
 
An introduction to_ns_nam_and_o_tcl_scripting
An introduction to_ns_nam_and_o_tcl_scriptingAn introduction to_ns_nam_and_o_tcl_scripting
An introduction to_ns_nam_and_o_tcl_scripting
 
Plenzogan technology
Plenzogan technologyPlenzogan technology
Plenzogan technology
 
Survey of open source cloud architectures
Survey of open source cloud architecturesSurvey of open source cloud architectures
Survey of open source cloud architectures
 
Network simulator
Network  simulatorNetwork  simulator
Network simulator
 
NS2-tutorial.ppt
NS2-tutorial.pptNS2-tutorial.ppt
NS2-tutorial.ppt
 
WiMAX implementation in ns3
WiMAX implementation in ns3WiMAX implementation in ns3
WiMAX implementation in ns3
 
LUCST walkthrough v1.2.pdf
LUCST walkthrough v1.2.pdfLUCST walkthrough v1.2.pdf
LUCST walkthrough v1.2.pdf
 
Omnet++
Omnet++Omnet++
Omnet++
 
Ns2: OTCL - PArt II
Ns2: OTCL - PArt IINs2: OTCL - PArt II
Ns2: OTCL - PArt II
 
ACMSE2022-Tutorial-Slides.pptx
ACMSE2022-Tutorial-Slides.pptxACMSE2022-Tutorial-Slides.pptx
ACMSE2022-Tutorial-Slides.pptx
 
Chapter 6 os
Chapter 6 osChapter 6 os
Chapter 6 os
 
Ns3
Ns3Ns3
Ns3
 
Enhancing the NS-2 Traffic Generator for the MANETs
Enhancing the NS-2 Traffic Generator for the MANETsEnhancing the NS-2 Traffic Generator for the MANETs
Enhancing the NS-2 Traffic Generator for the MANETs
 
Introduction to ns3
Introduction to ns3Introduction to ns3
Introduction to ns3
 
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
 
Introduction to ns2
Introduction to ns2Introduction to ns2
Introduction to ns2
 
study-of-network-simulator.pdf
study-of-network-simulator.pdfstudy-of-network-simulator.pdf
study-of-network-simulator.pdf
 
Eclipse Con Europe 2014 How to use DAWN Science Project
Eclipse Con Europe 2014 How to use DAWN Science ProjectEclipse Con Europe 2014 How to use DAWN Science Project
Eclipse Con Europe 2014 How to use DAWN Science Project
 
Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
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)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
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
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Introduction to NS2 - Cont..

  • 2. Contents Overview How to Install OTCL – The User Language Event Scheduler Packet Simulation Example
  • 3. Overview What is NS2? - Event driven network simulator - Developed at UC Berkely - Implements network protocols 1) TCP, UDP 2) Traffic source mechanism: FTP, TELNET, Web, CBR and VBR 3) Router Queue management mechanism: Drop Tail, RED, CBQ 4) Routing Algorithm: Dijkstra, and etc… 5) Multicasting, Mac layer protocols for LAN
  • 4. Overview Background on the ns Simulator - based on two languages( an object-oriented simulator (C++), and OTcl (object-oriented Tcl) interpreter. - has rich library of network and protocol object - Compiled C++ hierarchy gives efficiency in simulation and faster execution times. - With OTcl script provided by user, a network topology is simulated.
  • 5. Overview Ns2 is event simulator where the advance of time depends on the timing of events which are maintained by a scheduler. Event – an object in C++ hierarchy. unique ID, Scheduled time, pointer to an object Scheduler – maintains ordered data structure with the events to be executed and fires them one by one, invoking the handler of the event.
  • 6. How to Install -Window XP- Go to Website: http://nsnam.isi.edu/nsnam/index.php/Running_Ns_and_Nam_Under_Windows_9x/2000/XP_Using_Cygwin Read “Requirements and Installation Tips” Carefully. Download cygwin.exe from http://www.cygwin.com/ Click the “cygwin.exe”
  • 7. How to Install  Cygwin Installation
  • 9. How to Install  Select browse for “cygwin” file( I selected as “default”)
  • 10. How to Install  Local package directory (I recommend c:cygwin).
  • 11. How to Install  Select to Install all ( I recommend it)  You can select “install”, “default”, “uninstall”, “install”, and “reinstall” behind the first line “all”. If you select “install”, then all sub items will be automatically selected. Otherwise you may lose some items.
  • 12. How to Install  Select download site
  • 14. How to Install  Finishing Installing
  • 15. How to Install NS2 Installation Download ns-allinone-2.29.2.tar.gz from Website and Save it to the c:/cygwin /usr/local Unpack it: tar xvfz ns-allinone- 2.29.2.tar.gz Click on desktop icon “cygwin”
  • 17. How to Install  Type “cd ..” to go to the upper folder(“cd” must be low case. And there is one space between “d” and “.”)  Type “cd ..” again.
  • 18. How to Install  “cd usr”, go to folder “usr”  “cd local”, go to folder “local”
  • 19. How to Install  Find “install.exe”
  • 20. How to Install  Start to run the installation “./install”
  • 21. How to Install  Installing
  • 22. How to Install  Installing
  • 23. How to Install  Configure system variables and library paths  After finishing installing, following window appears
  • 24. How to Install  Configure system variables  Go to “My computer” and click “view system information”
  • 25. How to Install  Go to “advanced” Tab and Click “Environmental variables”
  • 27. How to Install  Highlight “path” which is “system variable” box and press the “Edit” button.
  • 29. How to Install Add the following path separated with “;” make sure to not change the existing path. /usr/local/ns-allinone-2.29.2/bin /usr/local/ns-allinone-2.29.2/tcl8.4.11/unix /usr/local/ns-allinone-2.29.2/tk8.4.11/unix
  • 30. How to Install Go to cygwin and type the following content Export LD_LIBRARY_PATH=/usr/local/ns- allinone-2.29/otcl-1.11 Export LD_LIBRARY_PATH=/usr/local/ns- allinone-2.29/lib Export TCL_LIBRARY_PATH=/usr/local/ns- allinone-2.29/tcl8.4.11/library
  • 32. OTcl – The User Language NS2 is basically an OTcl interpreter with network simulation object libraries Very simple syntax and easy integration with other languages. Characteristics: - fast development - provide graphic interface - compatible with many platforms - flexible for integration - easy to use - free
  • 33. OTcl – The User Language Example
  • 34. OTcl – The User Language Proc: define a procedure, followed by an procedure name and arguments Set: assign a value to a variable [expr …]: to make the interpreter calculate the value of expression within the bracket To assign to variable x the value that variable a has, then write “set x $a”. Put: prints out
  • 35. OTcl – The User Language
  • 36. Event Scheduler  Main users of an event scheduler are network components that simulate packet-handling delay or that need time
  • 37. Event Scheduler Two different types of event schedulers - real time: for emulation which allow the simulator to interact with a real network - non-real time: three implementations are available (Heap, List, Calendar). The default is set as Calendar
  • 38. Event Scheduler  Example . . . set ns [new Simulator] $ns use-scheduler Heap . . . . . . set ns [new Simulator] $ns use-scheduler Heap $ns at 300.5 "complete_sim" . . . proc complete_sim {} { . . . }
  • 39. Packet NS2 packet is composed of a stack of headers and optional dataspace. Packet format is initialized when a Simulator object is created. So, a network object can access any header in the stack of a packet it processes using corresponding offset value.
  • 43. Simple Simulation Implement Click on desktop icon “cygwin” Make sure to put the exe files under C:cygwinusrlocal Do the following steps to execute example.
  • 45. Simple Simulation Implement  However you will fail to run the “ns-simple.tcl” with the displayed notice. This is because you did not open “XWin” yet
  • 46. Simple Simulation Implement  Open “Xwin” from “C:cygwinusrX11R6bin”. If everything is fine, you will then get the following figures.
  • 47. Simple Simulation Implement  Yet you may get the following warning messages:
  • 48. Simple Simulation Implement  That means some components missed. You can then copy these files from “C:cygwinbin” to “C:cygwinusrX11R6bin”  After you open X11, you may still can not run “ns-simple.tcl”
  • 49. Simple Simulation Implement The following command can solve this issue export DISPLAY=:0.0
  • 51. Simple Simulation Implement  Run “ns-simple.tcl”