From: Victor Grishchenko Date: Fri, 26 Feb 2010 15:52:16 +0000 (+0100) Subject: ACK/HAVE works locally X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=d3a59859cde37c10fffbb4cf523d514453e3e539;p=swift-upb.git ACK/HAVE works locally --- diff --git a/sendrecv.cpp b/sendrecv.cpp index e357a02..bfe1ee7 100644 --- a/sendrecv.cpp +++ b/sendrecv.cpp @@ -102,8 +102,8 @@ void Channel::AddHandshake (Datagram& dgram) { int encoded = EncodeID(id_); dgram.Push32(encoded); dprintf("%s #%u +hs %x\n",tintstr(),id_,encoded); - ack_out_.clear(); - AddAck(dgram); + have_out_.clear(); + AddHave(dgram); } @@ -224,9 +224,9 @@ void Channel::AddAck (Datagram& dgram) { if (data_in_==tintbin()) return; dgram.Push8(SWIFT_ACK); - dgram.Push32(data_in_.bin.to32()); - dgram.Push32(data_in_.time); - ack_out_.set(data_in_.bin); + dgram.Push32(data_in_.bin.to32()); // FIXME not cover + dgram.Push64(data_in_.time); // FIXME 32 + have_out_.set(data_in_.bin); dprintf("%s #%u +ack %s %s\n", tintstr(),id_,data_in_.bin.str(),tintstr(data_in_.time)); if (data_in_.bin.layer()>2) @@ -243,11 +243,11 @@ void Channel::AddHave (Datagram& dgram) { } for(int count=0; count<4; count++) { bin64_t ack = file().ack_out().find_filtered // FIXME: do rotating queue - (ack_out_, bin64_t::ALL, binmap_t::FILLED); + (have_out_, bin64_t::ALL, binmap_t::FILLED); if (ack==bin64_t::NONE) break; ack = file().ack_out().cover(ack); - ack_out_.set(ack); + have_out_.set(ack); dgram.Push8(SWIFT_HAVE); dgram.Push32(ack.to32()); dprintf("%s #%u +have %s\n",tintstr(),id_,ack.str()); @@ -338,7 +338,8 @@ bin64_t Channel::OnData (Datagram& dgram) { // TODO: HAVE NONE for corrupted da void Channel::OnAck (Datagram& dgram) { bin64_t ackd_pos = dgram.Pull32(); - tint peer_time_ = dgram.Pull64(); + tint peer_time_ = dgram.Pull64(); // FIXME 32 + // FIXME FIXME: wrap around here if (ackd_pos==bin64_t::NONE) return; // likely, brocken packet / insufficient hashes if (file().size() && ackd_pos.base_offset()>=file().packet_size()) { @@ -355,9 +356,9 @@ void Channel::OnAck (Datagram& dgram) { // rule out retransmits while ( ri> 3; diff --git a/swift.h b/swift.h index df9398f..be996c7 100644 --- a/swift.h +++ b/swift.h @@ -342,7 +342,7 @@ namespace swift { tbqueue data_out_tmo_; bin64_t data_out_cap_; /** Index in the history array. */ - binmap_t ack_out_; + binmap_t have_out_; /** Transmit schedule: in most cases filled with the peer's hints */ tbqueue hint_in_; /** Hints sent (to detect and reschedule ignored hints). */ diff --git a/tests/connecttest.cpp b/tests/connecttest.cpp index e49c6c7..20482d6 100644 --- a/tests/connecttest.cpp +++ b/tests/connecttest.cpp @@ -16,7 +16,7 @@ using namespace swift; -TEST(SWIFT,CwndTest) { +TEST(Connection,CwndTest) { srand ( time(NULL) ); @@ -56,6 +56,7 @@ int main (int argc, char** argv) { swift::LibraryInit(); testing::InitGoogleTest(&argc, argv); + Channel::debug_file = stdout; int ret = RUN_ALL_TESTS(); return ret;