zoukankan      html  css  js  c++  java
  • NS2网络模拟(2)-丢包率

      1: #NS2_有线部分LossRate.awk
    
      2: 
    
      3: BEGIN {
    
      4:     #Initialize the variable
    
      5:     Lost = 0;      #the Sum of Lost packet
    
      6:     Send = 0;      #the Sum of Send packet
    
      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 from n1
    
     47:     if (EVENT == "+" && SRCNODE == 1 && DSTNODE == 0 && PKTNAME == "tcp")
    
     48:         Send ++;
    
     49:     #Count up the drop packet
    
     50:     if (EVENT == "d" && SRCNODE == 0 && DSTNODE == 1 && PKTNAME == "ack")
    
     51:         Lost ++;
    
     52: }
    
     53: 
    
     54: END {
    
     55:     printf("TCP:number of packets send: %d lost: %d
    ", Send, Lost);
    
     56:     printf("TCP:the loss rate of packets: %.5f
    ", Lost/Send);
    
     57: }
  • 相关阅读:
    设计模式之桥接模式
    设计模式之适配器模式
    设计模式之代理模式
    设计模式之建造者模式
    设计模式之抽象工厂模式
    设计模式之工厂方法模式
    设计模式之简单工厂模式
    设计模式之原型模式
    api接口测试的步骤
    3种优化回归测试的方法
  • 原文地址:https://www.cnblogs.com/lanzhi/p/6468752.html
Copyright © 2011-2022 走看看