60
The Network Simulator NS2 [email protected] h8p://www.ce.uniroma2.it/courses/MMI/ h8p://www.uniroma2.it/dida?ca/MMI Emiliano Casalicchio ‐ [email protected]

The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

TheNetworkSimulatorNS2

[email protected]

h8p://www.ce.uniroma2.it/courses/MMI/

h8p://www.uniroma2.it/dida?ca/MMI

EmilianoCasalicchio‐[email protected]

Page 2: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Agenda

•  Conce?fondamentali•  EvenFeScheduler•  Archite8ura•  Esempio

•  NodieRouFng•  Workloadelivellodiapplicazione

•  Generaziondedelletopologiedirete

EmilianoCasalicchio‐[email protected]

Page 3: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Documentazione

•  Questalezioneèbasatasulmaterialeseguente•  h8p://www.isi.edu/nsnam/ns/

–  MarcGreis'stutorial–  "NSforBeginners"byAltmanandJimenez–  NsManual–  “NSbyExample”byJ.ChungandM.Claypoolh8p://nile.wpi.edu/NS/–  Variepresentazionietutorial“nsworkshopsandpresentaFons”

•  Tcl/tk,h8p://www.tcl.tk/•  Otcl,h8p://bmrc.berkeley.edu/research/cmt/cmtdoc/otcl/index.html•  Altrichetroveretenelseguito…

EmilianoCasalicchio‐[email protected]

Page 4: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Installazioneh8p://www.isi.edu/nsnam/ns/ns‐build.html

All‐in‐one(Consigliata–Linux/Windows/Mac):UlFmaversione(Jun17,2009)h"p://sourceforge.net/projects/nsnam/files/allinone/ns‐allinone‐2.34/

–  Tclrelease8.4.18(requiredcomponent)–  Tkrelease8.4.18(requiredcomponent)–  Otclrelease1.13(requiredcomponent)–  TclCLrelease1.19(requiredcomponent)–  Nsrelease2.33(requiredcomponent)–  Namrelease1.13(opFonalcomponent)–  Xgraphversion12(opFonalcomponent)–  CWebversion3.4g(opFonalcomponent)–  SGBversion1.0(?)(opFonalcomponent,buildssgblibforallUNIXtype

plaiorms)–  Gt‐itmgt‐itmandsgb2ns1.1(opFonalcomponent)–  Zlibversion1.2.3(opFonal,butrequiredshouldNambeused)

Oppure…InstallazioneeconfigurazioneseparatadeisingolicomponenA

EmilianoCasalicchio‐[email protected]

Page 5: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Cos’èNS2•  Discrete‐eventsimulator

–  Sviluppatoall’UCBerkeley•  SimulazionealivellodipaccheEo•  ModellazionedallivelloDataLinkalivelloApplicazione

–  protocollilivelloMAC(persimulazioniLAN)–  AlgoritmidirouFng:Dijkstra,etc…–  MeccanismidigesFonedellecodedeirouter:DropTail,RandomEarly

DetecFon/Drop(RED)e(Class‐BasedQueueing)CBQ–  Protocollidirete:TCP,UPD(overIPeIPv6)–  SorgenFditraffico:FTP,Telnet,Web,CBReVBR,

•  Opensource(vastacomunitàdisviluppatoriedutenF)•  Basatosu

–  C++persimulaFonengineemodelli–  Tcl/OTcl(ObjectToolCommandLanguage)perconfigurazionescenarie

logicadisimulazione

EmilianoCasalicchio‐[email protected]

Page 6: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Vistautente:conce?fondamentali

•  Otclpersetupedesecuzionesimulazione–  inizializzazioneeventscheduler,–  SetuptopologiauFlizzando“networkobject”e“plumbingfuncFon”–  Specificareinizioefinegenerazionetraffico(evenF)

•  Evento=(packetID,ScheduleTime,ObjPointer)–  L’ObjèunnetworkobjectchegesFràilpacche8o

•  L’EventScheduler–  ManFeneiltemposimulato–  Estrae(fire)tu?glievenF(pacche?)cheoccorronoaltempotinvocandoirelaFvi

componenFdirete(networkobject/component)–  Loschedulerèsinglethread(noproblemilocking/compeFzionerisorse)

•  IcomponenFdiretecomunicanoscambiandosipacche?EmilianoCasalicchio‐[email protected]

