send and track packets with ECN markings

This commit is contained in:
Marten Seemann 2023-08-12 10:08:40 +08:00
parent f919473598
commit 5dd6d91c11
21 changed files with 264 additions and 206 deletions

View file

@ -228,7 +228,7 @@ func (t *Transport) WriteTo(b []byte, addr net.Addr) (int, error) {
if err := t.init(false); err != nil {
return 0, err
}
return t.conn.WritePacket(b, addr, nil, 0)
return t.conn.WritePacket(b, addr, nil, 0, protocol.ECNNon)
}
func (t *Transport) enqueueClosePacket(p closePacket) {
@ -246,7 +246,7 @@ func (t *Transport) runSendQueue() {
case <-t.listening:
return
case p := <-t.closeQueue:
t.conn.WritePacket(p.payload, p.addr, p.info.OOB(), 0)
t.conn.WritePacket(p.payload, p.addr, p.info.OOB(), 0, protocol.ECNNon)
case p := <-t.statelessResetQueue:
t.sendStatelessReset(p)
}
@ -414,7 +414,7 @@ func (t *Transport) sendStatelessReset(p receivedPacket) {
rand.Read(data)
data[0] = (data[0] & 0x7f) | 0x40
data = append(data, token[:]...)
if _, err := t.conn.WritePacket(data, p.remoteAddr, p.info.OOB(), 0); err != nil {
if _, err := t.conn.WritePacket(data, p.remoteAddr, p.info.OOB(), 0, protocol.ECNNon); err != nil {
t.logger.Debugf("Error sending Stateless Reset to %s: %s", p.remoteAddr, err)
}
}