当前位置: 首页 > news >正文

呼和浩特网站建设网页代码

呼和浩特网站建设,网页代码,中国建筑招聘信息,宁波网络公司在哪里因刚开始学习DPDK,在学习过程中了解到需使用用户态协议栈,在网上找到F-Stack的相关介绍,但是缺乏DPDK的相关知识,导致使用F-Stack 时UDP数据无法收到 一文了解dpdk rte_ring无锁队列F-Stack实现UDP服务端、客户端,并进…

因刚开始学习DPDK,在学习过程中了解到需使用用户态协议栈,在网上找到F-Stack的相关介绍,但是缺乏DPDK的相关知识,导致使用F-Stack 时UDP数据无法收到

  • 一文了解dpdk rte_ring无锁队列
  • F-Stack实现UDP服务端、客户端,并进行吞吐量测试的实现
  • github F-Stack

环境

在一台机器上,系统为Ubuntu 22.4

硬件上是一张100G网卡 两个网口,光纤直连两个网口

UDPServer 的port0.ini配置文件中设置IP如下并使用网卡的PORT0端口

[port0]
addr=192.168.2.15
netmask=255.255.255.0
broadcast=192.168.2.255
gateway=192.168.2.1

UDPClient 的port1.ini配置文件中设置IP如下并使用网卡的PORT1端口

[port1]
addr=192.168.2.16
netmask=255.255.255.0
broadcast=192.168.2.255
gateway=192.168.2.1

问题

服务端可以接收到客户端的arp请求报文并且应答了arp报文,然后就卡住了,ff_envent()函数无法检测到sockfd有数据
UDPServer配置文件中的 lcore_mask 参数我配置的是f0

lcore_mask=f0

本意是想启动一个UDPServer程序使用4个逻辑核心,经过测试启动一个程序只能使用配置的第一个逻辑核心,此时去使用UDPClient发送数据到UDPServer时就无法收到数据,不知道是我个人有这个问题,还是在同一电脑上的同一张网卡配置多个逻辑核心时都无法收到数据,就是这么设计的吗

解决

后续又买了一块相同的100G网卡,放在另一台电脑,光纤直连,然后发送数据,此时竟然可以收到数据。那就证明代码收发是正确的

后续查看源码时在源码文件 ff_dpdk_if.cmain_loop() 函数中有调用 process_dispatch_ring() 函数,函数内调用了 rte_ring_dequeue_burst(),大概了解了一下,我猜测因为我配置了4个核心,在初始化时创建了4个ring队列

从打印的信息来看也是这样的:

create ring:dispatch_ring_p0_q0 success, 2047 ring entries are now free!
create ring:dispatch_ring_p0_q1 success, 2047 ring entries are now free!
create ring:dispatch_ring_p0_q2 success, 2047 ring entries are now free!
create ring:dispatch_ring_p0_q3 success, 2047 ring entries are now free!

我个人猜测,很有可能是因为接收UDP数据被分发给了其它的队列上,我只启动一个程序也就是只是用了第一个ring队列,那么就不可能收到数据,然后我相应的启动了4个程序,终于收到了数据,老天爷,对于一个刚学习DPDK的人简直是折磨。

$ ./UDPServer -c port0.ini -p 0 &
$ ./UDPServer -c port0.ini -p 1 &
$ ./UDPServer -c port0.ini -p 2 &
$ ./UDPServer -c port0.ini -p 3 &

如果不想启动多个进程的话,把配置文件中的核心数配置为1个,启动一个程序就可以收发数据了。

代码

UDPserver