Page 7: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Agenda

•  Introduzione•  EvenFeScheduler•  Archite8ura•  Esempio

•  RouFng•  Workloadelivellodiapplicazione

•  Generaziondedelletopologiedirete

EmilianoCasalicchio‐[email protected]

Page 8: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Stru8uradaFEvent•  ungenericoeventocomprendegeneralmenteunfiringFmeeunafunzione

manipolatrice(de8a“handler”)•  LaclassedenominataHandlerconFenesemplicementeunafunzionevirtuale,che

quindidovràesserespecializzatatramiteleclassidaessaderivate

EmilianoCasalicchio‐[email protected]

Page 9: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

EventScheduler

EmilianoCasalicchio‐[email protected]

A seconda di come gestisco la coda ho diverse prestazioni, e.g 1)  massimizzare il numero di eventi che riesco a processare nell’unità di

tempo (reale), e quindi aumentare la velocità della simulazione 2)  massimizzare la quantità di eventi che riesco a gestire,

indipendentemente dalla loro velocità di processamento (dimensione della coda!!), per aumentare la dimensione dei sistemi che riesco a simulare

3)  1) e 2) strettamente correlati

Page 10: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

SchedulerinNS‐2

•  Listscheduler

•  Heapscheduler

•  Calendarscheduler(default)

•  Real‐Fmescheduler

•  “All made the same task with different performances”

EmilianoCasalicchio‐[email protected]

Es: set ns [new Simulator] $ns use-scheduler Heap

Page 11: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

ListScheduler

•  Thelistscheduler(Scheduler/List../ns‐2/scheduler.cc)implementstheschedulerusingasimplelinked‐liststructure

•  ThelistiskeptinAme‐order(earliesttolatest),–  soeventinserFonanddeleFonrequirescanningthelisttofindtheappropriate

entry

•  ChoosingthenexteventforexecuFonrequirestrimmingthefirstentryofftheheadofthelist–  ThisimplementaFonpreserveseventexecuFoninaFIFOmannerforsimultaneous

events.

EmilianoCasalicchio‐[email protected]

Page 12: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

HeapScheduler

•  Theheapscheduler(Scheduler/Heap../ns‐2/scheduler.cc)implementstheschedulerusingaheapstructure.

•  Aheapisaspecializedtree‐baseddatastructurethatsaFsfiestheheapproperty:ifBisachildnodeofA,thenkey(A)≥key(B).

•  Thisstructureissuperiortotheliststructureforalargenumberofevents,asinserFonanddeleFonFmesareinO(logn)fornevents.

EmilianoCasalicchio‐[email protected]

Page 13: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Calendarscheduler•  Thecalendarqueuescheduler(Scheduler/Calendar../ns‐2/scheduler.cc)

usesadatastructureanalogoustoaone‐yeardeskcalendar,inwhicheventsonthesamemonth/dayofmulFpleyearscanberecordedinoneday.

•  TheoriginalimplementaFonofCalendarqueuesinnsv2wascontributedbyDavidWetherall.–  AnewimplementaFonfromXi(2005)h8p://netlab.caltech.edu/projects/

ns2tcplinux/ns2patch/

•  TheoriginalNS‐2.28usesaCalendarQueuetoimplementthepriorityqueue,whichstorethefutureeventsinthesimulaFon.

EmilianoCasalicchio‐[email protected]

Page 14: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

OriginalCalendarscheduler•  Thecalendarqueuestoresevents

intoanarrayofbuckets.–  Abucketcorrespondstoa"day"

inarealcalendar.

–  AbucketcanholdmulFpleevents,asyoucanwritedownmulFplenotesineachdayinarealcalendar.

–  Thewholebucketarraycorrespondstoa"year".Ifeventsinthesame"day"butindifferent"years"sharethesamebucket.

–  Whenaneweventisinserted,wecancalculatetherightbucketinO(1)andinserttheeventintothisbucketvialinearsearch.

–  Thesizeofthearraymaybedoubledifthenumberofeventsgrowslarger,orhalvedifthenumberofeventsgrowssmaller.EmilianoCasalicchio‐

[email protected]

R. Brown. 1988. Calendar queues: a fast 0(1) priority queue implementation for the simulation event set problem. Commun. ACM 31, 10 (October 1988), 1220-1227.

