tcp可靠性实现 抄了一堆东西 信息量太大了 看不过来

This commit is contained in:
impact-eintr
2022-12-13 16:17:57 +08:00
parent fb578a6f9e
commit 5a9042d890
12 changed files with 700 additions and 23 deletions

View File

@@ -33,6 +33,7 @@ func ChecksumCombine(a, b uint16) uint16 {
// given destination protocol and network address, ignoring the length
// field. Pseudo-headers are needed by transport layers when calculating
// their own checksum.
// hash(protocol, hash(dst, hash(src, 0)))
func PseudoHeaderChecksum(protocol tcpip.TransportProtocolNumber, srcAddr tcpip.Address, dstAddr tcpip.Address) uint16 {
xsum := Checksum([]byte(srcAddr), 0)
xsum = Checksum([]byte(dstAddr), xsum)

View File

@@ -131,6 +131,23 @@ const (
)
// SACKBlock 表示 sack 块的结构体
/*
+--------+--------+
| Kind=5 | Length |
+--------+--------+--------+---------+
| Start of 1st Block |
+--------+--------+--------+---------+
| End of 1st Block |
+--------+--------+--------+---------+
| |
/ . . . . . . /
| |
+--------+--------+--------+---------+
| Start of nth Block |
+--------+--------+--------+---------+
| End of nth Block |
+--------+--------+--------+---------+
*/
type SACKBlock struct {
// Start indicates the lowest sequence number in the block.
Start seqnum.Value