@@ -17,9 +17,9 @@ use crate::wire::{
17
17
TCP_HEADER_LEN ,
18
18
} ;
19
19
20
- use self :: congestion_controller:: CongestionController ;
20
+ use self :: congestion_controller:: { ActiveCC , CongestionController } ;
21
21
22
- pub mod congestion_controller;
22
+ mod congestion_controller;
23
23
24
24
macro_rules! tcp_trace {
25
25
( $( $arg: expr) ,* ) => ( net_log!( trace, $( $arg) ,* ) ) ;
@@ -156,7 +156,7 @@ const RTTE_MAX_RTO: u32 = 10000;
156
156
157
157
#[ derive( Debug , Clone , Copy ) ]
158
158
#[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
159
- pub struct RttEstimator {
159
+ struct RttEstimator {
160
160
// Using u32 instead of Duration to save space (Duration is i64)
161
161
rtt : u32 ,
162
162
deviation : u32 ,
@@ -178,14 +178,6 @@ impl Default for RttEstimator {
178
178
}
179
179
180
180
impl RttEstimator {
181
- pub fn get_rtt ( & self ) -> u32 {
182
- self . rtt
183
- }
184
-
185
- pub fn get_deviation ( & self ) -> u32 {
186
- self . deviation
187
- }
188
-
189
181
fn retransmission_timeout ( & self ) -> Duration {
190
182
let margin = RTTE_MIN_MARGIN . max ( self . deviation * 4 ) ;
191
183
let ms = ( self . rtt + margin) . clamp ( RTTE_MIN_RTO , RTTE_MAX_RTO ) ;
@@ -402,23 +394,14 @@ impl Display for Tuple {
402
394
}
403
395
}
404
396
405
- #[ cfg( feature = "socket-tcp-cubic" ) ]
406
- type DefaultCC = congestion_controller:: cubic:: Cubic ;
407
-
408
- #[ cfg( feature = "socket-tcp-reno" ) ]
409
- type DefaultCC = congestion_controller:: reno:: Reno ;
410
-
411
- #[ cfg( not( any( feature = "socket-tcp-cubic" , feature = "socket-tcp-reno" ) ) ) ]
412
- type DefaultCC = congestion_controller:: no_control:: NoControl ;
413
-
414
397
/// A Transmission Control Protocol socket.
415
398
///
416
399
/// A TCP socket may passively listen for connections or actively connect to another endpoint.
417
400
/// Note that, for listening sockets, there is no "backlog"; to be able to simultaneously
418
401
/// accept several connections, as many sockets must be allocated, or any new connection
419
402
/// attempts will be reset.
420
403
#[ derive( Debug ) ]
421
- pub struct Socket < ' a , CC : CongestionController = DefaultCC > {
404
+ pub struct Socket < ' a > {
422
405
state : State ,
423
406
timer : Timer ,
424
407
rtte : RttEstimator ,
@@ -486,7 +469,7 @@ pub struct Socket<'a, CC: CongestionController = DefaultCC> {
486
469
nagle : bool ,
487
470
488
471
/// The congestion control algorithm.
489
- congestion_controller : CC ,
472
+ congestion_controller : ActiveCC ,
490
473
491
474
#[ cfg( feature = "async" ) ]
492
475
rx_waker : WakerRegistration ,
@@ -496,22 +479,10 @@ pub struct Socket<'a, CC: CongestionController = DefaultCC> {
496
479
497
480
const DEFAULT_MSS : usize = 536 ;
498
481
499
- impl < ' a > Socket < ' a , DefaultCC > {
500
- /// Create a socket using the given buffers with the default
501
- /// congestion controller
502
- pub fn new < T > ( rx_buffer : T , tx_buffer : T ) -> Socket < ' a , DefaultCC >
503
- where
504
- T : Into < SocketBuffer < ' a > > ,
505
- {
506
- Socket :: new_with_cc ( rx_buffer, tx_buffer)
507
- }
508
- }
509
-
510
- impl < ' a , CC : CongestionController > Socket < ' a , CC > {
482
+ impl < ' a > Socket < ' a > {
511
483
#[ allow( unused_comparisons) ] // small usize platforms always pass rx_capacity check
512
484
/// Create a socket using the given buffers
513
- /// with the `CC` of a congestion controller.
514
- pub fn new_with_cc < T > ( rx_buffer : T , tx_buffer : T ) -> Socket < ' a , CC >
485
+ pub fn new < T > ( rx_buffer : T , tx_buffer : T ) -> Socket < ' a >
515
486
where
516
487
T : Into < SocketBuffer < ' a > > ,
517
488
{
@@ -558,7 +529,7 @@ impl<'a, CC: CongestionController> Socket<'a, CC> {
558
529
ack_delay_timer : AckDelayTimer :: Idle ,
559
530
challenge_ack_timer : Instant :: from_secs ( 0 ) ,
560
531
nagle : true ,
561
- congestion_controller : CC :: default ( ) ,
532
+ congestion_controller : ActiveCC :: default ( ) ,
562
533
563
534
#[ cfg( feature = "async" ) ]
564
535
rx_waker : WakerRegistration :: new ( ) ,
@@ -2436,7 +2407,7 @@ impl<'a, CC: CongestionController> Socket<'a, CC> {
2436
2407
}
2437
2408
}
2438
2409
2439
- impl < ' a , CC : CongestionController > fmt:: Write for Socket < ' a , CC > {
2410
+ impl < ' a > fmt:: Write for Socket < ' a > {
2440
2411
fn write_str ( & mut self , slice : & str ) -> fmt:: Result {
2441
2412
let slice = slice. as_bytes ( ) ;
2442
2413
if self . send_slice ( slice) == Ok ( slice. len ( ) ) {
@@ -7365,8 +7336,5 @@ mod test {
7365
7336
r. sample ( 100 ) ;
7366
7337
assert_eq ! ( r. retransmission_timeout( ) , Duration :: from_millis( rto) ) ;
7367
7338
}
7368
-
7369
- r. get_deviation ( ) ;
7370
- r. get_rtt ( ) ;
7371
7339
}
7372
7340
}
0 commit comments