mirror of
https://github.com/impact-eintr/netstack.git
synced 2025-10-18 18:54:30 +08:00
emmm 注册式网络栈不太好写
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
package loopback
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"netstack/logger"
|
||||
"netstack/tcpip"
|
||||
"netstack/tcpip/buffer"
|
||||
"netstack/tcpip/stack"
|
||||
)
|
||||
|
||||
type endpoint struct {
|
||||
count int
|
||||
dispatcher stack.NetworkDispatcher
|
||||
}
|
||||
|
||||
@@ -43,6 +46,13 @@ func (e *endpoint) WritePacket(r *stack.Route, hdr buffer.Prependable, payload b
|
||||
views = append(views, payload.Views()...)
|
||||
vv := buffer.NewVectorisedView(len(views[0])+payload.Size(), views)
|
||||
|
||||
// TODO 这里整点活 在特定的情况下丢掉数据报 模拟网络阻塞
|
||||
|
||||
e.count++
|
||||
if e.count == 5 || e.count == 7 || e.count == 9 {
|
||||
logger.NOTICE(fmt.Sprintf("统计 %d 丢掉这个报文", e.count))
|
||||
return nil
|
||||
}
|
||||
// Because we're immediately turning around and writing the packet back to the
|
||||
// rx path, we intentionally don't preserve the remote and local link
|
||||
// addresses from the stack.Route we're passed.
|
||||
|
@@ -299,3 +299,9 @@ Silly Window Syndrome 翻译成中文就是“糊涂窗口综合症”。正如
|
||||
|
||||
1. 要等到 Window Size >= MSS 或是 Data Size >= MSS
|
||||
2. 收到之前发送数据的 ack 回包,他才会发数据,否则就是在攒数据
|
||||
|
||||
> 上面是通过 keepalive 实现的
|
||||
|
||||
## tcp的拥塞控制
|
||||
|
||||
节介绍 tcp 的拥塞控制,拥塞控制控制是 tcp 协议中最复杂问题之一,主要是如何探测链路已经拥塞?探测到拥塞后如何处理?
|
||||
|
Reference in New Issue
Block a user