|
 |
栏目导栏 |
|
| |
|
|
|
|
 |
资料搜索 |
|
| |
|
|
|
|
 |
热门文章 |
|
| |
|
|
|
|
 |
最新文章 |
|
| |
|
|
|
| |
| |
|
|
|
| |
| Linux 和FreeBSD libnet 发送机制对比 |
|
研究libnet代码以及实际测试:JBJLinux联盟 发现在Freebsd中,实际发送的数据帧不能超过2034,加上14字节正好是2048了JBJLinux联盟 在Linux中,LibNet采取了RAW SOCKET的方式发送数据socket(PF_SOCKET,SOCK_RAW,htons(ETH_P_ALL))JBJLinux联盟 Freebsd中换了机制,使用的是bpf驱动方式。JBJLinux联盟 查看BPF源代码,发现内核实现时JBJLinux联盟 bpf.c:248JBJLinux联盟 if ((unsigned)len > MCLBYTES)JBJLinux联盟 return (EIO);JBJLinux联盟 而MCLBYTE宏缺省定义为2048,在内核配置文件sys/params.h:144行JBJLinux联盟 /*JBJLinux联盟 * Constants related to network buffer management.JBJLinux联盟 * MCLBYTES must be no larger than PAGE_SIZE.JBJLinux联盟 */JBJLinux联盟 #ifndef MSIZEJBJLinux联盟 #define MSIZE 256 /* size of an mbuf */JBJLinux联盟 #endif /* MSIZE */JBJLinux联盟 JBJLinux联盟 #ifndef MCLSHIFTJBJLinux联盟 #define MCLSHIFT 11 /* convert bytes to mbuf clusters */JBJLinux联盟 #endif /* MCLSHIFT */JBJLinux联盟 JBJLinux联盟 #define MCLBYTES (1 << MCLSHIFT) /* size of an mbuf cluster */JBJLinux联盟 JBJLinux联盟 #define MJUMPAGESIZE PAGE_SIZE /* jumbo cluster 4k */JBJLinux联盟 #define MJUM9BYTES (9 * 1024) /* jumbo cluster 9k */JBJLinux联盟 #define MJUM16BYTES (16 * 1024) /* jumbo cluster 16k */JBJLinux联盟 JBJLinux联盟 在配置内核时应该可以通过配置JBJLinux联盟 MCLSHIFT 12 来将缓冲区提高到4096JBJLinux联盟 但是我想发送8K的数据包怎么办??JBJLinux联盟 /*JBJLinux联盟 * Constants related to network buffer management.JBJLinux联盟 * MCLBYTES must be no larger than PAGE_SIZE.JBJLinux联盟 */JBJLinux联盟 专门有一个提示要求不能大于PAGE_SIZE,难道我还要改动PAGE_SIZE?改动后对系统会不会造成较大影响??JBJLinux联盟 JBJLinux联盟 看了系统源码,在IA64中,PAGE_SIZE默认为8K,在其其他体系中,包括AMD64,都是4096JBJLinux联盟 为何?待研究JBJLinux联盟 JBJLinux联盟 看来RAW SOCKET性能是要高。JBJLinux联盟 JBJLinux联盟 下来再研究bfp源码吧JBJLinux联盟
Linux联盟收集整理 ,转贴请标明原始链接,如有任何疑问欢迎来本站Linux论坛讨论 |
|
|
|
|
|