RTT 还是没整明白

This commit is contained in:
impact-eintr
2022-12-21 17:46:16 +08:00
parent e69ed41455
commit 94e12c1f21
6 changed files with 30 additions and 14 deletions

View File

@@ -2,10 +2,12 @@ package loopback
import (
"fmt"
"math/rand"
"netstack/logger"
"netstack/tcpip"
"netstack/tcpip/buffer"
"netstack/tcpip/stack"
"time"
)
type endpoint struct {
@@ -47,6 +49,8 @@ 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())
//time.Sleep(time.Duration(rand.Intn(50)+50) * time.Millisecond)
e.count++
if e.count == -1 { // 丢掉客户端写入的第二个包