network simulator ns tutorial n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Network Simulator(NS) Tutorial PowerPoint Presentation
Download Presentation
Network Simulator(NS) Tutorial

Loading in 2 Seconds...

play fullscreen
1 / 50

Network Simulator(NS) Tutorial - PowerPoint PPT Presentation


  • 146 Views
  • Uploaded on

Network Simulator(NS) Tutorial. These slides can be downloaded from: http://networks.cs.ucdavis.edu/~lijian/289I/. Agenda. What Is NS? Elements of Simulation NS Architecture NS Internals Summary. What is NS. Discrete event simulator Packet-level Protocol stack

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Network Simulator(NS) Tutorial' - kynan


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
network simulator ns tutorial

Network Simulator(NS) Tutorial

These slides can be downloaded from:

http://networks.cs.ucdavis.edu/~lijian/289I/

Lijian@cs.ucdavis.edu

agenda
Agenda
  • What Is NS?
  • Elements of Simulation
  • NS Architecture
  • NS Internals
  • Summary

Lijian@cs.ucdavis.edu

what is ns
What is NS
  • Discrete event simulator
  • Packet-level
  • Protocol stack
    • Link layer and up for wired networks;
    • Physical layer and up for wireless networks
  • Wired and wireless(both local and satellite)

Detour

Lijian@cs.ucdavis.edu

history and status
History and Status
  • Now part of VINT(Virtual InterNet Testbed) project
    • Columbia NEST --> UCB REAL --> NS-1 --> NS-2
  • Users from approximately
    • 600 institutes
    • 50 countries
  • Releases
    • Periodic releases (currently 2.1b9, April 2002)
    • Nightly snapshots (probably compiles and works, but “unstable”)
    • Available from: USC/ISI, UC Berkeley, UK mirror

Lijian@cs.ucdavis.edu

platforms
Platforms
  • Most UNIX and UNIX-like systems
    • FreeBSD or *BSD
    • Linux
    • Sun Solaris
    • HP, SGI
  • Window 95/98/NT
    • Some work, some does not
  • (Emulation only for FreeBSD for now)

Lijian@cs.ucdavis.edu

functionality of ns
Functionality of NS
  • Wired world
    • Point-to-point link, LAN
    • Unicast/multicast routing
    • Transport
    • Application layer
  • Wireless
    • Mobile IP
    • Ad hoc routing
  • Tracing, visualization, various utilities

Lijian@cs.ucdavis.edu

visualization tools
Visualization Tools
  • nam-1 (Network AniMator Version 1)
    • Packet-level animation
    • Well supported by ns
  • xgraph
    • Conversion from ns trace to xgraph format

Lijian@cs.ucdavis.edu

getting started
Getting Started
  • NS official site:
    • http://www.isi.edu/nsnam/ns/
  • A painless tutorial by Marc Greis:
    • http://www.isi.edu/nsnam/ns/tutorial/index.html
  • Another good tutorial from WPI
    • http://nile.wpi.edu/NS/

Lijian@cs.ucdavis.edu

getting help reference
Getting Help & Reference
  • Building NS
    • http://www.isi.edu/nsnam/ns/ns-build.html
  • NS user mailing list
    • http://mailman.isi.edu/mailman/listinfo/ns-users
  • NS manual
    • http://www.isi.edu/nsnam/ns/ns-documentation.html

Lijian@cs.ucdavis.edu

agenda1
Agenda
  • What Is NS?
  • Elements of Simulation
  • NS Architecture
  • NS Internals
  • Summary

Lijian@cs.ucdavis.edu

elements of simulation
Elements of Simulation
  • Create the event scheduler
  • [Turn on tracing]
  • Create network
  • Setup routing
  • [Insert errors]
  • Create traffic
  • Start simulation
  • Post-process trace

Detour

Lijian@cs.ucdavis.edu

