Advanced Computer communication laboratory: NS2 Introduction - PowerPoint PPT Presentation

1 / 34
About This Presentation
Title:

Advanced Computer communication laboratory: NS2 Introduction

Description:

Human activities: Infrastructure installation. Provider and billing. Network Administration ... Physical activities are translated to events ... – PowerPoint PPT presentation

Number of Views:157
Avg rating:3.0/5.0
Slides: 35
Provided by: miri7
Category:

less

Transcript and Presenter's Notes

Title: Advanced Computer communication laboratory: NS2 Introduction


1
Advanced Computer communication laboratoryNS-2
Introduction
Miriam Allalouf
  • 2005-2006 - Semester B

2
NS-2 lab Introduction
  • Wild list of Network components
  • Customers / Edge components / Home Equipment
  • Service to be transferred
  • Infrastructure Transportation cables/wires
  • Switching components, Topology
  • Routing, Connection kinds and Geographical span
  • Protocol layers
  • Addressing, Management and Traffic Management
  • Human activities
  • Infrastructure installation
  • Provider and billing
  • Network Administration
  • Owners

3
NS-2 lab Introduction
  • Network Simulation and -
  • Real-world experiments sometimes impossible
  • Mathematical modeling can be painful
  • Sometimes even painful and inaccurate
  • -Simulation cannot replace real-world experiments
  • -Processing delay, traffic pattern, Physical
    layer
  • Scaling, Long Simulations
  • Simulation sometimes misses the whole picture
  • Specific layers, wrong assumption

4
NS-2 lab Introduction
  • NS-2 Goals
  • Support networking research and education
  • Protocol design, traffic studies, etc
  • Protocol comparison
  • Provide a collaborative environment
  • Freely distributed, open source
  • Share code, protocols, models, etc
  • Allow easy comparison of similar protocols
  • Helps to debug problems in a controlled
    environment
  • Increase confidence in results
  • More people look at models in more situations
  • Experts develop models
  • Multiple levels of detail in one simulator

5
NS-2 lab Introduction
  • ns-2 functionalities
  • Focus on Internet technology (layers IP and up )
  • Wired world
  • Intra-Domain Routing DV, LS
  • Transportation TCP and UDP the tool for TCP
    simulations
  • Traffic sources and generator web, ftp, telnet,
    cbr, stochastic
  • Queuing disciplines drop-tail, RED, FQ, SFQ, DRR
  • QoS IntServ and Diffserv
  • Emulation
  • Wireless Not ideal for new link layer
    technologies
  • CSMA/CD, 802.11 (?) - Contributed Modules
  • Ad hoc routing and mobile IP
  • Satellite nodes
  • Link Loss Model
  • Tracing, visualization

6
NS-2 lab Introduction
  • History
  • 1989 REAL network simulator
  • 1995 DARPA VINT project at LBL, Xerox PARC, UCB,
    and USC/ISI
  • Present DARPA SAMAN project and NSF CONSER
    project
  • Collaboration with other researchers including
    ACIRI

7
NS-2 lab Introduction
  • Help and Resources
  • Course Home Page
  • http//www.eng.tau.ac.il/miriama/ns2.htm
  • NS-2
  • http//www.isi.edu/nsnam/ns/
  • http//www.isi.edu/nsnam/ns/tutorial/index.html
  • TCL
  • http//dev.scriptics.com/scripting
  • Otcl tutorial
  • http//www.isi.edu/nsnam/otcl/README.html

8
NS-2 lab Introduction
  • ns-2 Overview
  • OTcl and C
  • OTcl scripts and C mechanism implementation,
    timing critical code
  • Open source
  • Facilitates building upon other work
  • Support via mailing list (frequently no answers)
  • Huge and complicated code
  • Semi-Poor documentation

9
NS-2 lab Introduction
  • Ns Status
  • Periodical release (ns-2.29, February 2006)
  • 200K LOC in C and Otcl,
  • 100 test suites and 100 examples
  • 371 pages of ns manual
  • Daily snapshot (with auto-validation)
  • Stability validation
  • http//www.isi.edu/nsnam/ns/ns-tests.html
  • Platform support
  • FreeBSD, Linux, Solaris, Windows and Mac
  • User base
  • 1000 institutes (50 countries), gt10000 users
  • About 300 posts to ns-users_at_isi.edu every month

10
NS-2 lab Introduction
  • Ns Components
  • Ns, the simulator itself
  • Nam, the network animator
  • Visualize ns (or other) output (files .nam)
  • Nam editor GUI interface to generate ns scripts
  • Pre-processing
  • Traffic and topology generators
  • Post-processing
  • Generates Output files
  • Simple trace analysis, often in Awk, Perl, or Tcl