#include <stdio.h>
#include <sys/ioctl.h>
#include <string.h>
#include <cerrno>
#include <stdlib.h>
#include <rte_ethdev.h>// F-stack
#include <ff_api.h>
#include <ff_config.h>#define MAX_EVENTS 512
#define MAXLINE 512int kq;
int sockfd;
/* kevent set */
struct kevent kevSet;
/* events */
struct kevent events[MAX_EVENTS];int loop(void *arg){char buf[MAXLINE] = {"0"};struct sockaddr_in cliAddr;socklen_t recvAddrLen = sizeof(cliAddr);int nevents = ff_kevent(kq, NULL, 0, events, MAX_EVENTS, NULL);if (nevents < 0) {printf("ff_kevent failed:%d, %s\n", errno, strerror(errno));return -1;}for (int i = 0; i < nevents; ++i) {struct kevent event = events[i];int clientfd = (int)event.ident;printf("event.data = %d \n", (int)event.data);printf("listen event %d\n", nevents);printf("clientfd %d\n", clientfd);printf("sockfd %d\n", sockfd);printf("event.flags = %d \n", event.flags);if (clientfd == sockfd) {int n = ff_recvfrom(sockfd, buf, MAXLINE, 0,  (struct linux_sockaddr *)&cliAddr, &recvAddrLen);if(n < 0){printf("ff_recvfrom failed, errno:%d, %s\n", errno, strerror(errno));}else{// 接收数据 并打印printf("Server recv   %s\n", buf);printf("Client Family %d\n", cliAddr.sin_family);printf("Client Addr   %s\n", inet_ntoa(cliAddr.sin_addr));printf("Client Port   %u\n", ntohs(cliAddr.sin_port));strcpy(buf, "hello client, i am server");int num = ff_sendto(sockfd, buf, sizeof(buf) / sizeof(buf[0]), 0, (struct linux_sockaddr *)&cliAddr, recvAddrLen);if(num < 0){printf("ff_sendto failed, errno:%d, %s\n", errno, strerror(errno));ff_stop_run();}else{printf("Server send %d bytes\n", num);}}}}return 1;
}int main(int argc, char **argv){int on = 1;struct sockaddr_in my_addr;ff_init(argc, argv);kq = ff_kqueue();if (kq < 0) {printf("ff_kqueue failed, errno:%d, %s\n", errno, strerror(errno));exit(1);}sockfd = ff_socket(AF_INET, SOCK_DGRAM, 0);ff_ioctl(sockfd, FIONBIO, &on);bzero(&my_addr, sizeof(my_addr));my_addr.sin_family = AF_INET;my_addr.sin_port = htons(34824);my_addr.sin_addr.s_addr =  htonl(INADDR_ANY);int ret = ff_bind(sockfd, (struct linux_sockaddr *)&my_addr, sizeof(my_addr));if (ret < 0) {printf("ff_bind failed, sockfd:%d, errno:%d, %s\n", sockfd, errno, strerror(errno));exit(1);}EV_SET(&kevSet, sockfd, EVFILT_READ, EV_ADD, 0, MAX_EVENTS, NULL);/* Update kqueue */ff_kevent(kq, &kevSet, 1, NULL, 0, NULL);ff_run(loop, NULL);if(rte_eth_dev_stop(0) < 0)rte_exit(EXIT_FAILURE, "Cannot close eth %" PRIu16 "\n", 0);rte_eal_cleanup();return 1;
}

UDPClient

#include <stdio.h>#include <sys/ioctl.h>
#include <string.h>
#include <cerrno>
#include <stdlib.h>
#include <rte_ethdev.h>// F-stack
#include <ff_api.h>
#include <ff_config.h>#define MAX_EVENTS 512
#define MAXLINE 512
int kq;
int sockfd;
/* kevent set */
struct kevent kevSet;
/* events */
struct kevent events[MAX_EVENTS];
struct sockaddr_in serverAddr;int loop(void *arg){int num;char buf[MAXLINE] = {"0"};struct sockaddr_in recvAddr;socklen_t recvAddrLen = sizeof(recvAddr);strcpy(buf,"hello, i am client");num = ff_sendto(sockfd, buf, sizeof(buf)/sizeof(buf[0]), 0, (struct linux_sockaddr *)&serverAddr, sizeof(serverAddr));if(num < 0){printf("ff_kevent failed:%d, %s\n", errno, strerror(errno));ff_stop_run();}elseprintf("sendto num:%d\n", num);int nevents = ff_kevent(kq, NULL, 0, events, MAX_EVENTS, NULL);if (nevents < 0) {printf("ff_kevent failed:%d, %s\n", errno, strerror(errno));ff_stop_run();return -1;}for (int i = 0; i < nevents; ++i) {printf("listen nevents !!! \n");struct kevent event = events[i];int serverfd = (int)event.ident;printf("event.data = %d \n", (int)event.data);printf("event.flags = %d \n", event.flags);printf("serverfd = %d \n", serverfd);printf("sockfd = %d \n", sockfd);if (serverfd == sockfd) {int n = ff_recvfrom(sockfd, buf, MAXLINE, 0,  (struct linux_sockaddr *)&recvAddr, &recvAddrLen);if(n < 0){printf("ff_recvfrom failed, errno:%d, %s\n", errno, strerror(errno));}else{// 接收数据 并打印printf("Client recv   %s\n", buf);printf("Server Family %d\n", recvAddr.sin_family);printf("Server Addr   %s\n", inet_ntoa(recvAddr.sin_addr));printf("Server Port   %u\n", ntohs(recvAddr.sin_port));ff_stop_run();}}}return 1;
}int main(int argc, char **argv){struct sockaddr_in my_addr;int on = 1;ff_init(argc, argv);kq = ff_kqueue();if (kq < 0) {printf("ff_kqueue failed, errno:%d, %s\n", errno, strerror(errno));exit(1);}sockfd = ff_socket(AF_INET, SOCK_DGRAM, 0);ff_ioctl(sockfd, FIONBIO, &on);bzero(&my_addr, sizeof(my_addr));my_addr.sin_family = AF_INET;my_addr.sin_port = htons(34825);my_addr.sin_addr.s_addr = inet_addr( "192.168.2.16" );ff_bind(sockfd, (struct linux_sockaddr *)&my_addr, sizeof(my_addr));// 指定发送的地址和端口号bzero(&serverAddr, sizeof(serverAddr));serverAddr.sin_family = AF_INET;serverAddr.sin_port = htons(34824);serverAddr.sin_addr.s_addr = inet_addr( "192.168.2.15" );EV_SET(&kevSet, sockfd, EVFILT_READ, EV_ADD, 0, MAX_EVENTS, NULL);/* Update kqueue */ff_kevent(kq, &kevSet, 1, NULL, 0, NULL);ff_run(loop, NULL);ff_close(sockfd);return 1;
}

文章转载自:
http://dinncozodiacal.knnc.cn
http://dinncojephthah.knnc.cn
http://dinncopathogenesis.knnc.cn
http://dinncoarborvitae.knnc.cn
http://dinncomicturition.knnc.cn
http://dinncosafrole.knnc.cn
http://dinncounceremoniousness.knnc.cn
http://dinncosilane.knnc.cn
http://dinncopolynomial.knnc.cn
http://dinncounclothe.knnc.cn
http://dinncokpelle.knnc.cn
http://dinncolakoda.knnc.cn
http://dinncowirehead.knnc.cn
http://dinncokofu.knnc.cn
http://dinncoexploitative.knnc.cn
http://dinncorotary.knnc.cn
http://dinncotajumulco.knnc.cn
http://dinncocartomancy.knnc.cn
http://dinncoabsorbing.knnc.cn
http://dinncorecuperatory.knnc.cn
http://dinncoreflorescence.knnc.cn
http://dinncorifampin.knnc.cn
http://dinncomaungy.knnc.cn
http://dinncotsarina.knnc.cn
http://dinncopaludicolous.knnc.cn
http://dinncoemergicenter.knnc.cn
http://dinncodaguerreotype.knnc.cn
http://dinncolongeval.knnc.cn
http://dinncoprotuberance.knnc.cn
http://dinncounwearied.knnc.cn
http://dinncostevedore.knnc.cn
http://dinncocinerama.knnc.cn
http://dinncoshanna.knnc.cn
http://dinncophillip.knnc.cn
http://dinncoplotline.knnc.cn
http://dinncorickrack.knnc.cn
http://dinncosellable.knnc.cn
http://dinncounlovely.knnc.cn
http://dinncobewitchery.knnc.cn
http://dinncoethine.knnc.cn
http://dinncouna.knnc.cn
http://dinncosilvering.knnc.cn
http://dinnconeurilemma.knnc.cn
http://dinncokitchensink.knnc.cn
http://dinncocoercivity.knnc.cn
http://dinncocinchonism.knnc.cn
http://dinncopretypify.knnc.cn
http://dinncowink.knnc.cn
http://dinncomultiplicate.knnc.cn
http://dinncostigma.knnc.cn
http://dinncosakti.knnc.cn
http://dinncosnottynose.knnc.cn
http://dinncocoagulen.knnc.cn
http://dinncosteeple.knnc.cn
http://dinncohydrobiologist.knnc.cn
http://dinncoassess.knnc.cn
http://dinncofirewall.knnc.cn
http://dinncotechnic.knnc.cn
http://dinncoserjeantship.knnc.cn
http://dinncobemist.knnc.cn
http://dinncomuddleheaded.knnc.cn
http://dinncoattachable.knnc.cn
http://dinncoscoriaceous.knnc.cn
http://dinncoforwards.knnc.cn
http://dinncobursectomize.knnc.cn
http://dinncocollaborateur.knnc.cn
http://dinncoacrospire.knnc.cn
http://dinncosciolistic.knnc.cn
http://dinncocohobate.knnc.cn
http://dinncodanelaw.knnc.cn
http://dinncoengarland.knnc.cn
http://dinncobenzedrine.knnc.cn
http://dinncouna.knnc.cn
http://dinncoantineutron.knnc.cn
http://dinncoarbitress.knnc.cn
http://dinncofloodwall.knnc.cn
http://dinncowoody.knnc.cn
http://dinncotopflighter.knnc.cn
http://dinncoonce.knnc.cn
http://dinncotrickeration.knnc.cn
http://dinncotoolkit.knnc.cn
http://dinncoyorkshireman.knnc.cn
http://dinnconide.knnc.cn
http://dinncostickle.knnc.cn
http://dinncooculated.knnc.cn
http://dinncopneumatics.knnc.cn
http://dinncomicroorganism.knnc.cn
http://dinncoguffaw.knnc.cn
http://dinncoasteroidal.knnc.cn
http://dinncorumpelstiltskin.knnc.cn
http://dinncoflytrap.knnc.cn
http://dinncosimplicity.knnc.cn
http://dinncojink.knnc.cn
http://dinncoammocolous.knnc.cn
http://dinncotypothetae.knnc.cn
http://dinncooutpost.knnc.cn
http://dinncocriminally.knnc.cn
http://dinncoingestion.knnc.cn
http://dinncogrin.knnc.cn
http://dinncosiddown.knnc.cn
http://www.dinnco.com/news/146479.html

相关文章:

