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

📄 throughput.awk

📁 ns2中的trace分析脚本
💻 AWK
字号:
# ======================================================================
#
#     Simulation Goal     : Link Throughput
#     Simulation Topology : Chain
#     Trace type          : Normal trace
#
# ======================================================================

# ======================================================================
#                       Measure Link Throughput 
# ======================================================================

BEGIN {
	total_pkt_size_0 = 0;
	sim_time = 0;
	packet_size = 0;
}
{
	# field parameters of normal trace
	event           = $1;     #; Event : r , s , d , f
	time            = $2;     #; Time : send time , receive time , drop time
	node            = $3;     #; Node : source node , receive node
	trace_type      = $4;     #; Trace type MAC trace
	error_state     = $5;     #; Error state : DUP , ERR , RET , STA , BSY , TTL , CBK
	pkt_id          = $6;     #; Event ID : Frame sequence number for total flows
	pkt_type        = $7;     #; Packet type : RTS , CTS , Data = cbr , ACK
	pkt_size        = $8;     #; Packet size (unit : bytes)
	
	# pick the part of number among "node" variables
	node = substr ( node, 2, length(node) - 2 );
	
	if (event == "r"){
		end_node = $14 - 1; 
		packet_size = $12;
	}
	


	# === flow 0 throughput ===
#node == end_node 
	if ( event == "r" && node == end_node && pkt_type == "cbr" ) {
		total_pkt_size_0 = total_pkt_size_0 + pkt_size;
	}
	
	sim_time = time;
}
END {
	throughput_0 = total_pkt_size_0 * 8 / ( sim_time * 1000000 );
	printf ( "%d %f\n", packet_size, throughput_0);
}

⌨️ 快捷键说明

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