Community
cancel
Showing results for 
Search instead for 
Did you mean: 
MKour
Novice
3,400 Views

Dpdk packet processing

Jump to solution

Hello everyone,

I am currently new to the DPDK library, so my questions are a bit basic.

I would like to know how could someone read a received packet's data using the dpdk functions.

To be more specific a packet we have just captured from running the l3fwd example.

Thank you for your time

1 Solution
CChon
Beginner
334 Views

By parsing the packet headers, you can access the UDP payload of course.

About about this,

eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);

if (m->ol_flags & PKT_RX_IPV4_HDR) {

/* Handle IPv4 headers.*/

ipv4_hdr = (struct ipv4_hdr *)(rte_pktmbuf_mtod(m, unsigned char *) + sizeof(struct ether_hdr));

udp_hdr = (struct udp_hdr *)(struct (ipv4_hdr + 1);

udp_payload = (uint8_t *)(udp_hdr + 1);

 

Regards,

View solution in original post

6 Replies
334 Views

Dear customer,

Thanks for using Intel(R)DPDK

If you see in l3fwd_simple_forward function, you will see rte_pktmbuf_mtod used.

Can I please request you to find if that usage is useful to you.

For example, below the usage - eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);

For detailed information about the API, kindly refer to API Document http://www.intel.com/content/www/us/en/intelligent-systems/intel-technology/intel-dpdk-api-reference... http://www.intel.com/content/www/us/en/intelligent-systems/intel-technology/intel-dpdk-api-reference...

l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid, struct lcore_conf *qconf)

{

struct ether_hdr *eth_hdr;

struct ipv4_hdr *ipv4_hdr;

void *d_addr_bytes;

uint8_t dst_port;

eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);

if (m->ol_flags & PKT_RX_IPV4_HDR) {

/* Handle IPv4 headers.*/

ipv4_hdr = (struct ipv4_hdr *)(rte_pktmbuf_mtod(m, unsigned char *) +

sizeof(struct ether_hdr));

Thank you

MKour
Novice
334 Views

Thank you for the helpful answer.

MKour
Novice
334 Views

Regarding your answer, is it possible to use the API to read the UDP payload of a packet?

Thank you for your time and sorry about the beginner questions

334 Views

Dear customer

DPDK offers high performance Polled mode driver and infrastructure for high performance memory allocation and pinning cores to thread.

UDP layer is something you can definitely develop on top of that.

Currently, below find UDP header defined as http://dpdk.org/doc/api/structudp__hdr.html http://dpdk.org/doc/api/structudp__hdr.html

Also, you are familiar with the pktmbuf [defined in] http://dpdk.org/doc/api/structrte__pktmbuf.html http://dpdk.org/doc/api/structrte__pktmbuf.html

Please find the list of eco systems that provide higher level stack on top of Intel DPDK

https://www-ssl.intel.com/content/www/us/en/intelligent-systems/intel-technology/packet-processing-i... https://www-ssl.intel.com/content/www/us/en/intelligent-systems/intel-technology/packet-processing-i...?

Thank you very much

CChon
Beginner
335 Views

By parsing the packet headers, you can access the UDP payload of course.

About about this,

eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);

if (m->ol_flags & PKT_RX_IPV4_HDR) {

/* Handle IPv4 headers.*/

ipv4_hdr = (struct ipv4_hdr *)(rte_pktmbuf_mtod(m, unsigned char *) + sizeof(struct ether_hdr));

udp_hdr = (struct udp_hdr *)(struct (ipv4_hdr + 1);

udp_payload = (uint8_t *)(udp_hdr + 1);

 

Regards,

View solution in original post

MKour
Novice
334 Views

That is exactly what I was looking for thank you very much for the kind answer

Regards

Reply