From: Victor Grishchenko Date: Sun, 13 Dec 2009 11:59:50 +0000 (+0100) Subject: getting cong control back to sanity X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=e417d708237b05ab15f29cf3e5c5518c978d1b6b;p=swift-upb.git getting cong control back to sanity --- diff --git a/BUGS b/BUGS index 373b47e..12d3b41 100644 --- a/BUGS +++ b/BUGS @@ -42,3 +42,4 @@ v whether sending is limited by cwnd or app * actually: whether packets are ACKed faster than sent * uproot DATA NONE: complicates and deceives + * r735 goes to github diff --git a/hashtree.cpp b/hashtree.cpp index 7f19502..0a4626f 100644 --- a/hashtree.cpp +++ b/hashtree.cpp @@ -315,8 +315,11 @@ bool HashTree::OfferData (bin64_t pos, const char* data, size_t lengt if (peak==bin64_t::NONE) return false; - if (!OfferHash(pos, Sha1Hash(data,length))) + Sha1Hash data_hash(data,length); + if (!OfferHash(pos, data_hash)) { + printf("invalid hash for %s: %s\n",pos.str(),data_hash.hex().c_str()); return false; + } //printf("g %lli %s\n",(uint64_t)pos,hash.hex().c_str()); ack_out_.set(pos,bins::FILLED); diff --git a/p2tp.h b/p2tp.h index b2ac571..95354aa 100644 --- a/p2tp.h +++ b/p2tp.h @@ -226,6 +226,8 @@ namespace p2tp { AIMD_CONTROL, LEDBAT_CONTROL } send_control_t; + + static const char* SEND_CONTROL_MODES[]; static Channel* RecvDatagram (int socket); @@ -288,9 +290,9 @@ namespace p2tp { /** Channel id: index in the channel array. */ uint32_t id; /** Socket address of the peer. */ - Address peer_; + Address peer_; /** The UDP socket fd. */ - int socket_; + int socket_; /** Descriptor of the file in question. */ FileTransfer* transfer_; /** Peer channel id; zero if we are trying to open a channel. */ @@ -299,7 +301,7 @@ namespace p2tp { /** Peer's progress, based on acknowledgements. */ bins ack_in_; /** Last data received; needs to be acked immediately. */ - tintbin data_in_; + tintbin data_in_; bin64_t data_in_dbl_; /** The history of data sent and still unacknowledged. */ tbqueue data_out_; diff --git a/send_control.cpp b/send_control.cpp index ff46b4d..a49909f 100644 --- a/send_control.cpp +++ b/send_control.cpp @@ -17,6 +17,8 @@ tint Channel::MAX_SEND_INTERVAL = TINT_SEC*58; tint Channel::LEDBAT_TARGET = TINT_MSEC*25; float Channel::LEDBAT_GAIN = 1.0/LEDBAT_TARGET; tint Channel::LEDBAT_DELAY_BIN = TINT_SEC*30; +const char* Channel::SEND_CONTROL_MODES[] = {"keepalive", "pingpong", + "slowstart", "standard_aimd", "ledbat"}; tint Channel::NextSendTime () { @@ -62,13 +64,15 @@ tint Channel::KeepAliveNextSendTime () { return TINT_NEVER; if (ack_rcvd_recent_) return SwitchSendControl(SLOW_START_CONTROL); + if (data_in_.bin!=bin64_t::NONE) + return NOW; send_interval_ <<= 1; if (send_interval_>MAX_SEND_INTERVAL) send_interval_ = MAX_SEND_INTERVAL; return last_send_time_ + send_interval_; } -tint Channel::PingPongNextSendTime () { +tint Channel::PingPongNextSendTime () { // FIXME INFINITE LOOP if (last_recv_time_ < last_send_time_-TINT_SEC*3) { // FIXME keepalive <-> pingpong (peers, transition) } // last_data_out_time_ < last_send_time_ - TINT_SEC... @@ -76,6 +80,8 @@ tint Channel::PingPongNextSendTime () { return SwitchSendControl(KEEP_ALIVE_CONTROL); if (ack_rcvd_recent_) return SwitchSendControl(SLOW_START_CONTROL); + if (data_in_.bin!=bin64_t::NONE) + return NOW; if (last_recv_time_>last_send_time_) return NOW; else if (last_send_time_) @@ -85,6 +91,8 @@ tint Channel::PingPongNextSendTime () { } tint Channel::CwndRateNextSendTime () { + if (data_in_.bin!=bin64_t::NONE) + return NOW; // TODO: delayed ACKs send_interval_ = rtt_avg_/cwnd_; if (data_out_.size()next_send_time_!=send_time && sender->next_send_time_!=TINT_NEVER ) sender = NULL; // it was a stale entry } - if ( sender && send_time <= NOW ) { // it's time + if ( sender!=NULL && send_time<=NOW ) { // it's time if (sender->next_send_time_id, @@ -539,7 +543,7 @@ void Channel::Loop (tint howlong) { } - } while (Datagram::Time()