}
int Datagram::Send () {
+ if (rand()%10==0) {
+ Time();
+ dprintf("%s datagram killed\n",TimeStr());
+ return size();
+ }
int r = sendto(sock,(const char *)buf+offset,length-offset,0,
(struct sockaddr*)&(addr.addr),sizeof(struct sockaddr_in));
//offset=0;
if (b==bin64_t::ALL) { // nothing to send, absolutely
data_out_.clear();
cwnd >>= 1;
+ if (!cwnd)
+ cwnd = 1;
} else if (b==bin64_t::NONE) { // sent some metadata
cwnd = 1; // no more data => no need for cwnd
+ data_out_.clear();
data_out_.push_back(b);
} else {
data_out_.push_back(b);
}
- dprintf("%s #%i cwnd %i infl %i peer_cwnd %i\n",
- Datagram::TimeStr(),channel_id,cwnd,in_flight(),peer_cwnd);
+ dprintf("%s #%i cwnd %i infl %i peer_cwnd %i //%lli\n",
+ Datagram::TimeStr(),channel_id,cwnd,in_flight(),peer_cwnd,
+ (uint64_t)b);
return get_send_time();
}
for (int i=0; data_out_.size() && i<6; i++) {
tintbin x = data_out_.front();
data_out_.pop_front();
- if (x.bin==ackd) {
+ if (x.bin.within(ackd)) {
// van Jacobson's rtt
tint rtt = Datagram::now-x.time;
rtt_avg = (rtt_avg*3 + rtt) >> 2;
// SOLUTION: once free_cwnd==0 => don't invoke OnDataSent
// TODO: once it's time, but free_cwnd=0 => need to set timeout
- */
\ No newline at end of file
+ */
hint_out_.clear();
}
- uint64_t hinted = hint_out_.mass() + hint_out_old_.mass();
-
+ uint64_t hinted = hint_out_.mass();// + hint_out_old_.mass();
+ int bps = cc_->PeerBPS();
+ dprintf("%s #%i hinted %lli peer_bps %i\n",Datagram::TimeStr(),id,hinted,bps);
//float peer_cwnd = cc_->PeerBPS() * cc_->RoundTripTime() / TINT_SEC;
- if ( cc_->PeerBPS() > hinted*1024 ) { //hinted*1024 < peer_cwnd*4 ) {
+ if ( bps > hinted*1024 ) { //hinted*1024 < peer_cwnd*4 ) {
uint8_t layer = 2; // actually, enough
bin64_t hint = file().picker().Pick(ack_in_,layer);
+ // FIXME: any layer
+ if (hint==bin64_t::NONE)
+ hint = file().picker().Pick(ack_in_,0);
if (hint!=bin64_t::NONE) {
hint_out_.set(hint);