124 memset((
char *) &packet_hdr->
ipv4_hdr, 0,
sizeof(
struct rte_ipv4_hdr));
129 struct ipaddr src_reversed_order;
135 struct ipaddr dst_reversed_order;
141 rte_le32_t src_addr_ser = *((rte_le32_t *) &src_reversed_order);
142 rte_le32_t dst_addr_ser = *((rte_le32_t *) &dst_reversed_order);
144 packet_hdr->
ipv4_hdr.src_addr = rte_cpu_to_be_32(src_addr_ser);
145 packet_hdr->
ipv4_hdr.dst_addr = rte_cpu_to_be_32(dst_addr_ser);
149 packet_hdr->
ipv4_hdr.total_length = rte_cpu_to_be_16(packet_len);
154 packet_hdr->
ipv4_hdr.packet_id = rte_cpu_to_be_16(0);
155 packet_hdr->
ipv4_hdr.fragment_offset = 0;
156 packet_hdr->
ipv4_hdr.next_proto_id = IPPROTO_UDP;
158 packet_hdr->
ipv4_hdr.hdr_checksum = 0;
162 packet_hdr->
udp_hdr.dgram_cksum = 0;
202void construct_packets_for_burst(
const int port_id,
const std::string& dst_mac_addr,
const int payload_bytes,
const int burst_size, rte_mbuf** bufs) {
205 constexpr int eth_header_bytes = 14;
206 constexpr int udp_header_bytes = 8;
207 constexpr int ipv4_header_bytes = 20;
210 int ipv4_packet_bytes = eth_packet_bytes - eth_header_bytes;
211 int udp_datagram_bytes = ipv4_packet_bytes - ipv4_header_bytes;
225 void* dataloc =
nullptr;
226 for (
int i_pkt = 0; i_pkt < burst_size; ++i_pkt) {
228 dataloc = rte_pktmbuf_mtod(bufs[i_pkt],
char*);
229 rte_memcpy(dataloc, &packet_hdr,
sizeof(packet_hdr));
231 dataloc = rte_pktmbuf_mtod_offset(bufs[i_pkt],
char*,
sizeof(packet_hdr));
232 rte_memcpy(dataloc, &daqethheader_obj,
sizeof(daqethheader_obj));
234 bufs[i_pkt]->pkt_len = eth_packet_bytes;
235 bufs[i_pkt]->data_len = eth_packet_bytes;