码迷,mamicode.com
首页 > 其他好文 > 详细

update_dctcp_alpha

时间:2015-01-09 12:03:12      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:

 

 1  /*
 2 +  * Update dctcp alpha based on the ecn bit in the received packet.
 3 +  * This procedure is called only when dctcp_ is 1.
 4 +  */
 5 + void FullTcpAgent::update_dctcp_alpha(Packet *pkt)
 6 + {
 7 +     int ecnbit = hdr_flags::access(pkt)->ecnecho();
 8 +     int ackno = hdr_tcp::access(pkt)->ackno();
 9 +     int acked_bytes = ackno - highest_ack_; 
10 + 
11 +     if (acked_bytes <= 0) 
12 +         acked_bytes = size_;    
13 +     dctcp_total += acked_bytes;
14 +     if (ecnbit) {
15 +         dctcp_marked += acked_bytes;
16 +     }
17 + 
18 +     /* Check for barrier indicating its time to recalculate alpha.
19 +      * This code basically updated alpha roughly once per RTT.
20 +      */
21 +     if (ackno > dctcp_alpha_update_seq) {
22 +         double temp_alpha;
23 +         dctcp_alpha_update_seq = dctcp_maxseq;
24 +         if (dctcp_total > 0) 
25 +             temp_alpha = ((double) dctcp_marked) / dctcp_total;
26 +         else 
27 +             temp_alpha = 0.0;
28 + 
29 +         dctcp_alpha_ = (1 - dctcp_g_) * dctcp_alpha_ + dctcp_g_ * temp_alpha;
30 +         dctcp_marked = 0;
31 +         dctcp_total = 0;
32 +     }
33 + }

 

update_dctcp_alpha

标签:

原文地址:http://www.cnblogs.com/forcheryl/p/4212765.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!