快速重传失效了

This commit is contained in:
impact-eintr
2022-12-26 18:00:37 +08:00
parent 94e12c1f21
commit 823e76e979
5 changed files with 63 additions and 9 deletions

View File

@@ -2,12 +2,10 @@ package loopback
import (
"fmt"
"math/rand"
"netstack/logger"
"netstack/tcpip"
"netstack/tcpip/buffer"
"netstack/tcpip/stack"
"time"
)
type endpoint struct {
@@ -49,11 +47,11 @@ func (e *endpoint) WritePacket(r *stack.Route, hdr buffer.Prependable, payload b
vv := buffer.NewVectorisedView(len(views[0])+payload.Size(), views)
// TODO 这里整点活 在特定的情况下丢掉数据报 模拟网络阻塞
rand.Seed(time.Now().Unix())
//rand.Seed(time.Now().Unix())
//time.Sleep(time.Duration(rand.Intn(50)+50) * time.Millisecond)
e.count++
if e.count == -1 { // 丢掉客户端写入的第二个包
if e.count == 10 { // 丢掉客户端写入的第二个包
logger.NOTICE(fmt.Sprintf("统计 %d 丢掉这个报文", e.count))
return nil
}