Browse Source

fix mkcp sending window

Page Fault 5 years ago
parent
commit
1a652933d9
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
 	}
 
-	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() {
 		w.window.Flush(current, w.conn.roundTrip.Timeout(), cwnd)
 		w.firstUnacknowledgedUpdated = false