HAL Id: inria-00078318
https://hal.inria.fr/inria-00078318v2
Submitted on 7 Jun 2006
HAL is a multi-disciplinary open access
archive for the deposit and dissemination of
sci-entific research documents, whether they are
pub-lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.
L’archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d’enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.
Yet Another Network Simulator
Mathieu Lacage, Thomas Henderson
To cite this version:
Mathieu Lacage, Thomas Henderson. Yet Another Network Simulator. [Research Report] RR-5927,
INRIA. 2006, pp.16. �inria-00078318v2�
inria-00078318, version 2 - 7 Jun 2006
a p p o r t
d e r e c h e r c h e
9
-6
3
9
9
IS
R
N
IN
R
IA
/R
R
--5
9
2
7
--F
R
+
E
N
G
Thème COM
Yet Another Network Simulator
Mathieu Lacage — Tom Henderson
N° 5927
Mathieu La age , TomHenderson
ThèmeCOMSystèmes ommuni ants Projetplanete
Rapport dere her he n°5927Juin200616pages
Abstra t: We report onthedesign obje tivesand initialdesign ofanew dis rete-event network simulator for the resear h ommunity. Creating Yet Another Network Simulator (yans) is notthe sort of prospe t network resear hersarehappyto ontemplate, but this eortmaybetimelygiventhatns-2 is onsideringamajorrevisionandisevaluatingnew simulator ores. Wedes ribewhywedidnot hoosetobuildonexistingtoolssu hasns-2, GTNetS,andOPNET,outlineourfun tionalrequirements,provideahigh-levelviewofthe ar hite ture and ore omponents, and des ribea new IEEE802.11 model provided with yans.
Résumé: Nouspresentonslesobje tifs et la on eptioninitialed'unnouveausimulateur reseauevenementielatemps-dis ret destineala ommunautedere her heenreseaux. Le demarrage du projet ns-3 qui a ommen e a evaluer de nouveaux oeurs de simulations onstitue le moment ideal pour ontribuer a l'ar hite ture des outils que nous utiliserons demain: nous de rivons ainsi pourquoi nous n'avons pas hoisit de re-utiliser des outils existantstelsquens-2,GTNetSouOPNET,presentonsnosobje tifsfon tionelspuismettons eneviden eleur impa tsurl'ar hite tureet les omposants entraux deyans. Enn,nous de rivonsunnouveaumodelepourlesreseauxIEEE802.11quiest integredansyans.
1 Introdu tion
This paper reports on the designand goals of anew dis rete-eventnetwork simulator for Internet resear h. The title of the simulator (Yet Another Network Simulator, or yans) and of this paperexpli itly begs thequestion ofwhy, with anumber ofavailable existing networksimulatorsto hoosefrom,wewould undertaketo startover. Thispaperexplains therationaleforyans, omparisontoexisting tools,and urrentandfuture designplans.
Our work on yans is an outgrowth of the INRIA Planete' resear h group's work on implementing an IEEE 802.11a/eMAC model for the ns-2 simulator [1℄. The impa t of ns-2 onnetworking resear hhasbeen onsiderable. Briefsurveysof theliteratureturn up largenumbersofpapersinmostnetworkingjournalsand onferen esthat iteusageofns-2. Ithasarguablythelargestmodelsetforresear honInternetproto ols,andthesour e ode isli ensed(GNUGPLv2) appropriatelyforourproje t.
However,ourinitialworkonns-2 revealedsomelimitationsforouruse:
ouplingbetweenvariousmodelsisveryhigh: Manyunrelated omponents,orthogonal features,andmodelsdependonea hother,sometimesinnon-obviousways. Thisoften makesitimpossibleto ombine variousmodelstogether. Forexample,ifonewereto implement a new type of network node (a sub lass of the Node lass), it would be impossibletoreusethedefaultimplementationsoftheDSDVorDSRroutingproto ols be ausethesedependontheMobileNode lass.
obje t-oriented te hniques have been widely ignored: A lot of OT l ode, as well as someC++ ode,tests forthetypeof theobje tmanipulated before using it,rather thandelegatingtheworktoobje t-spe i methods. Forexample,thismakesitmu h hardertoaddnewtypesofwirelessroutingproto ols,requiringa arefulauditofthe odebasetosprinklethewireless odewithyetanothersetofif/then/elsestatements testingforthetypeof routingproto ol. Related tothis, theC++fa ilitiesfor type- asting of pointers has been largely ignored. The integration of OT l/C++ obje t bindingsmayhavedriventhedesignawayfrom ertainaspe tsoftheC++language. theuse ofC++standardlibraryhas been depre ated: Forhistori alreasons( ompiler support), the use of C++ STL and onstru ts therein su h as templates has been avoided by ns-2. However, ompiler support for the standard library is now mu h improvedsin ethetimewhenthe orens-2 ar hite turewasdened.
ouplingbetweenC++andOT lisveryhigh: Theuseoftheot landt l llibraries hasen ouraged theauthors ofmodelsto split fun tionalitybetweenOT land C++ and makethe C++ side of the model aware of the OT l side and vi e-versa. This sort of te hnique probably looks attra tive from an abstra t point of view, but its drawba kisthatitrequiresmaintainerstospendtheirtimetryingtogureoutwhere agiven fun tionality is implemented (in OT l orC++) and muddies the denition of an obje t's interfa e. Typi ally, it qui kly be omesveryhard to gureout what methods an be invokedon agivenC++ obje t be ause part of itsfun tionality is exported as C++ methods and the other part as OT l methods. Of ourse, this problem isamplied when inheritan e enters thegame sin eboththe OT l andthe
Table1: Simulatorli ensingterms
GloMoSim/Qualnet A ademi until 2000 and om-mer ialsin ethen.
GTNetS BSD-likewithexportrestri tions forrtikit.
OMNET++ A ademi and ommer ial for the oreanddiverseforthe mod-els.
OPNET A ademi and ommer ial: the a ademi version is limited in features.
JiST/SWANS Restri tredto a ademi use.
SSFNet Themain implementationofthe SSF spe i ation provided by Renesysisrestri tedto ommer- ial use, or to a ademi s only withintheUS.
C++methodsof theparentsareinherited. Experien ehasshownthat debuggingin thisenvironment anbea hallenge.
Besides ns-2,anumberofother open-sour esimulatorshavebeendeveloped,in luding GloMoSim[2℄,NCTUns[3℄,GTNetS[4℄(in ludingtheRTIKitlibrary[5℄),OMNET++[6℄, SSFNet[7℄,andJiST[8℄. Twopopular ommer ialtoolsareOPNET[9℄andQualNet [10℄. Wereviewedtheli ensingtermsofthesesimulatorsandfoundthattherestri tionswere nota eptableforourproje t;alloftheabovearenot ompletelyfreelyandopenlyavailable orpla erestri tionsonuseofthesoftware. Whatweunderstoodofthesevariousli ensesis summarizedinTable1.
In light of the fa t that several ns-2 developersare interested in exploring a move to anewsimulation ore, wede ided to experimentwith ouryans approa h. Theremainder ofthis paperdes ribesthehigh-levelgoalsandrequirementsofyans, thebasi design,the IEEE802.11a model, and reviewssomeof theperforman e hara teristi softhe resulting ar hite ture.
2 yans goals and requirements
2.1 Li ensing
We desire to develop our software with a well-known li ense that allows unen umbered resear hand useofthe resultingsimulator. Clearly,theGNU GPLoraBSD-styleli ense
wouldt thebill. However,be ausewewould liketomakesureeveryuser ontributeba k hisorhermodi ationstothesimulator(whetherthesemodi ationsareaimedatresear h or ommer ialuse),we hosetheGPLv2withoutrequestingany opyrightassignment;i.e., ea h ontributorownsthe opyrightofhis ontribution.
2.2 Ar hite ture
Whiletheli ensingissuessurroundingeveryopensour eproje tseemtra table,designinga softwarear hite turewhi hwillbeassu essfulintermsofnumberofusersasns-2 andwill be ableto withstandthis su ess ismu h harder: ensuring thelong-term (15to 20 years) ar hite turalintegrityofareasonably-large odebaseonwhi hmany ontributorswillwork isveryhard. Thefollowingparagraphsoutlinehowweplantolearnfrompreviousproje ts su h asns-2.
Clearly, the rst lesson we learned from ns-2 is to avoid a dual-language simulator 1
to de rease the overall omplexity of the system. While it should be possible to use the simulator from any language (Python, Perl, t l, java, et .), writing new models for the simulatorshould bedonein asinglelanguage. Thisis thear hite tureadopted byalot of softwareproje ts: wrappersfor thesingle-language appli ation oreare reatedasneeded forea h languageofinterestandnumeroustoolssu h asSWIG[11℄ havebeendesignedto makethiseasier.
Thesingle-language orewaswritteninC++,mostlybe ausewefeltthattheintegration ofexistingC/C++modelswouldbeeasier.
2.3 Pro esses
Using asingle languageis a ne essaryrst step to tryto minimize the omplexityof the simulator. However,itis farfrom beingenough: it isalsone essaryto dene lear ontri-butionrulesandpro essesto beabletodealwiththede entralizeddevelopmentofmodels bymultiple usersin dierent ountries,with dierentba kgrounds. These rulesmustalso beenfor edduring integration: thens-2 manual des ribesasimple oding style butlarge amountsofits odedonotfollowit.
yans thusdenes:
a oding styleenfor edduring integrationthrough ode reviews: the oding styleis des ribedintheCONTRIBUTINGlein ludedin theyans distribution;
aninformal ode review pro ess: the authors whowould like to see their ode inte-gratedin yans needtohavetheir odereviewedatleaston e;and
requirements on model maintainership: ea h model should have at least one main-tainer. Modelsthat la kmaintainerswill beremovedfromtheyans sour etree. The listofmaintainersisdes ribedintheMAINTAINERSlein ludedin theyans distri-bution.
1
Beforeworkingonyans,weattemptedtomodifyns-2 tobeabletoperformC++-onlysimulationsbut thisexer iseinrefa toringwastoodi ultforusto ompleteit.
3 Fun tional requirements
yans was builtwiththeideathat wewantedto makeit veryeasytoperform anumberof taskswhi h areoften regardedasveryhard and sometimes impossiblewith ns-2 orother simulators:
1. Emulation: itshouldbeeasytoplugthesimulatorintoarealnetworkandmakethe simulatednodesex hangedatawiththerealnodes.
2. Integrationofuser-spa enetworkingappli ations/daemons: itshould bepossibleto re- ompile some of the lassi Unix daemons and make them use the simulator as theirsour eofinput/output.
3. Integrationofkernel-spa enetworkingsta ks: itshouldbepossibletore- ompilethe networkingsta ksofopensour eoperatingsystemsin thesimulatorwithaminimal amountofmodi ations.
4. Tra ing: easytra ing/dumping of pa kets and interestingevents, from deep in the networkingsta k,inwidely-a eptedformats(e.g.,p apforpa kettra es).
5. S ripting: theavailabilityofatleastones riptinglanguagethatwrapsthesimulation oreandmakesitpossibleto ontrolmostaspe tsofasimulation
Asdes ribedbelow,ourprototypehasa omplisheditems4,and5to date,andwebelieve wehavepavedthewayforitems1,2and3.
4 Ar hite tural overview
yans isbuiltaroundaC/C++simulation orethatprovides:
asimulationevents heduler(lo atedin sr /simulator),and
a number of utility APIs used to implement various network models (lo ated in sr / ommon).
TherestoftheC/C++ odeimplementsmodelsforvariousnetwork omponents. yans also provides a default Python wrapper for the simulation ore and the models bundled with it. This Python wrapper imposes negligible performan e penalty on Python simulations omparedtopureC++simulations.
4.1 The event s heduler
TheeventS hedulerprovidesa lassi events hedulingAPIthatallowsitsuserstolookup the urrentsimulationtime,s heduleeventsatarbitrarypointsinthefutureand an elany eventwhi hhasnotyetexpired.
However,someofitsfeaturesarenoteworthy. Itsusers an:
S hedule events for the "end of simulation" time to release any resour e a quired (typi ally,memory).
S hedule events for the"now" time; that is, eventsthat will bes heduledafter the urrentevent ompletesandbeforeanyothereventruns. Thisfeature anbeusedto avoidre ursionandre-entran yproblems.
Choosetheunderlying priorityqueuealgorithmusedtoorderevents.
Re ordto atext le theexa tlist ofs hedulingoperations(su hasinserts, deletes, et .) andreplayfromatextletheseevents. Thisisespe iallyusefultoevaluatethe performan eofvariouss hedulingalgorithmsonagivenload.
UseC++ templates to generatethe ode of forwardingevents; these automati ally-generated events an forwardevent noti ationsto arbitrary lass methods or fun -tionswithanarbitrarynumberofper-eventarguments.
Thesimulationtimeismaintainedinternallybya64-bitintegerinunitsofmi rose onds. Whilethe S heduler also exports this simulationtime asaoating-pointnumberin units of se onds, users are advised not to use it: past experien e with ns-2 models based on oating-pointarithmeti fortimehasshownnumerousproblemsrelatedtoa ura y. Indeed, most model developers assume that oating-point operations are performed with innite arithmeti pre ision and ignore all the issues related to a ura y ontrol. This makes it hardtoensurethereprodu tionofsimulations enariosandresultsa rossalargerangeof hardware andsoftware platformsand sometimes leadsto veryhard to debug problemson ertainplatforms.
The s hedulingorder of events s heduledto expire at thesame time is spe ied to be thatoftheinsertiontime. i.e.: theeventsinsertedrstares heduledrst. Thisorderholds whatever the s heduling algorithm hosen: it is implemented by using an event sequen e number,in rementedforea hinsert.
Be ause it is possible to hange the priority-queuealgorithm used by theevent s hed-uler,the omplexityperforman eoftheinsertandtheremoveoperationsarenotspe ied. However,the urrently-implementedalgorithmsprovide:
LinkedList: O(n)insert,andO(1)remove;
Binary Heap: O(log(n)) insert and remove (ns-2 is O(log(n)), insert, O(n) random removeandO(log(n))rstremove);and
stdC++map: O(log(n))insertandremove.
4.2 Network model fa ilities
Tomaketheimplementationofnetwork-related modelsaseasyaspossible,yans also pro-videsafewveryimportantfa ilities:
allba kobje tsthatimplementaC++template-basedversionoftheFun tordesign pattern,
apa ketAPIto reateandmanipulatepa kets, tra esupport lasses,and
auniformrandomnumbergeneratorbasedonthemrg32k3arandomnumbergenerator usedinns-2 anddes ribedin[12℄.
The allba k API is absolutely fundamental to yans: its purpose is to minimize the overall oupling between various pie es of yans by making ea h module depend on the allba kAPIitselfratherthandependonothermodules. Ita tsasasortofthird-partyto whi h work is delegatedand whi h forwardsthis work to the propertarget module. This
allba kAPI,beingbasedonC++ templates, istype-safe; that is, itperformsstati type he ks to enfor e propersignature ompatibility between allers and allees. The API is minimal,providingonlytwoservi es:
allba ktypede laration: awaytode lareatypeof allba kwith agivensignature, and,
allba kinstantiation: awayto instantiateatemplate-generatedforwarding allba k that anforwardany alls toanotherC++ lassmembermethod orC++fun tion.
This allba k API is already used extensively in most models urrently available in yans . Forexample, ourLLC/SNAP en apsulationmodule was madeindependent of theIPv4 andArplayerswith allba ksinvokedwheneverapayloadmustbeforwardedtothehigher layers.
The pa ket-manipulation API is based on the skb/mbuf APIs from the BSD/Linux operating systems: a pa ket is a buer of bytes and it is possible to e iently add and remove hunksofbytes from thestartandtheend ofthebuer. A essto theunderlying bytebuerisdoneonlythroughaspe ializedBuerAPIthatprovides onvenientmethods toserializeanddeserializepa ketheadersandtrailersto/fromhostandnetworkformat. It is also possible to e iently add and removean arbitrary number of tags to ea h pa ket toalloweasyimplementationof ross-layerme hanisms(forexample,a802.11eappli ation ouldtagea hpa ketwithits802.11e lasstoallowtheMACtoa uratelys hedulepa kets a ordingtotheirs heduling lassandthenegotiateds hedulingpoli y).
ThisAPIshoulden ouragemodeldeveloperstomaketheirsimulationpa ketsa urately ree t theexa tstru ture of the simulatednetwork pa kets. This should makeit easy to ex hangepa ketswithrealnetworksinrealtime. Furthermore,generating onformantp ap tra esoutofsu hpa ketsistrivialandgenerallyimprovestheuserexperien e.
The tra esupportis abit lessmaturebut it allowsusalready toprovidetwotypesof tra ing:
pa ketlogging: wheneverthemodellogsapa ket,auser-provided allba kisinvoked. variable hangelogging: wheneverthevalueofavariable hanges(whenbeingassigned
toforexample),auser-provided allba kisinvoked.
Thisframeworkwasdesignedto oeralot ofexibility: theusers ansele twhi h events theywantto monitorandthey arefreeto usearbitrarily omplexlogi to de idewhen to logtheeventstoatra ele. For onvenien e,wealsoprovideafewdefaulttra ewritersto simplify thetask ofserializing theeventsto atra ele in p apformatwhi h anthen be readba kwiththird-partyGUIssu hasEthereal.
Theuniformnumbergeneratorwasin ludedafterextensivedis ussionswithafewusers: initially,wewere planningtomakeyans depend onathird-partylibrarysu hasGSL [13℄ whi h would haveprovided both su h simplerandom numbergeneration servi esbut also more elaborate mathemati al fun tions. However, the ost of in reasing the size of the dependen ylist foryans andthusthe riskofmakingyans hardertobuild andusefor our userswas onsideredtoohigh; oeringabuilt-inrandomnumbergeneratormakesporting and using yans on numerous platforms easier. This also makes it mu h easier to ensure properreprodu eabilityof thesimulationresults,whatevertheplatform onsidered.
4.3 The default Simulation Models
yans omeswithasmallbutfo usedsetofdefaultsimulationmodels:
aThreadmodelallowsouruserstomix lassi sequentialsyn hronous odewiththeir event-drivenasyn hronous ode;
aNodemodelwhi himplementsaTCP/UDP/IPv4sta kandoersaso ket-likeAPI. TheTCP sta kis aport of the BSD4.4Lite TCP sta k: it isdistributed separately be auseitsBSDli enseisnot ompatiblewiththeGPLli enseofthesimulator. Nodes are onne tedto ea hotherthroughtheirNetworkInterfa es;
anEthernet NetworkInterfa emodel;and
a802.11NetworkInterfa emodelwhi himplementstheIEEE802.11MACDCFand theIEEE802.11eEDCAandHCCA.ItalsoimplementsamultiratePHYmodelbased onpie ewiseSNIR al ulationswith anenergythreshold.
5 Real-world ode integration
Ourinterestinbeingabletointegratereal-world odeinthesimulator omesfromtwovery dierentperspe tives:
ourlimiteddevelopmentresour esmakeusverysensitivetothepossibilityofreusing existing ode,and
wewouldliketosimulatea uratelyareal-worldnetworkwithitsreal-worldbugsand limitations.
Doing soposes a numberof veryinteresting te hni al hallenges whi h we havespent onsiderabletimetoattempttota kle:
1. theneedtoprovideapro ess-drivenAPIin anevent-drivensimulator,
2. theneedto provideseparate addressspa esto separatesimulatedpro esses: global stati variablesmustnotbeshareda rosssimulatedpro esses.
3. the need to provide a suitable build and link environment to both user-spa e and kernel-spa e ode.
The thread model provided byyans oers apro ess-drivenAPI (whereaddressspa es areshared) that is builton topof theexisting event-drivenservi es. It uses asmall user-spa ethread librarythathasbeenported tox86Linuxand pp 32OS Xsystems. Porting itfurthershould notposenewproblems andisamatterofmanpower.
OnsystemsbasedonELF[14℄,ourplantodealwithstati variablesinpro ess ontext is to buildthe pro ess ode asaseparate sharedlibrarywith Position IndependentCode. Then,yanswouldneedtoloadthesharedlibraryitselfinmemoryatruntime,on eforea h simulatedpro ess. Theideaisthat ea h simulatedpro esswould runtheexa tsame ode but mapped at dierent virtual addresses. On any modern operating system, this would onsume onlythe address spa e and no real physi al memorywould be wasted, provided thatthe memorymappingsare notwritable andthe odeis not hanged. Sin eea h opy ofthe odeof thesimulatedpro ess a essesitsstati variables throughtheGlobalOset Tablewhose position isrelativetothat ofthe ode,ea hsimulatedpro esswoulda ess a
dierent opyoftheGOT,whi hwoulda hievethedesiredee t,thatis,theabilitytouse simulated-pro ess-spe i stati variables.
Othersystemswhi huseotherbinarystandardstodealwithpro ess-spe i stati vari-ables ouldseesimilarsolutionsbutourinitialfo usisonLinuxELF systems.
Providing aproperbuild and link environment to kernel-spa e ode requires a areful re-implementation of the OS-spe i libraries used by this kernel-spa e ode. One su h important library is the skb and the mbuf buer abstra tions of the Linux and the BSD kernelsrespe tively. ThePa ketAPIusedinournetworkmodelshasbeendesignedtomake itpossibletowriteathin relativelysimplewrapperaroundittomakeitlooklikeeitheran skboranmbuf.
User-spa e odehassimilarrequirements: itneedsaso ketand alib implementation. TheTCPandUDPmodelsimplementedinyans weredesignedtomakesu han implemen-tationpossible.
6 The 802.11 model
The ore node-based models in yans allow the users to plug any number of network in-terfa esin ea h node and makes the network interfa emodels ompletely independent of theotheryans models. The802.11modelwasdevelopedindependentlyfrom yans itself(it wasoriginally written for ns-2). It implements aMACand aPHY layerthat onform to the 802.11aspe i ation. Work onfull 802.11esupport (in luding EDCA and HCCA) is underwayatthetimeof thiswritingandshould be ompletebytheend ofAugust2006.
6.1 The PHY model
Sin eweareunawareofanypublisheddetaileddes riptionofa ompletewirelesslinkmodel, thisse tionsummarizesthedes riptionof theBER al ulationsfoundin [15℄,presentsthe equations requiredto takeinto a ount theForwardError Corre tion presentin 802.11a, and des ribes the algorithm we implemented to de ide whether or not a pa ket an be su essfullyre eived.
ThePHY layer anbein oneofthreestates:
TX:thePHY is urrentlytransmittingasignalonbehalfofitsasso iatedMAC RX:the PHY issyn hronizedon asignaland iswaiting untilit hasre eivedits last
bittoforwardittotheMAC.
IDLE:thePHYisnotin theTXorRX states.
Whentherstbitofanewpa ket isre eivedwhilethePHY isnotIDLE(that is,itis alreadysyn hronizedonthere eptionof anotherearlierpa ketoritissendingdataitself), there eivedpa ket is dropped. Otherwise, ifthe PHY is IDLE, we al ulate the re eived energy of the rst bit of this new signal and ompare it against our Energy Dete tion threshold(asdened bythe ClearChannelAssessmentfun tion mode1). If theenergyof thepa ketkis higher,then thePHY movestoRX stateands hedulesaneventwhenthe
last bitof thepa ketis expe ted to bere eived. Otherwise,the PHY staysin IDLEstate anddropsthepa ket.
The energy of the re eived signal
S(k, t)
is assumed to be zero outside of the re ep-tion interval of pa ket k and is al ulated from the transmission power with a path-loss propagationmodelin there eptioninterval:P
l
(d) = P
l
(d
0
) + n10log
10
(
d
d
0
)
(1)wherethepathlossexponent,
n
, is hosenequalto3,thereferen edistan e,d
0
is hoosen equalto1.0m
andthereferen eenergyP
l
(d
0
)
isbasedbasedonaFriispropagationmodel:P
l
(d
0
) =
P
t
G
t
G
r
λ
2
16π
2
d
2
0
L
(2)
where
P
t
represents the transmission power,G
t
, the transmission gain (set to 1 dbm by default),G
r
there eptiongain(set to1dbmbydefault),λ
the arrierwavelength,d
0
= 1
andL
isthesystemloss( hosenequalto1in oursimulations).When the last bit of the pa ket upon whi h the PHY is syn hronizedis re eived, we al ulatetheprobabilitythatthepa ketisre eivedwithanyerror,
P
err
(k)
,tode idewhether ornotthis pa ket ouldbe su essfullyre eivedornot: a randomnumberrand
is drawn fromauniformdistributionandis omparedagainstP
err
(k)
. Ifrand
islargerthanP
err
(k)
, then the pa ket is assumed to be su essfully re eived. Otherwise, it is reported as an erroneousre eption.Toevaluate
P
err
(k)
, westartfrom thepie ewiselinearfun tions shownin gure1and al ulatetheSignaltoNoiseInterferen eRatiofun tionSN IR(k, t)
withequation3.SN IR(k, t) =
S
k
(t)
N
i
(k, t) + N
f
(3)
where
N
f
representsthenoiseoorwhi hisa hara teristi onstantofthere eiver ir uitry andN
i
(k, t)
representstheinterferen enoise,thatis,thesumoftheenergyofalltheother signalsre eivedonthesame hannel:N
i
(k, t) =
X
m6=k
S(m, t)
(4).
Fromthe
SN IR(k, t)
fun tion,we anderiveBER(k, t)
forBPSK(seeequation5)and QAM(seeequations6,7,and8) modulations.BER(k, t) =
1
2
erf c(
r E
b
N
0
(k, t))
(5)BER(k, t) = 1 − (1 − P
√
M
(k, t))
2
(6)Figure1: SNIRfun tionovertime
P
√
M
(k, t) =
1 −
√
1
M
.X(k, t)
(7)X(k, t) = erf c
r
1.5
M − 1
. log
2
M.
E
b
N
0
(k, t)
!
(8)where
E
b
istheenergyperbit,N
0
thenoisepowerdensity,andE
b
N
0
(k, t)
isdenedas:E
b
N
0
(k, t) = SN IR(k, t).
B
t
R
b
(k, t)
(9)B
t
istheunspreadbandwidthofthesignal(thatis, 20MHzfor802.11a)andR
b
(k, t)
isthe bit-rateofthetransmissionmodeused bysignalk
attimet
.Then,forea hinterval
l
whereBER(k, t)
andR
b
(k, t)
are onstant,wedenetheP
e
(k, l)
fun tionwhi hrepresentsanupperbound ontheprobabilitythatanerrorispresentinthe hunk of bits lo ated in intervall
for pa ketk
. If we assume an AWGN hannel, binary onvolutional oding (whi h is the ase in 802.11a) and hard-de ision Viterbi de oding,P
e
(k, l)
anbedenedbytheequations10,11and12asdetailedin [16℄.when
L(k, l)
isthesizeoftheintervall
inbits,andtheunionboundP
u
(k, l)
oftherst-event errorprobabilityisgivenby:P
u
(k, l) =
∞
X
d=d
f ree
a
d
.P
d
(k, l)
(11)where
d
f ree
is the freedistan e of the onvolutional ode,a
d
is the totalnumber oferror eventsof weightd
andP
d
(k, l)
is theprobabilitythat anin orre tpathat distan ed from the orre tpathis hosenbytheViterbide oderasdened by:
d
X
i=(d+1)/2
d
i
ρ
i
(1 − ρ)
d−i
ifd
isodd1
2
d
d/2
d
X
i=d/2+1
d
i
ρ
i
(1 − ρ)
d−i
otherwise (12)where
ρ(k, l)
isequaltoBER(k, t)
.The
P
e
(k, l)
fun tion isnallyusedtoevaluateP
err
(k)
withthelast equation:P
err
(k) = 1 −
Y
l
(1 − P
e
(k, l))
(13)6.2 The MAC model
The 802.11 Distributed Coordination Fun tion is used to al ulate when to grant a ess to the transmissionmedium. While implementingthe DCF would have been parti ularly easyif wehad usedare urring timerthat expiredeveryslot,we hoseto use themethod des ribedin[17℄wheretheba kotimerdurationislazily al ulatedwheneverneeded,sin e itis laimedtohavemu hbetterperforman ethanthesimplerre urringtimersolution.
Thehigher-levelMACfun tionsareimplementedinasetofotherC++ lassesanddeal with:
pa ket fragmentationanddefragmentation, useof theRTS/CTSproto ol,
rate ontrol algorithm,
onne tionanddis onne tionto andfromanA essPoint, theMACtransmissionqueue,
bea ongeneration, et .
Table2: Performan eofSimulationCore GTNetS yans
eventHOLD(s)
avg
1.2e
−5
1.3e
−5
stddev9.4e
−8
9.9e
−8
pa ket transmission (pa kets/s) avg 260447 423945 stddev 15109 4151 pa ket reation (pa kets/s) avg 526441 1352757 stddev 6388 136717 Performan e And S alability Considerations
Althoughourdesignobje tiveswereto put orre tness,API leanliness,andeaseofuseon top of therequirements, performan e and s alability are also of major on ern to us: we wantto beableto qui klyperformlargeand omplexsimulations.
The pu and memory usage of the ore utilities provided by the simulator has been loselymonitoredandproledandextensivelyoptimizedtoallowthesimulatortodealwith verylargenumbersof eventsandpa kets:
thememoryused bythesimulationpa kets depends linearlyonthesize ofthe simu-latedpa ketssin ethesimulationpa ketsserializeea hsimulatedheaderandpayload ina orrespondingly-sizedbytebuer;
the allo ation of pa kets is done by a Pa ketFa tory whi h uses afree-list to avoid de-allo atingandallo atingpa ketstru tures onstantly;and
pa ketbuersarealmostalways reatedwiththerightreservedsizebe ausetheBuer lassusedbythe Pa ket lass al ulatesonthey thetotalnumberofbytesneeded byalltheproto olheaders andtrailersduring thestartofthesimulation.
Wedesignedafewmi ro-ben hmarkstoevaluatetheperforman eoftheresultingAPIs: ea h run of a simulator was repeated 10 times and the average and standard deviation al ulated. Theresultsaresummarizedin Table2;namely
thebehaviorof theevents heduler wasproled on asyntheti workload(a uniform distributionof320000elementsfortheHOLDmodel)withthestdC++maps heduler; thePa ket API wassubmittedto asimple pa ket transmission ben hmark repeated 1000000times: apa ket is reated,payload,UDP, and IPv4headers areadded, the pa ket is opiedon e,andtheIPv4,UDPandpayload areremoved;and
the Pa ket API was also submitted to a pa ket reation ben hmark also repeated 1000000times: apa ketis reatedandpayload,UDP, andIPv4headersareadded.
The performan eof the GTNetSand yans events hedulers are, ratherunsurprisingly, very losesin etheyarebothbasedonthestdC++map datastru ture. ThePa ketdata stru tures, on the other hand, have very dierent performan e hara teristi s: yans an
generate about 60%more pa kets than GTNetS when using an optimized sharedlibrary. This performan e gain omes mostly from the very small number of memory allo ations performed by yans: proto ol headers an be allo ated on the sta k and do not require a ostly alltotheheapallo ator.
Of ourse, one ould wonder how a urately these ben hmarks ree t real-world use. To answerthis question,weperformeda 802.11s enariobased onour 802.11MAC/PHY model. Node A moves away from Node B and saturates the transmission medium with onstant-sizedpa kets generatedat periodi intervalsatthe UDPlayer. Everysimulation se ond andfor 42simulation se onds,A moves5meters awayfrom node Bandgenerates 100000pa ketsof2000bytesea h.
The odewasbuiltwithg 4.1.0,fulloptimizationsenabled,assertsdisabled,andwith stati linking enabled. Building yans asasharedlibraryonanx86system generates ode whi h is vastly slowerdue to the wayPosition Independent Code is implemented on this platform: our sample simulation s enario is 38% faster when using a stati library than whenusingasharedlibrary. OurIPv4andUDPsta ksdonot al ulatetheIPv4andUDP he ksums by default, whi h generates slightly in orre tp ap output but whi h saves up to 20%of runtime. The wall- lo k runtime of this simulation on an x86 Centrino-based systemis just under 15s whi h meansthat thissimulation reates, anddeals witharound
42×100000
15
= 280000
pa kets/s: this is a bit more than half the theoreti al throughput reportedbyourpa ket reationben hmark.8 Con lusion
Dissatisfa tionwiththesoftwaredesignprovidedbyns-2andtheinadequa yoftheli ensing termsoftheotherexistingtoolsledustodesignYet AnotherNetworkSimulator. Thenew featuresprovidedbythissimulatorhavealreadyprovenusefultous: our802.11modelshave seenmajorsimpli ationsand leanupssin ewestartedportingthemtoyans andwehope to be able to add emulation, parallelization, and real-world ode integration apabilities easilytothisframework.
9 A knowledgments
Hossein Manshaei ontributed to the design of the 802.11 PHY model used in yans and ThierryTurlettiprovided ommentsonearlyversionsofthispaper. M.L.ar hite tedyans, wrotemostofthesoftware,anddesignedand ondu tedalloftheexperimentsherein,while T.H.providedyans feedba kandassistedin writingthispaper.
Referen es
[1℄ S. Bajaj, L.Breslau, D. Estrin, K. Fall, S. Floyd, P. Haldar, M. Handley, A. Helmy, J. Heidemann, P. Huang, S. Kumar, S. M Canne, R. Rejaie, P. Sharma, S. Shenker,
K.Varadhan,H.Yu,Y.Xu,andD.Zappala,Virtualinternetworktestbed: Statusand resear hagenda, July1998,uSC ComputerS ien e Dept,Te hni alReport98-678.
[2℄ Global Mobile Information Systems Simulation Library, http://p l. s.u la.edu/proje ts/glomosim/.
[3℄ NCTUnsNetworkSimulatorandEmulator, http://nsl. sie.n tu.edu.tw/n tuns.html.
[4℄ G. F. Riley, The georgiate hnetwork simulator, in MoMeTools '03: Pro eedings of the ACMSIGCOMMworkshop onModels,methodsandtools for reprodu ible network resear h. NewYork,NY,USA:ACM Press,2003,pp.512.
[5℄ FDK. Fdk usage agreement. [Online℄. Available: http://www-stati . .gate h.edu/ omputing/pads/fdk/fdk-usage-agreement.html
[6℄ A. Varga, The OMNeT++ distrete event simulation system, Software on-line: http://whale.hit.bme.hu/omnetpp/,1999.
[7℄ J.Cowie,A.Ogielski,andD.Ni ol,TheSSFNetnetworksimulator, Softwareon-line: http://www.ssfnet.org/homePage.html,2002,renesysCorporation.
[8℄ JavainSimulationTime (JiST),http://jist.e e. ornell.edu.
[9℄ OPNETTe hnologies,In . http://www.opnet. om.
[10℄ S alableNetworkTe hnologies,In . http://www.s alable-networks. om.
[11℄ Simpliedwrapperandinterfa egenerator.[Online℄.Available: http://www.swig.org/
[12℄ P. L'E uyer, Good parameter sets for ombined multiple re ursive random number generators, Math. Oper.Res.,no.1,pp.159164,1998.
[13℄ FSF. Gnus ienti library.[Online℄.Available: http://www.gnu.org/software/gsl/
[14℄ Exe utable andlinkableformat, TISstandardPortableFormatsSpe i ation, 1993.
[15℄ G.Holland,N.Vaidya,andP.Bahl,Arate-adaptivema proto olformulti-hop wire-less networks, in Pro eedings of the 7th annual international onferen e on Mobile omputingandnetworking,2001,pp.236251.
[16℄ M.B.PursleyandD.J.Taipale, Errorprobabilitiesforspread-spe trumpa ketradio with onvolutional odesandViterbide oding, inMILCOM'85- Military Communi- ationsConferen e,1985,pp.438441.
[17℄ Z. Ji, J.Zhou, M.Takai,and R.Bagrodia,S alable simulationoflarge-s alewireless networks wirhbounded ina ura ies, in Pro eedings of the Seventh ACM Symposium on Modeling, AnalysisandSimulation ofWireless andMobileSystems,O tober2004.