* git
* check hints agains ack_out?_
* check data against ack_in
- * channel suspend/wake. 3 cong modes state machine - ???
+ v channel suspend/wake. 3 cong modes state machine - ???
* minimize the number of template instantiations
* Channel thinks how much it HINTs a second,
picker thinks which HINTs are snubbed
* dead Channels are not killed => cannot open a new one
(have a channel already)
+ * peers don't cooperate
}
bins::bins() : height(4), blocks_allocated(0), cells(NULL),
- ap(0), cells_allocated(0) {
+ ap(0), cells_allocated(0), twist_mask(0) {
extend();
assert(!alloc_cell());
}
+void bins::twist (uint64_t mask) {
+ assert( (1<<height) > mask );
+ twist_mask = mask;
+}
+
bins::bins (const bins& b) : height(b.height), ap(b.ap),
blocks_allocated(b.blocks_allocated), cells_allocated(b.cells_allocated) {
size_t memsz = blocks_allocated*16*32;
host->split(half);
history[pos.layer()] = half; // FIXME
pos = pos.to(right);
+ if ( (host->twist_mask >> pos.layer()) & 1 )
+ right = !right; // twist it!
half = (host->halves[half]<<1) + right;
- //host->dump("/\\ ");
}
void clear ();
static bool is_mixed (uint16_t val) { return val!=EMPTY && val!=FILLED; }
+
+ void twist (uint64_t mask);
private:
uint32_t cells_allocated;
int height;
uint32_t ap;
+ uint64_t twist_mask;
void extend();
}
tint KeepAliveController::NextSendTime () {
- return ch_->last_send_time_ + TINT_SEC*58;
+ if (!delay_)
+ delay_ = ch_->rtt_avg_;
+ return ch_->last_send_time_ + delay_;
}
void KeepAliveController::OnDataSent(bin64_t b) {
+ delay_ *= 2;
+ if (delay_>TINT_SEC*58)
+ delay_ = TINT_SEC*58;
if (b!=bin64_t::ALL)
Swap(new PingPongController(this));
}
struct KeepAliveController : public SendController {
+
+ tint delay_;
- KeepAliveController(SendController* prev) : SendController(prev){}
+ KeepAliveController(SendController* prev) : SendController(prev),
+ delay_(0) {}
const char* type() const { return "KeepAlive"; }
bool MaySendData();
tint NextSendTime () ;
EXPECT_EQ(50<<4,b50.mass());
}
+TEST(BinsTest,Twist) {
+ bins b;
+ b.set(bin64_t(3,2));
+ EXPECT_EQ(bins::FILLED,b.get(bin64_t(3,2)));
+ EXPECT_EQ(bins::EMPTY,b.get(bin64_t(3,3)));
+ b.twist(1<<3);
+ EXPECT_EQ(bins::FILLED,b.get(bin64_t(3,3)));
+ EXPECT_EQ(bins::EMPTY,b.get(bin64_t(3,2)));
+ b.twist(0);
+ EXPECT_EQ(bins::FILLED,b.get(bin64_t(3,2)));
+ EXPECT_EQ(bins::EMPTY,b.get(bin64_t(3,3)));
+}
+
TEST(BinheapTest,Eat) {
binheap b;
#include "datagram.h"
#include "p2tp.h"
#include <gtest/gtest.h>
-#include <glog/logging.h>
using namespace p2tp;
using namespace std;
( $EXEC/leecher 282a863d5567695161721686a59f0c667250a35d \
$STORE/sofi$i.jpg 7001 710$i > $STORE/leecher$i.log ) &
TOKILL="$TOKILL $!"
- sleep 1;
+ sleep 4;
done
sleep 10