Wednesday, November 24, 2010
The corresponding variable in OTCL node class of protocols in NS2
$ns_ node-config -adhocRouting $opt(adhocRouting) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
-agentTrace OFF \
-routerTrace ON \
-macTrace ON\
-topoInstance $topo\
-energyModel $opt(energy)\
-txPower $opt(txpower)\
-rxPower $opt(rxpower)\
-initialEnergy $opt(initialenergy)\
-idlePower $opt(idlepower)\
-channel $chan_1_ \
-movementTrace OFF
Then, for each node, the instance of declared protocols is generated. Accrodingly, a corresponding variable in OTCL class Node is bound to the instance.
Sometimes, we need to setup the attribute of the protocol on each node individually. In this case, we should access the corresponding variable of the protocol. For example, we access routing protocol instance using
set rt [$node_($i) set ragent_]
then, we can use $rt to call the command designed for the routing protocol or set its C++ variables.
Following are some otcl variables in class Node
arptable_
nifs_ #number of interfaces
netif_
mac_
ifq_
ll_
imep_
For each of the last 5 variables, we totally have nifs_ elements. Thus, we should use index to specify which interface it is on. For example, we use the following command to access the mac protocol object on the first interface.
set mac [$node_($i) set mac_(0)]
Wednesday, November 10, 2010
[zz]vi 技巧
VIM TIPS
1. 词自动补全:
2. 行自动补全:
3. 文件名自动补全:
4. 搜索的正则表达式:
\ 取消后面所跟字符的特殊含义。比如 \[vim\] 匹配字符串“[vim]”
[] 匹配其中之一。比如 [vim] 匹配字母“v”、“i”或者“m”,[a-zA-Z] 匹配任意字母
[^] 匹配非其中之一。比如 [^vim] 匹配除字母“v”、“i”和“m”之外的所有字符
. 匹配任意字符
* 匹配前一字符大于等于零遍。比如 vi*m 匹配“vm”、“vim”、“viim”……
\+ 匹配前一字符大于等于一遍。比如 vi\+m 匹配“vim”、“viim”、“viiim”……
\? 匹配前一字符零遍或者一遍。比如 vi\?m 匹配“vm”或者“vim”
^ 匹配行首。例如 /^hello 查找出现在行首的单词 hello
$ 匹配行末。例如 /hello$ 查找出现在行末的单词 hello
\(\) 括住某段正规表达式
\数字 重复匹配前面某段括住的表达式。例如 \(hello\).*\1 匹配一个开始和末尾都是“hello”,中间是任意字符串的字符串
对于替换字符串,可以用“&”代表整个搜索字符串,或者用“\数字”代表搜索字符串中的某段括住的表达式。
5. 替换1,3s/pattern/replace/gc
1,3表示从第一行到第3行,可以用.,$表示当前行到文件末尾,可以用%表示当前行
s表示替换
pattern表示要替换的模式(可以是正则)
replace表示要使用的替换文本;
g表示全局,会在替换一个后替换下一个
c表示确认,再替换每一个时提示确认信息
6.替换中:可用v选中一个区域,使用’<和’>分别代表区域开始和结束
7.替换中,可用\zs和\ze分别表示匹配由此开始和匹配到此结束;\=表示后面是一个表达式,可以使用printf等方法,来根据匹配到的串计算值;
line()方法用来获取行号,如line(“.”)表示当前行,line(“‘<”)表示选中的第一行行号
submatch(0) == \0
|可用于分隔多条命令
g/str1/s//str2/ 表示对于匹配“str1”的所有串,执行后面的命令(g的作用,后面命令指s替换),s省略匹配串,表示使用前面g命令的匹配串,str2表示替换为str2
8. f@表示在该行向后调到第一个‘@’字符处,F@是向左跳转
9. [{向前跳转到第一个{ ]}是像后跳转到第一个}
10. v|c|d i|a { | [ | ” | ‘ 实现块级编辑
如在
{
aaaaaaaaaa
}
的aaa这行出按下vi{将选中aaa这一行,如果是va{则表示选中包含左右大括号和aaa那一行的三行
待补充。。。
read file in shell
s 1 3 0 1095738.816916 120
s 1 3 1 1095777.816447 120
s 1 3 2 1095839.816783 120
s 1 3 3 1095849.817093 120
s 1 3 4 1095889.817398 120
s 1 3 5 1095890.817669 120
s 1 3 6 1095894.817986 120
s 1 3 7 1095993.818285 120
s 1 3 8 1096094.818604 120
s 1 3 9 1096112.818891 120
s 1 3 10 1096138.819238 121
s 1 3 11 1096177.819493 121
s 1 3 12 1096185.819823 121
s 1 3 13 1096249.820129 121
s 1 3 14 1096296.820428 121
s 1 3 15 1096302.820737 121
r 1 3 0 1095793.176704 120
r 1 3 1 1095924.886250 120
r 1 3 2 1096002.680910 120
r 1 3 3 1096038.632938 120
r 1 3 4 1096074.528630 120
r 1 3 5 1096188.276739 120
r 1 3 6 1096248.133086 120
r 1 3 7 1096272.128736 120
r 1 3 8 1096319.986210 120
$ cat ./tmp.data | while read a b c d e f; do echo $a $b $c $d ; done
1 3 0
1 3 1
1 3 2
1 3 3
1 3 4
1 3 5
1 3 6
1 3 7
1 3 8
1 3 9
1 3 10
1 3 11
1 3 12
1 3 13
1 3 14
1 3 15
1 3 0
1 3 1
1 3 2
1 3 3
1 3 4
1 3 5
1 3 6
1 3 7
1 3 8