2007/12/11

NS2 快速入門: DV-distance 模擬 (2)

第一個可正常使用 DSR, DSDV, AODV Routing 的 Wireless Simulation

參考 ns-2/tcl/test/test-suite-WLtutorial.tcl
參考網址 http://www.net.c.dendai.ac.jp/~yuuki/

如果要使用 DSDV

記得 Application 啟動的時間要比較晚

因為 DSDV 要建立好 routing table

花的時間比較久

routing-test.tcl
[code]
#===================================
# Simulation parameters setup
#===================================
set opt(chan) Channel/WirelessChannel ;# channel type
set opt(prop) Propagation/TwoRayGround ;# radio-propagation model
set opt(netif) Phy/WirelessPhy ;# network interface type
set opt(mac) Mac/802_11 ;# MAC type
set opt(ifq) Queue/DropTail/PriQueue ;# interface queue type
set opt(ll) LL ;# link layer type
set opt(ant) Antenna/OmniAntenna ;# antenna model
set opt(ifqlen) 50 ;# max packet in ifq
set opt(nn) 20 ;# number of mobilenodes
set opt(rp) DSDV ;# routing protocol
set opt(x) 700 ;# X dimension of topography
set opt(y) 550 ;# Y dimension of topography
set opt(stop) 150.0 ;# time of simulation end
set opt(cp) "cbr-test.tcl"
set opt(sc) "scen-test.tcl"

#===================================
# Initialization
#===================================

# Create a ns simulator
set ns [new Simulator]

# Setup topography object
set topo [new Topography]
$topo load_flatgrid $opt(x) $opt(y)
set god [create-god $opt(nn)]

# Open the NS trace file
$ns use-newtrace
set tracefile [open out.tr w]
$ns trace-all $tracefile

# Open the NAM trace file
set namfile [open out.nam w]
$ns namtrace-all $namfile
$ns namtrace-all-wireless $namfile $opt(x) $opt(y)

#===================================
# Mobile node parameter setup
#===================================
if {$opt(rp) == "DSR"} {
set opt(ifq) CMUPriQueue
} else {
set opt(ifq) Queue/DropTail/PriQueue
}

$ns node-config -adhocRouting $opt(rp) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
-channel [new $opt(chan)] \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace ON

#===================================
# Nodes Definition
#===================================

# Create 20 nodes
for {set i 0} {$i < $opt(nn)} {incr i} {
set node($i) [$ns node]
$node($i) random-motion 0
}

puts "Loading scenario file..."
source $opt(sc)

for {set i 0} {$i < $opt(nn)} {incr i} {
$ns initial_node_pos $node($i) 20
}

#===================================
# Agents & Applications Definition
#===================================

puts "Loading connection pattern..."
source $opt(cp)

#===================================
# Termination
#===================================

# Define a 'finish' procedure
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile

puts "running nam..."
exec nam out.nam &
exit 0
}
for {set i 0} {$i < $opt(nn)} {incr i} {
$ns at $opt(stop) "$node($i) reset"
}
$ns at $opt(stop) "$ns nam-end-wireless $opt(stop)"
$ns at $opt(stop) "finish"
$ns at $opt(stop) "puts \"done\" ; $ns halt"

puts "Starting Simulation..."
$ns run
[/code]

cbr-test.tcl
[code]
#===================================
# Agents Definition
#===================================

# Setup a TCP connection
set tcp [new Agent/TCP]
$ns attach-agent $node(15) $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $node(4) $sink
$ns connect $tcp $sink

#===================================
# Applications Definition
#===================================

set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 120.0 "$ftp start"
[/code]

scen-test.tcl
[code]
#===================================
# Nodes Definition
#===================================
set god [God instance]
#$god set-dist 15 16 1 ;# node 15 <--> node 16 : 2 hop
#$god set-dist 16 17 1 ;# node 15 <--> node 17 : 2 hop
#$god set-dist 17 18 1 ;# node 15 <--> node 16 : 2 hop


$node(0) set X_ 0
$node(0) set Y_ 600
$node(0) set Z_ 0.0

$node(1) set X_ 200
$node(1) set Y_ 600
$node(1) set Z_ 0.0

$node(2) set X_ 400
$node(2) set Y_ 600
$node(2) set Z_ 0.0

$node(3) set X_ 600
$node(3) set Y_ 600
$node(3) set Z_ 0.0

$node(4) set X_ 800
$node(4) set Y_ 600
$node(4) set Z_ 0.0

$node(5) set X_ 0
$node(5) set Y_ 400
$node(5) set Z_ 0.0

$node(6) set X_ 200
$node(6) set Y_ 400
$node(6) set Z_ 0.0

$node(7) set X_ 400
$node(7) set Y_ 400
$node(7) set Z_ 0.0

$node(8) set X_ 600
$node(8) set Y_ 400
$node(8) set Z_ 0.0

