今天根据柯老师的书,实验了一个非常简单的差分服务网络的例子.
这就是网络结构,很简单,结点0和1产生CBR流量2和3是边缘服务器,4是核心结点,5是目的结点.
流程是这样的:首先数据流进入边缘路由器,这时被根据它的速率被分类,这里选用TSW3CM方法,分为绿色,黄色,红色三类来标记数据包,对应不同的丢弃概率.概率计算具体跟设置的CIR和PIR有关,队里管理方式则是选择相匹配的WRED,这样在发生拥塞时就能根据不同的概率选择性丢包数据包了.要说下队列管理方面是建立了1个物理队列,和3个虚拟队列,对应之前3种不同丢弃概率的数据流,实际是只有一个物理队列来存储的.
之后又试着用awk和gnuplot来对tr文件进行简单的分析,例如吞吐率,延迟,丢包率等.结果会一一贴出,但是感觉有点奇怪,丢包率是0,一个包都没丢...吞吐率稳定的一笔,在4000kbps,延迟也很低,可能是网络太简单了,看不出QOS的效果,也没法进行什么改进,准备开始设计一个稍微大型点的网络,至少50个结点把...
trace文件分析代码和结果:
丢包率:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 BEGIN{ 2 s1=0; 3 s2=0; 4 d1=0; 5 d2=0; 6 } 7 { 8 action = $1; 9 time = $2; 10 from = $3; 11 to = $4; 12 type = $5; 13 pktsize = $6; 14 flow_id = $8; 15 src = $9; 16 dst = $10; 17 seq_no = $11; 18 packet_id = $12; 19 20 if(from==0 && action=="+"){ 21 s1++; 22 }else if (from==1 && action=="+"){ 23 s2++; 24 } 25 26 if(flow_id==1&&action=="d"){ 27 d1++; 28 }else if(flow_id==2&&action=="d"){ 29 d2++; 30 } 31 } 32 END{ 33 printf("结点1发送:%d 结点2发送:%d 数据流1丢失:%d 数据流2丢失:%d\n",s1,s2,d1,d2); 34 }
延迟部分分析代码和结果截图:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 BEGIN{ 2 highest_packet_id = 0; 3 } 4 { 5 action = $1; 6 time = $2; 7 from = $3; 8 to = $4; 9 type = $5; 10 pktsize = $6; 11 flow_id = $8; 12 src = $9; 13 dst = $10; 14 seq_no = $11; 15 packet_id = $12; 16 17 if (packet_id>highest_packet_id) 18 highest_packet_id = packet_id; 19 20 if (start_time[packet_id]==0){ 21 pkt_seqno[packet_id]=seq_no; 22 start_time[packet_id]=time; 23 } 24 25 if(flow_id==1&&action!="d"){ 26 if(action=="r"){ 27 end_time[packet_id]=time; 28 } 29 } else{ 30 end_time[packet_id]=-1; 31 } 32 } 33 END{ 34 for(packet_id=0;packet_id<=highest_packet_id;packet_id++){ 35 start=start_time[packet_id]; 36 end=end_time[packet_id]; 37 packet_duration=end-start; 38 if(start<end) 39 printf("%f %f\n",start,packet_duration); 40 } 41 }
吞吐率部分代码和截图:
1 BEGIN{ 2 init=0; 3 i=0; 4 } 5 { 6 action=$1; 7 time=$2; 8 from = $3; 9 to = $4; 10 type = $5; 11 pktsize = $6; 12 flow_id = $8; 13 src = $9; 14 dst = $10; 15 seq_no = $11; 16 packet_id = $12; 17 18 if(action=="r"&&from==3&&to==5&&flow_id==1){ 19 pkt_byte_sum[i+1]=pkt_byte_sum[i]+pktsize; 20 21 if(init==0){ 22 start_time=time; 23 init=1; 24 } 25 end_time[i]=time; 26 i=i+1; 27 } 28 } 29 END{ 30 printf("%.2f %.2f\n",end_time[0],0); 31 for(j=1;j<i;j++){ 32 th=pkt_byte_sum[j]/(end_time[j]-start_time)*8/1000; 33 printf("%.2f %.2f\n",end_time[j],th); 34 } 35 printf("%.2f %.2f\n",end_time[i-1],0); 36 }