awk script- delay 계산
참고 : http://www.winlab.rutgers.edu/~zhibinwu/html/ns_trace.html
작성 : 2006.12.17 by 임헌정
http://www.4ellene.net
CMU use a special fomat. Basically, you could
$ns use-newtrace
to generate the new trace and the detailed explanation could be found
in Ns Manual.By default, old trace format is used. We need to analyze
the source code ./trace/cmu-trace.cc to understand it completely.
For instance, the function format_ip will explain the trace of IP part.
void |
A typical trace for a CBR traffic is:
s 20.000000000 _0_ AGT --- 6 cbr 512 [0 0 0 0] ------- [0:0 1:0 32 0]
[0] 0 0
r 20.000000000 _0_ RTR --- 6 cbr 512 [0 0 0 0] ------- [0:0 1:0 32 0]
[0] 0 0
s 20.000000000 _0_ RTR --- 6 cbr 532 [0 0 0 0] ------- [0:0 1:0 32 1]
[0] 0 0
s 20.000275000 _0_ MAC --- 6 cbr 584 [13a 1 0 800] -------
[0:0 1:0 32 1] [0] 0 0
r 20.004947063 _1_ MAC --- 6 cbr 532 [13a 1 0 800] -------
[0:0 1:0 32 1] [0] 1 0
s 20.004957063 _1_ MAC --- 0 ACK 38 [0 0 0 0]
r 20.004972063 _1_ AGT --- 6 cbr 532 [13a 1 0 800] -------
[0:0 1:0 32 1] [0] 1 0
r 20.005261125 _0_ MAC --- 0 ACK 38 [0 0 0 0]
A typical awk code for analyzing traces is:
For a topology involve 4 flows with distinguishing source and
destination nodes,
this awkcode gets throughout data and put in wu.dat file
[예제]
로 delay_throughout.awk 파일 생성
$ awk -f delay_though.awk aodv_3nodes_tcp.tr 실행
# 50~100ms 사이에, 2노드로 수신한 패킷들
BEGIN {counter1 = 0;}
$1~/r/ && $2>50 && $2< 100 && /_2_/ && /AGT/ { counter1 +=
($8- 20)
size = $8 - 20 }
END {
print (size , counter1*8/(50) ) >> "wu.dat"}
$1~/r/ && $2>50 && $2< 100 && /_2_/ && /AGT/ { counter1 +=
($8- 20)
size = $8 - 20 }
END {
print (size , counter1*8/(50) ) >> "wu.dat"}
로 delay_throughout.awk 파일 생성
$ awk -f delay_though.awk aodv_3nodes_tcp.tr 실행
# 50~100ms 사이에, 2노드로 수신한 패킷들
BEGIN {counter1 = 0; counter2 = 0; counter3 = 0; counter4 = 0;} $1~/r/ && $2>50 && $2< 100 && /_12_/ && /AGT/ { counter1 += ($8- 20) size = $8 - 20 } $1~/r/ && $2>50 && $2 <100 && /_13_/ && /AGT/ { counter2 += ($8- 20) size = $8 - 20 } $1~/r/ && $2>50 && $2<100 && /_14_/ && /AGT/ { counter3 += ($8- 20) size = $8 - 20 } $1~/r/ && $2>50 && $2<100 && /_15_/ && /AGT/ { counter4 += ($8- 20) size = $8 - 20 } END { print (size , counter1*8/(50), counter2*8/50, counter3*8/(50), counter4*8/50, (counter1+counter2+counter3+counter4)*8/50 ) >> "wu.dat"} |
To analyze throughout or delay in a finite time duration,
we need extract send and receive time from the trace file
[예제]
$ awk '$2>100 && $2 < 150 && (/_0_/ || /_2_/) && /AGT/ { print
$1, $2, $6 > "dst2.tr" }' aodv_3nodes_tcp.tr
$2>100 && $2 < 150 && (/_6_/ || /_2_/) && /AGT/ { print $1, $2, $6 > "dst2.tr" } $2>100 && $2 <150 && (/_0_/ || /_9_/) && /AGT/ { print $1, $2, $6 > "dst9.tr" } $2>100 && $2 <150 && (/_12_/ || /_3_/) && /AGT/ { print $1, $2, $6 > "dst3.tr" } $2>100 && $2 <150 && (/_10_/ || /_4_/) && /AGT/ { print $1, $2, $6 > "dst4.tr" } $2>100 && $2 <150 && (/_11_/ || /_8_/) && /AGT/ { print $1, $2, $6 > "dst8.tr" } |
The respective new trace files such as "dst2.tr" will keep time, "s'"
or "r" and, "index",
From that we could use a program to calculate the mean of delay.
The files is here:
And to use this C code:
$ gcc delay.c -o delaycal $ ./delaycal dst2.tr wu0.dat wu1.dat |
'Network > Ns2_source' 카테고리의 다른 글
mac의 transmit (0) | 2009.01.17 |
---|---|
awk script- delay 계산 (0) | 2009.01.17 |
멈춰!! 움직이지마!! 움직여!! 빨리 달려!! 달리라고!!!! (0) | 2009.01.17 |
Analysis of 802.11 MAC code in NS-2 (0) | 2009.01.17 |
[ns] Dropping Packets with RTR CBK (0) | 2009.01.17 |