oh God
authorvictor <victor@e16421f0-f15b-0410-abcd-98678b794739>
Wed, 28 Oct 2009 17:11:46 +0000 (17:11 +0000)
committervictor <victor@e16421f0-f15b-0410-abcd-98678b794739>
Wed, 28 Oct 2009 17:11:46 +0000 (17:11 +0000)
git-svn-id: https://ttuki.vtt.fi/svn/p2p-next/TUD/p2tp/trunk@489 e16421f0-f15b-0410-abcd-98678b794739

datagram.cpp
ext/dummy_controller.cpp
sendrecv.cpp

index ea6e60f..5776d98 100644 (file)
@@ -42,6 +42,11 @@ char* Datagram::TimeStr (tint time) {
 }
     
 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;
index 636bffb..9eeaeca 100755 (executable)
@@ -79,14 +79,18 @@ struct BasicController : public CongestionController {
         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();
     }
     
@@ -133,7 +137,7 @@ struct BasicController : public CongestionController {
         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;
@@ -211,4 +215,4 @@ void OnAckRcvd(const tintbin& ack) {
 // 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
+ */
index db52e50..bd0dfe7 100644 (file)
@@ -129,14 +129,18 @@ void      Channel::AddHint (Datagram& dgram) {
         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);