Page 15: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

OriginalCalendarscheduler•  Theefficiencyofthecalendarqueueseemstodependonthewidthof

eachbucket.–  Ifthewidthofabucketistoolong,manyeventsmaybeputintoonebucket

wherelinearsearchhappenswhenaneweventisinserted

–  Ifthewidthofabucketistoosmall,mostoftheeventsinthebucketsareofdifferentyearsandthereisalargeoverheadfordequeue(linearsearchoverthecalendardays).

EmilianoCasalicchio‐[email protected]

Page 16: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

OriginalCalendarscheduler•  TheopFmalsoluFonforbucketwidth,istheaverageintervalbetweenadjacentevents.

•  Tocalculatetheaverageintervalbetweenadjacentevents,onehastotraversethewholequeueandcalculatetheaverageintervals.

•  NS‐2calculatestheaverageintervalbetweenadjacentevents:

1)pickupthefullestbucket(withlargestnumberofevents),

2)calculatetheaverageintervalinthatbucket,assuggestedinDynamicCalendarQueue

3)setbucketsize=averageinterval*4.(4isprobablytheheurisFcnumberthatkeeptheinqueueanddequeuecomplexitybalanced)

•  Steps1‐3mayresultinawidthvaluemuchlargerthanthesuggestedopFmialvalue.

•  Ifinthefullestbuckettherearesomeeventsindifferent"years"andmostoftheeventsareclusteredwithin"seconds”

–  eachbucketwillhaveawidthinunitof"years"and

–  mostoftheevents(clusteredwithinseconds)willgointoafewbucketsof"years".

•  NS2doesnotadopttheDynamicCalendarQueue'sresizetriggeringalgorithm.

–  Oncethebucketwidthissettobeavalue,itwon'tchangeunlessthebucketnumberneedstobechanged(bysignificantchangeonnumberofeventsinthequeue)

EmilianoCasalicchio‐[email protected]

JongSuk Ahn, SeungHyun Oh. "Dynamic Calendar Queue,"

Page 17: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

SpeedingupNS‐2scheduler•  AnewimplementaFonfromXi(2005)

–  h8p://netlab.caltech.edu/projects/ns2tcplinux/ns2patch/

•  ThreechangestotheoriginalCalendarScheduler:

1)TheesFmaFonofthebucket_size:Thepatches1matesthebucket_sizebytheaverageintervalofdequeuedeventsinthepastwindow.Thisisclosertotherealdistribu1onunlesstheeventarrivalpaAernsignificantlychanges.

2)SNOOPyCalendarQueuedynamicadjustmentisimplementedtoreacttothechangeofeventarrivalpaAern.

3)Forthe"insert"funcFon,theoriginalcodetraversesfromtheheadtothetail.Thepatchtraversesfromthetailtothehead,whichmaytraverselessnodesifeventsareoReninsertedtotheendofthepriorityqueue.

EmilianoCasalicchio‐[email protected]

Kah Leong Tan, Li-Jin Thng, "SNOOPy Calendar Queue", Proceedings of the 32nd conference on Winter simulation, Orlando, Florida, Pages: 487 - 495, 2000,

Page 18: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Confrontodiprestazionitraschedulers

EmilianoCasalicchio‐[email protected]

Xi (2005) http://netlab.caltech.edu/projects/ns2tcplinux/ns2patch/

Page 19: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

RealTimescheduler

•  Thereal‐Fmescheduler(classScheduler/RealTime)a8emptstosynchronizetheexecuFonofeventswithreal‐Fme.–  Itiscurrentlyimplementedasasubclassofthelistscheduler.

•  Thereal‐FmecapabilityisusedtointroduceanNSsimulatednetworkintoareal‐worldtopologytoexperimentwitheasily‐configurednetworktopologies,cross‐traffic,etc.–  ThisonlyworksforrelaFvelyslownetworktrafficdatarates,asthe

simulatormustbeabletokeeppacewiththereal‐worldpacketarrivalrate,andthissynchronizaFonisnotpresentlyenforced.

EmilianoCasalicchio‐[email protected]

Page 20: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

TimePrecision•  Precisionoftheschedulerclockcanbedefinedasthesmallest

Ame‐scaleofthesimulatorthatcanbecorrectlyrepresented.

