资源描述
ns-3 TrainingComputerandCommunicationNetworkLabDepartmentofElectricalEngineeringNationalSunYat-SenUniversity5/13/2019TopicspGettingStartedns-3nWhatisns-3?nInstallationpAFirstns-3ScriptnTwotutorialexamplespAsimpleexampleforthisprojectnCompletetheremainingparts2Getting Started ns-3Pleasereadthefollowingdocumentsns-3overviewnsnam.org/docs/ns-3-overview.pptnsnam.org/docs/ns-3-overview.pdfns-3Tutorialnsnam.org/docs/release/3.13/tutorial/ns-3-tutorial.pdfns-3Manualnsnam.org/docs/release/3.13/manual/ns-3-manual.pdfWhat is ns-3?pns-3isadiscrete-eventnetworksimulatorforInternetsystemsnns-3allowsresearcherstostudyInternetprotocolsandlarge-scalesystemsinacontrolledenvironmentnns-3isanewsimulator(notbackwards-compatiblewithns-2)pns-3isafree,opensourcesoftwareprojectorganizedaroundresearchcommunitydevelopmentandmaintenancenthetargetusercommunityisnetworkingresearchersandeducators4Extensible Software CorepWritteninC+withoptionalPythoninterfacenextensivelydocumentedAPI(doxygen):nnsnam.org/doxygen-release/index.html5Node BasicspAnns-3Nodeisahuskofacomputertowhichapplications,stacks,andNICsareadded6Tracing and StatisticspTracingisastructuredformofsimulationoutputpExample(fromns-2):pProblem:Tracingneedsvarywidelynwouldliketochangetracingoutputwithouteditingthecorenwouldliketosupportmultipleoutputs7ns-3 Has A New Tracing Modelpns-3solution:decoupletracesourcesfromtracesinkspBenefit:Customizabletracesinks8Downloading ns-3pnsnam.org/nLatestrelease:ns-3.16(2019/12/21)9Problems under WindowspCygwinorMinGWpIfyoudouseCygwinorMinGWanduseLogitechproductsnitcancauseCygwinorMinGWDLLstodieinmysteriouswaypNotethatNSCisnotsupportedonOSXorCygwin.nNetworkSimulationCradle10Building ns-3(1/5)p#./build.py11Building ns-3(2/5)p#./waf-doptimizedconfigurenns-3usesthewafbuildsystem12Building ns-3(3/5)p#./waf-ddebugconfigure13Building ns-3(4/5)p#./test.py-ccore14Building ns-3(5/5)15Running a Scriptp./waf-runhello-simulator16Building Your Scriptp#cpexamples/tutorial/firstscratch/myfirstp./waf17Building Your Scriptp#./waf-runscratch/myfirst18A First ns-3 Script/ns-allinone-3.10/ns-3.10/examples/tutorialfirstthirdBoilerplatepThefirstlineinthefileisanemacsmodeline.npThens-3simulatorislicensedusingtheGNUGeneralPublicLicense.n20Module IncludespThecodeproperstartswithanumberofincludestatements.np././build/debug/ns321Ns3 NamespacepThenextlineinthefirstscriptisanamespacedeclaration.npLoggingn22Main FunctionspThenextlinesofthescriptyouwillfindare,nnns3提供的log訊息分成了以下幾個等級:1.NS_LOG_ERRORLogerrormessages;2.NS_LOG_WARNLogwarningmessages;3.NS_LOG_DEBUGLogrelativelyrare,ad-hocdebuggingmessages;4.NS_LOG_INFOLoginformationalmessagesaboutprogramprogress;5.NS_LOG_FUNCTIONLogamessagedescribingeachfunctioncalled;6.NS_LOG_LOGICLogmessagesdescribinglogicalflowwithinafunction;7.NS_LOG_ALLLogeverything.8.NS_LOG_UNCONDLogtheassociatedmessageunconditionally.23Topology HelperspCreatethens-3Nodeobjectsthatwillrepresentthecomputersinthesimulation.npWeareconstructingapointtopointlinkn24Topology HelperspWewillneedtohavealistofalloftheNetDeviceobjectsthatarecreatedn25Internet Stack HelperpProtocolstacksinstalledonournodesnpTCP,UDP,IP,etc.pIpv4AddressHelpernnpmaketheassociationbetweenanIPaddressandadevice26ApplicationspTwospecializationsofthecorens-3classApplicationcallednUdpEchoServerApplicationnUdpEchoClientApplicationpUdpEchoServerHelpern27ApplicationspUdpEchoClientHelpern28SimulatorpWhatweneedtodoatthispointistoactuallyrunthesimulation.npscheduledeventsinthesimulatorat1.0seconds,2.0secondsandtwoeventsat10.0secondsn29Building Your ScriptpDropyourscriptintothescratchdirectorynpNowbuildyourfirstexamplescriptusingwafnn30Building Your ScriptpYoucannowruntheexamplenn31Building a Wireless Network TopologypAddtheWifiandthemobilitymodulesnpThenetworktopologyillustrationfollows:32Building a Wireless Network TopologypForenablingordisablingloggingcomponentsandforchangingthenumberofdevicescreatedn33Building a Wireless Network TopologypPartoftheWifinetworknpConfigurethePHYandchannelhelpersnnYetAnotherNetworkSimulatorpM.LacageandT.R.Henderson,“YetAnotherNetworkSimulator,”WNS2ns-2:TheIPNetworkSimulator,Italy,2019.pcutebugs/files/wns2-yans.pdf34Building a Wireless Network TopologypCreateachannelobjectandassociateittoourPHYlayerobjectmanagernpNqosWifiMacHelperobjecttosetMACparametersnnratecontrolalgorithmpAARF(AdaptiveAuto-RateFallback)algorithm35Building a Wireless Network TopologypTheSSIDoftheinfrastructurenetworknpCreatethewifidevicesofthesestationsn36Building a Wireless Network TopologypConfiguretheAP(accesspoint)nodenpSharesthesamesetofPHY-levelAttributes(andchannel)asthestationsn37Building a Wireless Network TopologypSetsomeAttributescontrollingthe“positionallocator”functionalitynThenumberofobjectslayedoutonaline.38Building a Wireless Network TopologypNeedtotellthemhowtomovenRandomWalk2dMobilityModelprandomdirectionprandomspeednpRectangle(double_xMin,double_xMax,double_yMin,double_yMax)n39Building a Wireless Network TopologypWanttheaccesspointtoremaininafixedpositionduringthesimulationnpProtocolstacksn40Building a Wireless Network TopologypassignIPaddressestothedeviceinterfacesn41Building a Wireless Network TopologypEnableinternetworkroutingnnpCreatejustenoughtracingtocoverallthreenetworksnn42Building a Wireless Network TopologypRunthesimulation,cleanupandthenexittheprogramnpOutputn43Read the pcap filespp44Plot figurespp45An Example of MANETReference/ns-allinone-3.10/ns-3.10/examples/wireless/wifi-hidden-terminalCodes(1/7)47Codes(2/7)48Codes(3/7)49Codes(4/7)50Codes(5/7)51Codes(6/7)52Codes(7/7)53Result54Need to do(1/3)pTransmissionrangeofanodenns3:RangePropagationLossModelpMaxRangepNodemovingspeednns3:RandomWaypointMobilityModelpSpeedpPausepNodedataratenns3:ConstantRateWifiManager55Need to do(2/3)pRTSretrylimitnns3:UanMacRcpRetryRatepBuffersizenns3:TcpSocketpSndBufSizepAODVhelloperiodsnns3:aodv:RoutingProtocolpHelloInterval56Need to do(3/3)pUniformdistributioninasquarewith500metersnns3:RandomRectanglePositionAllocatorppns3:UniformVariable57Q&A58xiexie!xiexie!谢谢!谢谢!
展开阅读全文