1 #ifndef ARTDAQ_DAQDATA_PORTMANAGER_HH
2 #define ARTDAQ_DAQDATA_PORTMANAGER_HH
4 #include <fhiclcpp/fwd.h>
5 #include <netinet/in.h>
7 #include "fhiclcpp/types/Atom.h"
8 #include "fhiclcpp/types/ConfigurationTable.h"
10 #define DEFAULT_BASE 10000
11 #define DEFAULT_PORTS_PER_PARTITION 1000
12 #define DEFAULT_ROUTING_TOKEN_OFFSET 10
13 #define DEFAULT_ROUTING_TABLE_ACK_OFFSET 30
14 #define DEFAULT_XMLRPC_OFFSET 100
15 #define DEFAULT_TCPSOCKET_OFFSET 500
16 #define DEFAULT_REQUEST_PORT 3001
17 #define DEFAULT_ROUTING_TABLE_PORT 3001
18 #define DEFAULT_MULTICAST_GROUP_OFFSET 128
33 fhicl::Atom<int>
artdaq_base_port{fhicl::Name{
"artdaq_base_port"}, fhicl::Comment{
"Base port for all artdaq partitions. Should be the same across all running systems. Overridden by environment variable ARTDAQ_BASE_PORT."}, DEFAULT_BASE};
35 fhicl::Atom<int>
ports_per_partition{fhicl::Name{
"ports_per_partition"}, fhicl::Comment{
"Number of ports to reserve for each partition. Should be the same across all running systems. Overridden by environment variable ARTDAQ_PORTS_PER_PARTITION."}, DEFAULT_PORTS_PER_PARTITION};
37 fhicl::Atom<std::string>
multicast_output_interface{fhicl::Name{
"multicast_output_interface"}, fhicl::Comment{
"Name of the interface to be used for all multicasts. Has precedence over \"multicast_output_network\". OPTIONAL"},
""};
39 fhicl::Atom<std::string>
multicast_output_network{fhicl::Name{
"multicast_output_network"}, fhicl::Comment{
"Address in network to be used for all multicasts. OPTIONAL"},
"0.0.0.0"};
41 fhicl::Atom<int>
multicast_group_offset{fhicl::Name{
"multicast_group_offset"}, fhicl::Comment{
"Number to add to last byte of multicast groups, to avoid problematic 0s."}, DEFAULT_MULTICAST_GROUP_OFFSET};
43 fhicl::Atom<int>
routing_token_port_offset{fhicl::Name{
"routing_token_port_offset"}, fhicl::Comment{
"Offset from partition base port for routing token ports"}, DEFAULT_ROUTING_TOKEN_OFFSET};
45 fhicl::Atom<int>
routing_table_ack_port_offset{fhicl::Name{
"routing_table_ack_port_offset"}, fhicl::Comment{
"Offset from partition base port for routing table ack ports"}, DEFAULT_ROUTING_TABLE_ACK_OFFSET};
47 fhicl::Atom<int>
xmlrpc_port_offset{fhicl::Name{
"xmlrpc_port_offset"}, fhicl::Comment{
"Offset from partition base port for XMLRPC ports"}, DEFAULT_XMLRPC_OFFSET};
49 fhicl::Atom<int>
tcp_socket_port_offset{fhicl::Name{
"tcp_socket_port_offset"}, fhicl::Comment{
"Offset from partition base port for TCP Socket ports"}, DEFAULT_TCPSOCKET_OFFSET};
51 fhicl::Atom<int>
request_port{fhicl::Name{
"request_port"}, fhicl::Comment{
"Port to use for request messages (multicast)"}, DEFAULT_REQUEST_PORT};
53 fhicl::Atom<std::string>
request_pattern{fhicl::Name{
"request_pattern"}, fhicl::Comment{
"Pattern to use to generate request multicast group. PPP => Partition number, SSS => Subsystem ID (default 0)"},
"227.128.PPP.SSS"};
55 fhicl::Atom<int>
routing_table_port{fhicl::Name{
"routing_table_port"}, fhicl::Comment{
"Port to use for routing tables (multicast)"}, DEFAULT_ROUTING_TABLE_PORT};
57 fhicl::Atom<std::string>
routing_table_pattern{fhicl::Name{
"routing_table_pattern"}, fhicl::Comment{
"Pattern to use to generate routing table multicast group. PPP => Partition number, SSS => Subsystem ID (default 0)."},
"227.129.PPP.SSS"};
59 fhicl::Atom<int>
multicast_transfer_port_offset{fhicl::Name{
"multicast_transfer_port_offset"}, fhicl::Comment{
"Offset to use for MulticastTransfer ports (port = offset + rank)"}, 1024};
61 fhicl::Atom<std::string>
multicast_transfer_pattern{fhicl::Name{
"multicast_transfer_pattern"}, fhicl::Comment{
"Pattern to use to generate Multicast Transfer group address. PPP => Partition Number, SSS => Subsystem ID (default 0), RRR => Rank"},
"227.130.14.PPP"};
152 bool base_configured_;
153 bool multicasts_configured_;
155 bool routing_tokens_configured_;
156 bool routing_acks_configured_;
157 bool xmlrpc_configured_;
158 bool tcpsocket_configured_;
159 bool request_port_configured_;
160 bool request_pattern_configured_;
161 bool routing_table_port_configured_;
162 bool routing_table_pattern_configured_;
163 bool multicast_transfer_port_configued_;
164 bool multicast_transfer_pattern_configured_;
167 int ports_per_partition_;
169 in_addr multicast_interface_address_;
170 int multicast_group_offset_;
172 int routing_token_offset_;
173 int routing_ack_offset_;
175 int tcp_socket_offset_;
176 int request_message_port_;
177 int routing_table_port_;
178 int multicast_transfer_offset_;
179 std::string request_message_group_pattern_;
180 std::string routing_table_group_pattern_;
181 std::string multicast_transfer_group_pattern_;
183 std::string parse_pattern_(std::string pattern,
int subsystemID = 0,
int rank = 0);
187 #endif //ARTDAQ_DAQDATA_PORTMANAGER_HH
int GetRequestMessagePort()
Get the port that should be used for multicast request messages.
fhicl::Atom< std::string > routing_table_pattern
"routing_table_pattern" (Default: "227.129.PPP.SSS"): Pattern to use to generate routing table multic...
fhicl::Atom< int > multicast_group_offset
"multicast_group_offset" (Default: 128): Number to add to last byte of multicast groups, to avoid problematic 0s.
fhicl::Atom< std::string > multicast_output_network
"multicast_output_network" (Default: "0.0.0.0"): Address in network to be used for all multicasts...
fhicl::Atom< std::string > multicast_output_interface
"multicast_output_interface" (Default: ""): Name of the interface to be used for all multicasts...
fhicl::Atom< std::string > request_pattern
"request_pattern" (Default: "227.128.PPP.SSS"): Pattern to use to generate request multicast group...
fhicl::Atom< int > routing_table_ack_port_offset
"routing_table_ack_port_offset" (Default: 30): Offset from partition base port for routing table ack ...
fhicl::Atom< int > request_port
"request_port" (Default: 3001): Port to use for request messages (multicast)
int GetMulticastTransferPort(int rank)
Get the multicast transfer port for the given rank.
int GetRoutingAckPort(int subsystemID=0)
Get the port that should be used for Routing Acknowledgements.
std::string GetRequestMessageGroupAddress(int subsystemID=0)
Get the multicast address for request messages.
fhicl::Atom< int > multicast_transfer_port_offset
"multicast_transfer_port_offset" (Default: 1024): Offset to use for MulticastTransfer ports (port = o...
PortManager attempts to automatically detect interfaces and ports used for the various TCP and UDP so...
fhicl::WrappedTable< Config > Parameters
Used for ParameterSet validation (if desired)
fhicl::Atom< int > routing_table_port
"routing_table_port" (Default: 3001): Port to use for routing tables (multicast)
PortManager()
PortManager Construator.
int GetRoutingTokenPort(int subsystemID=0)
Get the port that should be used for Routing Tokens.
in_addr GetMulticastOutputAddress(std::string interface_name="", std::string interface_address="")
Determine the output interface address, using the hints provided.
Configuration of PortManager. May be used for parameter validation
std::string GetMulticastTransferGroupAddress()
Get the multicast address for multicast transfers.
fhicl::Atom< int > ports_per_partition
"ports_per_partition" (Default: 1000): Number of ports to reserve for each partition. Should be the same across all running systems. Overridden by environment variable ARTDAQ_PORTS_PER_PARTITION.
int GetXMLRPCPort(int rank)
Get the XMLRPC port for the given rank.
fhicl::Atom< std::string > multicast_transfer_pattern
"multicast_transfer_pattern" (Default: "227.130.14.PPP"): Pattern to use to generate Multicast Transf...
fhicl::Atom< int > artdaq_base_port
"artdaq_base_port" (Default: 10000): Base port for all artdaq partitions. Should be the same across a...
void UpdateConfiguration(fhicl::ParameterSet const &ps)
Override the default configuration.
fhicl::Atom< int > xmlrpc_port_offset
"xmlrpc_port_offset" (Default: 100): Offset from partition base port for XMLRPC ports ...
int GetRoutingTablePort()
Get the port that should be used for multicast Routing Tables.
int GetTCPSocketTransferPort(int rank)
Get the TCP Socket transfer port for the given rank.
std::string GetRoutingTableGroupAddress(int subsystemID=0)
Get the multicast address for Routing Tables.
fhicl::Atom< int > tcp_socket_port_offset
"tcp_socket_port_offset" (Default: 500): Offset from partition base port for TCP Socket ports ...
fhicl::Atom< int > routing_token_port_offset
"routing_token_port_offset" (Default: 10): Offset from partition base port for routing token ports ...