pack packets into large buffers when GSO is available

This commit is contained in:
Marten Seemann
2023-04-30 17:27:50 +02:00
parent 628ba87727
commit 5b5ffa942b
16 changed files with 339 additions and 186 deletions

View File

@@ -1,12 +1,15 @@
package quic
import (
"math"
"net"
"github.com/quic-go/quic-go/internal/protocol"
)
// A sendConn allows sending using a simple Write() on a non-connected packet conn.
type sendConn interface {
Write([]byte) error
Write(b []byte, size protocol.ByteCount) error
Close() error
LocalAddr() net.Addr
RemoteAddr() net.Addr
@@ -40,8 +43,11 @@ func newSendConn(c rawConn, remote net.Addr, info *packetInfo) *sconn {
}
}
func (c *sconn) Write(p []byte) error {
_, err := c.WritePacket(p, c.remoteAddr, c.oob)
func (c *sconn) Write(p []byte, size protocol.ByteCount) error {
if size > math.MaxUint16 {
panic("size overflow")
}
_, err := c.WritePacket(p, uint16(size), c.remoteAddr, c.oob)
return err
}