void RUDPCCCObject::on_timer(uint64_t now_ts) { uint32_t delay = core_max(rtt_ / 8, 50); if (now_ts >= prev_on_ts_ + delay) //10个RTT决策一次 { print_count_ ++; if(print_count_ % 4 == 0) { RUDP_DEBUG("send window size = " << snd_cwnd_ << ",rtt = " << rtt_ << ",rtt_var = " << rtt_var_ << ",resend = " << resend_count_); set_max_cwnd(rtt_); } if(slow_start_) //停止慢启动过程 { if(print_count_ > 10) { slow_start_ = false; RUDP_INFO("ccc stop slow_start, snd_cwnd = " << snd_cwnd_); } } else { if (recv_count_ > (snd_cwnd_ * delay * 7 / (rtt_ * 8))) { snd_cwnd_ = (uint32_t)(snd_cwnd_ + core_max(8,(snd_cwnd_ / 8))); snd_cwnd_ = core_min(max_cwnd_, snd_cwnd_); loss_flag_ = false; } else if (recv_count_ < snd_cwnd_ * delay * 5 / (rtt_ * 8)){ snd_cwnd_ = (uint32_t)(snd_cwnd_ - (snd_cwnd_ / 16)); snd_cwnd_ = core_max(min_cwnd_, snd_cwnd_); loss_flag_ = true; } else if (rtt_var_ > 30 && resend_count_ >= core_max(8, snd_cwnd_ * delay * 3 / (8 * rtt_))){ snd_cwnd_ = (uint32_t)(snd_cwnd_ - (snd_cwnd_ / 10)); snd_cwnd_ = core_max(min_cwnd_, snd_cwnd_); loss_flag_ = true; } resend_count_ = 0; } recv_count_ = 0; prev_on_ts_ = now_ts; } }
void RUDPCCCObject::set_rtt(uint32_t keep_live_rtt) { //提高高延迟网络的吞吐量(BDP) if(max_cwnd_ == DEFAULT_CWND_SIZE) set_max_cwnd(keep_live_rtt); //计算rtt和rtt修正 if(rtt_first_) { rtt_first_ = false; rtt_ = keep_live_rtt; rtt_var_ = rtt_ / 2; } else //参考了tcp的rtt计算 { rtt_var_ = (rtt_var_ * 3 + core_abs(rtt_, keep_live_rtt)) / 4; rtt_ = (7 * rtt_ + keep_live_rtt) / 8; } rtt_ = core_max(5, rtt_); rtt_var_ = core_max(3, rtt_var_); }
bool ExprRep::withinKnownPrecision(const extLong& relPrec, const extLong& absPrec) { if (appComputed()) { // an approximate value has been evaluated. if (appValue().isExact()) { return true; } else { // approximation has certain error. // decide to which position it is required to compute correctly. extLong required = core_max(-absPrec, appValue().lMSB()-relPrec); // see whether the existing error is smaller than the requirement. return (knownPrecision() <= required); } } else return false; }//withinKnownPrecision(a, r)
int32_t CEpollReactor::open_reactor(uint32_t number_of_handlers) { for(uint32_t i = 1; i < EPOLL_HEAP_SIZE; i ++) { handler_heap_[i] = 0; free_set_.insert(i); } max_handler_num_ = core_max(number_of_handlers, max_handler_num_); epfd_ = epoll_create(max_handler_num_); if(epfd_ == -1) { return -1; } events_ = new epoll_event[2 * max_handler_num_]; return 0; }
void DivRep::computeApproxValue(const extLong& relPrec, const extLong& absPrec) { if (lMSB() < EXTLONG_BIG && lMSB() > EXTLONG_SMALL) { extLong rr = relPrec + EXTLONG_SEVEN; // These rules come from extLong ra = uMSB() + absPrec + EXTLONG_EIGHT; // Koji's Master Thesis, page 65 extLong ra2 = core_max(ra, EXTLONG_TWO); extLong r = core_min(rr, ra2); extLong af = - first->lMSB() + r; extLong as = - second->lMSB() + r; extLong pr = relPrec + EXTLONG_SIX; extLong pa = uMSB() + absPrec + EXTLONG_SEVEN; extLong p = core_min(pr, pa); // Seems to be an error: // p can be negative here! // Also, this does not conform to // Koji's thesis which has a default // relative precision (p.65). appValue() = first->getAppValue(r, af).div(second->getAppValue(r, as), p); } else { std::cerr << "lMSB = " << lMSB() << std::endl; core_error("a huge lMSB in DivRep", __FILE__, __LINE__, false); } }