creating event scheduler
Creating Event Scheduler
  • Create event scheduler
    • set ns [new Simulator]
  • Schedule events
    • $ns at <time> <event>
    • <event>: any legitimate ns/tcl commands
  • Start scheduler
    • $ns run

Lijian@cs.ucdavis.edu

tracing
Tracing
  • Trace packets on all links
    • $ns trace-all [open test.out w]

<event> <time> <from> <to> <pkt> <size> -- <fid> <src> <dst> <seq> <attr>

+ 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

  • Trace packets on all links in nam-1 format
    • $ns namtrace-all [open test.nam w]
  • Turn on tracing on specific links
    • $ns trace-queue $n0 $n1
    • $ns namtrace-queue $n0 $n1
  • Must appear immediately after creating scheduler

Lijian@cs.ucdavis.edu

creating network
Creating Network
  • Nodes
    • set n0 [$ns node]
    • set n1 [$ns node]
  • Links and queuing
    • $ns duplex-link $n0 $n1 <bandwidth> <delay> <queue_type>
    • <queue_type>: DropTail, RED, CBQ, FQ, SFQ, DRR

Lijian@cs.ucdavis.edu

creating network lan
Creating Network: LAN
  • LAN
    • $ns make-lan <node_list> <bandwidth> <delay> <ll_type> <ifq_type> <mac_type> <channel_type>
    • <ll_type>: LL
    • <ifq_type>: Queue/DropTail,
    • <mac_type>: MAC/802_3
    • <channel_type>: Channel

Lijian@cs.ucdavis.edu

inserting errors
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

Lijian@cs.ucdavis.edu

network dynamics
Network Dynamics
  • Link failures
    • Hooks in routing module to reflect routing changes
  • Four models

$ns rtmodel Trace <config_file> $n0 $n1

$ns rtmodel Exponential {<params>} $n0 $n1

$ns rtmodel Deterministic {<params>} $n0 $n1

$ns rtmodel-at <time> up|down $n0 $n1

  • Parameter list

[<start>] <up_interval> <down_interval> [<finish>]

Lijian@cs.ucdavis.edu

setup routing
Setup Routing
  • Unicast
    • $ns rtproto <type>
    • <type>: Static, Session, DV, cost, multi-path
  • Multicast
    • $ns multicast (right after [new Simulator])
    • $ns mrtproto <type>
    • <type>: CtrMcast, DM, ST, BST

Lijian@cs.ucdavis.edu

creating connection udp or tcp
Creating Connection: UDP or TCP
  • UDP
    • set udp [new Agent/UDP]
    • set null [new Agent/Null]
    • $ns attach-agent $n0 $udp
    • $ns attach-agent $n1 $null
    • $ns connect $udp $null
  • TCP
    • set tcp [new Agent/TCP]
    • set tcpsink [new Agent/TCPSink]
    • $ns attach-agent $n0 $tcp
    • $ns attach-agent $n1 $tcpsink
    • $ns connect $tcp $tcpsink

Lijian@cs.ucdavis.edu

creating traffic on top of udp
Creating Traffic: On Top of UDP
  • CBR
    • set src [new Application/Traffic/CBR]
  • Exponential or Pareto on-off
    • set src [new Application/Traffic/Exponential]
    • set src [new Application/Traffic/Pareto]

Lijian@cs.ucdavis.edu

creating traffic on top of tcp
Creating Traffic: On Top of TCP
  • FTP
    • set ftp [new Application/FTP]
    • $ftp attach-agent $tcp
  • Telnet
    • set telnet [new Application/Telnet]
    • $telnet attach-agent $tcp

Lijian@cs.ucdavis.edu

creating traffic trace driven
Creating Traffic: Trace Driven
  • Trace driven
    • set tfile [new Tracefile]
    • $tfile filename <file>
    • set src [new Application/Traffic/Trace]
    • $src attach-tracefile $tfile
  • <file>:
    • Binary format (native!)
    • inter-packet time (msec) and packet size (byte)

