bool CwndController::MaySendData() {
- dprintf("%s #%i maysend %i < %f & %s (rtt %lli)\n",tintstr(),
+ dprintf("%s #%i sendctrl may send %i < %f & %s (rtt %lli)\n",tintstr(),
ch_->id,(int)ch_->data_out_.size(),cwnd_,tintstr(NextSendTime()),
ch_->rtt_avg_);
return ch_->data_out_.size() < cwnd_ && NOW >= NextSendTime();
void CwndController::OnAckRcvd(bin64_t ackd) {
if (ackd==bin64_t::NONE) {
+ dprintf("%s #%i sendctrl loss detected\n",tintstr(),ch_->id);
if (NOW>last_change_+ch_->rtt_avg_) {
cwnd_ /= 2;
last_change_ = NOW;
if (cwnd_<1)
cwnd_ *= 2;
else
- cwnd_ += 1/cwnd_;
+ cwnd_ += 1.0/cwnd_;
+ dprintf("%s #%i sendctrl cwnd to %f\n",tintstr(),ch_->id,cwnd_);
}
}
void AIMDController::OnAckRcvd (bin64_t pos) {
- if (pos!=bin64_t::NONE)
+ if (pos==bin64_t::NONE) {
+ dprintf("%s #%i sendctrl loss detected\n",tintstr(),ch_->id);
+ if (NOW>last_change_+ch_->rtt_avg_) {
+ cwnd_ /= 2;
+ last_change_ = NOW;
+ }
+ } else {
cwnd_ += 1.0/cwnd_;
- else
- cwnd_ /= 2;
+ dprintf("%s #%i sendctrl cwnd to %f\n",tintstr(),ch_->id,cwnd_);
+ }
}
if (dgram.size()==4) // only the channel id; bare keep-alive
data = bin64_t::ALL;
cc_->OnDataSent(data);
- if (dgram.Send()==-1)
+ if (dgram.Send()==-1)
print_error("can't send datagram");
last_send_time_ = NOW;
RequeueSend(cc_->NextSendTime());
return bin64_t::NONE;
bin64_t tosend = DequeueHint();
if (tosend==bin64_t::NONE) {
- dprintf("%s #%i out of hints\n",tintstr(),id);
+ dprintf("%s #%i out of hints #sendctrl\n",tintstr(),id);
return bin64_t::NONE;
}
if (ack_in_.is_empty() && file().size())
dgram.Push(buf,r);
dprintf("%s #%i +data (%lli)\n",tintstr(),id,tosend.base_offset());
data_out_.push_back(tosend);
- ack_in_.set(tosend);
+ // FIXME BUG this makes data_out_ all stale ack_in_.set(tosend);
return tosend;
}
void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *dataIn, unsigned long len);
void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx);
-#endif
\ No newline at end of file
+#endif
+