WEB开发网
开发学院软件开发Java tcp connection setup的实现(一) 阅读

tcp connection setup的实现(一)

 2009-09-10 00:00:00 来源:WEB开发网   
核心提示: 接下来看几个和bind相关的数据结构: 第一个是inet_hashinfo,它主要用来管理 tcp的bind hash bucket(在tcp的初始化函数中会将tcp_hashinfo初始化.然后在tcp_prot中会将tcp_hashinfo付给结构体h,然后相应的我们就可以通过sock中的s

接下来看几个和bind相关的数据结构:

第一个是inet_hashinfo,它主要用来管理 tcp的bind hash bucket(在tcp的初始化函数中会将tcp_hashinfo初始化.然后在tcp_prot中会将tcp_hashinfo付给结构体h,然后相应的我们就可以通过sock中的sock_common域来存取这个值).后面我们会分析这个流程.

Java代码  

struct inet_hashinfo { 
 /* This is for sockets with full identity only. Sockets here will 
 * always be without wildcards and will have the following invariant: 
 * 
 *     TCP_ESTABLISHED <= sk->sk_state < TCP_CLOSE 
 * 
 * TIME_WAIT sockets use a separate chain (twchain). 
 */ 
///下面会分析这个结构. 
 struct inet_ehash_bucket *ehash; 
 rwlock_t  *ehash_locks; 
 unsigned int  ehash_size; 
 unsigned int  ehash_locks_mask; 
 
 /* Ok, let's try this, I give up, we do need a local binding 
 * TCP hash as well as the others for fast bind/connect. 
 */ 
///表示所有的已经在使用的端口号的信息.这里bhash也就是一个hash链表,而链表的元素是inet_bind_bucket,紧接着我们会分析这个结构. 
 struct inet_bind_hashbucket *bhash; 
 
 unsigned int  bhash_size; 
 /* Note : 4 bytes padding on 64 bit arches */ 
 
 /* All sockets in TCP_LISTEN state will be in here. This is the only 
 * table where wildcard'd TCP sockets can exist. Hash function here 
 * is just local port number. 
 */ 
///listening_hash表示所有的处于listen状态的socket. 
 struct hlist_head listening_hash[INET_LHTABLE_SIZE]; 
 
 /* All the above members are written once at bootup and 
 * never written again _or_ are predominantly read-access. 
 * 
 * Now align to a new cache line as all the following members 
 * are often dirty. 
 */ 
 rwlock_t  lhash_lock ____cacheline_aligned; 
 atomic_t  lhash_users; 
 wait_queue_head_t lhash_wait; 
 struct kmem_cache  *bind_bucket_cachep; 
};

上一页  1 2 3 4 5 6 7  下一页

Tags:tcp connection setup

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接