1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-04 23:40:26 +08:00

fix 分片

This commit is contained in:
fumiama
2021-12-31 13:24:49 +08:00
parent a5e6135dd9
commit 9316a0064e
3 changed files with 12 additions and 5 deletions

View File

@@ -89,6 +89,14 @@ func (l *Link) Write(p *head.Packet, istransfer bool) (n int, err error) {
return n, err
}
data = data[(offset+1)*int(l.me.mtu):]
offset++
}
packet := *p
packet.Data = data[offset*int(l.me.mtu):]
i, err := l.write(&packet, uint16(offset), istransfer, false)
n += i
if err != nil {
return n, err
}
return n, nil
}
@@ -122,7 +130,6 @@ func (l *Link) write(p *head.Packet, offset uint16, istransfer, hasmore bool) (n
if d == nil {
return 0, errors.New("[link] ttl exceeded")
}
logrus.Debugln("[link] write", len(d), "bytes data")
if err == nil {
peerlink := l.me.router.NextHop(p.Dst.String())
if peerlink != nil {
@@ -130,7 +137,7 @@ func (l *Link) write(p *head.Packet, offset uint16, istransfer, hasmore bool) (n
if peerep == nil {
return 0, errors.New("[link] nil endpoint of " + p.Dst.String())
}
logrus.Infoln("[link] write data from ep", l.me.myconn.LocalAddr(), "to", peerep)
logrus.Infoln("[link] write", len(d), "bytes data from ep", l.me.myconn.LocalAddr(), "to", peerep)
n, err = l.me.myconn.WriteToUDP(d, peerep)
} else {
logrus.Warnln("[link] drop packet: nil peerlink")

View File

@@ -58,8 +58,8 @@ func (nc *NIC) Start(m *link.Me) {
logrus.Infoln("[lower] recv write", n, "bytes packet to nic")
}
}()
buf := make([]byte, m.MTU()+64) // 增加报头长度与 TEA 冗余
buf2 := make([]byte, m.MTU()+64) // 增加报头长度与 TEA 冗余
buf := make([]byte, m.MTU()+68) // 增加报头长度与 TEA 冗余
buf2 := make([]byte, m.MTU()+68) // 增加报头长度与 TEA 冗余
off := 0
isrev := false
for nc.hasstart { // 从 NIC 发送

View File

@@ -111,7 +111,7 @@ func main() {
}
defer w.Stop()
w.Run(upper.ServiceWireGold, upper.ServiceWireGold, 32768-64)
w.Run(upper.ServiceWireGold, upper.ServiceWireGold, 32768-68)
}
func displayHelp(hint string) {