Browse Source

Refinements to meek polling jitter

Rod Hynes 9 years ago
parent
commit
9d1b3c1b6c
1 changed files with 11 additions and 2 deletions
  1. 11 2
      psiphon/meekConn.go

+ 11 - 2
psiphon/meekConn.go

@@ -477,9 +477,15 @@ func (meek *MeekConn) relay() {
 	// Note: meek.Close() calls here in relay() are made asynchronously
 	// (using goroutines) since Close() will wait on this WaitGroup.
 	defer meek.relayWaitGroup.Done()
-	interval := MIN_POLL_INTERVAL
+
+	interval := common.JitterDuration(
+		MIN_POLL_INTERVAL,
+		MIN_POLL_INTERVAL_JITTER)
+
 	timeout := time.NewTimer(interval)
+
 	sendPayload := make([]byte, MAX_SEND_PAYLOAD_LENGTH)
+
 	for {
 		timeout.Reset(interval)
 		// Block until there is payload to send or it is time to poll
@@ -540,6 +546,10 @@ func (meek *MeekConn) relay() {
 		} else {
 
 			if common.FlipCoin() {
+				interval = common.JitterDuration(
+					interval,
+					POLL_INTERVAL_JITTER)
+			} else {
 				interval = common.JitterDuration(
 					time.Duration(float64(interval)*POLL_INTERVAL_MULTIPLIER),
 					POLL_INTERVAL_JITTER)
@@ -550,7 +560,6 @@ func (meek *MeekConn) relay() {
 					MAX_POLL_INTERVAL,
 					MAX_POLL_INTERVAL_JITTER)
 			}
-
 		}
 	}
 }