Professional Documents
Culture Documents
Day-2
Sample:
Conti..
Tcl example:
Otcl example:
Flow monitor
set fmon [$ns_ makeflowmon Fid]
$ns_ attach-fmon $slink $fmon
$fmon set pdrops_
Creating Network
Nodes
set n0 [$ns node]
set n1 [$ns node]
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
Basic ns-2
Create a new simulator object
[Turn on tracing]
[Open your own trace files]
Create network (physical layer)
Create link and queue (data-link layer)
Define routing protocol
Create transport connection (transport layer)
Create traffic (application layer)
Insert errors
Creating simulator
instance
Create simulator instance
set ns [new Simulator]
Usually the first non-comment statement in
ns2 script
Initialize the packet format
Create a scheduler (default is a calendar
scheduler)
Create a null agent
Simple code:
Run your
program %
ns Simple.tcl
Node Architecture
Node
Classifier
Node entry
point
Addr
Classifier
Local
Agent
Port
Agent
Agent
Classifiers: packet
demultiplexers.
Link
Link
Link
17
Links
Links: keeps track of from and to node objects.
blocked
Link
entry
point
Enq Trace
Queue
Deq Trace
Drop head
Drp Trace
Varaprasad Reddy
Delay
TTL
Rcv Trace
18
N1
N2
Node
Node
Application
Classifier
Port
Local
Agent
Classifier
Classifier
Classifier
Local
Port
Agent
Application
Addr
Addr
Link
Enq Trace
Queue
Link
Drop head
Deq Trace
Delay
TTL
Rcv Trace
Drp Trace
Varaprasad Reddy
19
SIMPLE CODE
SIMPLE CODE
SIMPLE CODE