2008年7月4日 星期五
2008年6月27日 星期五
9426135 期末程式
2008年6月26日 星期四
2008年6月23日 星期一
ns2技能檢視 9676050 張佑任
在實驗五中,有一個create-要設定基地台個數+mobile host個數但是這個god_有需要嗎?
Q2. 執行影像編碼解碼作效能測試中轉檔兩次的目的是?
在實驗六中,使用ffmpeg對原始YUV檔案轉換成m4v檔案再轉成mp4檔案,轉兩次的目的為何?
Q3. G++ & make 指令差異?
在ns2中要使所提供的小工具前要先編譯,會使用g++指令作編譯動作,與make 指令差異為何?
Q4. 承上,而小工具又要如何與NS2連結進行編譯?
使用exlonked進行編譯?
5. ./XXX.exe means PWD ?
會看到./XXX.exe ,此在linux指的是在當前目錄下的路徑嗎?
9426135 鍾昱宏 我檢視的五個問題(5-5)
proxytrace2any.cc: In function `int main(int, char**)':
proxytrace2any.cc:112: error: `IsLittleEndian' undeclared (first use this function)
proxytrace2any.cc:112: error: (Each undeclared identifier is reported only once for each function it appears in.)
proxytrace2any.cc:120: error: `ToOtherEndian' undeclared (first use this function)
make[1]: *** [proxytrace2any.o] Error 1
問題答案:
問題點在於 proxytrace2any.cc這隻程式,因為使用到兩個未經定義(undeclared) 的函數。修正的方法:找到下列檔案 /indep-utils/webtrace-conv/dec/my-endian.h
將 #ifndef _ENDIAN_H_ 與 #endif 兩行註解
起來,其他地方不變。
//#ifndef _ENDIAN_H_
#define _ENDIAN_H_
#include "proxytrace.h"
/* detects endian-ness */
int IsLittleEndian(void);
/* changes endian-ness */
void ToOtherEndian(TEntry *e);
//#endif
9426135 鍾昱宏 我檢視的五個問題(5-4)
是一個無迴路,由來源主機開始啟動,且能擴展到大量移動節點的一種通訊協定;和 DSDV 不同的地方在於,AODV
是一種在需要時才啟用的路由協定,意即當有來源端主機想傳送資料時,才開始建立由來源主機至目的主機的路由
(Route)。
RREQ 中的訊息如下:
這些訊息分別為:來源主機的 IP 位址、來源端的序列號碼、廣播 ID、目的主機的 IP 位址、目的端的序列號碼,最
後是經過的 hop 數。
RREP 則會包含如下的訊息:
這些訊息分別為:來源主機的 IP 位址、目的主機的 IP 位址,目的端的序列號碼,經過的 hop 數以及連線的有效存活
9426135 鍾昱宏 我檢視的五個問題(5-3)
所以使用時記得 include這個標頭檔。
(1)取得節點座標
使用MobileNode 類別內的 getLoc() 函數:
double x = 0.0, y = 0.0, z = 0.0; //傳入三變數
Node *thisnode; // 宣告指標
thisnode = Node::get_node_by_address(index);
((MobileNode *)thisnode)->getLoc(&x, &y, &z);
(2)取得節點速度
使用MobileNode 類別內的 getVelo() 函數,用法同上:
double x = 0.0, y = 0.0, z = 0.0; //傳入三變數
Node *thisnode; // 宣告指標
thisnode = Node::get_node_by_address(index);
((MobileNode *)thisnode)->getVelo(&x, &y, &z);
或者使用 speed()函數
Node *thisnode; // 宣告指標
double [...]
9426135 鍾昱宏 自我檢視的五個問題( 5-2)
9426135 鍾昱宏 自我檢視的五個問題(5-1)
2008年6月21日 星期六
2008年6月20日 星期五
2008年6月19日 星期四
2008年6月15日 星期日
2008年6月12日 星期四
2008年6月11日 星期三
2008年6月9日 星期一
2008年6月6日 星期五
2008年6月5日 星期四
2008年6月4日 星期三
Comprehension to NS2
http://hunghuan.liu.googlepages.com/comprehensiontons2
學期只剩下一點時間,這個project應該是做不完,暑假期間有空會陸續完成有興趣的自己follow。另外你們思考的結果和設計的程式可以另外開個一網頁貼上來討論討論。
2008年6月3日 星期二
NS2的擴充方法(三)
http://hunghuan.liu.googlepages.com/addnewqueue
NS2 Class Hierarchy:
http://www-rp.lip6.fr/ns-doc/ns226-doc/html/inherits.htm
Sec. 5.1 LAN Example
下載http://nile.wpi.edu/NS/Example/ex-lan.tcl執行,在我的電腦上不能執行。請各位動動腦抓bug。
網路上下載的東西有些會有版本的問題,太舊了不能在新版的NS2上執行,若碰到這個問題按照程式設計師的經驗:重寫可能會比較快!不過我們在學習,所以請修正程式的錯誤使他可以執行。
Sec. 5.2 Multicasting 和 Sec. 5.3 Web Server Example也有版本的問題
2008年5月31日 星期六
2008年5月29日 星期四
實驗六:MyEvalVid
3.完成後利用mp4trace成是將影片中的每個frame相關資訊擷取出來並存放到附檔名為st的檔案中
2008年5月28日 星期三
2008年5月26日 星期一
如何更改部落格寬度
參考資料:資料來源
部落格的版面物件都是以區塊來定義,整個頁面最外層定義的名稱 (ID) 叫 outer-wrapper,像是整個 Blog 的 container。在 outer 裡面從上到下分成三大塊,分別是 header-wrapper, content-wrapper 和 footer-wrapper。顧名思義,這三塊就是分別用來放最上方的標題列(頁首)、內文以及頁尾。其中表現內文的那一塊 content-wrapper 裡面又分了兩個區塊,ID 分別是 main-wrapper 和 sidebar-wrapper,就是用來顯示 Blog 文章和旁邊 sidebar 的。
底下是部落格區塊的階層關係:
- outer-wrapper
----- header-wrappe
----- content-wrapper
--------- main-wrapper
--------- sidebar-wrapper
----- footer-wrapper
如果要使部落格寬一點,那麼就必須更改部落格每個版面物件的寬度(找到區塊名稱底下的width屬性)。
有一點必須注意的是,不能只更改main-wrapper或是sidebar-wrapper而content-wrapper的寬度沒改,也就是說,每個區塊的大小不能超出它所在的區塊大小。
2008年5月22日 星期四
2008年5月21日 星期三
2008年5月20日 星期二
2008年5月19日 星期一
2008年5月15日 星期四
2008年5月14日 星期三
NS2的擴充方法(一)
如果需要將自己開發的元件加入NS2應該怎麼做? 這裡將程序RUN一次,並將中間使用到的檔案稍微說明。首先將需要的檔案ex-linkage.cc下載下來使用另一個視窗開啟,在以下的程序可以很快的參考到。
NS2的檔案架構如下圖

依照這個架構,新寫好的C程式只要放置在ns-2的目錄下即可。在我們的課程裡是ns-2.29 (or ns-2.33)。當然如果為了便於管理你可以開一個子目錄放置自己開發的程式碼。
另外有幾個檔案是比較重要的
- ns-lib.tcl: The simulator class and most of its member function definitions except for LAN, Web, and Multicast related ones are located here. If you want to know which member functions of the Simulator object class are available and how they work, this is a place to look.
- ns-default.tcl: The default values for configurable parameters for various network components are located here. Since most of network components are implemented in C++, the configurable parameters are actually C++ variables made available to OTcl via an OTcl linkage function, bind(C++_variable_name, OTcl_variable_name). How to make OTcl linkages from C++ code is described in the next section.
- ns-packet.tcl: The packet header format initialization implementation is located here. When you create a new packet header, you should register the header in this file to make the packet header initialization process to include your header into the header stack format and give you the offset of your header in the stack. A new header creating example is shown in "Add New Application and Agent" section.
- other OTcl files: Other OTcl files in this directory, contain OTcl implementation of compound network objects or the front end (control part) of network objects in C++. The FTP application is entirely implemented in OTcl and the source code is located in "ns-source.tcl".
我當然知道英文是有看沒有懂,簡單用中文說一下,在這個範例裡面我們只用到ns-default.tcl,它放在ns/tlc/lib目錄下,它是一個tcl檔,所以裡面用的是otcl的語法,C語言不通。這個檔案放的是你用C語言開發出來的程式的一些變數的初值。基本上每一個變數都需要初值的設定,如果沒有設定在執行ns的時候就會有warning message出現,不過如果你的tcl檔案中在使用變數以前有指定數值那就可以不要管這個warning message。最好每一個變數都在ns-default.tcl中定義初值。另外和Simulator相關的初值設定放在ns-lib.tcl這個檔案裡。對於自己開發的程式,放在哪裡沒有影響。
ns-default.tcl中定義的是otcl的變數初值,我們開發的C語言所使用的變數名稱須要經過link的程序連結到otcl的變數,這點等下會提到。
C物件的開發需要遵循NS2的物件架構,所以在開發的時候先判斷一下所開發的物件應該是繼承哪一個NS2類別。這個範例我們開發一個新的agent類別稱為MyAgent,繼承自Agent類別。
MyAgent類別中宣告了兩個變數(my_var1, my_var2)和一個函式(MyPrivFunc)。另外MyAgentClass是用來當作鏈結類別,連結C類別MyAgent到Otcl類別Agent/MyAgentOtcl。Agent/MyAgentOtcl前面的Agent/指明MyAgentOtcl是Agent下的一個衍生類別。當ns開始執行的時候會建立 class_my_agent物件,此時Agent/MyAgentOtcl類別和其相關的函式就會被建立在OTcl空間中。上面所提到的鏈結類別(static class開頭那段)可以拷貝到你開發的程式碼當中,只要將相對應的類別名稱(有顏色的部分,以及class_my_agent)做修改即可。
變數的連結:
需要在建構子當中將變數的繫結做好。NS2提供四種繫結的方式
- bind(): real or integer variables
- bind_time(): time variable
- bind_bw(): bandwidth variable
- bind_bool(): boolean variable
變數的初值可以設定在/tcl/lib/ns-default.tcl中。
函數的繫結:OTcl command interpreter
NS2利用command這個函式呼叫來處理C和OTcl間的函式繫結,基本上拷貝後做適當修改貼上即可。上面的程式將C語言中的MyPrivFunc繫結到Otcl上的call-my-priv-func函式。在.tcl程式中使用的時候看起來就像
set myagent [new Agent/MyAgentOtcl]
$myagent call-my-priv-func #這個陳述式會呼叫MyAgent的MyPrivFunc()
Compile, run and test "MyAgent"
- Download "ex-linkage.cc" file, and save it under the "ns-2" directory.
- Open "Makefile", add "ex-linkage.o" at the end of object file list.
- Re-compile NS using the "make" command.
- Download the "ex-linkage.tcl" file that contains "MyAgent" testing OTcl commands. (see Figure 22 for the input script and the result)
- Run the OTcl script using command "ns ex-linkage.tcl".
第二個步驟指示在做連結(link or bind)的時候要加入剛剛開發完成的C程式語言的.obj檔。"Makefile"這個檔案放在ns目錄下(ns-2.29 or ns-2.33),修改完成後執行make重新編譯與連結NS2的核心。.obj檔放置的位置在Makefile檔案中OBJ_CC = \和$(OBJ_STL)陳述句中間。
上面的warning message是因為變數的初值沒有事先設定,你可以嘗試設定看看。
另外的例子可以看一下課本實驗四,在實驗中作者加入了mTcpSink和mUDP,mUdpSink等三個類別,光是只學會這裡講的新增Agent還不足以完成實驗四,不過可以先追蹤mTcpSink和mUdpSink的程式撰寫方法,程式碼稍微的追蹤一下應該可以有很大的收穫。
(還有NS2的擴充方法(二)(三),未完待續)
作業:NS2技能的自我檢視
這裡我舉一個例子,請你們提問的時候要依照下面的範例。
- 問題(請限制字數在20字以內):不會自己創立NS2元件
- 描述(字數不限,以能描述問題的情境為主):當我學習到實驗九和實驗十的時候,我希望可以調整一下路由協定的設定以及多收集一些資料(或是過濾掉一些不必要的資料,不必記錄在檔案裡面,因為如果所有資料都記錄會需要很大的儲存空間),這需要改寫C程式。我會寫C程式,也會從現有的程式去改,不過改好以後我沒辦法讓NS2去執行它,需要重新編譯C程式嗎?要用什麼工具編譯?然後要怎樣將C程式和Otcl連結在一起?
2008年5月11日 星期日
2008年5月8日 星期四
2008年5月7日 星期三
2008年5月2日 星期五
2008年5月1日 星期四
2008年4月30日 星期三
2008年4月28日 星期一
2008年4月27日 星期日
2008年4月22日 星期二
2008年4月17日 星期四
2008年4月16日 星期三
2008年4月14日 星期一
2008年4月11日 星期五
2008年4月10日 星期四
2008年4月9日 星期三
2008年3月31日 星期一
2008年3月30日 星期日
2008年3月27日 星期四
國合會2008年長期海外志工招募公告
Q: 這是什麼?
A: 朋友轉來的信件,她已經出去流浪一年了
Q: 這跟這門課沒關係吧?
A: 這裡我最大
Q: %$&#@*&!
A: 什麼? 我沒聽清楚?
Q: 為什麼想要貼在這裡?
A: 純粹是不曉得要轉寄給誰,請你們幫忙轉寄一下順便也讓你們了解到有一些人過的日子跟妳們不太一樣,也許你也可以透過這種方法讓你的生命更加開闊。
加點料:http://blog.dcview.com.tw/article.php?a=BDNQNARi (這是盜連)
(以下本文)
------------------------------------------------------
您好:
財團法人國際合作發展基金會將於97年4月1日起開始招募「2008年長期海外志工」,由於您之前已填寫過報名表,因此我們另發此信給您,如果您有意願參與本年度的長期志工派遣計畫,請在4月30日前將甄選意願調查表填妥後,以:(1)傳真-(02)2876-6433;(2)電子郵件tov@icdf.org.tw;(3)郵寄-台北市天母西路62巷9號13樓等方式回覆,謝謝您。
國合會海外服務工作團「2008年長期志工」甄選意願調查表
l2008年長期志工相關作業預定時程:
4月01日~4月30日接受報名
5年01月~5月14日第一階段書面審核
5月15日~5月17日寄發第二階段甄試通知書
5月19日~5月25日擇期辦理第二階段筆試與口試
5月26日~6月06日公布錄取名單並辦理錄取說明會
6月29日~7月25日國內專業暨語言訓練
8月5日 啟程赴任
註:作業時程僅為暫訂,本會保留變動作業時程之權利。
l 聯絡電話:
陳珏吟 小姐/電話:(02)2876-8112
顏銘宏 先生/電話:(02)2876-8112
相關訊息請參考:
http://www.icdf.org.tw/chinese/c_index_news_content.asp?m001_id=467&m001_version=1
2008年3月26日 星期三
動態指標鏈結(Scheduler)
(尚未完工,持續增補中)
附上另外一個以前寫的程式,沒有使用template應該比較容易看懂,相對的擴展性較差
http://hunghuan.liu.googlepages.com/DynamicQueue.h
2008年3月25日 星期二
2008年3月22日 星期六
2008年3月20日 星期四
實驗十 無線網路效能分析探討(二) AdHoc網路路由協定效能分析
目前常用的無線網路路由協定有:DSDV, AODV, DSR三種。效能評估的參數為:
1. 封包送達的比率 (Packet delivery faction)
2. 封包平均延遲時間 (Average end-to-end delay of data packet)
3. 第一個封包收到的時間
Note: 這個實驗的內容與程式碼主要來自於CMU的Monarch project: Wireless and Mobility Extensions to ns-2。更詳細的參考資料在ns manual的Chapter 16
工具程式:
1. cbrgen: 是可以用來產生所需要的TCP flow或是CBR flow的Tcl Script產生器,程式位址於 ~/ns-allinone-2.29/ns2.29/indep-utils/cmu-scan-gen/cbrgen.tcl
語法:ns cbrgen.tcl [-type cbrtcp] [-nn nodes] [-seed seed][-mc connections] [-rate rate]
(用法課本上有,不贅述)
測試一下
$ns cbrgen.tcl -type cbr -nn 5 -seed 1 -mc 2 -rate 10.0 > cbr_n5_m2_r10
(ps: 課本上面的指令有一點錯誤,少了上面紅色的部分。綠色部分型態是浮點數所以要加上小數點與後面的0才不會被誤判為整數。如果不小心寫成10(整數)程式還是會執行,也會有結果產出,不過是錯誤的結果。漸漸地,在後段的學習中需要學習由結果的分析判斷模擬過程是否有錯誤的產生)。
結果
cbr_n5_m2_r10
仔細去看一下與範例所顯示的有一點不同,看起來是課本放錯範例圖了。
2. setdest: 用來產生隨機的無線網路節點的移動劇本。程式位址於 ~/ns-allinone-2.29/ns2.29/indep-utils/cmu-scan-gen/setdest目錄下。在早期的版本中使用前需要先用make產生執行檔,不過2.29版好像不需要這個步驟。
setdest命令格式如下: ./setdest -n
參數定義如下(參數的順序不重要):
-n num_of_nodes 的值指定了場景中總共有多少個節點。
-p pausetime 指定了節點運動到一個目的地後停留的時間,如果設為0,則節點不停留。
-s maxspeed 指定了節點隨機運動速度的最大值,單位是(m/s),節點的運動速度將在[0,maxspeed]中隨機選擇。
-t simtine 指定了類比場景持續的時間(單位為s)
-x maxx 指定節點運動區域的長度(x軸方向,單位為m)
-y maxy 指定節點運動區域的寬度(y軸方向,單位為m)
>
測試
$ ./setdest -n 2 -p 0.0 -M 20.0 -t 10 -x 300 -y 300 > scen_2n_0p_20M_10t_300_300
(note: 另外有一個參數 -v 可以設定setdest的版本,version 2會多出幾個參數需要給定,可以直接打入 ./setdest 觀看使用說明)
範例一
這個實驗由100個無線節點所組成,模擬時間為100秒,pause time為100秒(這等於靜止不動),使用CBR資料流,最大連線數目10條,每一條flow每秒送出10個封包。
使用cbrgen產生traffic pattern
$ns cbrgen.tcl -type cbr -nn 100 -seed 1 -mc 10 -rate 10.0 > cbr_n100_m10_r10
使用setdest產生無線網路移動場景
./setdest.exe -n 100 -p 100.0 -M 10.0 -t 100 -x 300 -y 300 > scen_100n_100p_10M_100t_300_300
(note: setdest和cbrgen的參數設定需要一致,另外有一些參數是無效的,例如這個實驗中所有的node都是靜止不動的,所以移動速度的設定就沒有影響。)
將所產生的檔案名稱放入book2/lab10/lab10_1.tcl中的適當位置
#設定traffic pattern檔案
set opt(cp) "cbr_n100_m10_r10"
#設定節點移動場景
set opt(sc) "scen_100n_100p_10M_100t_300_300"
然後執行 $ns lab10_1.tcl DSDV (使用DSDV作為路由協定)
大約三分鐘就跑完了,還算很快。看結果

然後再試試 AODV的效能: $ns lab10_1.tcl AODV

DSR: $ns lab10_1.tcl DSR

效能參數都差不多,實驗量太少不足以說明什麼。另外因為網路節點是靜止不動的也沒有錯誤模型被加入以至於在delivery ratio方面都是100%。
範例二
改成移動模型(pause time = 0),然後範圍大一點(500 x 500)其餘皆相同。
./setdest.exe -n 100 -p 0.0 -M 10.0 -t 100 -x 500 -y 500 > scen_100n_0p_10M_100t_500_500
lab10_2.tcl的程式碼與lab10_1.tcl完全相同,除了載入的移動劇本檔案不同以外。
$ns lab10_2.tcl DSDV

$ns lab10_2.tcl AODV

$ns lab10_2.tcl DSR

這裡就可以稍微判定一下,在移動的環境下DSDV表現不如DSR和AODV。
2008年3月19日 星期三
隨機變數的產生
假設我們需要產生一個連續的r. v. X,其具有distribution function F。
F 是嚴格遞增的函數(strictly increasing), i.e., if x1 <= x2, then 0 < F(x1) <= F(x2) <1。
令invF表示 F 的反函數,則產生X的隨機變數的程序為:
1. Generate U ~ U(0, 1)
2. Return X = invF(U)
remark: P(X <= x) = P(invF(U) <= x) = P(U <= F(x)) = F(x)
Examle. Let X have the exponential distribution with mean a. The distribution function is
F(x) = 1 - exp{ -x/a }, if x >= 0; 0, otherwise
so invF(u) = -a.ln(1 - u)
程式碼
Truncated density
考慮一個狀況,我們想要使用程式產生網路封包的大小(size)用來模擬網路的效能,通常可以假設封包的大小是依據exponential distribution。不過網路上的封包不會無限大,也不可能是0,所以需要限定所產生出來封包的上下限。How to do it?
define the truncated density
f*(x) = f(x) / (F(b) - F(a)), if a <= x <= b; 0, otherwise
the corresponding truncated distribution function is
F*(x) = ((F(x) - F(a)) / ((F(b) - F(a)), if a <= x <= b; 0, if x < a; 1, if b < x
The algorithm for generating an X having distribution function F* is as follows:
1. Generate U ~ U(0, 1).
2. Let V = F(a) + [F(b) - F(a)]U.
3. Return X = invF(V)
有兩個問題給你們想想:
1. 經過裁剪以後,mean與variance的改變為何?
2. 為何上述演算法的第三項是X = invF(V) 而不是X = invF*(V)?
NS2中的亂數產生器
NS2目前提供Pareto, Constant, Uniform, Exponential, 和 HyperExponintial分佈,程式碼放在
~/ns-allinone-2.29/ns-2.29/tools目錄下。
NS2中使用的方法:
1. 設定seed
set rng [new RNG]
$rng seed 1
2. 設定分佈
a. Pareto :
set r1 [new RandomVariable/Pareto]
$r1 use-rng $rng
$r1 set avg_ 10.0
$r1 set shape_ 1.2
b. Constant :
set r2 [new RandomVariable/Constant]
$r2 use-rng $rng
$r2 set avg_ 10.0
c. Uniform :
set r3 [new RandomVariable/Uniform]
$r3 use-rng $rng
$r3 set min_ 0.0
$r3 set max_ 10.2
d. Exponential :
set r4 [new RandomVariable/Exponential]
$r4 use-rng $rng
$r4 set avg_ 10.0
e. Hyperexponential :
set r5 [new RandomVariable/HyperExponential]
$r5 use-rng $rng
$r5 set avg_ 1.0
$r5 set cov_ 5.0
實驗九 無線網路效能分析探討(一) 隱藏節點和暴露節點問題
實驗九 無線網路效能分析探討(一) 隱藏節點和暴露節點問題
背景知識
1. 隱藏節點問題
2. 暴露節點問題
傳輸模型(propagation model)與門檻(threshold)
1. Free Space Path Loss

程式碼放在 ~ns/mobile/propagation.h, propagation.cc
2. Two Ray Ground

程式碼放在 ~ns/mobile/tworayground.h, tworayground.cc
3. Shadowing
(in-door) ~ns/mobile/shadowing.h, shadowing.cc
4. Threshold
以上的model基本上可以看成距離的函數 f(d),沒有機率的成份在裡面。
~ns/mac/wireless-phy.h, wireless-phy.cc
實驗步驟
先利用一些獨立的小工具程式來計算模擬所需要的設定參數,這些小工具放在 ~/ns-allinone-2.29/ns-2.29/indep-utils下面。這裡需要用的threshold.cc, threshold.exe在~/ns-allinone-2.29/ns-2.29/indep-utils/propagation目錄下。
先執行一次計算若是有效距離是250公尺的時候需要設定的參數有哪些
./threshold.exe -m TwoRayGround 250

這些結果有一些是需要事先設定的,例如antenna gain and height。還有一些是無關的,例如frequency。所以如果要得到適合的結果需要修改程式內容然後重新編譯。這裡我試試改成frequency = 2.3 GHz, transmit antenna height = 30 m, transmit power = 0.1 W
重新編譯
$g++ -lm threshold.cc -o threshold
然後在計算一次
./threshold.exe -m TwoRayGround 250

就會得到不同的結果了。
後面的實驗照著書跑吧,需要注意的是當你們在做實驗的時候也許會套用現成的模型,這個模型所使用的參數應該需要檢查一下是否符合系統設置的環境,例如:
test_2nodes.tcl中
#天線高度
Antenna/OmniAntenna set Z_ 1.5
#天線增益
Antenna/OmniAntenna set Gt_ 1.0
Antenna/OmniAntenna set Gr_ 1.0
#按照threshold所設定
Phy/WirelessPhy set RXThresh_ 3.652e-10
Phy/WirelessPhy set bandwidth_ 2e6
Phy/WirelessPhy set Pt_ 0.28183815
Phy/WirelessPhy set freq_ 914e+6
Phy/WirelessPhy set L_ 1.0
可以觀察一下有哪些和目前所使用的IEEE 802.11系統參數不同的。
2008年3月18日 星期二
2008年3月15日 星期六
[公告]未發文名單_第四週小計
三位同學現在仍未見到你們發表實驗一
請問是否有blogger操作上的困難
請依課程要求須完成至少10個課本實驗與1個C語言實驗
請大家自行規劃
**勿於期末趕進度一次貼上
2008年3月14日 星期五
實驗五 無線網路封包傳輸遺失模型
- J. P. Ebert, A. Willing, A Gilbert-Elliot Bit Error Model and the Efficient Use in Packet Level Simulation, Technical Report, TKN-99-002, Technical University of Berlin, March 1999.
- H. S. Wand, N. Moayeri, Finite state morkov channel - a useful model for radio communication channel, IEEE Trans. on Vehicular Tech., 44 (1), 163-171, Feb. 1995.
- 如何修改現有的模組,加入自己需要的功能
- 如何設計具有兩個或兩個以上的位址空間的網路
作者直接修改了wireless-phy.cc 和 wireless-phy.h這兩個檔案 (class WirelessPhy),另外一種方式是由WirelessPhy衍生下一個類別,不過如過是這樣做還需要再產生相對應的Otcl linkage, 程序上是比較複雜不過可在用性與程式的擴充性會比較好。
wireless-phy.cc 和 wireless-phy.h這兩個檔案放在C:\cygwin\home\hhliu\ns-allinone-2.29\ns-2.29\mac目錄下,很容易可以找到。目錄下面有保留原始的檔案,可以拿來做比較。
加入的程式碼我可以找到的部分如下(紅色字體部分):
另外關於定址的部分,Tcl程式碼如下:
#若模擬的環境,是單純的有線網路,或無線網路,定址的方是使用flat即可(default設定)
#但是若包含了有線網路和無線網路,則就需要使用hierarchial addressing的方式定址 [ref]
$ns_ node-config -addressType hierarchical
#設定有兩個domain(第一個domain是有線網路,第二個是無線網路)
AddrParams set domain_num_ 2 ; # AddrParams 是類別名稱
# Class AddrParams is used to store the topology hierarchy like number of levels of hierarchy,
# number of areas in each levellike number of domains, number of clusters and number of nodes
# in each cluster.
#每個domain各有一個cluster(每一個domain只包含一個子網路)
lappend cluster_num 1 1
AddrParams set cluster_num_ $cluster_num
#而在第一個domain,其第一個cluster中,只有一個有線網路節點#而在地二個domain,其第一個cluster中,會有兩個無線網路節點,基地台算無線節點
lappend eilastlevel 1 2
AddrParams set nodes_num_ $eilastlevel
這個部份的程式說明還是先擱置,以後再說明。
實驗結果:
Scenario 1.
PG = 0.2, loss-model = 0, comm_type = 0 (multicast)
packet loss ratio = (12350 - 12349) / 12350 = 8.1 e-5, 這個結果和課本呈現的差很多。
再跑一次,結果一樣 =.=?
Scenario 2.
packet loss ratio = (12350 - 12350) / 12350 = 0, ====> 看來問題大了
Scenario 3
packet loss ratio = (12350 - 12350) / 12350 = 0, ====> >.<"
是什麼原因造成的錯誤我先暫時不去debug了,請執行看看如果結果跟我的一樣後續再來抓bug。
2008年3月13日 星期四
2008年3月12日 星期三
實驗四 網路效能量測
- 計算CBR的封包遺失率 (cbr packet loss rate)
- 計算封包延遲時間 (cbr delay)
- 計算抖動率 (jitter)
- UDP吞吐量 (UDP throughput)
- TCP吞吐量 (TCP throughput)
實驗四之二(無線網路)的主題:
- 計算CBR的封包遺失率 (cbr packet loss rate)
- 計算封包延遲時間 (cbr delay)
- 計算抖動率 (jitter)
- 吞吐量 (throughput)
實驗四之一 (有線網路)和實驗二大致相同,可以使用nsBench, NSG2來產生.tcl檔案,或是直接拷貝CD中的範例。
set nd [open out.tr w]
$ns trace-all $nd #這段程式碼開啟一個模擬過程記錄檔,用來記錄封包傳送的過程
NS2所提供的模擬過程記錄檔格式並不是統一的,模擬環境若是全部都是有線的,其紀錄檔格式如下所示:

有線網路環境下的模擬過程記錄檔範例:
+ 0.1 1 2 cbr 1000 ------- 2 1.0 3.1 0 0
#在0.1秒的時候一個cbr資料封包,大小是1000bytes,封包的序號(seq. no.)為0,封包的編號(id.)為0。從node 1傳送出來進入了連結到node 2 的link的queue當中。這個封包屬於資料流2,它的來源端是1.0,表示node 1的第0個port;目的端是3.1,表示node 3的第1個port。
- 0.1 1 2 cbr 1000 ------- 2 1.0 3.1 0 0
+ 0.108 1 2 cbr 1000 ------- 2 1.0 3.1 1 1
- 0.108 1 2 cbr 1000 ------- 2 1.0 3.1 1 1
r 0.114 1 2 cbr 1000 ------- 2 1.0 3.1 0 0
+ 0.114 2 3 cbr 1000 ------- 2 1.0 3.1 0 0
- 0.114 2 3 cbr 1000 ------- 2 1.0 3.1 0 0
通常我們用awk將需要的資料從trace檔案中分離出來,同樣的工具還有grep, seed, perl。perl功能更強大,進階時建議使用。當然也可以用matlab, excel等。
$awk 'AWK程式' 資料檔檔名
然後用gnuplot畫圖,如下:

當然我們也可以用Matlab或是Excel畫圖。

2008年3月11日 星期二
2008年3月10日 星期一
2008年3月9日 星期日
2008年3月8日 星期六
NS Simulator for Beginners
這三篇文件努力把它看完應該可以對NS2的使用有一些了解
認識NS2 (浙江工業大學軟體學院劉世華)
NS Simulator for Beginners
NS by Examples (html) (ps)
其他:
CprE 543x – ns-2 Tutorial (ppt)
AWK Tutorial Guide
Perl
另外一些參考連結:
ns2 tutorial
ns2 Manual (最新的手冊,進階者需要閱讀。419頁)
NS2 教學手冊 ( NS2 Learning Guide) (金門技術學院柯志亨老師的網站)
The Network Simulator - ns-2
2008年3月7日 星期五
2008年3月6日 星期四
2008年3月5日 星期三
2008年3月3日 星期一
實驗二 nsBench and TCL
TCL語法的解釋:(摘錄自 NS by Example)
set ns [new Simulator]: generates an NS simulator object instance, and assigns it to variablens (italics is used for variables and values in this section). What this line does is thefollowing:
• Initialize the packet format (ignore this for now)
• Create a scheduler (default is calendar scheduler)
• Select the default address format (ignore this for now)
The "Simulator" object has member functions that do the following:
• Create compound objects such as nodes and links (described later)
• Connect network component objects created (ex. attach-agent)
• Set network component parameters (mostly for compound objects)
• Create connections between agents (ex. make connection between a "tcp" and "sink")
• Specify NAM display options
• Etc.
Most of member functions are for simulation setup (referred to as plumbing functions in the Overview section) and scheduling, however some of them are for the NAM display. The "Simulator" object member function implementations are located in the "ns-2/tcl/lib/nslib.tcl" file.
$ns color fid color: is to set color of the packets for a flow specified by the flow id (fid). This member function of "Simulator" object is for the NAM display, and has no effect on theactual simulation.
$ns namtrace-all file-descriptor: This member function tells the simulator to record simulation traces in NAM input format. It also gives the file name that the trace will be written to later by the command $ns flush-trace. Similarly, the member function trace-all is for recording the simulation trace in a general format.
proc finish {}: is called after this simulation is over by the command $ns at 5.0 "finish". Inthis function, post-simulation processes are specified.
set n0 [$ns node]: The member function node creates a node. A node in NS is compound object made of address and port classifiers (described in a later section). Users can create a node by separately creating an address and a port classifier objects and connecting them together. However, this member function of Simulator object makes the job easier. To see how a node is created, look at the files: "ns-2/tcl/libs/ns-lib.tcl" and "ns-2/tcl/libs/nsnode.tcl".
$ns duplex-link node1 node2 bandwidth delay queue-type: creates two simplex links of specified bandwidth and delay, and connects the two specified nodes. In NS, the output queue of a node is implemented as a part of a link, therefore users should specify the queue type when creating links. In the above simulation script, DropTail queue is used. If the reader wants to use a RED queue, simply replace the word DropTail with RED. The NS implementation of a link is shown in a later section. Like a node, a link is a compound object, and users can create its sub-objects and connect them and the nodes. Link source codes canbe found in "ns-2/tcl/libs/ns-lib.tcl" and "ns-2/tcl/libs/ns-link.tcl" files. One thing to note is that you can insert error modules in a link component to simulate a lossy link (actually users can make and insert any network objects). Refer to the NS documentation to find out how todo this.
$ns queue-limit node1 node2 number: This line sets the queue limit of the two simplex links that connect node1 and node2 to the number specified. At this point, the authors do not know how many of these kinds of member functions of Simulator objects are available and what they are. Please take a look at "ns-2/tcl/libs/ns-lib.tcl" and "ns-2/tcl/libs/ns-link.tcl", or NS documentation for more information.
$ns duplex-link-op node1 node2 ...: The next couple of lines are used for the NAM display. To see the effects of these lines, users can comment these lines out and try the simulation.
Now that the basic network setup is done, the next thing to do is to setup traffic agents such as TCP and UDP, traffic sources such as FTP and CBR, and attach them to nodes and agents respectively.
set tcp [new Agent/TCP]: This line shows how to create a TCP agent. But in general, users can create any agent or traffic sources in this way. Agents and traffic sources are in fact basic objects (not compound objects), mostly implemented in C++ and linked to OTcl. Therefore, there are no specific Simulator object member functions that create these object instances. To create agents or traffic sources, a user should know the class names these objects (Agent/TCP, Agnet/TCPSink, Application/FTP and so on). This information can be found inthe NS documentation or partly in this documentation. But one shortcut is to look at the "ns-2/tcl/libs/ns-default.tcl" file. This file contains the default configurable parameter value settings for available network objects. Therefore, it works as a good indicator of what kind of network objects are available in NS and what are the configurable parameters.
$ns attach-agent node agent: The attach-agent member function attaches an agent object created to a node object. Actually, what this function does is call the attach member function of specified node, which attaches the given agent to itself. Therefore, a user can do the samething by, for example, $n0 attach $tcp. Similarly, each agent object has a member function attach-agent that attaches a traffic source object to itself.
$ns connect agent1 agent2: After two agents that will communicate with each other arecreated, the next thing is to establish a logical network connection between them. This line establishes a network connection by setting the destination address to each others' network and port address pair.
Assuming that all the network configuration is done, the next thing to do is write a simulation scenario (i.e. simulation scheduling). The Simulator object has many scheduling member functions. However, the one that is mostly used is the following:
$ns at time "string": This member function of a Simulator object makes the scheduler(scheduler_ is the variable that points the scheduler object created by [new Scheduler] command at the beginning of the script) to schedule the execution of the specified string at given simulation time. For example, $ns at 0.1 "$cbr start" will make the scheduler call a start member function of the CBR traffic source object, which starts the CBR to transmit data. In NS, usually a traffic source does not transmit actual data, but it notifies the underlying agent that it has some amount of data to transmit, and the agent, just knowing how much of the data to transfer, creates packets and sends them.
After all network configuration, scheduling and post-simulation procedure specifications are done, the only thing left is to run the simulation. This is done by $ns run.
2008年2月29日 星期五
2008年2月26日 星期二
2008年2月22日 星期五
[公告]實驗心得發表統計
本學期共18週(含期考週),教材裡的實驗共13回
依課程要求須完成至少10個課本實驗與1個C語言實驗
請大家自行規劃,平均非配週數發表實驗心得
**勿於期末趕進度一次貼上
對統計數據有問題回應於本文,謝謝
A詳細且課外補充 B按部就班 C一行文 D只有畫面 E無法完成實驗
A超前 B一般進度 C落後一週 D落後兩週 E落後三周以上
張佑任 電子碩一 9676050 clarkboy.ren@gmail.com
第一週:未發表
第二週:未發表
第三週:實驗一AB
第四週:未發表
第五週:未發表
第六週:未發表
第七週(春假):實驗二BE,實驗三AD
第八週:未發表
第九週:實驗四BD,實驗五AC
第十週(期中考):未發表
第十一週:實驗九AA
第十二週:未發表
第十三週:未發表
第十四週:實驗十AB
第十五週:未發表
第十六週:未發表
第十七週:實驗六BE,實驗七AE,實驗八BE
第十八週:
C程式作業:
NS2技能自我檢視作業:已上傳
總篇數:10
蔡士楷 電子碩一 9676006 sky.tsai@gmail.com
第一週:實驗一BA
第二週:未發表
第三週:未發表
第四週:實驗二BB,實驗三
第五週:未發表
第六週:未發表
第七週(春假):未發表
第八週:實驗四BC,實驗五BB,實驗六BA,實驗七BA,實驗八BA
第九週:未發表
第十週(期中考):未發表
第十一週:實驗九BA
第十二週:未發表
第十三週:未發表
第十四週:未發表
第十五週:未發表
第十六週:實驗十BD
第十七週:實驗十一BD,實驗十二BC,實驗十三BB
第十八週:
C程式作業:已上傳
NS2技能自我檢視作業:已上傳
總篇數:13-->破台了
馬瑱賢 電子四乙 9326245 mstjsw@gmail.com
第一週:未發表
第二週:未發表
第三週:實驗一BB
第四週:未發表
第五週:未發表
第六週:實驗二CD,實驗三CC
第七週(春假):未發表
第八週:未發表
第九週:實驗四BD
第十週(期中考):未發表
第十一週:未發表
第十二週:實驗五BE
第十三週:未發表
第十四週:實驗七CE,實驗八ED,實驗九EC
第十五週:未發表
第十六週:未發表
第十七週:實驗十BE,實驗十一BD
第十八週:
C程式作業:已上傳
NS2技能自我檢視作業:已上傳
總篇數:10
朱衍印 電子四甲 9326149 yenyinchu@gmail.com
第一週:未發表
第二週:實驗一AA
第三週:未發表
第四週:實驗二BB,實驗三BA,實驗四BA
第五週:未發表
第六週:實驗五BA
第七週(春假):實驗六BA,實驗七BA,實驗八BA
第八週:未發表
第九週:未發表
第十週(期中考):未發表
第十一週:實驗九AA
第十二週:實驗十AA,實驗十一BA
第十三週:未發表
第十四週:未發表
第十五週:未發表
第十六週:未發表
第十七週:未發表
第十八週:
C程式作業:已上傳
NS2技能自我檢視作業:已上傳
總篇數:11
賴靖雯 電子三甲 9426111 M.0n.88key@gmail.com
第一週:未發表
第二週:未發表
第三週:未發表
第四週:未發表
第五週:未發表
第六週:未發表
第七週(春假):未發表
第八週:實驗一BE
第九週:未發表
第十週(期中考):未發表
第十一週:未發表
第十二週:實驗二BE
第十三週:未發表
第十四週:實驗三BE,實驗四BE,實驗五BE,實驗六BE
第十五週:未發表
第十六週:實驗七CE,實驗八BE,實驗九BE
第十七週:實驗十DE,實驗十一DD
第十八週:
C程式作業:已上傳
NS2技能自我檢視作業:已上傳
總篇數:11
彭書敏 電子四乙 9326227 sumine40@hotmail.com
第一週:未發表
第二週:未發表
第三週:未發表
第四週:未發表
第五週:未發表
第六週:實驗一BE,實驗二BD
第七週(春假):未發表
第八週:未發表
第九週:未發表
第十週(期中考):未發表
第十一週:實驗三BE
第十二週:未發表
第十三週:未發表
第十四週:實驗四BE,實驗五BE,實驗六BE,實驗七CE,實驗八BD,實驗九BC,實驗十BB
第十五週:未發表
第十六週:未發表
第十七週:未發表
第十八週:
C程式作業:
NS2技能自我檢視作業:
總篇數:10
葉友綸 電子四乙 9326259 s9326259@gmail.com
第一週:未發表
第二週:未發表
第三週:未發表
第四週:實驗一BC
第五週:未發表
第六週:實驗二DD
第七週(春假):未發表
第八週:實驗三CD
第九週:未發表
第十週(期中考):未發表
第十一週:未發表
第十二週:未發表
第十三週:實驗四BE,實驗五BE,實驗六BE
第十四週:未發表
第十五週:未發表
第十六週:未發表
第十七週:實驗七CE,實驗八CE,實驗九BE,實驗十CE
第十八週:
C程式作業:已上傳
NS2技能自我檢視作業:已上傳
總篇數:10
彭治平 電子四乙 9326253 daisuke99blog@gmail.com
第一週:未發表
第二週:未發表
第三週:實驗一BB
第四週:實驗二BB,實驗三BA
第五週:實驗四BA,實驗五CA
第六週:未發表
第七週(春假):未發表
第八週:實驗六BA,實驗七CA,實驗八CA
第九週:未發表
第十週(期中考):未發表
第十一週:未發表
第十二週:未發表
第十三週:實驗九BB,實驗十BA
第十四週:未發表
第十五週:實驗十一CB
第十六週:未發表
第十七週:未發表
第十八週:
C程式作業:已上傳
NS2技能自我檢視作業:已上傳
總篇數:11
阮文正 電子碩一 9676049 allenroan@hotmail.com
第一週:未發表
第二週:實驗一AA
第三週:未發表
第四週:實驗二AB,實驗三AA
第五週:未發表
第六週:實驗四AB
第七週(春假):未發表
第八週:實驗五BB
第九週:實驗六AB
第十週(期中考):未發表
第十一週:實驗七AB,實驗八AA
第十二週:實驗九AA,實驗十AA
第十三週:未發表
第十四週:未發表
第十五週:未發表
第十六週:未發表
第十七週:未發表
第十八週:
C程式作業:已上傳
NS2技能自我檢視作業:已上傳
總篇數:10
鍾昱宏 電子三甲 9426135 s9426135@cycu.edu.tw
第一週:未發表
第二週:未發表
第三週:實驗一BA
第四週:未發表
第五週:實驗二CC
第六週:未發表
第七週(春假):未發表
第八週:未發表
第九週:未發表
第十週(期中考):未發表
第十一週:未發表
第十二週:未發表
第十三週:實驗三BE,實驗五BE,實驗六BE
第十四週:實驗七BE,實驗八BD
第十五週:實驗九BD,實驗十BC,實驗十二CA
第十六週:未發表
第十七週:未發表
第十八週:
C程式作業:已上傳
NS2技能自我檢視作業:已上傳
總篇數:10
塗智宇 電機三甲 9428122 jackers3712@gmail.com
第一週:未發表
第二週:未發表
第三週:未發表
第四週:未發表
第五週:實驗一BD
第六週:實驗二CD,實驗三BC
第七週(春假):未發表
第八週:未發表
第九週:實驗四BD,實驗五BC
第十週(期中考):未發表
第十一週:實驗六BC,實驗七CB
第十二週:未發表
第十三週:未發表
第十四週:實驗八BD,實驗九BC,實驗十CB,實驗十一CA
第十五週:未發表
第十六週:未發表
第十七週:未發表
第十八週:
C程式作業:已上傳
NS2技能自我檢視作業:已上傳
總篇數:11
葉育辰 電機三甲 9428132 uncleyeh@hotmail.com
第一週:未發表
第二週:未發表
第三週:未發表
第四週:實驗一BC,實驗二AB,實驗三BB
第五週:實驗四AA,實驗五BA
第六週:未發表
第七週(春假):未發表
第八週:實驗九BA
第九週:實驗六BB
第十週(期中考):未發表
第十一週:實驗七BB,實驗八BA,實驗十CA
第十二週:實驗十一CA
第十三週:未發表
第十四週:未發表
第十五週:未發表
第十六週:未發表
第十七週:未發表
第十八週:
C程式作業:已上傳
NS2技能自我檢視作業:已上傳
總篇數:11
李承翰 電子三甲 9426136 s9426136@cycu.edu.tw
第一週:未發表
第二週:未發表
第三週:實驗一BB
第四週:實驗二CB
第五週:未發表
第六週:未發表
第七週(春假):未發表
第八週:未發表
第九週:未發表
第十週(期中考):未發表
第十一週:未發表
第十二週:未發表
第十三週:實驗三CE
第十四週:未發表
第十五週:未發表
第十六週:實驗四CE,實驗五CE,實驗六CE,實驗八CE,實驗九CE,實驗十CD
第十七週:實驗七CE
第十八週:
C程式作業:
NS2技能自我檢視作業:已上傳
總篇數:10
邱顯昌 電子四丙 9326362 kaoti520@yahoo.com.tw
第一週:未發表
第二週:未發表
第三週:未發表
第四週:實驗一BC
第五週:實驗二BC
第六週:未發表
第七週(春假):未發表
第八週:未發表
第九週:未發表
第十週(期中考):未發表
第十一週:未發表
第十二週:實驗三CE
第十三週:未發表
第十四週:未發表
第十五週:實驗四BE,實驗五BE,實驗六BE
第十六週:實驗七CE,實驗八CE
第十七週:實驗九CE,實驗十AE
第十八週:
C程式作業:
NS2技能自我檢視作業:
總篇數:10
陳永儒 電子碩一 9676044 balabalaboo69@hotmail.com
第一週:未發表
第二週:未發表
第三週:未發表
第四週:實驗一BC,實驗二BB
第五週:實驗三BB,實驗四BA
第六週:實驗五BA
第七週(春假):未發表
第八週:實驗九BA
第九週:實驗六BB,實驗七CA
第十週(期中考):實驗八BA
第十一週:未發表
第十二週:未發表
第十三週:未發表
第十四週:實驗十BB,實驗十一BA
第十五週:未發表
第十六週:未發表
第十七週:未發表
第十八週:
C程式作業:已上傳
NS2技能自我檢視作業:已上傳
總篇數:11
ps.若於期末才一次貼上由"張貼週"所統計的變異數會很低所以成績也可能很低!!









