开始研究拥塞算法

This commit is contained in:
impact-eintr
2022-12-19 12:39:28 +08:00
parent d101e88acb
commit 9fa4a0b87f
7 changed files with 147 additions and 34 deletions

View File

@@ -1,6 +1,8 @@
package loopback
import (
"fmt"
"netstack/logger"
"netstack/tcpip"
"netstack/tcpip/buffer"
"netstack/tcpip/stack"
@@ -47,13 +49,14 @@ func (e *endpoint) WritePacket(r *stack.Route, hdr buffer.Prependable, payload b
// TODO 这里整点活 在特定的情况下丢掉数据报 模拟网络阻塞
e.count++
//if e.count == 5 || e.count == 7 || e.count == 9 {
// logger.NOTICE(fmt.Sprintf("统计 %d 丢掉这个报文", e.count))
// return nil
//}
if e.count == 6 { // 丢掉客户端写入的第二个包
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.
logger.NOTICE(fmt.Sprintf("统计分发 %d 报文", e.count))
e.dispatcher.DeliverNetworkPacket(e, "" /* remoteLinkAddr */, "" /* localLinkAddr */, protocol, vv)
return nil