NS2 Tutorial - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

NS2 Tutorial

Description:

Impossible to carry real experiments. Difficult to find a location ... Friss-space attenuation at near distance. Two Ray Ground at far distance. Antenna ... – PowerPoint PPT presentation

Number of Views:60
Avg rating:3.0/5.0
Slides: 19
Provided by: lkl8
Category:

less

Transcript and Presenter's Notes

Title: NS2 Tutorial


1
NS-2 Tutorial
  • Presented by
  • Lap Kong Law
  • lklaw_at_cs.ucr.edu

2
Problem
  • Impossible to carry real experiments
  • Difficult to find a location
  • Wireless experiments take huge space (in the
    order of km).
  • Difficult to arrange experiments
  • Hard to manage a large number of nodes.
  • High equipment cost
  • Feasibility study is costly
  • The cost of implementing a real system to study
    the feasibility is very high
  • Not flexible
  • Difficult to change parameters

So, we use NS-2!
3
Roadmap
  • Introduction to NS-2
  • Installation
  • NS-2 Architecture
  • Mobile Networking in NS-2
  • Example simulation script
  • Trace file Analysis
  • Visualization
  • Cautions
  • Other Simulators

4
Introduction to NS-2
  • NS-2 stands for Network Simulator ver. 2
  • Discrete event simulator
  • Packet Level
  • Link layer and up
  • Provide substantial support on
  • TCP, Routing, Multicast protocols on both wired
    and wireless networks
  • Began in 1989 as a variant of the REAL network
    simulator
  • In 1995, NS development was supported by DARPA in
    VINT project
  • Supported and contributed by
  • DARPA, NSF, ACIRI and many researchers
  • Latest version 2.26
  • Released on Feb 28, 2003

5
Installation
  • Download NS-2
  • http//www.isi.edu/nsnam/ns/ns-build.html
  • Recommend the all-in-one package
  • Install NS-2
  • ./configure make in OTcl TclCL directory
  • ./configure make in ns directory
  • ./validate
  • Get an account with HUGE space available

6
NS-2 Architecture
  • Object-oriented (C, OTcl)
  • Scalability Extensibility
  • Data / Control Separation
  • Split C / OTcl object
  • C for data
  • Define packet action
  • OTcl for control
  • Periodic or triggered action
  • Each object defined in TCL script is an instance
    of class written by C language

7
Mobile Networking in NS-2
  • MobileNode inherits from Node object
  • MobileNode consists of
  • Link Layer (LL)
  • ARP module connected to LL
  • Interface priority queue (IFq)
  • MAC layer (MAC)
  • Network Interface (netIF)

8
Mobile Networking in NS-2
  • Support four Ad-hoc Routing Protocols
  • Destination Sequence Distance Vector (DSDV)
  • Dynamic Source Routing (DSR)
  • Temporally ordered Routing Algorithm (TORA)
  • Adhoc On-demand Distance Vector (AODV)
  • MAC layer protocols
  • 802.11
  • Preamble TDMA
  • Radio Propagation Model
  • Friss-space attenuation at near distance
  • Two Ray Ground at far distance
  • Antenna
  • Omni-directional antenna

9
Mobile Networking in NS-2
  • Basic steps to do simulation
  • Build your simulation script (.tcl)
  • Create scenario
  • Generating traffic pattern
  • Run simulation
  • Analyze trace file
  • Visualize your simulation

10
Example Simulation Script
11
Example Scenario
  • For large topologies, the node movement are
    defined in a separated file for convenience (and
    also for flexibility)
  • You can find some examples of node movement files
    in the /tcl/mobility/scene/ directory
  • There is a generator (called setdest) for
    creating node movement. It is located in the
    /indep-utils/cmu-scen-gen/setdest/ directory
  • Usage of the setdest tool
  • ./setdest n ltnum_of_nodegt -p ltpause_timegt
  • -s ltmax_speedgt -t ltsim_timegt -x ltmax_xgt -y
    ltmax_ygt
  • gt ltscenario_filegt

12
Example Traffic pattern
  • Similarly, traffic patterns are also defined in a
    separated file.
  • Examples can be found in the /tcl/mobility/scene/
    directory
  • Traffic generator is located in
    /indep-utils/cmu-scen-gen/ and are called
    cbrgen.tcl
  • Constant Bit Rate (CBR) or Transport Control
    Protocol (TCP)
  • To create connections, run
  • ns cbrgen.tcl -type cbrtcp -nn nodes
  • -seed seed -mc connections -rate rate
  • gt lttraffic pattern filegt

13
Trace file Analysis
  • Trace support for wireless simulations currently
    use cmu-trace objects
  • Cmu-trace objects are of three types
  • CMUTrace/Drop
  • CMUTrace/Recv
  • CMUTrace/Send
  • Tracing packets sent by agents, routers, mac
    layers or interface queues

14
Trace file Analysis
  • Revised trace format
  • ns use-newtrace
  • Example

s -t 0.267662078 -Hs 0 -Hd -1 -Ni 0 -Nx 5.00 -Ny
2.00 -Nz 0.00 -Ne -1.000000 -Nl RTR -Nw --- -Ma
0 -Md 0 -Ms 0 -Mt 0 -Is 0.255 -Id -1.255 It
message -Il 32 -If 0 -Ii 0 -Iv 32
Event type s ? send r ? receive d ? drop f ?
forward
Next hop info Hs ? id for this node Hd ? id for
next hop towards the dest.
  • Packet info for MAC level
  • Packet info for Application level
  • Consists of field leading with P
  • ARP
  • TCP
  • CBR
  • DSR

Packet info at IP level Is ? source
address.port Id ? dest. Address.port It ? packet
type Il ? packet size If ? flow id Ii ? unique
id Iv ? TTL value
Node property Ni ? node id Nx ? nodes x
coordinate Ny ? nodes y coordinate Nz ? nodes z
coordinate Ne ? nodes energy level
15
Visualization
  • Nam stands for Network Animator
  • It is a Tcl/TK based animation tools for viewing
    network simulation traces
  • Produce the nam trace file
  • set namtrace open opt(nam) w
  • ns namtrace-all-wireless namtrace ltmax_xgt
    ltmax_ygt

16
Result Visualization
  • Use Python!
  • To extract the required information from the
    trace file.
  • To produce output in particular formats that are
    easier to plot.
  • GNUPlot
  • Command-line driven program for producing 2D and
    3D plots.
  • Generate beautiful plots.
  • Matlab
  • More advanced ploting functions.
  • Various ploting libraries available for download.

17
Cautions
  • NS-2 is still under research and development
  • Bugs in the software are still being discovered
    and corrected
  • Users are responsible for verifying their
    simulation results that may be invalidated by
    bugs.
  • Similarly, users are responsible for verifying
    that they are using the correct models in their
    simulations.

18
Other Simulators
  • OPNET (http//www.opnet.com)
  • Commercial Software
  • Support Windows and Unix
  • Graphical Interface
  • Not free
  • GloMoSim (http//pcl.cs.ucla.edu/projects/glomosim
    )
  • Simulation environment for wireless network
  • Scalable to support thousands of nodes
  • Using layered approach to build different
    simulation layers
  • Free for educational users
Write a Comment
User Comments (0)
About PowerShow.com