11
NS-2 lab Introduction
  • Ns-2 A discrete Event Simulation
  • Model world as events
  • Simulator has list of events
  • Process take next one, run it, until done
  • Each event happens in an instant of virtual
    (simulated) time, but takes an arbitrary amount
    of real time
  • Ns uses simple model single thread of control gt
    no locking or race conditions to worry about
    (very easy)

12
NS-2 lab Introduction
  • Ns-2 is a discrete event driven simulation
  • Physical activities are translated to events
  • Events are queued and processed in the order of
    their scheduled occurrences
  • Time progresses as the events are processed

13
Event Driven Simulation
NS-2 lab Introduction
Event Queue
Simulation Finished!
14
Using ns
NS-2 lab Introduction
Problem
Result analysis
Simulation model
Modify ns
Setup/run simulation with ns
15
NS-2 lab Introduction
  • Using ns Simulation Model Components
  • Network core functions - building blocks
    (protocols, nodes, events, etc..)
  • C , OTCL implementation
  • Network configuration (build network topology,
    generate communication events, etc..)
  • Testing different configurations needs to be fast
    (without recompilation)
  • Use script language TCL

16
Basic tcl
NS-2 lab Introduction
  • proc test args body
  • proc test
  • set a 43
  • set b 27
  • set c expr a b
  • set d expr expr a - b c
  • for set k 0 k lt 10 incr k
  • if k lt 5
  • puts k lt 5, pow expr pow(d, k)
  • else
  • puts k gt 5, mod expr d k
  • tclgt test

17
Basic otcl
NS-2 lab Introduction
  • Class mom
  • mom instproc greet
  • self instvar age_
  • puts age_ years old mom How are you doing?
  • Class kid -superclass mom
  • kid instproc greet
  • self instvar age_
  • puts age_ years old kid Whats up, dude?
  • set a new mom
  • a set age_ 45
  • set b new kid
  • b set age_ 15
  • a greet
  • b greet
  • 45 years old mom How are you doing?
  • 15 years old kid What's up, dude?

18
NS-2 lab Introduction
  • Creating Event Scheduler
  • Create event scheduler
  • set ns new Simulator
  • Schedule events
  • ns at lttimegt lteventgt
  • lteventgt any legitimate ns/tcl commands
  • ns at 5.0 finish
  • Start scheduler
  • ns run

19
Hello World Example
NS-2 lab Introduction
  • Batch mode
  • simple.tcl
  • set ns new Simulator
  • ns at 1 puts \Hello World!\
  • ns at 1.5 exit
  • ns run
  • swllow 74 ns simple.tcl
  • Hello World!
  • swllow 75
  • Interactive mode
  • swallow 71 ns
  • set ns new Simulator
  • _o3
  • ns at 1 puts \Hello World!\
  • 1
  • ns at 1.5 exit
  • 2
  • ns run
  • Hello World!
  • swallow 72

20
NS-2 lab Introduction
  • NS Models
  • Traffic models and applications
  • Web, FTP, telnet, constant-bit rate, real audio
  • Transport protocols
  • unicast TCP (Reno, Vegas, etc.), UDP
  • Multicast SRM
  • Routing and queueing
  • Wired routing, ad hoc rtg and directed diffusion
  • queuing protocols RED, drop-tail, etc
  • Physical media
  • Wired (point-to-point, LANs), wireless (multiple
    propagation models), satellite

21
NS-2 lab Introduction
  • NS-2 programming
  • Create the event scheduler
  • Turn on tracing
  • Creating network
  • Computing routes and Setup routing
  • Creating transport connections - agents
  • Creating traffic applications
  • Transmit application-level data
  • Inserting errors
  • Monitoring

22
NS-2 lab Introduction
  • Packet Switching

23
NS-2 lab Introduction
  • Creating Network
  • Nodes
  • set ns new Simulator
  • set n0 ns node
  • set n1 ns node
  • Links Queuing
  • Set mylink ns duplex-link n0 n1 ltbandwidthgt
    ltdelaygt ltqueue_typegt
  • ltqueue_typegt DropTail, RED, CBQ, WFQ, SFQ, DRR
  • Set myqueue mylink queue
  • mylink set parameter value
  • For defaults ns/tcl/lib/ns-default.tcl

24
NS-2 lab Introduction
  • Computing Routes
  • Unicast
  • ns rtproto lttypegt
  • lttypegt Static, Session, DV, cost, multi-path
  • Multicast
  • Simulator set EnableMcast_ 1
  • Simulator set NumberInterfaces_ 1
  • ns mrtproto lttypegt
  • lttypegt CtrMcast, DM, dynamicDM, pimDM

25
NS-2 lab Introduction
  • Creating Connection agents
  • UDP
  • set src new Agent/UDP
  • set rcv new Agent/Null
  • ns connect src rcv
  • TCP
  • set tcp new Agent/TCP
  • set tcpsink new Agent/TCPSink
  • ns connect tcp tcpsink

