Chinaunix首页 | 论坛 | 博客
  • 博客访问: 659154
  • 博文数量: 186
  • 博客积分: 1875
  • 博客等级: 上尉
  • 技术积分: 2117
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-23 23:21
个人简介

有时候,就是想窥视一下不知道的东东,因为好奇!

文章分类

全部博文(186)

文章存档

2024年(2)

2023年(3)

2020年(1)

2019年(1)

2018年(1)

2017年(2)

2016年(69)

2015年(53)

2014年(14)

2013年(1)

2012年(5)

2011年(25)

2010年(9)

分类: LINUX

2015-08-07 20:06:28

第9章 准备连接请求
    本章从客户端socket程序出发,沿着第二路线分析客户端与服务器的连接过程
    connect(client_fd, (struct sockaddr *)&server_address, server_len)
    其中server_address是服务器地址.
9.1 内核的连接函数
9.2 分配数据包结构和数据块空间
9.3 构建/发送TCP数据包
        ......前一篇

9.4 进化成IP数据包
        ip选项结构 struct ip_option {
                            ......
                           };
        struct iphdr {
                ......
        };
        sys_socketcall()-->sys_connect()-->inet_stream_connect()-->tcp_v4_connect()-->tcp_connect()-->tcp_transmit_skb()-->ip_queue_xmit()-->......
        tcp_transmit_skb()-->ip_queue_xmit()-->__sk_dst_check()
                                                                    -->ip_options_build()
                                                                    -->ip_select_ident_more()-->__ip_select_ident()-->inet_getid()
                                                                                                                                                
-->ip_select_fb_ident()
                                                                    -->ip_local_out()-->__ip_local_out()-->nf_hook()
                                                                                              -->dst_output()-->ip_output()-->ip_finish_output()-->ip_finish_output2()-->neigh_resolve_output()
        ip_queue_xmit(struct sk_buff *sk, int ipfragok)发送数据包. 其skb是客户要发送的SYN数据包, ipfragok是指定是否分段.
        ip_options_build()将程序设置的ip选项复制到数据中. 将目标地址保存在源路由中并记录时间戳等内容.
        ip_select_ident_more()设置ip头部的标识ID
        __ip_select_ident()设置ip头部的标识编号
        inet_getid()
        ip_select_fb_ident()根据目标地址生成ID, 记录到头部中
        ip_local_out()
        __ip_local_out()通过Netfilter发送数据包
        nf_hook()通过Netfilter过滤
        dst_output()直接发送数据包
        ip_output()
        ip_finish_output2()对分段数据进行发送
        neigh_resolve_output()一方面完善客户端的邻居子系统,另一方面实现数据包的发送
        ......需进一步深入理解

9.5 进化成以太网数据包
9.6 发送以太网数据包
阅读(424) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~