The NS (v2) Sim ulator W orkshop br ought to you by Kevin - - PDF document

the ns v2 sim ulator w orkshop br ought to you by kevin f
SMART_READER_LITE
LIVE PREVIEW

The NS (v2) Sim ulator W orkshop br ought to you by Kevin - - PDF document

The NS (v2) Sim ulator W orkshop br ought to you by Kevin F all La wrence Berk eley National Lab oratory kfal l@e e.lbl.gov http://www-nr g.e e.lbl.gov/kfal l AND Kannan V aradhan USC/ISI kannan@c atarina.usc.e du


slide-1
SLIDE 1 The NS (v2) Sim ulator W
  • rkshop
br
  • ught
to you by Kevin F all La wrence Berk eley National Lab
  • ratory
kfal l@e e.lbl.gov http://www-nr g.e e.lbl.gov/kfal l AND Kannan V aradhan USC/ISI kannan@c atarina.usc.e du http://www.isi.e du/~kannan Septem b er 18, 1997
slide-2
SLIDE 2 Audience and Outline
  • Audience
{ net w
  • rk
researc hers { educators { dev elop ers
  • T
  • pics
for to da y { VINT pro ject goals and status (Sally) { arc hitecture plus some history (Stev en) {
  • v
erview
  • f
ma jor comp
  • nen
ts (Kevin) { pro ject/co de status (Kevin) { details
  • f
ma jor comp
  • nen
ts (Kevin) { C++/OTcl link age and sim ulation debugging (Kannan) { top
  • logy
generation and session-lev el supp
  • rt
(Kannan) { m ulticast and reliable m ulticast (Kannan) { a complex link: CBQ (Kevin) { discussion and futures (Ev ery
  • ne)
NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 2
slide-3
SLIDE 3 NSv2 Arc hitecture
  • Ob
ject-orien ted structure { ev
  • lution
from NSv1 (C++ with regular Tcl) {
  • b
jects implemen ted in C++ and \OTcl" { OTcl:
  • b
ject-orien ted extension to Tcl (from Da vid W etherall at MIT/LCS for V uSystem)
  • Con
trol/\Data" separation { con trol
  • p
erations in OTcl { data pass through C++
  • b
jects (for sp eed)
  • Mo
dular approac h { ne-grain
  • b
ject decomp
  • sition
{ p
  • sitives:
comp
  • sible,
re-usable { negatives: m ust \plum b" in OTcl, dev elop er m ust b e comfortable with b
  • th
en vironmen ts, to
  • ls
NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 3
slide-4
SLIDE 4 Dev elopmen t Status
  • sim
ulator co de basis for VINT Pro ject
  • 5ish
p eople activ ely con tributing to the co de base
  • ther
con tributions from Xero x P AR C, USC/ISI, UCB, LBNL
  • Some
appro ximate n um b ers: { 27K lines
  • f
C++ co de { 12K lines
  • f
OTcl supp
  • rt
co de { 18K lines
  • f
test suites, examples { 5K lines
  • f
do cumen tation!
  • See
main VINT and NS-2 w eb pages at: http://netweb.usc.edu/vint http://www-mash.cs.berkeley.edu/ns/ ns.htm l
  • Op
en mailing lists: { ns-users@mash.cs.b erk eley .edu { ns-announce@mash.cs.b erk eley .edu
  • T
  • subscrib
e: { ma jordomo@mash.cs.b erk eley .edu NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 4
slide-5
SLIDE 5 Directory Structure
  • common
directory shared b et w een MASH (UCB) and VINT pro jects

Tcl

conf ... WORK common vint doc ns-2 nam lib test ex

bin

tcl www

NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 5
slide-6
SLIDE 6 Class Hierarc h y
  • T
  • p-lev
el classes implemen t simple abstractions:

NewReno Replicator

AddrClassifier

Agent/Message/Prober

McastClassifier

Queue Classifier

Agent/Message

Delay Agent/TCP TclObject Connector

Shared with MASH Project:

NsObject Trace/Drop Trace/Hop Trace RED Agent Trace/Enq ... ... Trace/Deq Reno DropTail

NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 6
slide-7
SLIDE 7 Example: a no de
  • No
de: a collection
  • f
agents and classiers
  • Agen
ts: usually proto col endp
  • in
ts and related
  • b
jects
  • Classiers:
pac k et dem ultiplexers

Agent

Port Classifier Local Addr

Link Link

Classifier Addr

Node

Node.entry

Agent Agent

  • Note
that the no de \routes" to itself
  • r
to do wnstream links NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 7
slide-8
SLIDE 8 Example: a link
  • k
eeps trac k
  • f
\from" and \to" No de
  • b
jects
  • generally
encapsulates a queue, dela y and p
  • ssibly
ttl c hec k er

Queue split classes (OTcl class) Link Delay

  • Man
y more complex
  • b
jects built from this base NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 8
slide-9
SLIDE 9 Example: routers
  • routers
(unicast and m ulticast) b y \plum bing"

Node ... ... Node

Node.entry

Link Link Link

  • m
ulticast router adds additional classiers and replicators
  • Replicators:
dem uxers with m ultiple fanout

Addr Replicator Replicator Addr Classifier Classifier unicast? Mcast Classifier

MulticastNode

multicast?

... ...

(S1, G1) (S2, G2) (S3, G3)

Link Link

Node.entry

Link

NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 9
slide-10
SLIDE 10 OTcl Basics
  • See
the page at ftp://ftp.tns.lcs.mit.edu/pub/otcl/
  • b
ject
  • rien
ted extension to tcl
  • classes
are
  • b
jects with supp
  • rt
for inheritance
  • Analogs
to C++: { C++ has single class decl ) OTcl attac hes metho ds to
  • b
ject
  • r
class { C++ constructor/destructor ) OTcl init/destro y metho ds { this ) $self { OTcl metho ds alw a ys \virtual" { C++ shado w ed metho ds called explicitly with scop e
  • p
erator ) OTcl metho ds com bined implicitly with $self next { C++ static v ariables ) OTcl class v ariables { (m ultiple inheritance is supp
  • rted)
NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 10
slide-11
SLIDE 11 OTcl Basics (con td)
  • use
instvar and instpr
  • c
to dene/access mem b er functions and v ariables
  • Example:
Class Counter Counter instproc init fg f $self instvar cnt set cnt g Counter instproc bump fg f $self instvar cnt incr cnt g Counter instproc val fg f $self instvar cnt return $cnt g Counter c c val ! c bump c val ! 1 NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 11
slide-12
SLIDE 12 C++/OTcl Split Ob jects
  • Split
  • b
jects: implemen t metho ds in either language
  • new
and delete set c [new Counter] $c val
  • >
$c bump $c val
  • >
1 delete $c
  • Dene
instance v ariables in either C++
  • r
OTcl: Counter::Counter() f bind("cnt ", &value ); value = 10; ... g vs. $self set cnt 10 bind() simply uses Tcl T r ac eV ar NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 12
slide-13
SLIDE 13 Example: a simple sim ulation
  • A
small but complete sim ulation script: { set up 4-no de top
  • logy
and
  • ne
bulk-data transfer TCP { arrange to trace the queue
  • n
the r1-k1 link { place trace
  • utput
in the le simp.out.tr
  • #
Create a simple four node topology: # s1 # \ # 8Mb,5ms \ 0.8Mb,50ms # r1
  • k1
# 8Mb,5ms / # / # s2 set stoptime 10.0 set ns [new Simulator] set node_(s1) [$ns node] set node_(s2) [$ns node] set node_(r1) [$ns node] set node_(k1) [$ns node] $ns duplex-link $node_(s1) $node_(r1) 8Mb 5ms DropTail $ns duplex-link $node_(s2) $node_(r1) 8Mb 5ms DropTail $ns duplex-link $node_(r1) $node_(k1) 800Kb 50ms DropTail $ns queue-limit $node_(r1) $node_(k1) 6 $ns queue-limit $node_(k1) $node_(r1) 6 set tcp1 [$ns create-connection TCP $node_(s1) TCPSink $node_(k1) 0] $tcp1 set window_ 50 $tcp1 set packetSize_ 1500 # Set up FTP source set ftp1 [$tcp1 attach-source FTP] set tf [open simp.out.tr w] $ns trace-queue $node_(r1) $node_(k1) $tf $ns at 0.0 "$ftp1 start" $ns at $stoptime "close $tf; puts \"simulation complete\"; $ns halt" $ns run NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 13
slide-14
SLIDE 14 Example: a simple sim ulation (con t)
  • The
trace le pro duced lo
  • ks
lik e this: + 0.0065 2 3 tcp 1500
  • 0.0
3.0
  • 0.0065
2 3 tcp 1500
  • 0.0
3.0 + 0.23344 2 3 tcp 1500
  • 0.0
3.0 1 2
  • 0.23344
2 3 tcp 1500
  • 0.0
3.0 1 2 + 0.23494 2 3 tcp 1500
  • 0.0
3.0 2 3
  • 0.24844
2 3 tcp 1500
  • 0.0
3.0 2 3 + 0.46038 2 3 tcp 1500
  • 0.0
3.0 3 6
  • 0.46038
2 3 tcp 1500
  • 0.0
3.0 3 6 + 0.46188 2 3 tcp 1500
  • 0.0
3.0 4 7 + 0.47538 2 3 tcp 1500
  • 0.0
3.0 5 8 ... + 0.98926 2 3 tcp 1500
  • 0.0
3.0 25 40 + 0.99076 2 3 tcp 1500
  • 0.0
3.0 26 41 d 0.99076 2 3 tcp 1500
  • 0.0
3.0 26 41
  • 1.00426
2 3 tcp 1500
  • 0.0
3.0 21 36 + 1.00426 2 3 tcp 1500
  • 0.0
3.0 27 42 + 1.00576 2 3 tcp 1500
  • 0.0
3.0 28 43 d 1.00576 2 3 tcp 1500
  • 0.0
3.0 28 43
  • 1.01926
2 3 tcp 1500
  • 0.0
3.0 22 37 + 1.01926 2 3 tcp 1500
  • 0.0
3.0 29 44 + 1.02076 2 3 tcp 1500
  • 0.0
3.0 30 45 d 1.02076 2 3 tcp 1500
  • 0.0
3.0 30 45
  • 1.03426
2 3 tcp 1500
  • 0.0
3.0 23 38
  • 1.04926
2 3 tcp 1500
  • 0.0
3.0 24 39
  • 1.06426
2 3 tcp 1500
  • 0.0
3.0 25 40 ... NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 14
slide-15
SLIDE 15 The Sim ulator
  • Sim
ulator API is a set
  • f
metho ds b elonging to a simulator
  • b
ject:
  • Create
a sim ulator with: set ns [new Simulator]
  • What
this do es: { initialize the pac k et format (calls create packetformat) { create a sc heduler (defaults to a simple link ed-list sc heduler)
  • Sc
heduler: { handles time, timers and ev en ts (pac k ets), deferred executions (\A Ts") { Scheduler/List
  • link
ed-list sc heduler { Scheduler/Heap
  • heap-based
sc heduler { Scheduler/Calendar
  • calendar-queue
sc heduler { see Reev es, "Complexit y Analyses
  • f
Ev en t Set Algorithms", The Computer Journal, 27(1), 1984 NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 15
slide-16
SLIDE 16 Using the sc heduler
  • Sc
heduler API is through Sim ulator
  • b
ject: Simulator instproc now ;# r eturn sche duler's notion
  • f
curr ent time Simulator instproc at args ;# sche dule exe cution
  • f
c
  • de
at sp e ci- e d time Simulator instproc run args ;# start sche duler Simulator instproc halt ;# stop (p ause) the sche duler Simulator instproc create-trace type files src dst ;# cr e- ate tr ac e
  • bje
ct Simulator instproc create_packet fo rm at ;# set up the simula- tor's p acket format
  • Example:
MySim instproc begin {} { ... set ns_ [new Simulator] $ns_ use-scheduler Heap $ns_ at 300.5 "$self complete_sim" ... } MySim instproc complete_sim {} { ... } NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 16
slide-17
SLIDE 17 Sim ulator Timing
  • eac
h
  • b
ject has a generic receiv e metho d NsObject::recv(Packet*, Handler* h = 0)
  • most
  • b
jects ha v e single neigh b
  • r
Connector::target
  • cut-thr
  • ugh
transfers; send pac k et directly to neigh b
  • r
without in v
  • lving
sc heduler Connector::send(Packet* p) f target
  • >recv(p);
g
  • b
arrier: { an y p
  • in
t that adv ances time in to future (i.e., dela y elemen t) { need in ter-ob ject \proto col" to decouple timing { barrier tak es non-n ull Handler { sc hedule dela y and in v
  • k
e handler
  • n
completion { example: queue/dela y
  • b
jects (later) NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 17
slide-18
SLIDE 18 P ac k ets
  • pac
k ets are events (ma y b e sc heduled to \arriv e")
  • con
tain header section and (sometimes) data
  • header
section is a cascade
  • f
all in-use headers
  • all
pac k ets con tain a c
  • mmon
he ader: { pac k et size
  • used
to compute transmission time { timestamp, t yp e, uid, in terface lab el (for debugging, and m ulticast routing)
  • new
proto col agen ts ma y need to dene new headers NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 18
slide-19
SLIDE 19 P ac k et Header F
  • rmat

hdrlen_ ip header body tcp header body rtp header body trace header body next_

Packet

at compile time at compile time size determined at compile time size determined at compile time size determined size determined points to next packet in either free list or in a PacketQueue bits() accessdata() packet data Size determined at simulator config time, stored in hdrlen_

Figure 1: A P ac k et Ob ject
  • header
con ten ts are constructed at sim ulator initialization time
  • p
erformed b y create packetformat NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 19
slide-20
SLIDE 20 Connectors
  • Conne
ctor: simple in/out top
  • logy
  • b
ject with \drop target" /* * An NsObject with
  • nly
a single neighbor. */ class Connector : public NsObject { public: Connector(); inline NsObject* target() { return target_; } virtual void drop(Packet* p); protected: int command(int argc, const char*const* argv); void recv(Packet*, Handler* callback = 0); inline void send(Packet* p, Handler* h) { target_->recv(p, h); } NsObject* target_; NsObject* drop_; // drop target for this connector };
  • if
drop target undened, dropp ed pac k ets are freed NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 20
slide-21
SLIDE 21 Error Mo dels
  • Err
  • r
Mo del: a (simple) parameterized lossy connector (can b e used as a base class for
  • ther
loss mo dels)
  • drops
pac k et
  • r
sets \error" bit (in common header)
  • error
units: pac k ets, bits, time Usage: # create a loss_module and set its packet error rate to 1 percent set loss_module [new ErrorModel] $loss_module set rate_ 0.01 #
  • ptional:
set the unit and random variable $em unit pkt # error unit: packets (the default) $em ranvar [new RandomVariable/Uniform] # set target for dropped packets $loss_module drop-target [$ns_ set nullAgent_]
  • if
drop target undened, dropp ed pac k ets are freed NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 21
slide-22
SLIDE 22 Agen ts
  • A
gents: usually a proto col endp
  • in
t/en tit y (but ma y also b e used for implemen ting routing proto cols)
  • Where
they t in:

Agent

Port Classifier Local Addr

Link Link

Classifier Addr

Node

Node.entry

Agent Agent

  • What
they pro vide: { a lo cal and destination address (lik e an IP-la y er sender) { functions for helping to generate/ll-in in pac k et elds NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 22
slide-23
SLIDE 23 Creating a new Agen t
  • The
Agent class: class Agent : public Connector { public: Agent(int pktType); virtual ~Agent(); virtual void timeout(int tno); protected: int command(int argc, const char*const* argv); void recv(Packet*, Handler*); ...
  • basic
tasks to create a new agen t: 1. decide its inheritance structure 2. create the class, recv, and timeout functions (if needed) 3. dene OTcl link age functions (Kannan will explain ho w later) 4. write the necessary OTcl co de to access y
  • ur
agen t
  • hardest
part ma y b e understanding the OTcl/C++ in teraction (fortunately , m uc h
  • f
this is shielded from y
  • u
if y
  • u
so c ho
  • se)
NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 23
slide-24
SLIDE 24 Example: the Message Agen t
  • pro
vides a v ery simple place to store a message
  • P
ac k et header (from message.h): struct hdr_msg { char msg_[64]; /* per-field member functions */ char* msg() { return (msg_); } int maxmsg() { return (sizeof(msg_)); } };
  • OTcl
link age (for class creation, from message.cc): static class MessageHeaderC la ss : public PacketHeaderC la ss { public: MessageHeaderCl as s( ) : PacketHeaderCl as s( "P ac ke tH ead er /M es sa ge ", sizeof(hdr_msg )) {} } class_msghdr; NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 24
slide-25
SLIDE 25 Example: the Message Agen t (con t)
  • The
class denition, constructor and v ariable link age: static class MessageClass : public TclClass { public: MessageClass() : TclClass("Agen t/ Me ss ag e" ) {} TclObject* create(int, const char*const*) { return (new MessageAgent()) ; } } class_message; class MessageAgent : public Agent { public: MessageAgent() ; int command(int argc, const char*const* argv); void recv(Packet*, Handler*); protected: int
  • ff_msg_;
}; MessageAgent:: Me ss ag eA ge nt () : Agent(PT_MESSA GE ) { bind("packetSi ze _" , &size_); bind("off_msg_ ", &off_msg_); } NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 25
slide-26
SLIDE 26 Example: the Message Agen t (con t)
  • Main
functions: void MessageAgent::recv(Packet * pkt, Handler*) { hdr_msg* mh = (hdr_msg*)pkt->access(off_ msg_ ); ... process packet ... } int MessageAgent::command(int argc, const char*const* argv) { Tcl& tcl = Tcl::instance(); // call into interp if (argc == 3) { // $obj send msgtext if (strcmp(argv[1], "send") == 0) { Packet* pkt = allocpkt(); hdr_msg* mh = (hdr_msg*)pkt->access(off _ms g_); const char* s = argv[2]; int n = strlen(s); if (n >= mh->maxmsg()) { tcl.result("message too big"); Packet::free(pkt); return (TCL_ERROR); } strcpy(mh->msg(), s); send(pkt, 0); return (TCL_OK); } } return (Agent::command(argc, argv)); // for inheritance } NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 26
slide-27
SLIDE 27 TCP Agen ts
  • ns
has sev eral v arian ts
  • f
TCP a v ailable: { Agen t/TCP
  • a
\taho e" TCP sender { Agen t/TCP/Reno
  • a
\Reno" TCP sender { Agen t/TCP/NewReno
  • Reno
with a mo dication { Agen t/TCP/Sac k1
  • TCP
with selectiv e rep eat (follo ws RF C2018) { Agen t/TCP/V egas
  • TCP
V egas { Agen t/TCP/F ac k
  • Reno
TCP with \forw ard ac kno wledge- men t"
  • The
  • ne-w
a y TCP receiving agen ts curren tly supp
  • rted
are: { Agen t/TCPSink
  • TCP
sink with
  • ne
A CK p er pac k et { Agen t/TCPSink/DelAc k
  • TCP
sink with congurable dela y p er A CK { Agen t/TCPSink/Sac k1
  • selectiv
e A CK sink (follo ws RF C2018) { Agen t/TCPSink/Sac k1/DelAc k
  • Sac
k1 with DelAc k
  • The
t w
  • -w
a y exp erimen tal sender curren tly supp
  • rts
  • nly
a Reno form
  • f
TCP: { Agen t/TCP/F ullTcp NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 27
slide-28
SLIDE 28 Base TCP Agen ts
  • TCP
(T aho e), TCP/Reno, and TCP/NewReno
  • Common
features: { computations all in pac k et units w/congurable pac k et size { fast retransmit { slo w-start and congestion a v
  • idance
{ dynamic R TT estimation and R TX timeout assignmen t { sim ulated (constan t) receiv er's adv ertised windo w
  • T
aho e TCP: { p erform slo w-start
  • n
an y loss (R TO
  • r
fast retransmit) { no fast reco v ery
  • Reno
TCP: { fast r e c
  • very:
inate cw nd b y dup ac k coun t un til new A CK { slo w-start
  • n
R TO {
  • n
fast retransmit: cw nd cur w in=2 , ssthr esh cw nd
  • \Newreno"
TCP: { mo dest mo dication to Reno TCP {
  • nly
exit fast reco v ery after A CK for highest segmen t arriv es { helps reduce \stalling" due to m ultiple pac k et drops in a windo w NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 28
slide-29
SLIDE 29 Other TCP Agen ts
  • TCP/Sack,
TCP/Fack, and TCP/Vegas
  • Selectiv
e A CK TCP: { SA CK sim ulation based
  • n
RF C2018 { A CKs carry extra information indicating receiv ed segmen ts { requires SA CK-a w are sink { sender a v
  • ids
sending redundan t info { default to 3 \SA CK blo c ks" (for using timestamps, see RF C2018)
  • blo
c k con tains start/end sequence n um b ers
  • blo
c k con taining most recen tly receiv ed segmen t alw a ys presen t { regular A CK n um b er still giv es nal sa y
  • F
ac k TCP: { \forw ard A CK" TCP (exp erimen tal, see SIGCOMM '96) { use SA CK info for estimate
  • f
pac k ets in the net w
  • rk
{
  • v
erdamping algorithm (to limit slo w-start
  • v
ersho
  • t)
{ ramp do wn algorithm (for transmission smo
  • thing)
  • V
egas TCP: { con tributed co de from T ed Kuo (NC State Univ) { not directly supp
  • rted
at this time NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 29
slide-30
SLIDE 30 TCP Agen t P arameters
  • Common
conguration parameters and defaults for TCP agen ts: Agent/TCP set window_ 20 ;# max b
  • und
  • n
window size Agent/TCP set windowInit_ 1 ;# initial/r eset value
  • f
cwnd Agent/TCP set windowOption_ 1 ;# c
  • ng
avoid algorithm (1: standar d) Agent/TCP set windowConstant_ 4 ;# use d
  • nly
when windowOption != 1 Agent/TCP set windowThresh_ 0.002 ;# use d in c
  • mputing
aver age d window Agent/TCP set
  • verhead_
;# !=0 adds r andom time b etwe en sends Agent/TCP set ecn_ ;# TCP should r e act to e cn bit Agent/TCP set packetSize_ 1000 ;# p acket size use d by sender (bytes) Agent/TCP set bugFix_ true ;# se e do cumentation Agent/TCP set slow_start_restart_ true ;# se e do cumentation Agent/TCP set tcpTick_ 0.1 ;# timer gr anularity in se c (.1 is NONST AND ARD) Agent/TCP set maxrto_ 64 ;# b
  • und
  • n
R TO (se c
  • nds)
Agent/TCP set dupacks_ ;# duplic ate A CK c
  • unter
Agent/TCP set ack_ ;# highest A CK r e c eive d Agent/TCP set cwnd_ ;# c
  • ngestion
window (p ackets) Agent/TCP set awnd_ ;# aver age d cwnd (exp erimental) Agent/TCP set ssthresh_ ;# slow-stat thr eshold (p ackets) Agent/TCP set rtt_ ;# rtt sample Agent/TCP set srtt_ ;# smo
  • the
d (aver age d) rtt Agent/TCP set rttvar_ ;# me an deviation
  • f
rtt samples Agent/TCP set backoff_ ;# curr ent R TO b acko factor Agent/TCP set maxseq_ ;# max (p acket) se q numb er sent NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 30
slide-31
SLIDE 31 TCP Sink Agen ts
  • Sinks
for
  • ne-w
a y TCP senders
  • T
yp es { standard sinks, dela y ed-A CK sinks, SA CK sinks
  • Standard
sinks: { generate
  • ne
A CK p er pac k et receiv ed { A CK n um b er
  • v
erloaded in \sequence n um b er" pac k et eld
  • Dela
y ed-A CK sinks: { same as standard, but with v ariable dela y added b et w een A CKs { time to dela y A CKs sp ecied in seconds
  • SA
CK sinks: { generates additional information for SA CK capable sender { congurable maxSackBlocks parameter NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 31
slide-32
SLIDE 32 Tw
  • -W
a y TCP (\F ullTCP")
  • most
TCP
  • b
jects are
  • ne-w
a y (and require a source/sink pair)
  • real
TCP can b e bi-directional
  • sim
ultaneous t w
  • -w
a y data transfer alters TCP dynamics con- siderably
  • (new{
still undergoing debugging)
  • the
TCP/FullTcp agen t: { follo ws closely to \Reno" TCP implemen tation in 4.4 BSD { b yte-orien ted transfers { t w
  • -w
a y data supp
  • rted
{ most
  • f
the connection establishmen t/teardo wn { symmetric:
  • nly
  • ne
agen t t yp e used for b
  • th
sides NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 32
slide-33
SLIDE 33 F ullTCP P arameters
  • P
arameters and defaults: Agent/TCP/FullTcp set segsperack_ 1 ;# se gs r e c eive d b efor e gener ating A CK Agent/TCP/FullTcp set segsize_ 536 ;# se gment size (MSS size for bulk xfers) Agent/TCP/FullTcp set tcprexmtthresh_ 3 ;# dupA CKs thr esh to trigger fast r exmt Agent/TCP/FullTcp set iss_ ;# initial send se quenc e numb er Agent/TCP/FullTcp set nodelay_ false ;# disable sender-side Nagle algorithm Agent/TCP/FullTcp set data_on_syn_ false ;# send data
  • n
initial SYN? Agent/TCP/FullTcp set dupseg_fix_ true ;# avoid fast rxt due to dup se gs+acks Agent/TCP/FullTcp set dupack_reset_ false ;# r eset dupA CK ctr
  • n
!0 len data se g s c
  • ntaining
dup A CKs Agent/TCP/FullTcp set interval_ 0.1 ;# delaye d A CK interval NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 33
slide-34
SLIDE 34 T rac Sources
  • Sources
(\applications") used to driv e agen ts
  • curren
tly used
  • nly
b y TCP
  • T
yp es: { T elnet
  • sim
ulates c haracters t yp ed b y a user { FTP
  • bulk
data transfer
  • OTcl
In terface: $src start ;# start sending p ackets $src stop ;# stop sending p ackets $src attach-agent ;# asso- ciate agent with sour c e $ftpsrc produce npkts ;# send npkts num- b er
  • f
p ackets $ftpsrc producemore npkts ;# send npkts mor e p ackets
  • API
is still under some dev elopmen t
  • sources
  • nly
used b y TCP at this time NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 34
slide-35
SLIDE 35 T elnet T rac Source
  • ma
y sp ecify interval
  • if
zero, pic ks randomly among 10000 measured in terarriv als (TCPLIB)
  • if
nonzero, uses scaled exp
  • nen
tial for in terarriv als
  • pac
k et size constan t (but a v ailable via bind call) NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 35
slide-36
SLIDE 36 CBR and UDP Agen ts
  • CBR
Agen ts: { stands for \constan t bit rate" (not really used
  • nly
this w a y) { non-connection-orien ted sending agen t { sends pac k ets at p erio dic in terv al
  • r
quasi-p erio dically { constan t-size pac k ets
  • UDP
Agen ts: { v ery similar to CBR agen ts { uses TrafficGenerator class for pac k et sizes/times NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 36
slide-37
SLIDE 37 R TP and R TCP Agen ts
  • R
TP
  • \Real-time"
(transp
  • rt)
proto col (RF C 1889) { implemen ted as Agent/CBR/RTP
  • b
ject { sp ecial \R TP" header (con tains seq n um b er and srcID) { sends data p erio dically similar to CBR sources { resets faster when mo ving from high to lo w rate
  • R
TCP
  • con
trol proto col for R TP { implemen ted as Session/RTP
  • b
ject { sends at rate based
  • n
n um b er
  • f
  • ther
senders { rep
  • rts
kno wn sources and stats NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 37
slide-38
SLIDE 38 Other Simple Agen ts
  • the
LossMonitor agen t: { monitors arriv als
  • f
pac k ets { lo
  • ks
for sequence n um b er holes { pro vides coun ters for:
  • nlost
  • n
um b er
  • f
holes in n um b er space
  • npkts
  • pac
k et arriv als
  • bytes
  • b
yte arriv als
  • lastPktTime
  • time
  • f
last arriv al
  • expected
  • next
seq n um b er exp ected
  • the
Message agen t: { v ery simple agen t { allo ws for including text \messages" in pac k ets { curren tly limited to at most 64 b yte (short) messages NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 38
slide-39
SLIDE 39 T ap Agen ts and the \Real W
  • rld"
  • allo
ws the sim ulator to in teract with a real net w
  • rk
(curren tly exp erimen tal)
  • T
ap Agen ts: { for no w uses 1600 b yte buer as \header" (ie. ether frame + slop) { bi-directional agen t b et w een sim ulation and net w
  • rk
{ uses abstract \net w
  • rk"
  • b
ject { receiv es
  • ne
pac k et p er ev en t (handled through Tcl I/O)
  • the
Scheduler/RealTime class { sp ecial v ersion
  • f
(curren tly List-based) sc heduler { ties sim ulated time to real-time { for no w, pun ts if sim ulation gets far b ehind { (can still do in teresting things!) NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 39
slide-40
SLIDE 40 Net w
  • rk
Ob ject
  • abstraction
  • f
a (real-w
  • rld)
net w
  • rk
  • base
class for sp ecic net w
  • rk
t yp es (e.g. IP net w
  • rk)
  • used
b y
  • ther
to
  • ls
in Katz/McCanne/Brew er's MASH pro ject (see http://www-mash.cs.berkeley.edu/mash/ index. html)
  • Net
w
  • rk
class: { requires so c k et system API (UNIX
  • r
WinSo c k) { supp
  • rts
a basic send/recv in terface { separate send/recv \c hannels" (i.e. so c k ets) { non-blo c king
  • ptional
{ framew
  • rk
supp
  • rts
m ulticast, addr/iface selection, etc
  • IP
Net w
  • rk
(Network/IP class) { m ulticast group mem b ership { lo
  • pbac
k
  • n/o
con trol { implemen ts m ulticast and unicast con trols for IP net w
  • rks
NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 40
slide-41
SLIDE 41 T rac Generator
  • generate
trac according to distributions
  • r
traces
  • generally
used for CBR/UDP agen ts
  • Exp
  • nen
tial { exp
  • nen
tially distributed
  • n/o
times { parameters:
  • n
time,
  • time,
rate, pac k et size { what these mean:
  • burst
for exp
  • time
with mean
  • n
time
  • b
e silen t for exp
  • time
with mean
  • time
  • while
bursting, send at rate rate
  • use
appropriate in ter-departure time giv en rate/size
  • P
areto { pareto distributed
  • n/o
times { (man y aggregated together can b e LRD) { parameters:
  • n
time,
  • time,
rate, shap e, pac k et size { what these mean:
  • lik
e exp
  • ,
except pareto using shap e parameter NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 41
slide-42
SLIDE 42 T race-Based T rac Generator
  • generate
trac according to trace le
  • t
w
  • classes:
Tracefile and Traffic/Trace
  • trace
le uses small binary format: { rst 32-bit eld: in ter-pac k et time (microsecs) { second 32-bit eld: pac k et size (b ytes) NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 42
slide-43
SLIDE 43 Queue Managemen t and P ac k et Sc heduling
  • buer
management: ho w to hold and toss (mark) pac k ets
  • p
acket sche duling: what pac k ets get to depart when
  • Buer
managemen t: { Drop-tail (FIF O) { Random Early Detection (RED)
  • P
ac k et sc heduling: { FIF O { CBQ (includes priorit y + round-robin) { Round-robin (DRR) { V arian ts
  • f
F Q (WF Q, SF Q) NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 43
slide-44
SLIDE 44 Queue Handlers
  • Dequeued
pac k ets are
  • ften
sen t do wnstream to delays
  • dela
ys (usually) cause t w
  • actions:
1. the pac k et is sc heduled to arriv e do wnstream at time t + d 2. the queue b ecomes un blo c k ed at time t 3. t is transmit time, d is prop dela y time
  • so,
dela ys represen t a commonly-o ccurring sche duling b arrier
  • Queue
parameters: Queue set limit_ 50 ;# max p acket c
  • unt
in queue Queue set blocked_ false ;# queue starts
  • blo
cke d Queue set unblock_on_res um e_ true ;# queue is unblo cke d af- ter r esume
  • con
trol
  • f
blo c king can b e useful for queue banks (e.g. CBQ) NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 44
slide-45
SLIDE 45 Drop T ail and RED Queues
  • Drop-T
ail Queues (Queue/DropTail class) { simple FIF O, drop-tail queues { drop from tail when
  • ccupancy
reac hes qlim
  • RED
(Random Early Detection) Queues (Queue/RED class) { active buer managemen t tec hnique { t w
  • thresholds:
minth and maxth { also a maxim um probabilit y maxpr
  • b
{ compute aver age queue
  • ccupancy
  • v
er time { if a v erage exceeds maxth (or qlim ) drop a pac k et { if a v erage is under min th, allo w pac k et to en ter queue { b et w een, scale drop probabilit y linearly
  • n
[0; maxpr
  • b]
NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 45
slide-46
SLIDE 46 RED Queue P arameters
  • bytes
do computations in b ytes instead
  • f
pac k ets (requires assignmen t
  • f
a mean pac k et size estimate)
  • thresh
  • min
thresh
  • maxthresh
  • max
thresh
  • mean
pktsize
  • used
for computing estimated link utilizations during idle p erio ds
  • q
weight
  • w
eigh t giv en to instan taneous queue
  • ccupancy
for EWMA
  • wait
  • RED
should force a w ait b et w een drops
  • linterm
  • recipro
cal
  • f
maxprob
  • setbit
  • mark
instead
  • f
drop
  • drop-tail
  • drop
new pkt instead
  • f
random
  • ne
NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 46
slide-47
SLIDE 47 T race and Monitoring Supp
  • rt
  • Tw
  • main
items: tr ac es and monitors
  • T
races
  • write
an en try for some ev en t (often pac k et arriv als/departures/drops) { Trace/Enque
  • a
pac k et arriv al (usually at a queue) { Trace/Deque
  • a
pac k et departure (usually at a queue) { Trace/Drop
  • pac
k et drop (pac k et deliv ered to drop-target)
  • Monitors
  • k
eep statistics ab
  • ut
arriv als/departures/drops (and
  • ws)
{ SnoopQueue/Out
  • n
  • utput,
collect a time/size sample (pass pac k et
  • n)
{ SnoopQueue/Drop
  • n
drop, collect a time/size sample (pass pac k et
  • n)
{ SnoopQueue/EDrop
  • n
an "early" drop, collect a time/size sampl e (pass pac k et
  • n)
{ QueueMonitor
  • receiv
e and aggregate collected samples from sno
  • p
ers { QueueMonitor/ED
  • queue-monitor
capable
  • f
distinguish- ing b et w een \early" and standard pac k et drops { QueueMonitor/ED/Flowmon
  • p
er-o w statistics monitor (manager) { QueueMonitor/ED/Flow
  • p
er-o w statistics con tainer NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 47
slide-48
SLIDE 48 T race File F
  • rmat
  • File
format for traces generally
  • f
this form: + 1.45176 2 3 tcp 1000
  • 1
256 769 27 48 + 1.45276 2 3 tcp 1000
  • 1
256 769 28 49
  • 1.46176
2 3 tcp 1000
  • 1
256 769 22 43 + 1.46176 2 3 tcp 1000
  • 1
256 769 29 50 + 1.46276 2 3 tcp 1000
  • 1
256 769 30 51 d 1.46276 2 3 tcp 1000
  • 1
256 769 30 51
  • 1.47176
2 3 tcp 1000
  • 1
256 769 23 44 + 1.47176 2 3 tcp 1000
  • 768
3 52 + 1.47276 2 3 tcp 1000
  • 768
4 53 d 1.47276 2 3 tcp 1000
  • 768
4 53
  • Fields:
arriv al/departure/drop, time, trace link endp
  • in
ts, pac k et t yp e, size, ags,
  • w
ID, src addr, dst addr, sequence n um b er, uid
  • Man
y
  • f
these elds are from the common pac k et header: struct hdr_cmn { double ts_; // timestamp: for q-delay measurement int ptype_; // packet type (see above) int uid_; // unique id int size_; // simulated packet size int iface_; // receiving interface (label) static int
  • ffset_;
//
  • ffset
for this header int&
  • ffset()
{ return
  • ffset_;
} /* per-field member functions */ int& ptype() { return (ptype_); } int& uid() { return (uid_); } int& size() { return (size_); } int& iface() { return (iface_); } double& timestamp() { return (ts_); } }; NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 48
slide-49
SLIDE 49 T race Callbac ks
  • ma
y
  • pt
to in v
  • k
e a Tcl function in lieu
  • f
writing to le
  • see
the le tcl/ex/callback demo.tcl MyTest instproc begin {} { ... $link12_ trace-callback $ns_ "$self dofunc" ... } MyTest instproc dofunc args { ... process args ... }
  • Args
passed to the callbac k are a string con taining a trace
  • utput
line (e.g.):
  • 0.80612
1 tcp 1000
  • 0.0
1.0 9 13 NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 49
slide-50
SLIDE 50 Monitors
  • Queue
monitors: aggregation p
  • in
ts for arriv al/depart/drop stats
  • Flo
w monitors: similar, but
  • n
a p er-o w basis
  • Sno
  • p
queues: part
  • f
the top
  • logy
, \taps" pac k et
  • w,
deliv ers samples to asso ciated monitor

Queue Delay Agent/Null Link Link::entry SnoopQueue/In SnoopQueue/Out SnoopQueue/Drop QueueMonitor

Figure 2: A QueueMonitor and supp
  • rting
  • b
jects NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 50
slide-51
SLIDE 51 Monitor Stats
  • Simple
stats k ept b y monitors: { arriv als (b ytes and pac k ets) { departures (b ytes and pac k ets) { drops (b ytes and pac k ets)
  • Aggregate
stats (optional): { queue
  • ccupancy
in tegral { (b ytes
  • r
pac k ets)
  • QueueMonitor/ED
  • b
jects { \early" drops (b ytes and pac k ets) { some drops ha v e this distinction (e.g. RED)
  • Flo
w monitors: { t yp es QueueMonitor/ED/Flow and QueueMonitor/ED/Flowmon { same as queue monitors, but also
  • n
p er-o w basis {
  • w
dened as com b
  • s
  • f
(src/dst/o wid) {
  • w
mon aggregates and creates new
  • w
  • b
jects NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 51
slide-52
SLIDE 52 Mathematical Supp
  • rt
  • Random
n um b er generation { RNG implemen ted in sim ulator (should pro duce same results
  • n
v arious platforms) { based
  • n
S. P ark and K Miller, CA CM 31:10, Oct. 1988 { supp
  • rt
for m ultiple streams { dieren t seeding
  • ptions
  • Random
v ariables { distributions applied to RNG streams { distributions: uniform, exp
  • nen
tial, pareto, constan t, h yp er- exp
  • nen
tial
  • In
tegrals { appro ximation
  • f
in tegral b y discrete sums { used for a v erage queue size computations
  • Samples
{ collect samples { pro vides mean, v ariance, sum, and coun t NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 52
slide-53
SLIDE 53 Break. . . NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 53
slide-54
SLIDE 54 Hash classier
  • Map
pac k ets to asso ciated
  • ws
  • r
classes
  • Curren
tly: src/dst, src/dst/d, d plus default

Hash Classifier

htab_ slot_ Hash Function Packet hnodes

Hash Functions: Source/Dest, Source/Dest/FID, FID Hnodes: active, slot, src, dst, fid

default

NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 54
slide-55
SLIDE 55 CBQ: Class Based Queueing
  • Flo
yd and Jacobson, "Link-sharing and Resource Managemen t Mo dels for P ac k e t Net w
  • rks",
T
  • N,
Aug 1995
  • rewrite
from CBQ co de in ns-1
  • pac
k ets are mem b ers
  • f
classes
  • classes
ma y con tain a priority and a b andwidth al lo c ation
  • classes
ma y b
  • rr
  • w
un used bandwidth from
  • ther
classes
  • pac
k ets are sc heduled using a round-robin sc heduler according to the classes they b elong to: { pac k et-b y-pac k et RR { w eigh ted RR { high-to-lo w priorit y NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 55
slide-56
SLIDE 56 CBQ Implemen tation

Queue (arbitrary) Queue (arbitrary) SD SD Connector CBQClass CBQClass Classifier (e.g. hash) SI SI SO SO CBQ (scheduler) QMon QMon

CBQLink

head_ drophead_ classifier_ queue_

  • Ma
jor comp
  • nen
ts: { classier (maps pac k ets to classes) { classes (holds class state) { sc heduler (sc hedules pac k et departures)
  • Implemen
ted as a sub class
  • f
link: CBQ link NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 56
slide-57
SLIDE 57 Router Mec hanisms
  • Flo
yd and F all, "Router Mec hanisms to Supp
  • rt
End-to-End Congestion Con trol", LBNL TR, F eb 1997
  • p
  • rt
from ns-1 v ersion based
  • n
new Flo wMon and CBQ

Connector RED Queue RED Queue SD CBQClass CBQClass Classifier SI SI SO SO CBQ (scheduler) FlowMon head_ drophead_ classifier_ queue_

CBQLink with Router Mechanisms

FlowMon w/default SD ESD ESD

  • kboxfm_

pboxfm_

NSv2 W
  • rkshop
kfal l@e e.lbl.gov Slide 57