我编写了以下awk脚本来计算NS2.35中路由协议的平均吞吐量。下面给出了我的示例代码。
BEGIN {
recvdSize = 0
startTime = 400
stopTime = 0
}
{
event = $1
time = $2
node_id = $3
pkt_size = $8
level = $4
# Store start time
if (level == "AGT" && event == "s" && pkt_size >= 512) {
if (time < startTime) {
startTime = time
}
}
# Update total received packets' size and store packets arrival time
if (level == "AGT" && event == "r" && pkt_size >= 512) {
if (time > stopTime) {
stopTime = time
}
# Rip off the header
#hdr_size = pkt_size % 512
#pkt_size -= hdr_size
# Store received packet's size
recvdSize += pkt_size
}
}
END {
printf("Average Throughput[kbps] = %.2f\t\t StartTime=%.2f\tStopTime=%.2f\n",(recvdSize/(stopTime-startTime))*(8/1000),startTime,stopTime)
}现在,我只想计算CBR数据包()的吞吐量以及平均吞吐量,并显示它。我需要添加到代码中的其他东西是什么?
发布于 2015-11-21 18:51:40
您可以尝试读取ns2的其他默认吞吐量脚本:awk#perl#python__scripts-10.2015.tar.gz中大约有22个thr*.awk文件,还有一些perl脚本thr*.pl:$ ls | grep -i thr。
链接https://drive.google.com/file/d/0B7S255p3kFXNOUIteTVSWjdzQU0/view?usp=sharing
包中的专用tcp脚本是calc_tcp_goodput.awk、show_tcp_con、show_tcp_con.awk。
发布于 2015-11-23 07:06:46
throughput.awk
开始{
recvdSize = 0
startTime = 400
stopTime = 0}
{
event = $1
time = $2
node_id = $3
pkt_size = $8
level = $4存储启动时间
if (级别为"MAC“& == == "s”& pkt_size >= 300) {
if (time < startTime) {
startTime = time
}
}更新接收到的数据包的大小和存储数据包到达时间
if ( ==级"MAC“& ==事件"r”& pkt_size >= 300) {
if (time > stopTime) {
stopTime = time
}
# Rip off the header
hdr_size = pkt_size % 512
pkt_size -= hdr_size
# Store received packet's size
recvdSize += pkt_size
}}
END { print "+=======================================================================+\n";
printf("\t\tThroughput[kbps] : %.2f\n",(recvdSize/(stopTime-startTime))*(8/1000))打印"\n+=======================================================================+\n";
}
执行命令:
-f throughput.awk out.tr (示踪文件名)
https://stackoverflow.com/questions/33846435
复制相似问题