•  Theclockvariablefornsisrepresentedbyadouble.–  AspertheIEEEstdforfloaFngnumbers,adouble,consisFngof64bits

mustallocatethefollowingbitsbetweenitssign,exponentandmanFssafields:sign=1bitexponent=11bitmanFssa=52bit

–  AnyfloaFngnumbercanberepresentedintheformX*2nwhereXisthemanFssaandnistheexponent.

•  ThustheprecisionofFmeclockinnscanbedefinedas–  1/(252)=2.2204e‐16sec.

EmilianoCasalicchio‐[email protected]

Page 21: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Agenda

•  Conce?fondamentali•  EvenFeScheduler•  Archite8ura•  Esempio

•  RouFng•  Workloadelivellodiapplicazione

•  Generaziondedelletopologiedirete

EmilianoCasalicchio‐[email protected]

Page 22: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Archite8ura•  C++usatoperprocessareIpache?:

– SchedulereNetworkcomponentsscri?inC++

– Veloce,de8agliato,controllocompleto

•  Otclusatoperilcontrollo,–  setupdellasimulazione,configurazione,azionioccasionali

– Rapidodascrivereemodificare

•  C++eOTclcondividonolastessagerarchiadiclassi.– Corrispodenza(OTcllinkage‐TclCL)traogge?C++eOtcl

C++obj–TclCL–Otclobj

– Solopergliogge?chemodellanonetworkcomponent

EmilianoCasalicchio‐[email protected]

Tcl

OTcl

TclCL

ns‐2

EventScheduler

NetworkComponents

C/C++

Page 23: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Archite8ura:Overview

•  Thesimulatorsupports–  AclasshierarchyinC++,and

–  AsimilarclasshierarchywithintheOtclinterpreter

•  Thetwohierarchiesarecloselyrelatedtoeachother;fromtheuser’sperspecFve,thereisaone‐to‐onecorrespondence

–   TherootofthishierarchyistheclassTclObject•  Userscreatenewsimulatorobjectsthroughtheinterpreter

–  TheseobjectsareinstanFatedwithintheinterpreter,andarecloselymirroredbyacorrespondingobjectinthecompiledhierarchy.TheinterpretedclasshierarchyisautomaFcallyestablishedthroughmethodsdefinedintheclassTclClass.

–  UserinstanFatedobjectsaremirroredthroughmethodsdefinedintheclassTclObject.

–  ThereareotherhierarchiesintheC++codeandOTclscripts;theseotherhierarchiesarenotmirroredinthemannerofTclObject.

EmilianoCasalicchio‐[email protected]

Page 24: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Classiprincipali•  TclObjectisthebaseclassformostoftheotherclassesintheinterpreted

andcompiledhierarchies.•  EveryobjectintheclassTclObjectiscreatedbytheuserfromwithintheinterpreter.

• Anequivalentshadowobjectiscreatedinthecompiledhierarchy.Thetwoobjectsarecloselyassociatedwitheachother.

•  TheclassTclClasscontainsthemechanismsthatperformthisshadowing.

–  TclClassisapurevirtualclass.•  ClassesderivedfromthisbaseclassprovidetwofuncFons:constructtheinterpretedclasshierarchytomirrorthecompiledclasshierarchy;and

•  providemethodstoinstanFatenewTclObjects.

•  EachsuchderivedclassisassociatedwithaparFcularcompiledclassinthecompiledclasshierarchy,andcaninstanFatenewobjectsintheassociatedclass.

EmilianoCasalicchio‐[email protected]

Page 25: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Agenda

•  Introduzione•  EvenFeScheduler•  Archite8ura•  Esempio

•  NodieRouFng•  Workloadelivellodiapplicazione

•  Generaziondedelletopologiedirete

EmilianoCasalicchio‐[email protected]

Page 26: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

NodeandRouFng

Unicast‐  $nsrtprototype

(type:StaFc,Session,DistanceVector,cost,mulF‐path)MulFcast‐  $nsmulFcast(righta}erset$ns[newScheduler])‐  $nsmrtprototype

(type:CtrMcast,DM,ST,BST)EmilianoCasalicchio‐[email protected]

Page 27: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Link

EmilianoCasalicchio‐[email protected]

Page 28: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Tracing

•  $nstrace‐allfileor•  $nsnamtrace‐allfile

