您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 咨询培训 > 网络仿真工具NS3的培训文档
ns-3TrainingComputerandCommunicationNetworkLabDepartmentofElectricalEngineeringNationalSunYat-SenUniversity5/13/2013TopicsGettingStartedns-3Whatisns-3?InstallationAFirstns-3ScriptTwotutorialexamplesAsimpleexampleforthisprojectCompletetheremainingparts2GettingStartedns-3•Pleasereadthefollowingdocuments•ns-3overview•••ns-3Tutorial••ns-3Manual•ns-3isadiscrete-eventnetworksimulatorforInternetsystemsns-3allowsresearcherstostudyInternetprotocolsandlarge-scalesystemsinacontrolledenvironmentns-3isanewsimulator(notbackwards-compatiblewithns-2)ns-3isafree,opensourcesoftwareprojectorganizedaroundresearchcommunitydevelopmentandmaintenancethetargetusercommunityisnetworkingresearchersandeducators4ExtensibleSoftwareCoreWritteninC++withoptionalPythoninterfaceextensivelydocumentedAPI(doxygen):Anns-3Nodeisahuskofacomputertowhichapplications,stacks,andNICsareadded6TracingandStatisticsTracingisastructuredformofsimulationoutputExample(fromns-2):Problem:Tracingneedsvarywidelywouldliketochangetracingoutputwithouteditingthecorewouldliketosupportmultipleoutputs7ns-3HasANewTracingModelns-3solution:decoupletracesourcesfromtracesinksBenefit:Customizabletracesinks8Downloadingns-3Latestrelease:ns-3.16(2012/12/21)9ProblemsunderWindowsCygwinorMinGWIfyoudouseCygwinorMinGWanduseLogitechproductsitcancauseCygwinorMinGWDLLstodieinmysteriouswayNotethatNSCisnotsupportedonOSXorCygwin.NetworkSimulationCradle10Buildingns-3(1/5)11#./build.pyBuildingns-3(2/5)12#./waf-doptimizedconfigurens-3usesthewafbuildsystemBuildingns-3(3/5)13#./waf-ddebugconfigureBuildingns-3(4/5)14#./test.py-ccoreBuildingns-3(5/5)15RunningaScript16./waf--runhello-simulatorBuildingYourScript17#cpexamples/tutorial/first.ccscratch/myfirst.cc./wafBuildingYourScript18#./waf--runscratch/myfirstAFirstns-3Script•/ns-allinone-3.10/ns-3.10/examples/tutorial•first.cc•third.ccBoilerplateThefirstlineinthefileisanemacsmodeline.Thens-3simulatorislicensedusingtheGNUGeneralPublicLicense.20ModuleIncludesThecodeproperstartswithanumberofincludestatements.../../build/debug/ns321Ns3NamespaceThenextlineinthefirst.ccscriptisanamespacedeclaration.Logging22MainFunctionsThenextlinesofthescriptyouwillfindare,23ns3提供的log訊息分成了以下幾個等級:1.NS_LOG_ERROR—Logerrormessages;2.NS_LOG_WARN—Logwarningmessages;3.NS_LOG_DEBUG—Logrelativelyrare,ad-hocdebuggingmessages;4.NS_LOG_INFO—Loginformationalmessagesaboutprogramprogress;5.NS_LOG_FUNCTION—Logamessagedescribingeachfunctioncalled;6.NS_LOG_LOGIC–Logmessagesdescribinglogicalflowwithinafunction;7.NS_LOG_ALL—Logeverything.8.NS_LOG_UNCOND–Logtheassociatedmessageunconditionally.TopologyHelpersCreatethens-3Nodeobjectsthatwillrepresentthecomputersinthesimulation.Weareconstructingapointtopointlink24TopologyHelpersWewillneedtohavealistofalloftheNetDeviceobjectsthatarecreated25InternetStackHelperProtocolstacksinstalledonournodesTCP,UDP,IP,etc.Ipv4AddressHelpermaketheassociationbetweenanIPaddressandadevice26ApplicationsTwospecializationsofthecorens-3classApplicationcalledUdpEchoServerApplicationUdpEchoClientApplicationUdpEchoServerHelper27ApplicationsUdpEchoClientHelper28SimulatorWhatweneedtodoatthispointistoactuallyrunthesimulation.scheduledeventsinthesimulatorat1.0seconds,2.0secondsandtwoeventsat10.0seconds29BuildingYourScriptDropyourscriptintothescratchdirectoryNowbuildyourfirstexamplescriptusingwaf30BuildingYourScriptYoucannowruntheexample31BuildingaWirelessNetworkTopologyAddtheWifiandthemobilitymodulesThenetworktopologyillustrationfollows:32BuildingaWirelessNetworkTopologyForenablingordisablingloggingcomponentsandforchangingthenumberofdevicescreated33BuildingaWirelessNetworkTopologyPartoftheWifinetworkConfigurethePHYandchannelhelpersYetAnotherNetworkSimulatorM.LacageandT.R.Henderson,“YetAnotherNetworkSimulator,”WNS2ns-2:TheIPNetworkSimulator,Italy,2006.CreateachannelobjectandassociateittoourPHYlayerobjectmanagerNqosWifiMacHelperobjecttosetMACparametersratecontrolalgorithmAARF(AdaptiveAuto-RateFallback)algorithm35BuildingaWirelessNetworkTopologyTheSSIDoftheinfrastructurenetworkCreatethewifidevicesofthesestations36BuildingaWirelessNetworkTopologyConfiguretheAP(accesspoint)nodeSharesthesamesetofPHY-levelAttributes(andchannel)asthestations37BuildingaWirelessNetworkTopologySetsomeAttributescontrollingthe“positionallocator”functionality38Thenumberofobjectslayedoutonaline.BuildingaWirelessNetworkTopologyNeedtotellthemhowtomoveRandomWalk2dMobilityModelrandomdirectionrandomspeedRectangle(double_xMin,double_xMax,double_yMin,double_yMax)39BuildingaWirelessNetworkTopologyWanttheaccesspointtoremaininafix
本文标题:网络仿真工具NS3的培训文档
链接地址:https://www.777doc.com/doc-985649 .html