Skip to the content.

A TCP/IP Tutorial 阅读笔记

A TCP/IP Tutorial

TCP/IP 一般不仅仅指的是 TCP IP 两个协议,还包括 UDP, ARP 和 ICMP

Ethernet frame 的地址为 MAC 地址

Ethernet uses CSMA/CD (Carrier Sense and Multiple Access with Collision Detection).

ARP (Address Resolution Protocol) : 根据 IP 查询 MAC 地址

TCP is a sliding window protocol with time-out and retransmits.

基本路径

- send
  - `__sys_sendto`
    - sock_sendmsg
      - sock_sendmsg_nosec
        - `INDIRECT_CALL_INET(sock->ops->sendmsg, inet6_sendmsg, inet_sendmsg, sock, msg, msg_data_left(msg));`
          - inet_sendmsg
            - `INDIRECT_CALL_2(sk->sk_prot->sendmsg, tcp_sendmsg, udp_sendmsg, sk, msg, size);`
              - tcp_sendmsg
                - tcp_sendmsg_locked
                  - `__tcp_push_pending_frames`
                  - tcp_push_one
                    - tcp_write_xmit
                      - tcp_transmit_skb
                        - `__tcp_transmit_skb`
                          - `INDIRECT_CALL_INET(icsk->icsk_af_ops->queue_xmit, inet6_csk_xmit, ip_queue_xmit, sk, skb, &inet->cork.fl);`=
                            - inet_connection_sock::inet_connection_sock_af_ops::queue_xmit
                              - ip_queue_xmit
                                - `__ip_queue_xmit`
                                  - ip_local_out
                                    - `__ip_local_out`
                                      - dst_output
                                        - `skb_dst(skb)->output(net, sk, skb);`
                                          - ip_output
                                            - ip_finish_output
                                              - `__ip_finish_output`
                                                - ip_finish_output2
                                                  - neigh_output
                                                    - neigh_hh_output
                                                    - neighbour::output
                                                      - dev_queue_xmit
                                                        - `__dev_queue_xmit`
                                                          - `__dev_xmit_skb`
                                                            - `__qdisc_run`
                                                              - qdisc_restart
                                                                - sch_direct_xmit
                                                                  - dev_hard_start_xmit
                                                                    - xmit_one
                                                                      - netdev_start_xmit
                                                                        - `__netdev_start_xmit`
                                                                          - net_device_ops::ndo_start_xmit
                                                                            - e1000_xmit_frame

drawing

from https://ipads.se.sjtu.edu.cn/mospi/

9293

最官方的文档

三次握手

Moving past TCP in the data center, part 1

congestion control

似乎默认是 cubic

cat /proc/sys/net/ipv4/tcp_congestion_control
cubic
static struct tcp_congestion_ops cubictcp __read_mostly = {
	.init		= cubictcp_init,
	.ssthresh	= cubictcp_recalc_ssthresh,
	.cong_avoid	= cubictcp_cong_avoid,
	.set_state	= cubictcp_state,
	.undo_cwnd	= tcp_reno_undo_cwnd,
	.cwnd_event	= cubictcp_cwnd_event,
	.pkts_acked     = cubictcp_acked,
	.owner		= THIS_MODULE,
	.name		= "cubic",
};

搜索了下,感觉 tcp congestion 的参数真不少啊:

tools/testing/selftests/bpf/progs/tcp_ca_incompl_cong_ops.c:	.ssthresh = (void *)incompl_cong_ops_ssthresh,
tools/testing/selftests/bpf/progs/bpf_cubic.c:	.ssthresh	= (void *)bpf_cubic_recalc_ssthresh,
tools/testing/selftests/bpf/progs/bpf_dctcp.c:	.ssthresh	= (void *)dctcp_ssthresh,
tools/testing/selftests/bpf/progs/tcp_ca_update.c:	.ssthresh = (void *)ca_update_ssthresh,
tools/testing/selftests/bpf/progs/tcp_ca_update.c:	.ssthresh = (void *)ca_update_ssthresh,
tools/testing/selftests/bpf/progs/tcp_ca_update.c:	.ssthresh = (void *)ca_update_ssthresh,
tools/testing/selftests/bpf/progs/tcp_ca_update.c:	.ssthresh = (void *)ca_update_ssthresh,
tools/testing/selftests/bpf/progs/tcp_ca_write_sk_pacing.c:	.ssthresh = (void *)write_sk_pacing_ssthresh,
include/trace/events/rxrpc.h:		      __entry->sum.ssthresh,
net/ipv4/tcp_cubic.c:	.ssthresh	= cubictcp_recalc_ssthresh,
net/ipv4/tcp_cdg.c:	.ssthresh = tcp_cdg_ssthresh,
net/ipv4/tcp_cong.c:	.ssthresh	= tcp_reno_ssthresh,
net/ipv4/tcp_htcp.c:	.ssthresh	= htcp_recalc_ssthresh,
net/ipv4/tcp_hybla.c:	.ssthresh	= tcp_reno_ssthresh,
net/ipv4/tcp_lp.c:	.ssthresh = tcp_reno_ssthresh,
net/ipv4/tcp_vegas.c:	.ssthresh	= tcp_reno_ssthresh,
net/ipv4/tcp_yeah.c:	.ssthresh	= tcp_yeah_ssthresh,
net/ipv4/tcp_highspeed.c:	.ssthresh	= hstcp_ssthresh,
net/ipv4/tcp_illinois.c:	.ssthresh	= tcp_illinois_ssthresh,
net/ipv4/tcp_veno.c:	.ssthresh	= tcp_veno_ssthresh,
net/ipv4/tcp_westwood.c:	.ssthresh	= tcp_reno_ssthresh,
net/ipv4/tcp_scalable.c:	.ssthresh	= tcp_scalable_ssthresh,
net/ipv4/tcp_bbr.c:	.ssthresh	= bbr_ssthresh,
net/ipv4/tcp_bic.c:	.ssthresh	= bictcp_recalc_ssthresh,
net/ipv4/tcp_nv.c:	.ssthresh	= tcpnv_recalc_ssthresh,
net/ipv4/tcp_dctcp.c:	.ssthresh	= dctcp_ssthresh,
net/ipv4/tcp_dctcp.c:	.ssthresh	= tcp_reno_ssthresh,

资源

cs 144

数据中心的网络移除掉 TCP

[ ] big tcp

重传

通过 /proc/sys/net/ipv4/tcp_retries2 可以实现

TCP 拥塞控制对数据延迟的影响

https://www.kawabangga.com/posts/5181

重传实验

possible tcp sync

https://www.cloudflare.com/zh-cn/learning/ddos/syn-flood-ddos-attack/

TODO

It’s always TCP_NODELAY. Every damn time.

看看,不过可能意义不大

https://jeclark.net/articles/tcp-initcwnd/?tag=performance

https://cefboud.com/posts/tcp-deep-dive-internals/

https://brooker.co.za/blog/2024/05/09/nagle.html https://news.ycombinator.com/item?id=46359120

本站所有文章转发 CSDN 将按侵权追究法律责任,其它情况随意。