•  $nscreate‐trace{typefilesrcdst}EmilianoCasalicchio‐

[email protected]

Page 29: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

QueueMonitor

EmilianoCasalicchio‐[email protected]

Page 30: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

PacketFlow

EmilianoCasalicchio‐[email protected]

1

2

34

5

6

7

89

10

11

Page 31: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Agenda

•  Conce?fondamentali•  EvenFeScheduler•  Archite8ura•  Esempio

•  RouFng•  Workloadelivellodiapplicazione

•  Generaziondedelletopologiedirete

EmilianoCasalicchio‐[email protected]

Page 32: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Basictclproc test { a b } { set c [expr $a + $b] set d [expr [expr $a - $b] * $c] for {set k 0} {$k < 10} {incr k} {

if {$k < 5} { puts “k < 5, pow = [expr pow($d, $k)]” } else { puts “k >= 5, mod = [expr $d % $k]” } } }

test 43 27

%oppure

set aa 43 set bb 27 Test $aa $bb

Output

EmilianoCasalicchio‐[email protected]

Page 33: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

HelloWorld‐InteracFveMode

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%

EmilianoCasalicchio‐[email protected]

Page 34: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

HelloWorld‐BatchMode

simple.tcl set ns [new Simulator] $ns at 1 “puts \“Hello World!\”” $ns at 1.5 “exit” $ns run

swallow 74% ns simple.tcl Hello World!

swallow 75%

EmilianoCasalicchio‐[email protected]

Page 35: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Esempio(ex‐simple.tcl)

EmilianoCasalicchio‐[email protected]

Page 36: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

InstancesimulaFonobject•  setns[newSimulator]:generatesanNSsimulatorobject

instance,andassignsittovariablens.ToinstaFateaSimulatorobjectmeans:–  IniFalizethepacketformat

–  Createascheduler(defaultiscalendarscheduler)–  Selectthedefaultaddressformat

•  The"Simulator"objecthasmemberfuncFonsto:–  Createcompoundobjectssuchasnodesandlinks

–  Connectnetworkcomponentobjectscreated

–  Setnetworkcomponentparameters(mostlyforcompoundobjects)

–  CreateconnecFonsbetweenagents–  SpecifyNAMdisplayopFons

•  The"Simulator"objectmemberfuncFonimplementaFonsarelocatedinthe"ns‐2/tcl/lib/ns‐lib.tcl"file.

EmilianoCasalicchio‐[email protected]

Page 37: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

NAMsetup

•  $nscolorfidcolor:–  istosetcolorofthepacketsforaflowspecifiedbytheflowid(fid).–  isfortheNAMdisplay,andhasnoeffectontheactualsimulaFon.

•  $nsnamtrace‐allfile‐descriptor:–  tellsthesimulatortorecordsimulaFontracesinNAMinputformat.

–  givesthefilenamethatthetracewillbewri8entolaterbythecommand$nsflush‐trace.

–  Similarly,thememberfuncFontrace‐allisforrecordingthesimulaFontraceinageneralformat.

EmilianoCasalicchio‐[email protected]

Page 38: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Networkobjectsetup

•  procfinish{}:–  funcFonthatspecifypost‐simulaFonprocesses–  iscalleda}erthesimulaFonisoverbythecommand$nsat5.0"finish”

•  setn0[$nsnode]:–  createsanode.AnodeinNSiscompoundobjectmadeofaddressandportclassifiers

–  UserscancreateanodebyseparatelycreaFnganaddressandaportclassifierobjectsandconnecFngthemtogether.

–  Toseehowanodeiscreated,lookatthefiles:"ns‐2/tcl/libs/ns‐lib.tcl"and"ns‐2/tcl/libs/ns‐node.tcl".

EmilianoCasalicchio‐[email protected]

Page 39: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

•  $nsduplex‐linknode1node2bandwidthdelayqueue‐type:–  createstwosimplexlinksofspecifiedbandwidthanddelay,andconnectsthetwospecifiednodes.

–  InNS,theoutputqueueofanodeisimplementedasapartofalink,thereforeusersshouldspecifythequeue‐typewhencreaFnglinks.

–  IntheabovesimulaFonscript,DropTailqueueisused.–  Linksourcecodescanbefoundin"ns‐2/tcl/libs/ns‐lib.tcl"and"ns‐2/tcl/libs/ns‐link.tcl"files.