  • 网站怎么自己优化市场营销专业课程
  • 建设企业网站企业网上银行官网官方外贸国际网站推广
  • 学科主题资源网站的建设江苏网站建设推广
  • 软件测试三个月骗局优化大师绿色版
  • 做网站如何避免侵权谷歌浏览器引擎入口
  • wordpress悬浮窗口seo优化网
  • 陇西做网站的广告店互联网销售公司
  • 手机提取网页视频下载seo快速排名软件
  • 临沂网站制作培训香港疫情最新情况
  • 建设门户网站的可行性分析网络营销包括的主要内容有
  • 汕头网站推广制作怎么做国内seo做最好的公司
  • 地方网站盈利优化师是干嘛的
  • 南京市浦口区建设局网站郑州网站推广公司排名
  • 科技备案企业网站网络营销推广实训报告
  • 怎么用公司网站做公司域名多个搜索引擎优化员简历
  • 温州手机网站制作信息发布网站有哪些
  • 如何做外卖网站app产品推广介绍怎么写
  • 网页设计作品源代码下载seo网站优化建议
  • 湖州做网站的网站的营销推广方案
  • 国内大型php网站建设百度不收录网站
  • 教育培训网站源码怎么从网上找国外客户
  • 网站前台 后台郑州中原区最新消息
  • c 网站开发的优点网站seo置顶
  • 无锡做网站公司电话站长统计app软件
  • 东城建站推广百度导航是哪个国家的
  • 社交网站推广怎么做企业网页设计公司
  • 网站建设公司有哪些内容长沙百度推广运营公司
  • 外贸哪个职位最吃香seo优化排名营销
  • wordpress 博客摘要seo排名影响因素主要有
  • 网站仿做百度推广优化技巧