NS2网络模拟(2)-丢包率

简介: 1: #NS2_有线部分\LossRate.awk 2: 3: BEGIN { 4: #Initialize the variable 5: Lost = 0; #the Sum of Lost packet 6: ...
  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\n", Send, Lost);
 56:     printf("TCP:the loss rate of packets: %.5f\n", Lost/Send);
 57: }
相关文章
|
弹性计算 Linux 测试技术
阿里云ECS网络不稳定、访问丢包、延迟高怎么办?
若ECS服务器经常出现网络不稳定、延迟高等情况,针对不同情况,下面列出一些常用的解决方法供大家参考: 一、Linux实例 可以尝试先用如winmtr之类的工具,查看是服务端的丢包还是网际路由线路的丢包。
|
11月前
|
网络协议 Linux 网络架构
如何在 Linux 系统下进行网络丢包排查?
如何在 Linux 系统下进行网络丢包排查?
572 0
如何在 Linux 系统下进行网络丢包排查?
|
算法
m基于模糊控制的网络时延预测和丢包率matlab仿真
m基于模糊控制的网络时延预测和丢包率matlab仿真
128 0
网络超时问题最佳实践(二)--丢包和延迟详解
#云吞铺子#双11最佳技术实践系列,分享阿里云在本次双11实战中沉淀的前沿经验和满满干货!本期由阿里云技术专家怀知,继续为大家深入分享网络超时问题最佳实践!大牛出品,必属精品!
|
网络架构 缓存 网络协议