5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-22 17:40:26 +00:00

trying to debug UDP+large MTU issues

This commit is contained in:
Arceliar 2018-02-20 17:31:12 -06:00
parent a81c361484
commit d3dc7765f2
2 changed files with 9 additions and 3 deletions

View File

@ -164,7 +164,7 @@ func (iface *tcpInterface) handler(sock *net.TCPConn) {
} }
out := make(chan []byte, 32) // TODO? what size makes sense out := make(chan []byte, 32) // TODO? what size makes sense
defer close(out) defer close(out)
buf := bufio.NewWriterSize(sock, 65535) buf := bufio.NewWriterSize(sock, tcp_msgSize)
send := func(msg []byte) { send := func(msg []byte) {
msgLen := wire_encode_uint64(uint64(len(msg))) msgLen := wire_encode_uint64(uint64(len(msg)))
before := buf.Buffered() before := buf.Buffered()

View File

@ -171,10 +171,14 @@ func (iface *udpInterface) handleKeys(msg []byte, addr connAddr) {
linkIn: make(chan []byte, 1), linkIn: make(chan []byte, 1),
keysIn: make(chan *udpKeys, 1), keysIn: make(chan *udpKeys, 1),
out: make(chan []byte, 32), out: make(chan []byte, 32),
chunkSize: 576 - 60 - 8 - 3, // max save - max ip - udp header - chunk overhead chunkSize: 576 - 60 - 8 - 3, // max safe - max ip - udp header - chunk overhead
} }
if udpAddr.IP.IsLinkLocalUnicast() { if udpAddr.IP.IsLinkLocalUnicast() {
conn.chunkSize = 65535 - 8 - 3 ifce, err := net.InterfaceByName(udpAddr.Zone)
if ifce != nil && err == nil {
conn.chunkSize = uint16(ifce.MTU) - 60 - 8 - 3
}
//conn.chunkSize = 65535 - 8 - 3
} }
/* /*
conn.in = func (msg []byte) { conn.peer.handlePacket(msg, conn.linkIn) } conn.in = func (msg []byte) { conn.peer.handlePacket(msg, conn.linkIn) }
@ -262,6 +266,7 @@ func (iface *udpInterface) handleKeys(msg []byte, addr connAddr) {
conn.countOut += 1 conn.countOut += 1
conn.peer.updateBandwidth(len(msg), timed) conn.peer.updateBandwidth(len(msg), timed)
util_putBytes(msg) util_putBytes(msg)
//iface.core.log.Println("DEBUG: sent:", len(msg))
} }
}() }()
//*/ //*/
@ -296,6 +301,7 @@ func (iface *udpInterface) reader() {
//iface.core.log.Println("Starting read") //iface.core.log.Println("Starting read")
n, udpAddr, err := iface.sock.ReadFromUDP(bs) n, udpAddr, err := iface.sock.ReadFromUDP(bs)
//iface.core.log.Println("Read", n, udpAddr.String(), err) //iface.core.log.Println("Read", n, udpAddr.String(), err)
//iface.core.log.Println("DEBUG: read:", bs[0], bs[1], bs[2], n)
if err != nil { if err != nil {
panic(err) panic(err)
break break