#define HMBDC_LOG_CONTEXT hmbdc::app::Context<24>
#include "hmbdc/app/utils/Pingpong.hpp"
#include "hmbdc/app/tcpcast/NetContext.hpp"
#include <boost/program_options.hpp>
int
main(int argc, char** argv) {
string type;
string role;
string ifaceAddr;
uint16_t startCore;
size_t skipFirst;
uint16_t msgSize;
uint16_t msgPerSec;
uint32_t runTime;
auto CONFIG = R"|(
{
"outBufferSizePower2" : 5,
"nagling" : false,
"ping" : {
"topicRegex" : "ping"
},
"pong" : {
"topicRegex" : "pong"
}
}
)|";
namespace po = boost::program_options;
po::options_description desc("Allowed options");
auto helpStr =
"Warning: hmbdc tcpcast network messaging by default uses multicast functions and it is imperative that multicast is enabled (stop the firewall?) on your network for this test to work."
"for the usage of hmbdc-tcpcast WITHOUT multicast, see tryTopicSource method in RecvTransportEngine.hpp and additionalTopicSources config param\n"
"This program can be used to test round trip hmbdc tcpcast message latency among a group of hosts."
"The source code is in example dir: ping-pong-tcpcast.cpp"
"\nUsage example: \nponger$ sudo ./ping-pong-tcpcast -I 192.168.2.101"
"\npinger$ sudo ./ping-pong-tcpcast -r ping -I 192.168.2.100"
"\nwould start the test using two host ponger and pinger with default settings."
;
desc.add_options()
("help", helpStr)
("role,r", po::value<string>(&role)->default_value("pong"), "ping or pong")
("msgSize", po::value<uint16_t>(&msgSize)->default_value(16), "msg size: 16-1024")
("msgPerSec", po::value<uint16_t>(&msgPerSec)->default_value(1), "msg per second up to 1000")
("ifaceAddr,I", po::value<string>(&ifaceAddr), "interface to use, for example: 192.168.0.101 or 192.168.1.0/24.")
("startCore,C", po::value<uint16_t>(&startCore)->default_value(0u), "specify starting core number")
("skipFirst", po::value<size_t>(&skipFirst)->default_value(1u), "skipp the first N results (warming up stage) when collecting latency stats")
("runTime", po::value<uint32_t>(&runTime)->default_value(0), "how many seconds does the test last before exit. By default it runs forever")
;
po::positional_options_description p;
po::variables_map vm;
po::store(po::command_line_parser(argc, argv).
options(desc).positional(p).run(), vm);
po::notify(vm);
if (vm.count("help")) {
cout << desc << "\n";
return 0;
}
config.put("ifaceAddr", ifaceAddr);
config.put("startCore", startCore);
config.put("skipFirst", skipFirst);
config.put("msgSize", msgSize);
config.put("msgPerSec", msgPerSec);
config.put("runTime", runTime);
if (role == "ping" ) {
config.put("ping", true);
return pingpong<NetContext>(config);
} else if (role == "pong") {
config.put("ping", false);
return pingpong<NetContext>(config);
} else {
cout << desc << "\n";
return -1;
}
}