$treeview $search $mathjax $extrastylesheet
artdaq
v3_04_01
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #ifndef ARTDAQ_DAQDATA_PORTMANAGER_HH 00002 #define ARTDAQ_DAQDATA_PORTMANAGER_HH 00003 00004 #include <string> 00005 #include <fhiclcpp/fwd.h> 00006 #include "fhiclcpp/types/Atom.h" 00007 #include "fhiclcpp/types/ConfigurationTable.h" 00008 #include <netinet/in.h> 00009 00010 #define DEFAULT_BASE 10000 00011 #define DEFAULT_PORTS_PER_PARTITION 1000 00012 #define DEFAULT_ROUTING_TOKEN_OFFSET 10 00013 #define DEFAULT_ROUTING_TABLE_ACK_OFFSET 30 00014 #define DEFAULT_XMLRPC_OFFSET 100 00015 #define DEFAULT_TCPSOCKET_OFFSET 500 00016 #define DEFAULT_REQUEST_PORT 3001 00017 #define DEFAULT_ROUTING_TABLE_PORT 3001 00018 #define DEFAULT_MULTICAST_GROUP_OFFSET 128 00019 00020 namespace artdaq { 00024 class PortManager { 00025 public: 00029 struct Config 00030 { 00032 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 }; 00034 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 }; 00036 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"},"" }; 00038 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" }; 00040 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 }; 00042 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 }; 00044 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 }; 00046 fhicl::Atom<int> xmlrpc_port_offset{ fhicl::Name{ "xmlrpc_port_offset" }, fhicl::Comment{"Offset from partition base port for XMLRPC ports"},DEFAULT_XMLRPC_OFFSET }; 00048 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 }; 00050 fhicl::Atom<int> request_port{ fhicl::Name{ "request_port" }, fhicl::Comment{"Port to use for request messages (multicast)"},DEFAULT_REQUEST_PORT }; 00052 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" }; 00054 fhicl::Atom<int> routing_table_port{ fhicl::Name{ "routing_table_port" }, fhicl::Comment{"Port to use for routing tables (multicast)"},DEFAULT_ROUTING_TABLE_PORT }; 00056 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" }; 00058 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 }; 00060 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" }; 00061 00062 }; 00064 using Parameters = fhicl::WrappedTable<Config>; 00065 00066 PortManager(); 00067 00072 void UpdateConfiguration(fhicl::ParameterSet const& ps); 00073 00079 int GetRoutingTokenPort(int subsystemID = 0); 00080 00086 int GetRoutingAckPort(int subsystemID = 0); 00087 00093 int GetXMLRPCPort(int rank); 00094 00100 int GetTCPSocketTransferPort(int rank); 00101 00106 int GetRequestMessagePort(); 00107 00113 std::string GetRequestMessageGroupAddress(int subsystemID = 0); 00114 00119 int GetRoutingTablePort(); 00120 00126 std::string GetRoutingTableGroupAddress(int subsystemID = 0); 00127 00133 int GetMulticastTransferPort(int rank); 00134 00139 std::string GetMulticastTransferGroupAddress(); 00140 00149 in_addr GetMulticastOutputAddress(std::string interface_name = "", std::string interface_address = ""); 00150 00151 00152 private: 00153 bool base_configured_; 00154 bool multicasts_configured_; 00155 00156 bool routing_tokens_configured_; 00157 bool routing_acks_configured_; 00158 bool xmlrpc_configured_; 00159 bool tcpsocket_configured_; 00160 bool request_port_configured_; 00161 bool request_pattern_configured_; 00162 bool routing_table_port_configured_; 00163 bool routing_table_pattern_configured_; 00164 bool multicast_transfer_port_configued_; 00165 bool multicast_transfer_pattern_configured_; 00166 00167 int base_port_; 00168 int ports_per_partition_; 00169 00170 in_addr multicast_interface_address_; 00171 int multicast_group_offset_; 00172 00173 int routing_token_offset_; 00174 int routing_ack_offset_; 00175 int xmlrpc_offset_; 00176 int tcp_socket_offset_; 00177 int request_message_port_; 00178 int routing_table_port_; 00179 int multicast_transfer_offset_; 00180 std::string request_message_group_pattern_; 00181 std::string routing_table_group_pattern_; 00182 std::string multicast_transfer_group_pattern_; 00183 00184 00185 std::string parse_pattern_(std::string pattern, int subsystemID = 0, int rank = 0); 00186 }; 00187 } 00188 00189 #endif //ARTDAQ_DAQDATA_PORTMANAGER_HH