–  theusercaninserterrormodulesinalinkcomponenttosimulatealossylink EmilianoCasalicchio‐

[email protected]

Page 40: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

•  $nsqueue‐limitnode1node2number:–  setsthequeuelimitofthetwosimplexlinksthatconnectnode1andnode2tothenumberspecified.

–  takealookat"ns‐2/tcl/libs/ns‐lib.tcl"and"ns‐2/tcl/libs/ns‐link.tcl",orNSdocumentaFonformoreinformaFon.

•  $nsduplex‐link‐opnode1node2...:–  EffecttheNAManimaFonshowingflowsofpackets–  Toseetheeffectsoftheselines,userscancommenttheselinesoutandtrythesimulaFon.

EmilianoCasalicchio‐[email protected]

Page 41: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

SetupTrafficAgents•  settcp[newAgent/TCP]:

–  createsaTCPagent.Butingeneral,userscancreateanyagentortrafficsourcesinthisway.

–  Agentsandtrafficsourcesareinfactbasicobjects(notcompoundobjects),mostlyimplementedinC++andlinkedtoOTcl.Therefore,therearenospecificSimulatorobjectmemberfuncFonsthatcreatetheseobjectinstances.

–  Tocreateagentsortrafficsources,ausershouldknowtheclassnamestheseobjects(Agent/TCP,Agnet/TCPSink,ApplicaFon/FTPandsoon).

–  ThisinformaFoncanbefoundintheNSdocumentaFonorpartlyinthisdocumentaFon.Butoneshortcutistolookatthe"ns‐2/tcl/libs/ns‐default.tcl"file.Thisfilecontainsthedefaultconfigurableparametervaluese?ngsforavailablenetworkobjects. EmilianoCasalicchio‐

[email protected]

Page 42: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

•  $nsaEach‐agentnodeagent:–  a8achesanagentobjectcreatedtoanodeobject.Actually,whatthisfuncFondoesiscallthea8achmemberfuncFonofspecifiednode,whicha8achesthegivenagenttoitself.Therefore,ausercandothesamethingby,forexample,$n0a8ach$tcp.Similarly,eachagentobjecthasamemberfuncFona8ach‐agentthata8achesatrafficsourceobjecttoitself.

•  $nsconnectagent1agent2:–  toestablishalogicalnetworkconnecFonbetweentwoagents.ThislineestablishesanetworkconnecFonbyse?ngthedesFnaFonaddresstoeachothers'networkandportaddresspair.EmilianoCasalicchio‐

[email protected]

Page 43: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Scenariosetup

•  $nsat1me"string":–  makesthescheduler(scheduler_isthevariablethatpointstheschedulerobjectcreatedby[newScheduler]commandatthebeginningofthescript)toscheduletheexecuFonofthespecifiedstringatgivensimulaFonFme.

–  Forexample,$nsat0.1"$cbrstart"willmaketheschedulercallastartmemberfuncFonoftheCBRtrafficsourceobject,whichstartstheCBRtotransmitdata.

–  InNS,usuallyatrafficsourcedoesnottransmitactualdata,butitnoAfiestheunderlyingagentthatithassomeamountofdatatotransmit,andtheagent,justknowinghowmuchofthedatatotransfer,createspacketsandsendsthem.

EmilianoCasalicchio‐[email protected]

Page 44: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Agenda

•  Introduzione•  EvenFeScheduler•  Archite8ura•  Esempio

•  NodieRouFng•  GenerazionedelWorkload

•  Generaziondedelletopologiedirete

EmilianoCasalicchio‐[email protected]

Page 45: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

ApplicaFon•  App.toAgent:systemcall

–  send–  sendmsg–  close–  listen

•  AgenttoApp.:upcall–  recv–  resume

•  innsthereisnoactualdatabeingpassedbetweenapplicaAons

EmilianoCasalicchio‐[email protected]

Page 46: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

TypeofapplicaFon

•  H8pApp•  ApplicaFon/

– TcpApp– FTP– Telnet

