DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
dpdklibs
include
dpdklibs
wibeth
WIBEthPacketBuilder.hpp
Go to the documentation of this file.
1
8
#ifndef DPDKLIBS_INCLUDE_DPDKLIBS_WIBETH_WIBETHPACKETBUILDER_HPP_
9
#define DPDKLIBS_INCLUDE_DPDKLIBS_WIBETH_WIBETHPACKETBUILDER_HPP_
10
11
#include "
detdataformats/DAQEthHeader.hpp
"
12
#include "
dpdklibs/udp/IPV4UDPPacket.hpp
"
13
#include "
fddetdataformats/WIBEthFrame.hpp
"
14
15
#include <rte_byteorder.h>
16
#include <rte_ether.h>
17
#include <rte_ip.h>
18
#include <rte_udp.h>
19
20
#include <cstddef>
21
#include <cstdint>
22
#include <string>
23
24
namespace
dunedaq::dpdklibs::wibeth
{
25
26
constexpr
std::size_t
kEthernetHeaderBytes
=
sizeof
(rte_ether_hdr);
27
constexpr
std::size_t
kIPv4HeaderBytes
=
sizeof
(rte_ipv4_hdr);
28
constexpr
std::size_t
kUDPHeaderBytes
=
sizeof
(rte_udp_hdr);
29
constexpr
std::size_t
kPacketHeaderBytes
=
sizeof
(
dunedaq::dpdklibs::udp::ipv4_udp_packet_hdr
);
30
constexpr
std::size_t
kDAQEthHeaderBytes
=
sizeof
(
dunedaq::detdataformats::DAQEthHeader
);
31
constexpr
std::size_t
kWIBEthFrameBytes
=
sizeof
(
dunedaq::fddetdataformats::WIBEthFrame
);
32
constexpr
std::size_t
kEthernetPacketBytes
=
33
kEthernetHeaderBytes
+
kIPv4HeaderBytes
+
kUDPHeaderBytes
+
kWIBEthFrameBytes
;
34
constexpr
std::size_t
kIPv4TotalBytes
=
kIPv4HeaderBytes
+
kUDPHeaderBytes
+
kWIBEthFrameBytes
;
35
constexpr
std::size_t
kUDPDatagramBytes
=
kUDPHeaderBytes
+
kWIBEthFrameBytes
;
36
constexpr
std::uint16_t
kWIBEthBlockLength
=
37
static_cast<
std::uint16_t
>
((
kWIBEthFrameBytes
/
sizeof
(std::uint64_t)) - 1);
38
constexpr
std::uint64_t
kDefaultTimestampStep
= 2048;
39
constexpr
double
kDefaultRateHz
= 62500000.0 /
static_cast<
double
>
(
kDefaultTimestampStep
);
40
41
static_assert
(
kEthernetHeaderBytes
== 14,
"Unexpected Ethernet header size"
);
42
static_assert
(
kIPv4HeaderBytes
== 20,
"Unexpected IPv4 header size"
);
43
static_assert
(
kUDPHeaderBytes
== 8,
"Unexpected UDP header size"
);
44
static_assert
(
kPacketHeaderBytes
== 42,
"Unexpected Ethernet/IPv4/UDP header size"
);
45
static_assert
(
kDAQEthHeaderBytes
== 16,
"Unexpected DAQEthHeader size"
);
46
static_assert
(
kWIBEthFrameBytes
== 7200,
"Unexpected WIBEthFrame size"
);
47
static_assert
(
kEthernetPacketBytes
== 7242,
"Unexpected complete Ethernet packet size"
);
48
static_assert
(
kIPv4TotalBytes
== 7228,
"Unexpected IPv4 total length"
);
49
static_assert
(
kUDPDatagramBytes
== 7208,
"Unexpected UDP datagram length"
);
50
static_assert
(
kWIBEthBlockLength
== 899,
"Unexpected DAQEthHeader block_length"
);
51
52
struct
PacketConfig
53
{
54
rte_ether_addr
dst_mac
{};
55
rte_ether_addr
src_mac
{};
56
rte_be32_t
src_ip
= 0;
57
rte_be32_t
dst_ip
= 0;
58
std::uint16_t
src_port
= 55677;
59
std::uint16_t
dst_port
= 55678;
60
std::uint16_t
packet_id
= 0;
61
};
62
63
struct
HeaderPatch
64
{
65
bool
set_det_id
=
false
;
66
std::uint64_t
det_id
= 0;
67
bool
set_seq_id
=
false
;
68
std::uint64_t
seq_id
= 0;
69
bool
force_block_length
=
true
;
70
};
71
72
// Throws std::runtime_error if addr is not a dotted-quad IPv4 address.
73
rte_be32_t
74
parse_ipv4_addr
(
const
std::string& addr);
75
76
// Rewrites the DAQEthHeader fields selected by patch, in place. wibeth_frame
77
// may have any alignment.
78
void
79
patch_daq_header
(
void
* wibeth_frame,
const
HeaderPatch
& patch);
80
81
// Writes kEthernetPacketBytes to ethernet_packet: the 42-byte
82
// Ethernet/IPv4/UDP header, then the WIBEthFrame, then the header patch.
83
// ethernet_packet may have any alignment.
84
void
85
construct_packet
(
void
* ethernet_packet,
86
const
void
* wibeth_frame,
87
const
PacketConfig
& cfg,
88
const
HeaderPatch
& patch = {});
89
90
}
// namespace dunedaq::dpdklibs::wibeth
91
92
#endif
// DPDKLIBS_INCLUDE_DPDKLIBS_WIBETH_WIBETHPACKETBUILDER_HPP_
DAQEthHeader.hpp
IPV4UDPPacket.hpp
WIBEthFrame.hpp
dunedaq::dpdklibs::wibeth
Definition
WIBEthPacketBuilder.hpp:24
dunedaq::dpdklibs::wibeth::kWIBEthFrameBytes
constexpr std::size_t kWIBEthFrameBytes
Definition
WIBEthPacketBuilder.hpp:31
dunedaq::dpdklibs::wibeth::construct_packet
void construct_packet(void *ethernet_packet, const void *wibeth_frame, const PacketConfig &cfg, const HeaderPatch &patch={})
Definition
WIBEthPacketBuilder.cpp:54
dunedaq::dpdklibs::wibeth::kDAQEthHeaderBytes
constexpr std::size_t kDAQEthHeaderBytes
Definition
WIBEthPacketBuilder.hpp:30
dunedaq::dpdklibs::wibeth::kPacketHeaderBytes
constexpr std::size_t kPacketHeaderBytes
Definition
WIBEthPacketBuilder.hpp:29
dunedaq::dpdklibs::wibeth::patch_daq_header
void patch_daq_header(void *wibeth_frame, const HeaderPatch &patch)
Definition
WIBEthPacketBuilder.cpp:34
dunedaq::dpdklibs::wibeth::kIPv4HeaderBytes
constexpr std::size_t kIPv4HeaderBytes
Definition
WIBEthPacketBuilder.hpp:27
dunedaq::dpdklibs::wibeth::parse_ipv4_addr
rte_be32_t parse_ipv4_addr(const std::string &addr)
Definition
WIBEthPacketBuilder.cpp:24
dunedaq::dpdklibs::wibeth::kUDPHeaderBytes
constexpr std::size_t kUDPHeaderBytes
Definition
WIBEthPacketBuilder.hpp:28
dunedaq::dpdklibs::wibeth::kIPv4TotalBytes
constexpr std::size_t kIPv4TotalBytes
Definition
WIBEthPacketBuilder.hpp:34
dunedaq::dpdklibs::wibeth::kDefaultTimestampStep
constexpr std::uint64_t kDefaultTimestampStep
Definition
WIBEthPacketBuilder.hpp:38
dunedaq::dpdklibs::wibeth::kDefaultRateHz
constexpr double kDefaultRateHz
Definition
WIBEthPacketBuilder.hpp:39
dunedaq::dpdklibs::wibeth::kWIBEthBlockLength
constexpr std::uint16_t kWIBEthBlockLength
Definition
WIBEthPacketBuilder.hpp:36
dunedaq::dpdklibs::wibeth::kUDPDatagramBytes
constexpr std::size_t kUDPDatagramBytes
Definition
WIBEthPacketBuilder.hpp:35
dunedaq::dpdklibs::wibeth::kEthernetPacketBytes
constexpr std::size_t kEthernetPacketBytes
Definition
WIBEthPacketBuilder.hpp:32
dunedaq::dpdklibs::wibeth::kEthernetHeaderBytes
constexpr std::size_t kEthernetHeaderBytes
Definition
WIBEthPacketBuilder.hpp:26
dunedaq::detdataformats::DAQEthHeader
DAQEthHeader is a versioned and unified structure for every FE electronics.
Definition
DAQEthHeader.hpp:23
dunedaq::dpdklibs::udp::ipv4_udp_packet_hdr
Definition
IPV4UDPPacket.hpp:25
dunedaq::dpdklibs::wibeth::HeaderPatch
Definition
WIBEthPacketBuilder.hpp:64
dunedaq::dpdklibs::wibeth::HeaderPatch::set_det_id
bool set_det_id
Definition
WIBEthPacketBuilder.hpp:65
dunedaq::dpdklibs::wibeth::HeaderPatch::force_block_length
bool force_block_length
Definition
WIBEthPacketBuilder.hpp:69
dunedaq::dpdklibs::wibeth::HeaderPatch::seq_id
std::uint64_t seq_id
Definition
WIBEthPacketBuilder.hpp:68
dunedaq::dpdklibs::wibeth::HeaderPatch::set_seq_id
bool set_seq_id
Definition
WIBEthPacketBuilder.hpp:67
dunedaq::dpdklibs::wibeth::HeaderPatch::det_id
std::uint64_t det_id
Definition
WIBEthPacketBuilder.hpp:66
dunedaq::dpdklibs::wibeth::PacketConfig
Definition
WIBEthPacketBuilder.hpp:53
dunedaq::dpdklibs::wibeth::PacketConfig::dst_port
std::uint16_t dst_port
Definition
WIBEthPacketBuilder.hpp:59
dunedaq::dpdklibs::wibeth::PacketConfig::dst_ip
rte_be32_t dst_ip
Definition
WIBEthPacketBuilder.hpp:57
dunedaq::dpdklibs::wibeth::PacketConfig::dst_mac
rte_ether_addr dst_mac
Definition
WIBEthPacketBuilder.hpp:54
dunedaq::dpdklibs::wibeth::PacketConfig::packet_id
std::uint16_t packet_id
Definition
WIBEthPacketBuilder.hpp:60
dunedaq::dpdklibs::wibeth::PacketConfig::src_port
std::uint16_t src_port
Definition
WIBEthPacketBuilder.hpp:58
dunedaq::dpdklibs::wibeth::PacketConfig::src_mac
rte_ether_addr src_mac
Definition
WIBEthPacketBuilder.hpp:55
dunedaq::dpdklibs::wibeth::PacketConfig::src_ip
rte_be32_t src_ip
Definition
WIBEthPacketBuilder.hpp:56
dunedaq::fddetdataformats::WIBEthFrame
struct for accessing raw WIB eth frames, as used in ProtoDUNE-II
Definition
WIBEthFrame.hpp:40
Generated on
for DUNE-DAQ by
1.18.0