Просмотр исходного кода

Fix: tun_test updater test must allow for retransmission

Rod Hynes 8 лет назад
Родитель
Сommit
edfdb427e0
2 измененных файлов с 14 добавлено и 4 удалено
  1. 7 0
      psiphon/common/tun/tun.go
  2. 7 4
      psiphon/common/tun/tun_test.go

+ 7 - 0
psiphon/common/tun/tun.go

@@ -1110,6 +1110,13 @@ func (session *session) isTrackingFlow(ID flowID) bool {
 // TLS payload. The session's FlowActivityUpdaterMaker is invoked
 // to determine a list of updaters to track flow activity.
 //
+// Updaters receive reports with the number of application data
+// bytes in each flow packet. This number, totalled for all packets
+// in a flow, may exceed the total bytes transferred at the
+// application level due to TCP retransmission. Currently, the flow
+// tracking logic doesn't exclude retransmitted packets from update
+// reporting.
+//
 // Flows are untracked after an idle expiry period. Transport
 // protocol indicators of end of flow, such as FIN or RST for TCP,
 // which may or may not appear in a flow, are not currently used.

+ 7 - 4
psiphon/common/tun/tun_test.go

@@ -237,14 +237,17 @@ func testTunneledTCP(t *testing.T, useIPv6 bool) {
 		}
 	}
 
+	// Note: reported bytes transferred can exceed expected bytes
+	// transferred due to resent packets.
+
 	upstreamBytesTransferred, downstreamBytesTransferred, _ := counter.Get()
 	expectedBytesTransferred := CONCURRENT_CLIENT_COUNT * TCP_RELAY_TOTAL_SIZE
-	if upstreamBytesTransferred != expectedBytesTransferred {
-		t.Fatalf("unexpected upstreamBytesTransferred: %d: %d",
+	if upstreamBytesTransferred < expectedBytesTransferred {
+		t.Fatalf("unexpected upstreamBytesTransferred: %d; expected at least %d",
 			upstreamBytesTransferred, expectedBytesTransferred)
 	}
-	if downstreamBytesTransferred != expectedBytesTransferred {
-		t.Fatalf("unexpected downstreamBytesTransferred: %d: %d",
+	if downstreamBytesTransferred < expectedBytesTransferred {
+		t.Fatalf("unexpected downstreamBytesTransferred: %d; expected at least %d",
 			downstreamBytesTransferred, expectedBytesTransferred)
 	}