資源描述:
《ubuntu下編譯安裝ffmpeg》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在應(yīng)用文檔-天天文庫。
1、一個(gè)簡單的ns2實(shí)驗(yàn)全過程實(shí)驗(yàn)名稱:比較tcp和udp的丟包行為試驗(yàn)?zāi)康模?.熟練用ns2做網(wǎng)絡(luò)仿真試驗(yàn)的整個(gè)流程;2.練習(xí)寫tcl腳本,了解怎么應(yīng)用http和rtp;3.練習(xí)用awk處理trace數(shù)據(jù),了解怎么計(jì)算丟包率;4.練習(xí)用gnuplot繪制曲線圖,熟練gnuplot的使用。?實(shí)驗(yàn)步驟:1。確定網(wǎng)絡(luò)拓?fù)洹??一個(gè)簡單的三個(gè)節(jié)點(diǎn)的拓?fù)?,兩個(gè)運(yùn)行cbr(const-bitrate)應(yīng)用的發(fā)送結(jié)點(diǎn),一個(gè)接收結(jié)點(diǎn)。一條鏈路使用tcp鏈接,一條鏈路使用udp連接。如圖。2。寫tcl腳本。#jiqing2007-6-5#thisscrip
2、tistocomparethelossratesofhttpandrtp.setns[newSimulator]#openanamtracefilesetnf[openout.namw]$nsnamtrace-all$nf#openatracefilesettf[openout.trw]$nstrace-all$tf#finishprocedureprocfinish{}{globalnsnftf$nsflush-traceclose$nfclose$tfexec./namout.nam&exit0}#createnodessetnod
3、e(http)[$nsnode]setnode(rtp)[$nsnode]setnode(recv)[$nsnode]#createlinks$nsduplex-link$node(http)$node(recv)0.9Mb10msDropTail$nsduplex-link$node(rtp)$node(recv)0.9Mb10msDropTail#setqueuesize$nsqueue-limit$node(http)$node(recv)10$nsqueue-limit$node(rtp)$node(recv)10#relayo
4、utnodes$nsduplex-link-op$node(http)$node(recv)orientright-down$nsduplex-link-op$node(rtp)$node(recv)orientright-up#setcolors$nscolor1blue$nscolor2red#setatcpconnectionsettcp[newAgent/TCP]$nsattach-agent$node(http)$tcpsetsink[newAgent/TCPSink]$nsattach-agent$node(recv)$si
5、nk$nsconnect$tcp$sink$tcpsetfid_1#setacbrabovetcpconnectionsetcbr(http)[newApplication/Traffic/CBR]$cbr(http)attach-agent$tcp$cbr(http)settype_CBR$cbr(http)setpacket_size_1000$cbr(http)setrate_1mb$cbr(http)setrandom_false#setartpconnectionsetrtp[newAgent/UDP]$nsattach-ag
6、ent$node(rtp)$rtpsetnull[newAgent/Null]$nsattach-agent$node(recv)$null$nsconnect$rtp$null$rtpsetfid_2#setacbrabovetcpconnectionsetcbr(rtp)[newApplication/Traffic/CBR]$cbr(rtp)attach-agent$rtp$cbr(rtp)settype_CBR$cbr(rtp)setpacket_size_1000$cbr(rtp)setrate_1mb$cbr(rtp)set
7、random_false#schedule$nsat0.1"$cbr(http)start"$nsat0.1"$cbr(rtp)start"$nsat4.0"$cbr(http)stop"$nsat4.0"$cbr(rtp)stop"$nsat4.1"finish"$nsrun3。仿真。在命令提示符下輸入nshttp_vs_rtp.tcl,回車。仿真結(jié)束,會(huì)調(diào)用nam演示動(dòng)畫。4。用awk處理trace數(shù)據(jù)。awk的語法和c很像,不同的是awk中使用變量不用事先聲明。一個(gè)awk程序的結(jié)構(gòu)如下面所示:BEGIN{...}{...}END{
8、...}可見,程序分為三塊,BEGIN只在程序進(jìn)入時(shí)執(zhí)行一次,END只在程序退出前執(zhí)行一次。而中間的程序塊會(huì)在處理每行數(shù)據(jù)時(shí)都執(zhí)行一次。這里用awk計(jì)算tcp和udp連接的丟包率,具體程序如下:BEGIN{