•  ApplicaFon/Traffic/*– ExponenFalOn/Off– ParetoOn/Off– CBR– Traffictrace EmilianoCasalicchio‐

[email protected]

Page 47: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

ExponenFalOn/Off•  AnExponenFalOn/OffobjectisembodiedintheOTclclassApplicaFon/

Traffic/ExponenFal.

•  Themembervariablesthatparameterizethisobjectare:–  packetSize_theconstantsizeofthepacketsgenerated–  burst_Fme_theaverage“on”Fmeforthegenerator

–  idle_Fme_theaverage“off”Fmeforthegenerator

–  rate_thesendingrateduring“on”Fmes

•  AnewExponenFalOn/Offtrafficgeneratorcanbecreatedandparameterizedasfollows:

EmilianoCasalicchio‐[email protected]

Page 48: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

ParetoOn/Off•  AParetoOn/OffobjectisembodiedintheOTclclass

ApplicaFon/Traffic/Pareto.

•  Themembervariablesthatparameterizethisobjectare:–  packetSize_theconstantsizeofthepacketsgenerated–  burst_Fme_theaverage"on"Fmeforthegenerator

–  idle_Fme_theaverage"off"Fmeforthegenerator

–  rate_thesendingrateduring"on"Fmes–  shape_the"shape"parameterusedbytheparetodistribuFon

•  AnewParetoOn/Offtrafficgeneratorcanbecreatedasfollows:

EmilianoCasalicchio‐[email protected]

Page 49: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

CBR•  ACBRobjectisembodiedintheOTclclassApplicaFon/Traffic/

CBR.

•  Themembervariablesthatparameterizethisobjectare:–  rate_thesendingrate–  interval_(OpFonal)intervalbetweenpackets–  packetSize_theconstantsizeofthepacketsgenerated–  random_flagindicaFngwhetherornottointroducerandom“noise”

inthescheduleddepartureFmes(defaultisoff)

–  maxpkts_themaximumnumberofpacketstosend

EmilianoCasalicchio‐[email protected]

Page 50: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

TrafficTrace•  ATrafficTraceobjectisinstanFatedbytheOTclclassApplicaFon/Traffic/Trace.

–  TheassociatedclassTracefileisusedtoenablemulFpleTraffic/Traceobjectstobeassociatedwithasingletracefile.

–  TheTraffic/Traceclassusesthemethoda8ach‐tracefiletoassociateaTraffic/TraceobjectwithaparFcularTracefileobject.

–  ThemethodfilenameoftheTracefileclassassociatesatracefilewiththeTracefileobject.

•  ThefollowingexampleshowshowtocreatetwoAp‐plicaFon/Traffic/Traceobjects,eachassociatedwiththesametracefile(called"example‐trace"inthisexample).

•  ToavoidsynchronizaFonofthetrafficgenerated,randomstarFngplaceswithinthetracefilearechosenforeachTraffic/Traceobject.

EmilianoCasalicchio‐[email protected]

Page 51: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

EmilianoCasalicchio‐[email protected]

Webtraffic(Webcachemodel)

•  Therearethreemajorclassesrelatedtowebcache,asitisintherealworld:–  client(browser),–  server,and–  cache

Page 52: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

WebPageandPagePool•  WebPage

–  name,size,modificaFonFme,age

•  PagePool–  Math

•  onepage,whosesizecanbegeneratedbyagivenrandomvariable.

•  PagemodificaAonsequenceandrequestsequencearegeneratedusingtwogivenrandomvariables.

–  CompMath•  introducesacompoundpagemodel.

•  acompoundpage=mainpage+severalcomponentobjects.

•  Allcomponentobjectshavethesamesize;

–  ProxyTrace•  [<serverID><URL_ID><PageSize><AccessCount>]

–  WebTraffic(togeneratetrafficonlyandnotheaderinfo)

EmilianoCasalicchio‐[email protected]

Page 53: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Esempio

•  simple‐webcache.tcl

EmilianoCasalicchio‐[email protected]

Page 54: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Internettopologies•  ToeffecFvelyengineertheInternet,crucialissuessuchasthelargescale

structureofitsunderlyingphysicaltopology,–  itsFmeevoluFonandthecontribuFonofitsindividualcomponentstoitsoverallfuncFonneed

tobewellunderstood.•  DuringthedesignphaseofanInternet‐basedtechnology,extensive

simulaFonsareusuallyperformedtoassessitsfeasibility,intermsofefficiencyandperformance.

•  Ingeneral,InternetstudiesandsimulaAonsassumecertaintopologicalproperAesorusesyntheAcallygeneratedtopologies.

•  IfsuchstudiesaretogiveaccurateguidanceastoInternet‐widebehavioroftheprotocolsandalgorithmsbeingstudied,thechosentopologiesmustexhibitfundamentalproperAesorinvariantsempiricallyfoundintheactualextantstructureoftheInternet.Otherwise,correctconclusionscannotbedrawn.

EmilianoCasalicchio‐[email protected]

Page 55: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

BRITEtopologygenerator

•  BRITE:BostonuniversityRepresentaFveInternetTopologygEnerator

•  h8p://www.cs.bu.edu/brite/

•  Routertopologymodel

•  AStopologymodel

•  Hierarchical– Top‐downtopology model

– Bo8om‐uptopologymodelEmilianoCasalicchio‐

[email protected]

Page 56: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

RouterWaxman•  BasicallyreferstoageneraFonmodelforarandomtopologyusing

Waxman'sprobabilitymodelforinterconnecFngthenodesofthetopology,whichisgivenby:

P(u,v)=a*e‐d/(b*L)

where0<a,b<=1,

distheEuclideandistancefromnodeutonodev,andListhemaximumdistancebetweenanytwonodes.

EmilianoCasalicchio‐[email protected]

Page 57: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

RouteBarabasi‐Alberttopology•  RouterBarabasiAlbertmodelthatimplementsamodelproposedbyBarabási

andAlbert

•  Thismodelsuggeststwopossiblecausesfortheemergenceofapowerlawinthefrequencyofoutdegreesinnetworktopologies:incrementalgrowthandpreferenFalconnecFvity.–  IncrementalgrowthreferstogrowingnetworksthatareformedbytheconFnual

addiFonofnewnodes,andthusthegradualincreaseinthesizeofthenetwork.–  PreferenAalconnecAvityreferstothetendencyofanewnodetoconnectto

exisFngnodesthatarehighlyconnectedorpopular.

•  RouterBarabasiAlbertinterconnectsthenodesaccordingtotheincrementalgrowthapproach.Whenanodeijoinsthenetwork,theprobabilitythatitconnectstoanodejalreadybelongingtothenetworkisgivenby:

P(i,j)=di/S

wherediisthedegreeofthetargetnodeandSisthesumofoutdegreesofallnodesthatpreviouslyjoinedthenetwork.

EmilianoCasalicchio‐[email protected]

Page 58: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

AS‐leveltopology•  TheprovidedAS‐levelmodelsareverysimilartothemodels

providedforgeneraFngrouter‐leveltopologies.

•  Themaindifferencebetweentheserouter‐levelandAS‐levelmodelsisthefactthatASmodelsplaceASnodesintheplaneandthesehavethecapabilityofcontainingassociatedtopologies.

•  NotethatthisdoesnotmeanthattherearenoAS‐levelandrouter‐levelmodelsthatdiffersubstanFallyfromeachother.TheideaofseparaFngrouter‐levelfromAS‐levelfromthebeginningistoallowfortheflexibilityofdevelopingindependentmodelsforeachscenario.

•  ThetwoAS‐levelmodelsprovidedwiththeiniFaldistribuFonofBRITEareWaxmanandBarabasiAlbert

EmilianoCasalicchio‐[email protected]

Page 59: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

Top‐downtopology•  Top‐downmeansthatBRITEgeneratesfirstanAS‐leveltopology(1)according

tooneoftheavailableflatAS‐levelmodels(e.g.Waxman,ImportedFile,etc.).

•  Next,foreachnodeintheAS‐leveltopologyBRITEwillgeneratearouter‐leveltopology(2)usingadifferentgeneraFonmodelfromtheavailableflatmodelsthatcanbeusedattherouter‐level.

•  (3)BRITEusesanedgeconnecFonmechanismtointerconnectrouter‐leveltopologiesasdictatedbytheconnecFvityoftheAS‐leveltopology.

–  PerformingthisinterconnecFonofrouter‐leveltopologiesinarepresentaFvewayisanopenresearchquesFon.

EmilianoCasalicchio‐[email protected]

Page 60: The Network Simulator NS2 · 2013-03-17 · • NS2 does not adopt the Dynamic Calendar Queue's resize triggering algorithm. – Once the bucket width is set to be a value, it won't

EmilianoCasalicchio‐[email protected]