⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eval.awk

📁 code that can compile NS-2.27 on Fedora Core 4
💻 AWK
字号:
#!/bin/gawk# Run the following AWK program on STDIN to analyze the NS2 tracefiles## To calculate packet latency, we need to store the sending time for# each packet, and figure out when the packet is received..## Initialize all variables - is not strictly necessary in AWK, but better style#BEGIN { AGTSEND=0; AGTRECV=0;         MACSEND=0; MACRECV=0; 	MACBYTESEND=0; MACBYTERECV=0;        MACDROP=0; IFQDROP=0; RTRDROP=0; 	CTRLPACK=0; LAT=0.0; MISC=0;      }## deal with individual cases....## easiest: deal with miscellaneous items#$1 == "M" { MISC = MISC + 1 }## deal with AGENT SENT#$1 == "s" && $4 == "AGT" { AGTSEND = AGTSEND + 1; SENT[$3$6] = $2 }## deal with AGENT RECEIVE#$1 == "r" && $4 == "AGT" { AGTRECV = AGTRECV + 1; 	i = index($14,":");	if (i == 3) lookup = "_"substr($14,2,1)"_"$6;		else lookup = "_"substr($14,2,2)"_"$6;	if (SENT[lookup] == 0) print "Oops, no entry for", lookup;	LAT = LAT + $2 - SENT[lookup]; }## deal with MAC SENT#$1 == "s" && $4 == "MAC" { \	  if ($7 == "RTS" || $7 == "CTS" || $7 == "ACK") CTRLPACK = CTRLPACK+1;	  MACSEND = MACSEND+1; 	  MACBYTESEND = MACBYTESEND+$8 	}## deal with MAC RECEIVE#$1 == "r" && $4 == "MAC" { MACRECV = MACRECV+1; MACBYTERECV = MACBYTERECV+$8 }## deal with MAC DROP#$1 == "D" && $4 == "MAC" { MACDROP = MACDROP + 1 }## deal with IFQ DROP#$1 == "D" && $4 == "IFQ" { IFQDROP = IFQDROP + 1 }## deal with RTR DROP#$1 == "D" && $4 == "RTR" { RTRDROP = RTRDROP + 1 }#END { print "AGENT sent:", AGTSEND;      print "AGENT received:", AGTRECV;      print "MAC sent:", MACSEND;      # print "MAC received:", MACRECV;      print "MAC sent (Bytes):", MACBYTESEND;      # print "MAC received (Bytes):", MACBYTERECV;      print "Packet latency:", LAT;      print "MAC control packets:", CTRLPACK;      print "MAC dropped:", MACDROP;      print "IFQ dropped:", IFQDROP;      print "RTR dropped:", RTRDROP;      print "MISC lines:", MISC;      print "Total:", AGTSEND+AGTRECV+MACSEND+MACRECV+MACDROP+IFQDROP+RTRDROP+MISC," linecount:", NR;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -