@@ -25,14 +25,14 @@ public class MultipleClientServerTests
25
25
Interval : 1 , // 1ms so at interval code at least runs.
26
26
Timeout : 2000 ,
27
27
28
- // windows can be configured separately to test differently sized windows
29
- // use 2x defaults so we can test larger max message than defaults too.
30
- // IMPORTANT: default max message needs 127 fragments.
31
- // default x2 needs 255 fragments.
32
- // kcp sends 'frg' as 1 byte, so 255 still fits.
33
- // need to try x3 to find possible bugs.
34
- SendWindowSize : Kcp . WND_SND * 3 ,
35
- ReceiveWindowSize : Kcp . WND_RCV * 3 ,
28
+ // large window sizes so large messages are flushed with very few
29
+ // update calls. otherwise tests take too long .
30
+ SendWindowSize : Kcp . WND_SND * 1000 ,
31
+ ReceiveWindowSize : Kcp . WND_RCV * 1000 ,
32
+
33
+ // congestion window _heavily_ restricts send/recv window sizes
34
+ // sending a max sized message would require thousands of updates.
35
+ CongestionWindow : false ,
36
36
37
37
// maximum retransmit attempts until dead_link detected
38
38
// default * 2 to check if configuration works
@@ -147,13 +147,13 @@ int ServerLastConnectionId()
147
147
return server . connections . Last ( ) . Key ;
148
148
}
149
149
150
- void UpdateSeveralTimes ( )
150
+ void UpdateSeveralTimes ( int amount )
151
151
{
152
152
// update serveral times to avoid flaky tests.
153
153
// => need to update at 120 times for default maxed sized messages
154
154
// where it requires 120+ fragments.
155
155
// => need to update even more often for 2x default max sized
156
- for ( int i = 0 ; i < 500 ; ++ i )
156
+ for ( int i = 0 ; i < amount ; ++ i )
157
157
{
158
158
clientA . Tick ( ) ;
159
159
clientB . Tick ( ) ;
@@ -168,37 +168,37 @@ void UpdateSeveralTimes()
168
168
void ConnectClientsBlocking ( string hostname = "127.0.0.1" )
169
169
{
170
170
clientA . Connect ( hostname , Port , config ) ;
171
- UpdateSeveralTimes ( ) ;
171
+ UpdateSeveralTimes ( 5 ) ;
172
172
173
173
clientB . Connect ( hostname , Port , config ) ;
174
- UpdateSeveralTimes ( ) ;
174
+ UpdateSeveralTimes ( 5 ) ;
175
175
}
176
176
177
177
// disconnect and give it enough time to handle
178
178
void DisconnectClientsBlocking ( )
179
179
{
180
180
clientA . Disconnect ( ) ;
181
181
clientB . Disconnect ( ) ;
182
- UpdateSeveralTimes ( ) ;
182
+ UpdateSeveralTimes ( 5 ) ;
183
183
}
184
184
185
185
// kick and give it enough time to handle
186
186
void KickClientBlocking ( int connectionId )
187
187
{
188
188
server . Disconnect ( connectionId ) ;
189
- UpdateSeveralTimes ( ) ;
189
+ UpdateSeveralTimes ( 5 ) ;
190
190
}
191
191
192
192
void SendClientToServerBlocking ( KcpClient client , ArraySegment < byte > message , KcpChannel channel )
193
193
{
194
194
client . Send ( message , channel ) ;
195
- UpdateSeveralTimes ( ) ;
195
+ UpdateSeveralTimes ( 10 ) ;
196
196
}
197
197
198
198
void SendServerToClientBlocking ( int connectionId , ArraySegment < byte > message , KcpChannel channel )
199
199
{
200
200
server . Send ( connectionId , message , channel ) ;
201
- UpdateSeveralTimes ( ) ;
201
+ UpdateSeveralTimes ( 10 ) ;
202
202
}
203
203
204
204
// tests ///////////////////////////////////////////////////////////////
0 commit comments