artdaq  v3_09_01
RoutingPacket.hh
1 #ifndef artdaq_DAQrate_detail_RoutingPacket_hh
2 #define artdaq_DAQrate_detail_RoutingPacket_hh
3 
4 #include "artdaq-core/Data/Fragment.hh"
5 #define MAX_ROUTING_TABLE_SIZE 65000
6 
7 namespace artdaq {
8 namespace detail {
9 struct RoutingPacketEntry;
15 using RoutingPacket = std::vector<RoutingPacketEntry>;
16 struct RoutingPacketHeader;
17 struct RoutingAckPacket;
18 struct RoutingToken;
19 
23 enum class RoutingManagerMode : uint8_t
24 {
27  INVALID
28 };
29 } // namespace detail
30 } // namespace artdaq
35 {
45  RoutingPacketEntry(Fragment::sequence_id_t seq, int rank)
46  : sequence_id(seq), destination_rank(rank) {}
47 
48  Fragment::sequence_id_t sequence_id{Fragment::InvalidSequenceID};
49  int destination_rank{-1};
50 };
51 
55 #define ROUTING_MAGIC 0x1337beef
56 
61 {
62  uint32_t header{0};
63  RoutingManagerMode mode{RoutingManagerMode::INVALID};
64  size_t nEntries{0};
65  std::bitset<1024> already_acknowledged_ranks{0};
66 
73  : header(ROUTING_MAGIC), mode(m), nEntries(n) {}
78 };
79 
84 {
85  int rank;
86  Fragment::sequence_id_t first_sequence_id;
87  Fragment::sequence_id_t last_sequence_id;
88 
89  static RoutingAckPacket makeEndOfDataRoutingAckPacket(int rank)
90  {
91  RoutingAckPacket out;
92  out.rank = rank;
93  out.first_sequence_id = -3;
94  out.last_sequence_id = -2;
95  return out;
96  }
97 
98  static bool isEndOfDataRoutingAckPacket(RoutingAckPacket pkt)
99  {
100  return pkt.first_sequence_id == static_cast<Fragment::sequence_id_t>(-3) && pkt.last_sequence_id == static_cast<Fragment::sequence_id_t>(-2);
101  }
102 };
103 
107 #define TOKEN_MAGIC 0xbeefcafe
108 
114 {
115  uint32_t header;
116  int rank;
117  unsigned new_slots_free;
118  unsigned run_number;
119 };
120 
121 #endif //artdaq_Application_Routing_RoutingPacket_hh
A row of the Routing Table.
Events should be routed by sequence ID (BR -&gt; EB)
std::bitset< 1024 > already_acknowledged_ranks
Bitset of ranks which have already sent valid acknowledgements and therefore do not need to send agai...
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)
RoutingManagerMode
Mode indicating whether the RoutingManager is routing events by Sequence ID or by Send Count...
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.
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.
Events should be routed by send count (EB -&gt; Agg)
RoutingManagerMode mode
The current mode of the RoutingManager.
RoutingPacketHeader(RoutingManagerMode m, size_t n)
Construct a RoutingPacketHeader declaring a given number of entries.
RoutingPacketHeader()
Default Constructor.
unsigned run_number
The Run with which this token should be associated.
RoutingPacketEntry()
Default Constructor.
uint32_t header
The magic bytes that help validate the RoutingToken.