• 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: }
  • 相关阅读:
    第十三周进度条
    寻找水军
    第十二周进度条
    学习总结
    第十五周工作总结
    第十四周工作总结
    《梦断代码》阅读笔记03
    个人工作总结20
    个人工作总结19
    个人工作总结18
  • 原文地址:https://www.cnblogs.com/lanzhi/p/6468752.html
Copyright © 2020-2023  润新知