Giter Site home page Giter Site logo

wangbojing / ntytcp Goto Github PK

View Code? Open in Web Editor NEW
650.0 28.0 287.0 708 KB

单线程用户态TCP/IP协议栈,epoll实现,包含服务器案例,并发测试案例

License: MIT License

Makefile 0.54% C 99.46%
netmap userspace pf-ring dpdk epoll ip-hex tcpip

ntytcp's Introduction

image

配套视频讲解

netmap install

$ git clone https://github.com/wangbojing/netmap.git

$ ./configure

$ make 

$ sudo make install

netmap install complete.

Troubleshooting

1. problem : configure --> /bin/sh^M.

you should run . 
$ dos2unix configure

$ dos2unix ./LINUX/configure

2. problem : cannot stat 'bridge': No such or directory

$ make clean

$ cd build-apps/bridge

$ gcc -O2 -pipe -Werror -Wall -Wunused-function -I ../../sys -I ../../apps/include -Wextra    ../../apps/bridge/bridge.c  -lpthread -lrt    -o bridge

$ sudo make && make install

NtyTcp

netmap, dpdk, pf_ring, Tcp Stack for Userspace

compile:

$ sudo apt-get install libhugetlbfs-dev

$ make

update NtyTcp/include/nty_config.h


#define NTY_SELF_IP		"192.168.0.106" 	//your ip

#define NTY_SELF_IP_HEX	0x6A00A8C0 			//your ip hex.

#define NTY_SELF_MAC	"00:0c:29:58:6f:f4" //your mac

block server run:

$ ./bin/nty_example_block_server

epoll server run:

$ ./bin/nty_example_epoll_rb_server

Reference

if you discover bug to sending email to [email protected].

also, want to be an NtyTcper, so you can sent email to [email protected] .

ntytcp's People

Contributors

binvicent avatar bobo-peng avatar sparta2017 avatar wangbojing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ntytcp's Issues

您好,请教两个问题,如下:

  1. nty_example_epoll_rb_server 执行的时候,出现cpu占用率99%情况,连接server也无响应,请问作者有没有遇到过? 然后 NtyTcp协议栈的监听端口 可否用natstat 查询?
    root 1681 0.0 4.7 105240 47252 pts/0 S+ 11:55 0:00 gdb ./bin/nty_example_epoll_rb_se
    root 1683 99.0 2.1 381852 21084 pts/0 tLl 11:55 87:25 /home/ubuntu/workspace/NtyTcp/bin

2、nty_example_block_server执行出现段错误;如下:
(gdb)
99 if (nty_listen(sockfd, 5) < 0) {
(gdb)

Thread 1 "nty_example_blo" received signal SIGSEGV, Segmentation fault.
0x0000555555567e4b in HashListener (l=0x555555791a70) at nty_hash.c:93
93 return listener->s->s_addr.sin_port & (NUM_BINS_LISTENERS - 1);
(gdb) bt
#0 0x0000555555567e4b in HashListener (l=0x555555791a70) at nty_hash.c:93
#1 0x0000555555568392 in ListenerHTInsert (ht=0x55555578d440, it=0x555555791a70)
at nty_hash.c:218
#2 0x0000555555558bb0 in nty_listen (sockid=0, backlog=5) at nty_api.c:379
#3 0x00005555555836ae in main () at nty_example_tcp_server.c:99
(gdb)

如上问题,想请教一下,谢谢;(怀疑环境配置还有哪里有问题,请作者帮忙指正一下)

阅读代码遇到的问题

您好,关于代码中的像buffer的实现、addr的组织方式之类的有具体参考的资料吗?或者说有相同组织方式的开源项目吗?您这里的代码没注释,而且很复杂,有点看不太懂.....

请问我对RBN的理解对吗?

struct epitem {
	RB_ENTRY(epitem) rbn;
	/*  RB_ENTRY相当如定义了如下的一个结构成员变量
	struct {											
	struct type *rbe_left;		//指向左子树
	struct type *rbe_right;		//指向右子树
	struct type *rbe_parent;  	//指向父节点 正常的红黑树没有父节点,这里为什么需要?
	int rbe_color;			       //该红黑树节点颜色
	} rbn*/
};

epoll add 是向红黑树中添加节点
epoll wait 是将红黑树中就续的文件节点, 添加到双向链表中, 返回给应用,这个添加到链表中的操作,是内核完成,还是自己实现呢?
将一个fd添加到epoll中,底层的epoll是如何判断这个fd是否有数据可读,是否可以写数据,请问这样的判断是否消耗很大呢?
请问我理解的正确吗?

编译时遇到唯一问题

is:issue is:open vip 编译时遇到唯一问题:nty_socket.c:61:23: fatal error: hugetlbfs.h: 解决方法: 需要 安装 libhugetlbfs-dev 软件

运行./nty_example_block_server出现Segmentation fault

步骤如下:
1、虚拟机安装centos7(core 3.10.0-1127.8.2.el7.x86_64)
2、编译netmap13.0,得到e1000.ko和netmap.ko
3、加载e1000.ko和netmap.ko到系统
4、配置ip/mac和网卡,修改ntytcp的nty_config.h和nty_eth.c文件,如下:
image
image
5、编译ntytcp_maste
6、运行 nty_example_block_server
7、出现Segmentation fault,如下为gdb信息:
image
请问是何原因,谢谢!

代码中的问题

uint32_t right_wnd_edge = snd->peer_wnd + cur_stream->rcv->snd_wl1;

是不是应该为
uint32_t right_wnd_edge = snd->peer_wnd + cur_stream->rcv->snd_wl2;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.