Linux协议栈-TCP-SYN-处理逻辑

    今天整理了一下Linux协议栈针对TCP客户端三次握手的SYN请求流程

    简要流程如下:

入口:
-> ip_local_deliver_finish(struct sk_buff *skb) // L4入口
    -> ipprot->handler(skb);//进入udp、tcp传输层
    -> tcp_v4_rcv(struct sk_buff *skb)
        -> tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
            -> sk->sk_state == TCP_LISTEN //三次握手,①SYN③ACK
            -> tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, struct tcphdr *th, unsigned len) //收到服务器的SYN
                -> case TCP_LISTEN: // 服务端收到SYN
                -> th->syn
                    -> tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) //服务端处理SYN
                        -> 队列存储状况检查 //reqsk_queue, acceptq
                        -> inet_reqsk_alloc(struct request_sock_ops *ops) //tcp_request_sock_ops
                        -> tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx, u8 **hvpp, int estab) //解析SYN段中的TCP选项
                        -> tcp_openreq_init(struct request_sock *req, struct tcp_options_received *rx_opt, struct sk_buff *skb)
                        -> tcp_v4_init_sequence(struct sk_buff *skb) //服务端初始序列号
                        -> tcp_v4_send_synack(struct sock *sk, struct dst_entry *dst, struct request_sock *req, struct request_values *rvp)
                        -> inet_csk_reqsk_queue_hash_add(struct sock *sk, struct request_sock *req, unsigned long timeout)  //TCP_TIMEOUT_INIT

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值