File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -1023,7 +1023,11 @@ impl UtpSocket {
1023
1023
debug ! ( "({:?}, {:?})" , self . state, packet. get_type( ) ) ;
1024
1024
1025
1025
// Acknowledge only if the packet strictly follows the previous one
1026
- if packet. seq_nr ( ) . wrapping_sub ( self . ack_nr ) == 1 {
1026
+ // and only if it is a payload packet. The restriction on PacketType
1027
+ // is due to all other (non Data) packets are assigned seq_nr the
1028
+ // same as the next Data packet, thus we could acknowledge what
1029
+ // we have not received yet.
1030
+ if packet. get_type ( ) == PacketType :: Data && packet. seq_nr ( ) . wrapping_sub ( self . ack_nr ) == 1 {
1027
1031
self . ack_nr = packet. seq_nr ( ) ;
1028
1032
}
1029
1033
@@ -1056,6 +1060,12 @@ impl UtpSocket {
1056
1060
self . last_dropped = self . ack_nr ;
1057
1061
1058
1062
self . state_packet = Some ( self . prepare_reply ( packet, PacketType :: State ) ) ;
1063
+
1064
+ // Advance the self.seq_nr (the sequence number of the next packet),
1065
+ // this is because the other end will use the `seq_nr` of this state
1066
+ // packet as his `self.last_acked`
1067
+ self . seq_nr = self . seq_nr . wrapping_add ( 1 ) ;
1068
+
1059
1069
Ok ( self . state_packet . clone ( ) )
1060
1070
} ,
1061
1071
( SocketState :: Connected , PacketType :: Syn ) if self . connected_to == src => {
You can’t perform that action at this time.
0 commit comments