【正文】
Network Simulation and AnalysisUsing NS2 ChihHeng Ke (柯志亨 ) Webpage: Email: MSN: Methods for work research ? Analytical – Model – General expression or close form ? Emulation – Network testbed – Lab environment – Real code ? Simulation – Virtual work testbed Why Simulation ? Study of implemented protocols and algorithms – Behavior – Performance ? Test of unimplemented new protocols and algorithms ? Comparison of results across research efforts Simulation Advantage ? Inexpensive, Flexible and Reconfigurable ? Network phenomena interested can be reproduced ? Opportunity to study largescale work ? Easier parison of results across research efforts Simulation Disadvantage ? Important work details may be missed ? Protocols or algorithms must be “added” before simulation can be done ? High startup cost ? Have to be carefully verified before the test results can be used Outline1 ? NS2 Introduction and Installation – cygwin installation – , , , , myNS2, others – How to apply the patch – New module insertion – Repilation ? Tools – nsbench – NS2 Scenarios Generator (NSG) Outline2 ? How to measure the loss rate, delay, jitter, throughput? – parse the trace file – use ―LossMonitor‖ agent – modify the C++ code ? How to present the simulation result? – gnuplot (xgraph, or Excel) – random number generator – confidence interval ? How to run the simulation in a batch mode? Outline3 ? How CBR works? ? How UDP works? ? How DCF works ? – Trace the C++ code in NS2 ? Multicast ? Unicast ? Propagation Model – Transmission range Outline4 ? wireless error model – random uniform model – GE model (burst pattern) – Others ? DCF vs. EDCF – Adaptive Approach for QoS Support in IEEE Wireless LAN Outline5 ? How to dynamically set the link bandwidth during simulation? ? How to set the different operation modes (DCF or EDCF) for different mobile nodes? ? How to set the different transmission speeds to different mobile nodes? ? How to measure the queue length in the base station or mobile node? ? How to set the munication radius in wireless nodes? ? Hidden Terminal Problem ? How to get the information in different layers? Outline6 ? Multimedia simulation – myEvalvid (encoding from raw YUV video) – myEvalvidNT (for publicly available video traffic traces) – Multiple Description Coding (MDC) – voip simulation What is NS2 ? NEST (Network Simulation Testbed) ? REAL (Realistic and Large) ? NS1 ? NS2 ? NS2 is a mon work simulator ? NS2 is developed by the VINT project in order to reduce duplication of effort within the work research and develop munity ? Ns functionalities ? Wired – Transportation: TCP,UDP,RTP,SRM – Traffic sources:web, ftp, tel, cbr, stochastic – Queuing disciplines:droptail, RED, FQ, SFQ, DRR – QoS: IntServ and Diffserv – Emulation ? Wireless – Ad hoc routing and mobile IP – Directed diffusion, sensorMAC ? Tracing, visualization, various utilities “Ns” Components ? Ns, the simulator itself ? Nam, the work animator – Visualize ns (or other) output – Nam editor: GUI interface to generate ns scripts ? Preprocessing: – Traffic and topology generators ? Postprocessing: – Simple trace analysis, often in awk, perl, or Tcl NS Architecture ? SplitProgramming Model – C++ ? implement the simulation model ? Implement data path ? per packet processing, core of ns ? fast to run, detailed, plete control – OTcl (Tcl script language with Objectoriented extensions developed at MIT ) ? Simulation scenario configurations ? Periodic or triggered action ? Manipulating existing C++ objects ? fast to write and change The simulation procedure Problems Simulate the environment Run with ns2 Analysis the result Finish simulation Modify the simulation Yes No User‘s view of NS2 Architecture view of NS2 NS2 Installation ? Cygwin installation – install from Inter or local directory ? don‘t install from install Inter now – gcc version is new new ? install from local directory – – installation problems ? 完成安裝後, 並重新啟動(dòng) cygwin視窗,就會(huì)如上圖所示,產(chǎn)生一個(gè) home 目錄 並且把一些設(shè)定檔案放到 home目錄下 若是沒(méi)辦法產(chǎn)生如上圖所示,而是出現(xiàn)如 bash$這樣的問(wèn)題 ,可以 1)重新安裝 windows system 2)安裝完後馬上安裝 cygwin + ns2 3)裝完 ns2後 ,再裝其他的軟體 ,如 service pack, office等等 NS2 installation ? ns2 version ( for my provided cygwin) – (need patch) ? – cd – patch p0 ~/ – $./install – , , – myNS2—enhanced (It includes TKN EDCF module, NOAH routing, MFlood, CSFQ, Poisson traffic, wireless random uniform and GE error model, and tcldebug.) – ns2 support ? – ET/SNRT/BERbased PHY models – multirate – HCCA and EDCA ? 一個(gè) cygwin上面,可以同時(shí)安裝好幾個(gè)版本的 ns,不是只能安裝一個(gè) export NS_HOME=`pwd`/ export PATH=$NS_HOME/:$NS_HOME/:$NS_HOME/bin:$PATH export LD_LIBRARY_PATH=$NS_HOME/:$NS_HOME/:\ $NS_HOME/:$NS_HOME/lib:$LD_LIBRARY_PATH export TCL_LIBRARY=$NS_HOME/但不一定所有的電腦,設(shè)定路徑後一定會(huì)有效,所以當(dāng)路徑設(shè)定無(wú)效時(shí),可以把 拷貝到要模擬的 tcl script同一目錄下 $cd $cp ~/abc $cd ~/abc $./ 測(cè)試你安裝的 ns2 2. $cd $./validate How to insert a new module into your NS2? ? Take NOAH as an example – Stepbystep installation instructions for add noah/ \ to OBJ_CC and tcl/mobility/ \ to NS_TCL_LIB noah/noah.{h,cc} add and to a new subdirectory noah/ tcl/mobility/ add to tcl/mobility/ tcl/lib/ line 191: add source ../mobility/ line 603ff: add NOAH { set ragent [$self createnoahagent $node] } line 768ff: add Simulator instproc createnoahagent { node } { Create a noah routing agent for this node set ragent [new Agent/NOAH] setup address (supports hieraddr) for noah agent and mobilenode se