NS2网络模拟(3)-吞吐率

  1: #NS2_有线部分\Throughput.awk
  2: 
  3: BEGIN {
  4:     #Initialize the variable
  5:     init = 0;
  6:     i = 0;
  7: }
  8: 
  9: {
 10: #Event Abbreviation Type Value
 11: #%g %d %d %s %d %s %d %d.%d %d.%d %d %d
 12: #Normal Event
 13:         #r: Receive
 14:         #d: Drop
 15:         #e: Error
 16:         #+: Enqueue
 17:         #-: Dequeue       
 18: #double  Time
 19: #int  (Link-layer) Source Node
 20: #int  (Link-layer) Destination Node
 21: #string  Packet Name
 22: #int  Packet Size
 23: #string  Flags
 24: #int  Flow ID
 25: #int  (Network-layer) Source Address
 26: #int  Source Port
 27: #int  (Network-layer) Destination Address
 28: #int  Destination Port
 29: #int  Sequence Number
 30: #int  Unique Packet ID
 31: 
 32:     #Evaluate the fields to new viariables
 33:     EVENT       = $1;
 34:     TIME        = $2;
 35:     SRCNODE     = $3
 36:     DSTNODE     = $4;
 37:     PKTNAME     = $5;
 38:     PKTSIZE     = $6;
 39:     FLAGS       = $7;
 40:     FLOWID      = $8;
 41:     SRCADDPORT  = $9;
 42:     DSTADDPORT  = $10;
 43:     SEQNO       = $11;
 44:     PKTID       = $12;
 45: 
 46:     #Count up the packets send to DstNode
 47:     if (EVENT == "-" && SRCNODE == 0 && DSTNODE == 1) 
 48:     {
 49:         ByteSum[i + 1] = ByteSum[i] + PKTSIZE;
 50: 
 51: #        if (init == 0) {
 52: #            StartTime = Time;
 53: #            init = 1;
 54: #        }
 55: 
 56:         EndTime[i] = TIME;
 57:         i = i + 1;
 58:     }
 59: }
 60: 
 61: END {
 62:     printf("%.2f\t%.2f\n", EndTime[0], 0);
 63: 
 64:     #Calcute the throughput
 65:     for (j = 1; j < i; j ++) 
 66:     {
 67:         Throught = (ByteSum[j] / (EndTime[j] - EndTime[0])) * 8 / 1000;
 68:         printf("%.2f\t%.2f\n", EndTime[j], Throught);
 69:     }
 70: 
 71:     printf("%.2f\t%.2f\n", EndTime[i - 1], 0);
 72: }
 73: 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值