Lijian@cs.ucdavis.edu

application level simulation
Application-Level Simulation
  • Features
    • Build on top of existing transport protocol
    • Transmit user data, e.g., HTTP header
  • Two different solutions
    • TCP: Application/TcpApp
    • UDP: Agent/Message

Lijian@cs.ucdavis.edu

agenda2
Agenda
  • What Is NS?
  • Elements of Simulation
  • NS Architecture
  • NS Internals
  • Summary

Detour ends.

Lijian@cs.ucdavis.edu

ns architecture
NS Architecture
  • Object-oriented (C++, OTcl)
  • Scalability + Extensibility
    • Control/”data” separation
    • Split C++/OTcl object
  • Modular approach
    • Fine-grained object composition

Detour ends.

Lijian@cs.ucdavis.edu

c otcl split objects
C++/OTcl Split Objects

Pure OTcl

objects

Pure C++

objects

100K

70K

C++

OTcl

C++/OTcl split objects

NS

Lijian@cs.ucdavis.edu

c otcl linkage
C++/OTcl Linkage

Lijian@cs.ucdavis.edu

tclobject hierarchy and shadowing
TclObject: Hierarchy and Shadowing

C++ class

hierarchy

OTcl class

hierarchy

TclObject

TclObject

Agent

Agent

TcpAgent

Agent/TCP

*tcp

_o123

Agent/TCP OTcl

shadow object

Agent/TCP C++

object

Lijian@cs.ucdavis.edu

the merit of otcl
The Merit of OTcl
  • Smoothly adjust the granularity of scripting to balance extensibility and performance
  • With complete compatibility with existing simulation scripts

Program size, complexity

low

high

OTcl

C/C++

split objects

Lijian@cs.ucdavis.edu

scalability vs flexibility
Scalability vs Flexibility
  • It’s tempting to write all-OTcl simulation
    • Benefit: quick prototyping
    • Cost: memory + runtime
  • Solution
    • Control the granularity of your split object by migrating methods from OTcl to C++

Lijian@cs.ucdavis.edu

object granularity tips
Object Granularity Tips
  • Functionality
    • Per-packet processing  C++
    • Hooks, frequently changing code  OTcl
  • Data management
    • Complex/large data structure  C++
    • One-time configuration variables  OTcl

Lijian@cs.ucdavis.edu

agenda3
Agenda
  • What Is NS?
  • Elements of Simulation
  • NS Architecture
  • NS Internals
  • Summary

Lijian@cs.ucdavis.edu

ns internals
NS Internals
  • Discrete event scheduler
  • Network topology
  • Routing
  • Transport
  • Packet flow
  • Packet format
  • Application

Lijian@cs.ucdavis.edu

discrete event scheduler

head_ ->

handler_ -> handle()

reschedule

insert

time_, uid_, next_, handler_

Discrete Event Scheduler
  • Three types of schedulers
    • List: simple linked list, order-preserving, O(N)
    • Heap: O(logN)
    • Calendar: hash-based, fastest, O(1)

time_, uid_, next_, handler_

head_ ->

Lijian@cs.ucdavis.edu

network topology node

n0

n1

Port Classifier

Multicast Node

dmux_

Addr Classifier

classifier_

Node entry

Node entry

dmux_

entry_

entry_

Multicast Classifier

classifier_

multiclassifier_

Network Topology: Node

Unicast Node

Lijian@cs.ucdavis.edu

network topology link

n0

n1

duplex link

n1 entry_

head_

enqT_

queue_

deqT_

link_

ttl_

drophead_

drpT_

tracing

simplex link

Network Topology: Link

Lijian@cs.ucdavis.edu

routing

n0

n1

Port Classifier

Addr Classifier

n1 entry_

0

Node entry

head_

dmux_

enqT_

queue_

deqT_

link_

ttl_

1

entry_

