📄 wlan-chutil-new
字号:
#!/bin/tcsh## Channel utilization:# works on a trace file produced by ns# outputs idle time and the collision time on the channel between# the first and the (possibly unfinished) last transmission# for now: assumes that all MACs are on a single channelif ( $#argv != 2) then echo usage: echo " " $0 \<scenario\> \<flow id\> exit 1endifset scenario = $1set flow = $2set tracefile = $scenario.trset outfile = $scenario.channelrm -f $outfile##############################lamia###########set nbr_send = `egrep "^s.*\-Nl MAC.*\-If $flow" scen_2.tcl.tr | wc -l`set nbr_recv = `egrep "^r.*\-Nl MAC.*\-If $flow" scen_2.tcl.tr | wc -l` @ collisions = $nbr_send - $nbr_recvecho $collisions#egrep "\-Nl MAC.*\-If $flow" $tracefile > collision$flow.dategrep "\-Nl MAC " $tracefile > collision$flow.dat#egrep "\-Nl MAC " $tracefile | gawk -v busy=0 -v outf=$outfile '\gawk -v busy=0 -v outf=$outfile '\/s/ { \ if (busy == 0) { \ if (last_eot != 0) { \ idle += ($3 - last_eot); \ } else { \ first_send = $3; \ } \ } \ if (busy == 1) { \ start_collision = $3; \ ++collisions; \ } \ print $3, busy >> outf; \ ++busy; \ print $3, busy >> outf; \} \/^x/ { \ print $3, busy >> outf; \ --busy; \ print $3, busy >> outf; \ if (busy < 0) { \ print "Fatal Error: EOT without send"; \ } \ if (busy == 1 ) { \ collision += ($3 - start_collision); \ } \ if (busy == 0) { \ last_eot = $3; \ ++total; \ } \} \END { \ if (busy > 1 ) { \ collision += ($3 - start_collision); \ } \ printf "Total time = %13.9f (%d)\n", ($3 - first_send), total; \ printf "Idle time = %13.9f \n", idle; \ printf "Collision time = %13.9f (%d)\n", collision, collisions; \}' collision$flow.dat
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -