diff options
author | Jordan Augé <jordan.auge+fdio@cisco.com> | 2022-10-04 17:41:36 +0200 |
---|---|---|
committer | Jordan Augé <jordan.auge+fdio@cisco.com> | 2022-10-05 15:11:45 +0200 |
commit | 1e73c65c7b18ffcd5a8836fbc8384c21638faf48 (patch) | |
tree | 487fc2ecc484f53052ba1d6ca97433bcd9e39aa8 /apps | |
parent | 3476dd9ddecc87d9212c3bf56a5be52079e27def (diff) |
test: new packet format functional test with hiperf/libtransport
Change-Id: Ib6ca26e9ee1a042a72ac81da71493542e8b833e6
Ticket: HICN-774
Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/hiperf/src/common.h | 14 | ||||
-rw-r--r-- | apps/hiperf/src/main.cc | 22 | ||||
-rw-r--r-- | apps/hiperf/src/server.cc | 5 | ||||
-rw-r--r-- | apps/ping/src/ping_client.cc | 2 |
4 files changed, 23 insertions, 20 deletions
diff --git a/apps/hiperf/src/common.h b/apps/hiperf/src/common.h index 3a17e0c40..1565e63f7 100644 --- a/apps/hiperf/src/common.h +++ b/apps/hiperf/src/common.h @@ -174,20 +174,6 @@ class PayloadSize { transport_size - fec_size; } - static Packet::Format getFormatFromPrefix(const Prefix &prefix, - bool ah = false) { - switch (prefix.getAddressFamily()) { - case AF_INET: - return ah ? HICN_PACKET_FORMAT_IPV4_TCP_AH - : HICN_PACKET_FORMAT_IPV4_TCP; - case AF_INET6: - return ah ? HICN_PACKET_FORMAT_IPV6_TCP_AH - : HICN_PACKET_FORMAT_IPV6_TCP; - default: - return HICN_PACKET_FORMAT_NONE; - } - } - private: std::size_t mtu_; Packet::Format format_; diff --git a/apps/hiperf/src/main.cc b/apps/hiperf/src/main.cc index ac0f64d1d..d655b1fe3 100644 --- a/apps/hiperf/src/main.cc +++ b/apps/hiperf/src/main.cc @@ -19,6 +19,15 @@ namespace hiperf { +static std::unordered_map<std::string, hicn_packet_format_t> const + packet_format_map = {{"ipv4_tcp", HICN_PACKET_FORMAT_IPV4_TCP}, + {"ipv6_tcp", HICN_PACKET_FORMAT_IPV6_TCP}, + {"new", HICN_PACKET_FORMAT_NEW}}; + +#define TO_LOWER(s) \ + std::transform(s.begin(), s.end(), s.begin(), \ + [](unsigned char c) { return std::tolower(c); }); + void usage() { LoggerInfo() << "HIPERF - Instrumentation tool for performing active network" "measurements with hICN"; @@ -174,6 +183,8 @@ void usage() { << "Print the stats report <nb_iterations> times and exit.\n" << "\t\t\t\t\tThis option limits the duration of the run to " "<nb_iterations> * <stats_interval> milliseconds."; + LoggerInfo() << "-w <packet_format> Packet format (without signature, " + "defaults to IPV6_TCP)"; } int main(int argc, char *argv[]) { @@ -208,7 +219,7 @@ int main(int argc, char *argv[]) { while ( (opt = getopt(argc, argv, "A:B:CDE:F:G:HIJ:K:L:M:NP:RST:U:W:X:ab:c:d:e:f:g:hi:j:k:lm:" - "n:op:qrs:tu:vwxy:z:")) != -1) { + "n:op:qrs:tu:vw:xy:z:")) != -1) { switch (opt) { // Common case 'D': { @@ -270,8 +281,13 @@ int main(int argc, char *argv[]) { break; } case 'w': { - client_configuration.packet_format_ = HICN_PACKET_FORMAT_IPV6_UDP; - server_configuration.packet_format_ = HICN_PACKET_FORMAT_IPV6_UDP; + std::string packet_format_s = std::string(optarg); + TO_LOWER(packet_format_s); + auto it = packet_format_map.find(std::string(optarg)); + if (it == packet_format_map.end()) + throw std::runtime_error("Bad packet format"); + client_configuration.packet_format_ = it->second; + server_configuration.packet_format_ = it->second; break; } case 'k': { diff --git a/apps/hiperf/src/server.cc b/apps/hiperf/src/server.cc index ee236f358..b338c69df 100644 --- a/apps/hiperf/src/server.cc +++ b/apps/hiperf/src/server.cc @@ -143,8 +143,9 @@ class HIperfServer::Impl { signer); // Compute maximum payload size - Packet::Format format = PayloadSize::getFormatFromPrefix( - configuration_.name_, !configuration_.manifest_max_capacity_); + Packet::Format format = configuration_.packet_format_; + if (!configuration_.manifest_max_capacity_) + format = Packet::toAHFormat(format); payload_size_max_ = PayloadSize(format).getPayloadSizeMax( configuration_.rtc_ ? RTC_HEADER_SIZE : 0, configuration_.fec_type_.empty() ? 0 : FEC_HEADER_MAX_SIZE, diff --git a/apps/ping/src/ping_client.cc b/apps/ping/src/ping_client.cc index 116d228d4..b3495ed20 100644 --- a/apps/ping/src/ping_client.cc +++ b/apps/ping/src/ping_client.cc @@ -58,7 +58,7 @@ class Configuration { bool jump_ = false; uint32_t jump_freq_ = 0; uint32_t jump_size_ = 0; - hicn_packet_format_t packet_format_ = HICN_PACKET_FORMAT_IPV6_TCP; + hicn_packet_format_t packet_format_ = HICN_PACKET_FORMAT_DEFAULT; Configuration() = default; }; |