classifier_

drophead_

drpT_

Routing

Lijian@cs.ucdavis.edu

routing con t

n0

n1

Port Classifier

Port Classifier

Addr Classifier

Addr Classifier

0

1

dmux_

dmux_

0

1

entry_

entry_

classifier_

classifier_

Link n1-n0

Routing (con’t)

Link n0-n1

Lijian@cs.ucdavis.edu

transport

dst_=0.0

dst_=1.0

Agent/TCP

Agent/TCPSink

agents_

agents_

1

0

0

1

Transport

n0

n1

Port Classifier

Port Classifier

Addr Classifier

Addr Classifier

0

0

dmux_

dmux_

Link n0-n1

entry_

entry_

classifier_

classifier_

Link n1-n0

Lijian@cs.ucdavis.edu

application traffic generator

Application/FTP

dst_=0.0

dst_=1.0

0

1

1

0

Application: Traffic Generator

n0

n1

Port Classifier

Port Classifier

Agent/TCPSink

Addr Classifier

Addr Classifier

Agent/TCP

0

0

agents_

agents_

dmux_

dmux_

Link n0-n1

entry_

entry_

classifier_

classifier_

Link n1-n0

Lijian@cs.ucdavis.edu

plumbing packet flow

dst_=0.0

dst_=1.0

0

1

1

0

Plumbing: Packet Flow

n0

n1

Application/FTP

Port Classifier

Port Classifier

Agent/TCPSink

Addr Classifier

Addr Classifier

Agent/TCP

0

0

Link n0-n1

entry_

entry_

Link n1-n0

Lijian@cs.ucdavis.edu

packet format

ts_

cmn header

ptype_

ip header

uid_

tcp header

size_

rtp header

iface_

trace header

...

Packet Format

header

data

Lijian@cs.ucdavis.edu

abstract the real wireless world
Abstract the Real Wireless World
  • Packet headers
  • Mobile node
  • Wireless channel
  • Forwarding and routing
  • Visualization

Lijian@cs.ucdavis.edu

wireless packet format

ts_

cmn header

ptype_

IP header

uid_

......

size_

LL

iface_

MAC 802_11

ARP

......

Wireless Packet Format

header

data

Wireless headers

Lijian@cs.ucdavis.edu

mobile node abstraction
Mobile Node Abstraction
  • Location
    • Coordinates (x,y,z)
  • Movement
    • Speed, direction, starting/ending location, time ...

Lijian@cs.ucdavis.edu

portrait of a mobile node

Classifier: Forwarding

Agent: Protocol Entity

Node Entry

LL: Link layer object

IFQ: Interface queue

MAC: Mac object

PHY: Net interface

Portrait of A Mobile Node

port

classifier

Node

protocol

agent

255

routing

agent

addr

classifier

defaulttarget_

ARP

LL

LL

LL

IFQ

IFQ

MAC

MAC

Propagation and antenna models

PHY

PHY

MobileNode

CHANNEL

Lijian@cs.ucdavis.edu

wireless channel
Wireless Channel
  • Duplicate packets to all mobile nodes attached to the channel except the sender
  • It is the receiver’s responsibility to decide if it will accept the packet
    • Collision is handled at individual receiver
    • O(N2) messages  grid keeper

Lijian@cs.ucdavis.edu

agenda4
Agenda
  • What Is NS?
  • Elements of Simulation
  • NS Architecture
  • NS Internals
  • Summary

Lijian@cs.ucdavis.edu

summary
Summary
  • What can we do with NS?
  • Architectural overview of NS
    • split C++/OTcl Object
  • Inside NS
    • node, link, routing, tcp, app, wireless extension
    • how it works

Lijian@cs.ucdavis.edu

references
References
  • http://www.isi.edu/nsnam/dist/ns-workshop00/
  • http://www.isi.edu/nsnam/ns/

Lijian@cs.ucdavis.edu