NS2中RTP的簡單應用

NS2已經支持簡單的RTP應用了,但是很多人卻不知道如何使用。這其中一個主要的原因就是NS2的發行版中自帶的RTP示例並不能夠正常運行。這個問題好幾年前就已經有人提了出來,可是很奇怪的是,一直到現在都沒有修改掉,而且還有很多人在不同的論壇上提出同樣的問題。沒有辦法,只有自己動手,豐衣足食。

在安裝目錄的tcl/ex文件夾下有個simple-rtp.tcl文件,演示了RTP協議的簡單應用。但是如果直接運行的話,則可能出現廈門的錯誤提示:

$ ns simple-rtp.tcl
warning: no class variable Session/RTP::debug_
          see tcl-object.tcl in tclcl for info about this warning.
  warning: no class variable Session/RTP::debug_
          see tcl-object.tcl in tclcl for info about this warning.
  warning: no class variable Session/RTP::debug_
          see tcl-object.tcl in tclcl for info about this warning.
  warning: no class variable Session/RTP::debug_
          see tcl-object.tcl in tclcl for info about this warning.
  Warning dst_ is no longer being supported in NS. dst_ -2147483648
Use dst_addr_ and dst_port_ instead 

 這裏的提示給出了兩個信息,一個是沒有類變量Session/RTP::debug_,第二個信息變量使用錯誤。首先解決第一個問題,在tcl/lib/ns-default.tcl中添加下面一行代碼:

Session/RTP set debug_ 0

 這裏的意思表示默認將調試功能關閉。當然如果需要調試功能的時候,可以在TCL腳本中將此值設置爲1或者“ON”。

第二個問題是在tcl/rtp/session-rtp.tcl文件中修改join-group函數,修改代碼如下:

Session/RTP instproc join-group { g } {
	 set g [expr $g]
	 $self set group_ $g
	 mvar node_ dchan_ cchan_ 
	 $dchan_ set dst_addr_ $g
	 $node_ join-group $dchan_ $g
	 incr g
	 $cchan_ set dst_addr $g
	 $node_ join-group $cchan_ $g
}

 最後要注意的是,必須重新編譯NS2 ,修改的代碼纔會起作用。

重新編譯後,再運行這個simple-rtp.tcl文件就沒有問題了。

上一個NAM模擬運行的圖:



 從圖中並沒有看出有什麼不同的地方,因爲這裏傳輸的都是數據(黑色)。當然這裏只是一個演示,具體的分析信息還是要看Trace文件,可以看到其它類型的報文信息。

 

BTW: 由於是在Windows下使用Cygwin編譯的NS2,所以爲了使用NAM,裝了X,可是在運行的時候卻出現了下面的錯誤信息:

_XSERVTransmkdir: Owner of /tmp/.X11-unix should be set to root
(II) XF86Config is not supported
(II) See http://x.cygwin.com/docs/faq/cygwin-x-faq.html for more information
winAdjustVideoModeShadowGDI - Using Windows display depth of 32 bits per pixel
winAllocateFBShadowGDI - Creating DIB with width: 1280 height: 800 depth: 32
......
XFree86-Bigfont extension local-client optimization disabled due to lack of shared memory support in the kernel
(--) Setting autorepeat to delay=500, rate=31
(--) winConfigKeyboard - Layout: "00000804" (00000804) 
(EE) Keyboardlayout "中文 (簡體) - 美式鍵盤" (00000804) is unknown
(--) 3 mouse buttons found
Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!
winInitMultiWindowWM - pthread_mutex_lock () returned.
winProcEstablishConnection - Hello
......

 重新安裝Cygwin沒有解決這個問題,在網上搜索也沒有找到解決方案。無意中打開了Xming,結果在啓動X失敗後,Xming打開了X窗口。現在也沒有心思去琢磨背後是什麼原因引起的,如果有誰知道的話,麻煩告知一聲。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章