artdaq  v2_03_00
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
RoutingPacket.hh
1 #ifndef artdaq_Application_Routing_RoutingPacket_hh
2 #define artdaq_Application_Routing_RoutingPacket_hh
3 
4 #include "artdaq-core/Data/Fragment.hh"
5 
6 namespace artdaq
7 {
8  namespace detail
9  {
10  struct RoutingPacketEntry;
16  using RoutingPacket = std::vector<RoutingPacketEntry>;
17  struct RoutingPacketHeader;
18  struct RoutingAckPacket;
19  struct RoutingToken;
20 
21  enum class RoutingMasterMode : uint8_t
22  {
23  RouteBySequenceID,
24  RouteBySendCount,
25  INVALID
26  };
27  }
28 }
33 {
37  RoutingPacketEntry() : sequence_id(Fragment::InvalidSequenceID), destination_rank(-1) {}
43  RoutingPacketEntry(Fragment::sequence_id_t seq, int rank) : sequence_id(seq), destination_rank(rank) {}
44  Fragment::sequence_id_t sequence_id;
46 };
47 
48 
52 #define ROUTING_MAGIC 0x1337beef
53 
58 {
59  uint32_t header;
60  RoutingMasterMode mode;
61  size_t nEntries;
62 
68  explicit RoutingPacketHeader(RoutingMasterMode m, size_t n) : header(ROUTING_MAGIC), mode(m), nEntries(n) {}
72  RoutingPacketHeader() : header(0), mode(RoutingMasterMode::INVALID), nEntries(0) {}
73 };
74 
79 {
80  int rank;
81  Fragment::sequence_id_t first_sequence_id;
82  Fragment::sequence_id_t last_sequence_id;
83 };
84 
85 
89 #define TOKEN_MAGIC 0xbeefcafe
90 
96 {
97  uint32_t header;
98  int rank;
99  unsigned new_slots_free;
100 };
101 
102 #endif //artdaq_Application_Routing_RoutingPacket_hh
A row of the Routing Table.
A RoutingAckPacket contains the rank of the table receiver, plus the first and last sequence IDs in t...
unsigned new_slots_free
The number of slots free in the token sender (usually 1)
The RoutingToken contains the magic bytes, the rank of the token sender, and the number of slots free...
Fragment::sequence_id_t first_sequence_id
The first sequence ID in the received RoutingPacket.
RoutingPacketEntry(Fragment::sequence_id_t seq, int rank)
Construct a RoutingPacketEntry with the given sequence ID and destination rank.
The header of the Routing Table, containing the magic bytes and the number of entries.
uint32_t header
Magic bytes to make sure the packet wasn&#39;t garbled.
int destination_rank
The destination rank for this sequence ID.
Fragment::sequence_id_t last_sequence_id
The last sequence ID in the received RoutingPacket.
RoutingPacketHeader(RoutingMasterMode m, size_t n)
Construct a RoutingPacketHeader declaring a given number of entries.
std::vector< RoutingPacketEntry > RoutingPacket
A RoutingPacket is simply a vector of RoutingPacketEntry objects. It is not suitable for network tran...
int rank
The rank from which the RoutingToken came.
int rank
The rank from which the RoutingAckPacket came.
Fragment::sequence_id_t sequence_id
The sequence ID of the RoutingPacketEntry.
size_t nEntries
The number of RoutingPacketEntries in the RoutingPacket.
RoutingPacketHeader()
Default Constructor.
RoutingPacketEntry()
Default Constructor.
uint32_t header
The magic bytes that help validate the RoutingToken.