26
NS-2 lab Introduction
  • Agents - More
  • TCP ?? TCPsink
  • one-way Tahoe implementation
  • other flavors TCP/Reno, TCP/NewReno, TCP/Sack1,
  • TCP/Vegas
  • two-way use FullTCP at both sides
  • TCP-friendly connectionless protocols
  • RAP lt-gt RAP Rate Adaptation Protocol (rate-based
    AIMD Slow Start)
  • TFRC lt-gt TFRCSink
  • TCP Friendly Rate Control protocol (based on TCP
    throughput-equation)

27
NS-2 lab Introduction
  • Creating Traffic applications
  • Use app on Top of agent
  • app start
  • app stop
  • FTP
  • set ftp new Application/FTP
  • ftp attach-agent tcp
  • Telnet
  • set telnet new Application/Telnet
  • Web
  • set session new httpSession ns ltnumPagesgt
    ltclientNodegt
  • Traffic generator
  • set cbr new Application/traffic/cbr

28
NS-2 lab Introduction
  • Inserting Errors
  • Creating Error Module
  • set loss_module new ErrorModel
  • loss_module set rate_ 0.01
  • loss_module unit pkt
  • loss_module ranvar new RandomVariable/Uniform
  • loss_module drop-target new Agent/Null
  • Inserting Error Module
  • ns lossmodel loss_module n0 n1

29
NS-2 lab Introduction
  • Tracing
  • Trace packets on all links
  • ns trace-all open test.out w
  • lteventgt lttimegt ltfromgt lttogt ltpktgt ltsizegt--ltflowidgt
    ltsrcgt ltdstgt ltseqnogt ltuidgt
  • 1 0 2 cbr 210 ------- 0 0.0 3.1 0 0
  • - 1 0 2 cbr 210 ------- 0 0.0 3.1 0 0
  • r 1.00234 0 2 cbr 210 ------- 0 0.0 3.1 0 0
  • Uid packet id
  • Trace packets on all links in nam-1 format
  • ns namtrace-all open test.nam w
  • Beware of large output files

30
NS-2 lab Introduction
  • Visualization Tools
  • nam-1 (Network AniMator Version 1)
  • xgraph

31
Example TCP
NS-2 lab Introduction
set ns new Simulator set n0 ns node set n1
ns node
set ftp new Application/FTP ftp attach-agent
tcp ns at 0.2 "ftp start" ns at 1.2
exit" ns run
ns duplex-link n0 n1 1.5Mb 10ms DropTail
set tcp new Agent/TCP set tcpsink new
Agent/TCPSink ns attach-agent n0 tcp ns
attach-agent n1 tcpsink ns connect tcp
tcpsink
32
Example Nam
NS-2 lab Introduction
Create a simulator object set ns new
Simulator Open the nam trace file set nf open
out.nam w ns namtrace-all nf Open the general
trace file set tf open out.tr w ns trace-all
tf
Define a 'finish' procedure proc finish
global ns nf tf ns flush-trace
Close the trace files close nf
close tf Execute nam on the trace file
exec nam out.nam exit 0 ns at
5.0 "finish Run the simulation ns run
33
Summary Generic Script Structure
NS-2 lab Introduction
  • set ns new Simulator
  • Turn on tracing
  • Create topology
  • Setup packet loss, link dynamics
  • Create routing agents
  • Create
  • - multicast groups
  • - protocol agents
  • - application and/or setup traffic sources
  • Post-processing procs
  • Start simulation

34
NS-2 lab Introduction
  • Compare to Real World
  • More abstract (much simpler)
  • No addresses, just global variables
  • Connect them rather than name lookup/bind/listen/a
    ccept
  • Easy to change implementation
  • Set tsrc2 new agent/TCP/Newreno
  • Set tsrc3 new agent/TCP/Vegas

35
NS-2 lab Introduction
  • Getting Started
  • Cygwin install only using the Install (not
    the default) In case of already installed
    cygwin - ask me how!
  • ns-2 version ns-allinone_2.28 installation over
    cygwin
  • C/cygwin/home/user
  • .bashrc file contains the following
  • export NS_HOME/home/user/ns-allinone-2.28
  • export LD_LIBRARY_PATHNS_HOME/otcl1.9NS_HOM
    E/lib
  • export TCL_LIBRARYNS_HOME/tcl8.4.5/library
  • export PATH NS_HOMENS_HOME/binNS_HOME/
    tcl8.4.5/unixNS_HOME/tk8.4.5/unix/PATH
  • Use the C/cygwin/home/user/my_ns directory for
    your stuff
  • Read sections I-V in the Marc Greis tutorial.
  • http//www.isi.edu/nsnam/ns/tutorial/index.html
  • Run ns examples described in these sections that
    are located in
  • NS_HOME/ns-2.28/ns-tutorial/examples/
Write a Comment
User Comments (0)
About PowerShow.com