$node(9) set X_ 800
$node(9) set Y_ 400
$node(9) set Z_ 0.0

$node(10) set X_ 0
$node(10) set Y_ 200
$node(10) set Z_ 0.0

$node(11) set X_ 200
$node(11) set Y_ 200
$node(11) set Z_ 0.0

$node(12) set X_ 400
$node(12) set Y_ 200
$node(12) set Z_ 0.0

$node(13) set X_ 600
$node(13) set Y_ 200
$node(13) set Z_ 0.0

$node(14) set X_ 800
$node(14) set Y_ 200
$node(14) set Z_ 0.0

$node(15) set X_ 0
$node(15) set Y_ 0
$node(15) set Z_ 0.0

$node(16) set X_ 200
$node(16) set Y_ 0
$node(16) set Z_ 0.0

$node(17) set X_ 400
$node(17) set Y_ 0
$node(17) set Z_ 0.0

$node(18) set X_ 600
$node(18) set Y_ 0
$node(18) set Z_ 0.0

$node(19) set X_ 800
$node(19) set Y_ 0
$node(19) set Z_ 0.0
[/code]

2007/12/06

Proxy.pac example

最近常常連不到某些網站

不知道是哪裡擋掉

或是能 login 的連線有限

所以利用跳板就很重要啦 XD

紀錄一下 proxy.pac 的寫法如下:

[code]
function FindProxyForURL(url, host)
{
if (dnsDomainIs(host, "study-area.org"))
return "PROXY proxy.teatime.com.tw:8080";
else if(dnsDomainIs(host, "ieee.org"))
return "PROXY b.com:8080";
else
return "DIRECT";
}
[/code]

2007/12/05

Windows XP 安全性設定

Windows XP 在 "資料夾選項" 取消 "使用簡易檔案共用 (建議使用)" 後

會多出安全性的設定

然而 Windows XP 的安全性控制非常的爛

啟用後常常會出現不能存取某些檔案的怪問題

這裡紀錄最基本的安全性設定

如果安全性跑掉了

就重新照下面的方法設定吧

目前試過暫時還沒遇到問題

ps: 請使用進階設定

C:\ (系統碟) 設定:

[權限]
取消 "從父項繼承套用到子物件的權限項目,包括明確定義於此的項目"

權限項目:
Administrators
- 套用在 "這個資料夾,子資料夾及檔案"
- "完全控制"
- 取消 "套用這些權限到此容器中的物件及(或)容器"
CREATOR OWNER
- 套用在 "只有子資料夾及檔案"
- "完全控制"
- 取消 "套用這些權限到此容器中的物件及(或)容器"
Everyone
- 套用在 "只有這個資料夾"
- "周遊資料夾/執行檔案", "列出資料夾/讀取資料", "讀取屬性", "讀取擴充屬性", "讀取使用權限"
- 取消 "套用這些權限到此容器中的物件及(或)容器"
SYSTEM
- 套用在 "這個資料夾,子資料夾及檔案"
- "完全控制"
- 取消 "套用這些權限到此容器中的物件及(或)容器"
Users
- 套用在 "這個資料夾,子資料夾及檔案"
- "周遊資料夾/執行檔案", "列出資料夾/讀取資料", "讀取屬性", "讀取擴充屬性", "讀取使用權限"
- 取消 "套用這些權限到此容器中的物件及(或)容器"
Users
- 套用在 "這個資料夾及子資料夾"
- "建立資料夾/附加資料"
- 取消 "套用這些權限到此容器中的物件及(或)容器"
Users
- 套用在 "只有子資料夾"
- '建立檔案/寫入資料"
- 取消 "套用這些權限到此容器中的物件及(或)容器"
[擁有者]
Administrators

C:\WINDOWS (Windows 系統檔案目錄,注意若設定出錯,重開機後會無法進入 Windows) 設定:

[權限]
取消 "從父項繼承套用到子物件的權限項目,包括明確定義於此的項目"

權限項目:
Administrators
- 套用在 "這個資料夾,子資料夾及檔案"
- "完全控制"
- 取消 "套用這些權限到此容器中的物件及(或)容器"
CREATOR OWNER
- 套用在 "只有子資料夾及檔案"
- "完全控制"
- 取消 "套用這些權限到此容器中的物件及(或)容器"
Power Users
- 套用在 "這個資料夾,子資料夾及檔案"
- 先選取"完全控制"後,取消"完全控制", "刪除子資料夾及檔案", "變更使用權限", "取得擁有權"
- 取消 "套用這些權限到此容器中的物件及(或)容器"
SYSTEM
- 套用在 "這個資料夾,子資料夾及檔案"
- "完全控制"
- 取消 "套用這些權限到此容器中的物件及(或)容器"
Users
- 套用在 "這個資料夾,子資料夾及檔案"
- "周遊資料夾/執行檔案", "列出資料夾/讀取資料", "讀取屬性", "讀取擴充屬性", "讀取使用權限"
- 取消 "套用這些權限到此容器中的物件及(或)容器"
[擁有者]
Administrators

