UDT: Remove ackInterval which was never set anyway. Instead, send ACK every few packets depending on congestion window and count of sent packets.

Removing LightACK. The implementation of it was confusing (it competed with ACK in a race condition) and rather pointless. LightACKs will be ditched completely to get to a working version.
This commit is contained in:
Kleissner
2021-11-04 20:47:34 +01:00
parent d9bbdf573e
commit b728b939ec
3 changed files with 4 additions and 41 deletions

View File

@@ -38,9 +38,6 @@ type CongestionControlParms interface {
// SetACKPerid sets the time between ACKs sent to the peer
SetACKPeriod(time.Duration)
// SetACKInterval sets the number of packets sent to the peer before sending an ACK
SetACKInterval(uint)
// SetRTOPeriod overrides the default EXP timeout calculations waiting for data from the peer
SetRTOPeriod(time.Duration)
}

View File

@@ -216,11 +216,6 @@ func (s *udtSocketCc) SetACKPeriod(ack time.Duration) {
s.socket.recv.ackPeriod.set(ack)
}
// SetACKInterval sets the number of packets sent to the peer before sending an ACK
func (s *udtSocketCc) SetACKInterval(ack uint) {
s.socket.recv.ackInterval.set(uint32(ack))
}
// SetRTOPeriod overrides the default EXP timeout calculations waiting for data from the peer
func (s *udtSocketCc) SetRTOPeriod(rto time.Duration) {
s.socket.send.rtoPeriod.set(rto)

View File

@@ -8,10 +8,6 @@ import (
"github.com/PeernetOfficial/core/udt/packet"
)
const (
ackSelfClockInterval = 64
)
type udtSocketRecv struct {
// channels
sockClosed <-chan struct{} // closed when socket is closed
@@ -32,9 +28,7 @@ type udtSocketRecv struct {
recvLastArrival time.Time // time of the most recent data packet arrival
recvLastProbe time.Time // time of the most recent data packet probe packet
ackPeriod atomicDuration // (set by congestion control) delay between sending ACKs
ackInterval atomicUint32 // (set by congestion control) number of data packets to send before sending an ACK
unackPktCount uint // number of packets we've received that we haven't sent an ACK for
lightAckCount uint // number of "light ACK" packets we've sent since the last ACK
recvPktHistory []time.Duration // list of recently received packets.
recvPktPairHistory []time.Duration // probing packet window.
@@ -351,16 +345,12 @@ func (s *udtSocketRecv) attemptProcessPacket(p *packet.DataPacket, isNew bool) b
}
}
// we've received a data packet, do we need to send an ACK for it?
// Acknowledge the packet if the threshold is reached. This used to be a parameter s.ackInterval supposed to be set by congestion control, but never was.
// Before, there was both the (unused) ACK interval s.ackInterval and s.ackTimerEvent which fired at SynTime, which was way too often and basically a ddos.
// It makes more sense to just send the ACK x split of the congestion window.
s.unackPktCount++
ackInterval := uint(s.ackInterval.get())
if (ackInterval > 0) && (ackInterval <= s.unackPktCount) {
// ACK interval is reached
if s.unackPktCount >= s.socket.cong.GetCongestionWindowSize()/4 {
s.ackEvent()
} else if ackSelfClockInterval*s.lightAckCount <= s.unackPktCount {
//send a "light" ACK
s.sendLightACK()
s.lightAckCount++
}
if cannotContinue {
@@ -394,24 +384,6 @@ func (s *udtSocketRecv) attemptProcessPacket(p *packet.DataPacket, isNew bool) b
return true
}
func (s *udtSocketRecv) sendLightACK() {
var ack packet.PacketID
// If there is no loss, the ACK is the current largest sequence number plus 1;
// Otherwise it is the smallest sequence number in the receiver loss list.
if s.recvLossList == nil {
ack = s.farNextPktSeq
} else {
ack = s.farRecdPktSeq.Add(1)
}
if ack != s.recvAck2 {
// send out a lite ACK
// to save time on buffer processing and bandwidth/AS measurement, a lite ACK only feeds back an ACK number
s.sendPacket <- &packet.LightAckPacket{PktSeqHi: ack}
}
}
func (s *udtSocketRecv) getRcvSpeeds() (recvSpeed, bandwidth int) {
// get median value, but cannot change the original value order in the window
@@ -576,5 +548,4 @@ func (s *udtSocketRecv) ingestError(p *packet.ErrPacket) {
func (s *udtSocketRecv) ackEvent() {
s.sendACK()
s.unackPktCount = 0
s.lightAckCount = 1
}