2008/08/02

gvim: fatal IO error 104

Problem:
gvim: Fatal IO error 104 (Connection reset by peer) on X server 127.0.0.1:0.0.

Solution:
Try to run through "gvim --nofork &"

2008/07/20

2008/07/12

NS2 Energy Model

在 ns2 中套用有 energy 限制的環境方法如下

使用舊的 trace format 則可以看到

[energy 979.917000 ei 20.074 es 0.000 et 0.003 er 0.006]

這種 trace log

分別代表

energy: total remaining energy
ei: energy consumption in IDLE state
es: energy consumption in SLEEP state
et: energy consumed in transmitting packets
er: energy consumed in receiving packets

[code]
# ...

set opt(energymodel) EnergyModel ;# EnergyModel type
set opt(initenergy) 1.0 ;# Initial Energy, specified in Joules
set opt(rP) 1.0 ;# Receiving Power, specified in Watts
set opt(tP) 1.1 ;# Transmitting Power, specified in Watts
set opt(iP) 0.01 ;# Idle Power, specified in Watts
set opt(sP) 0.001 ;# Sleep Power, specified in Watts
set opt(transP) 0.2 ;# Transition Power, specified in Watts
set opt(transT) 0.005 ;# Transition Time, specified in Seconds

# ...

#$ns use-newtrace

# ...

$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 \
-energyModel $opt(energymodel) \
-initialEnergy $opt(initenergy) \
-rxPower $opt(rP) \
-txPower $opt(tP) \
-idlePower $opt(iP) \
-sleepPower $opt(sP) \
-transitionPower $opt(transP) \
-transitionTime $opt(transT)

# ...
[/code]

2008/07/11

Change wireless color as in wire network

Reference: http://mailman.isi.edu/pipermail/ns-users/2002-May/023058.html?

NS2 Wireless Simulation 中要讓 node 有顏色

只能用下面這種方法

[code]
# ...

# let the node has a color property
$node($i) color black

# change the color during animation
$ns at 0.0 "$node($i) color green"

# ...
[/code]



如果設定 node 的 label-color 會讓 node 的位置變成 (0, 0)



如果想要兩 node 間有線(ex: node 1, 2 之間)

在 tcl 檔內可以用下面這種方法

[code]$ns puts-nam-traceall "l -t * -s 1 -d 2 -c RoyalBlue -S COLOR"

$ns at 0.3 "$ns puts-nam-traceall \"l -t 0.30000000000000 -s 1 -d 2 -c blue -S COLOR\""
$ns at 0.4 "$ns puts-nam-traceall \"l -t 0.40000000000000 -s 1 -d 2 -c red -S COLOR\""
$ns at 0.5 "$ns puts-nam-traceall \"l -t 0.50000000000000 -s 1 -d 2 -S out\""
$ns at 0.6 "$ns puts-nam-traceall \"l -t 0.60000000000000 -s 1 -d 2 -c blue -S COLOR\""
$ns at 0.7 "$ns puts-nam-traceall \"l -t 0.70000000000000 -s 1 -d 2 -c red -S COLOR\""
$ns at 0.8 "$ns puts-nam-traceall \"l -t 0.80000000000000 -s 1 -d 2 -S out\""
[/code]

或是寫在 Agent 用下面這種方法

[cpp]Tcl::instance().evalf("[Simulator instance] puts-nam-traceall \"l -t "TIME_FORMAT" -s %d -d %d -c %s -S COLOR\"", Scheduler::instance().clock(), 1, 2, "blue");[cpp]

其他可以使用的顏色請參考 /usr/lib/X11/rgb.txt 檔案

關於 nam 讀取的格式,可以在 X window 的環境下
用 nam -p 指令查詢

如果想要用 man 查詢 nam 請將 nam.1 複製到 /usr/man/man1
ex: cp ~/ns-allinone-2.33/nam-1.13/nam.1 /usr/man/man1/