其他硬碟 (ex: D:\) 設定:

[權限]
取消 "從父項繼承套用到子物件的權限項目,包括明確定義於此的項目"

[權限]
取消 "從父項繼承套用到子物件的權限項目,包括明確定義於此的項目"

權限項目:
Administrators
- 套用在 "這個資料夾,子資料夾及檔案"
- "完全控制"
- 取消 "套用這些權限到此容器中的物件及(或)容器"
CREATOR OWNER
- 套用在 "只有子資料夾及檔案"
- "完全控制"
- 取消 "套用這些權限到此容器中的物件及(或)容器"
Everyone
- 套用在 "這個資料夾,子資料夾及檔案"
- "周遊資料夾/執行檔案", "列出資料夾/讀取資料", "讀取屬性", "讀取擴充屬性", "讀取使用權限"
- 取消 "套用這些權限到此容器中的物件及(或)容器"
SYSTEM
- 套用在 "這個資料夾,子資料夾及檔案"
- "完全控制"
- 取消 "套用這些權限到此容器中的物件及(或)容器"
Users
- 套用在 "這個資料夾,子資料夾及檔案"
- "周遊資料夾/執行檔案", "列出資料夾/讀取資料", "讀取屬性", "讀取擴充屬性", "讀取使用權限"
- 取消 "套用這些權限到此容器中的物件及(或)容器"
Users
- 套用在 "這個資料夾及子資料夾"
- "建立資料夾/附加資料"
- 取消 "套用這些權限到此容器中的物件及(或)容器"
Users
- 套用在 "只有子資料夾"
- '建立檔案/寫入資料"
- 取消 "套用這些權限到此容器中的物件及(或)容器"
[擁有者]
Administrators

Present 的論文內容

明顯有類似 protocol 這類的 paper

不要選實驗、理論推導

看看有沒有類似第一步、第二步 ... 的結構

主要是要融會貫通講精髓

讓大家知道一個流程

如果是用數學 model 來推導

難懂又不好講

著重找到該文主要突破點, 並找出該突迫所以能達成的 smart ideas, key techniques。

結論:
1. What are the important considerations in the special topic of research (與以前從相關論文所得心得相互驗証, 校正, 並總結)?
2. What are the existing approaches for the special topic of research?
3. What are their relative merits (優點) and disadvantages?
4. If this paper has any relative merits, how are they achieved?
5. If the paper has any disadvantages, what are the causes for them?
6. How to avoid such shortages in your proposed approach?
7. If they are unavoidable, what are the reasons for?

2007/12/04

NS2 快速入門: DV-distance 模擬 (1)

寫 Tcl 檔產生節點、座標和設定環境

NS2 快速入門: DV-distance 模擬 (0)

0. 先了解 DV-distance

論文:D. Niculescu and B. Nath. Ad Hoc Positioning System (APS). In Proceedings of IEEE GlobeCom, San Antonio, AZ, November 2001.

定位 protocol,屬於 Application Layer

DV-hop
1. 先使用 distance vector 交換到網路所有 node,以取得到 landmark 的 hop 距離
2. 每個 node 維護一個 table 包含 (X, Y, h) 只從 neighbor 更新,(X, Y) 為 landmark 的位置, h 為 hop count
3. 只要 landmark 收到到其他 landmark 的距離,就估計平均一個 one hop 的距離,接著廣播發佈一個 correction 通知到整個網路
4. 接收到 correction 的節點,會在可以用三角測量時,估計到 landmark 的距離
5. 接收到 correction 的節點,以第一個收到的 correction 為準

每個 landmark 計算 The correction a landmark (Xi, Yi) ci, 一個 hop 的平均距離,以公尺為單位

每個 landmark 知道與其他 landmark 間的 hop count 與 euclidean distance

flooding 時,forward 一個 correction 後,會 drop 隨後的同一個 correction,
以確保每個 node 只會收到一個 correction,從最近的 landmark

可以用封包 TTL 限制一個 node 收到的 landmark 數

DV-distance

和 DV-hop 相同只是與鄰居 node 間的距離用訊號強度而不是 hop count,以公尺為單位
distance vector algorithm 使用訊號強度來累計旅行的距離


1. 要撰寫 NS2 模擬需要了解的步驟


TCL 相關
- 如何產生節點和座標
- 如何使用 protocol

C++ 相關
- 如何產生自訂的 protocol
- C++ 和 TCL 間的關係
- 如何在 NS2 內用個 table (structure)
- 如何從點 A 傳資料到點 B
- 如何從點 A flooding 資料出去
- 如何用 RSSI 估計兩點間的距離
- 如何改封包 TTL 的位置