Browse Source

Merge pull request #168 from p4gefau1t/fix-mkcp-control-window

fix mkcp sending window
Kslr 5 years ago
parent
commit
a770d72ca4
1 changed files with 7 additions and 5 deletions
  1. 7 5
      transport/internet/kcp/sending.go

+ 7 - 5
transport/internet/kcp/sending.go

@@ -315,14 +315,16 @@ func (w *SendingWorker) Flush(current uint32) {
 		return
 		return
 	}
 	}
 
 
-	cwnd := w.firstUnacknowledged + w.conn.Config.GetSendingInFlightSize()
-	if cwnd > w.remoteNextNumber {
-		cwnd = w.remoteNextNumber
+	cwnd := w.conn.Config.GetSendingInFlightSize()
+	if cwnd > w.remoteNextNumber-w.firstUnacknowledged {
+		cwnd = w.remoteNextNumber - w.firstUnacknowledged
 	}
 	}
-	if w.conn.Config.Congestion && cwnd > w.firstUnacknowledged+w.controlWindow {
-		cwnd = w.firstUnacknowledged + w.controlWindow
+	if w.conn.Config.Congestion && cwnd > w.controlWindow {
+		cwnd = w.controlWindow
 	}
 	}
 
 
+	cwnd *= 20 // magic
+
 	if !w.window.IsEmpty() {
 	if !w.window.IsEmpty() {
 		w.window.Flush(current, w.conn.roundTrip.Timeout(), cwnd)
 		w.window.Flush(current, w.conn.roundTrip.Timeout(), cwnd)
 		w.firstUnacknowledgedUpdated = false
 		w.firstUnacknowledgedUpdated = false