aboutsummaryrefslogtreecommitdiffstats
path: root/apps/ping/src
diff options
context:
space:
mode:
Diffstat (limited to 'apps/ping/src')
-rw-r--r--apps/ping/src/ping_client.cc67
-rw-r--r--apps/ping/src/ping_server.cc177
2 files changed, 78 insertions, 166 deletions
diff --git a/apps/ping/src/ping_client.cc b/apps/ping/src/ping_client.cc
index 2371e4453..6cc6de548 100644
--- a/apps/ping/src/ping_client.cc
+++ b/apps/ping/src/ping_client.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021 Cisco and/or its affiliates.
+ * Copyright (c) 2021-2022 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -53,9 +53,6 @@ class Configuration {
bool verbose_;
bool dump_;
bool jump_;
- bool open_;
- bool always_syn_;
- bool always_ack_;
bool quiet_;
uint32_t jump_freq_;
uint32_t jump_size_;
@@ -73,9 +70,6 @@ class Configuration {
verbose_ = false;
dump_ = false;
jump_ = false;
- open_ = false;
- always_syn_ = false;
- always_ack_ = false;
quiet_ = false;
jump_freq_ = 0;
jump_size_ = 0;
@@ -155,12 +149,10 @@ class Client : interface::Portal::TransportCallback {
std::cout << "<<< interest name: " << interest.getName()
<< " (n_suffixes=" << interest.numberOfSuffixes() << ")"
<< " src port: " << interest.getSrcPort()
- << " dst port: " << interest.getDstPort()
- << " flags: " << interest.printFlags() << std::endl;
+ << " dst port: " << interest.getDstPort() << std::endl;
std::cout << "<<< object name: " << object.getName()
<< " src port: " << object.getSrcPort()
- << " dst port: " << object.getDstPort()
- << " flags: " << object.printFlags() << " path label "
+ << " dst port: " << object.getDstPort() << " path label "
<< object.getPathLabel() << " ("
<< (object.getPathLabel() >> 24) << ")"
<< " TTL: " << (int)object.getTTL() << std::endl;
@@ -185,12 +177,6 @@ class Client : interface::Portal::TransportCallback {
if (!config_->quiet_) std::cout << std::endl;
- if (!config_->always_syn_) {
- if (object.testSyn() && object.testAck() && state_ == SYN_STATE) {
- state_ = ACK_STATE;
- }
- }
-
received_++;
processed_++;
if (processed_ >= config_->maxPing_) {
@@ -202,8 +188,7 @@ class Client : interface::Portal::TransportCallback {
if (config_->verbose_) {
std::cout << "### timeout for " << name
<< " src port: " << interest->getSrcPort()
- << " dst port: " << interest->getDstPort()
- << " flags: " << interest->printFlags() << std::endl;
+ << " dst port: " << interest->getDstPort() << std::endl;
} else if (!config_->quiet_) {
std::cout << "### timeout for " << name << std::endl;
}
@@ -231,11 +216,11 @@ class Client : interface::Portal::TransportCallback {
void doPing() {
const Name interest_name(config_->name_, (uint32_t)sequence_number_);
- hicn_format_t format;
+ hicn_packet_format_t format;
if (interest_name.getAddressFamily() == AF_INET) {
- format = signer_ ? HF_INET_TCP_AH : HF_INET_TCP;
+ format = HICN_PACKET_FORMAT_IPV4_TCP;
} else {
- format = signer_ ? HF_INET6_TCP_AH : HF_INET6_TCP;
+ format = HICN_PACKET_FORMAT_IPV6_TCP;
}
size_t additional_header_size = 0;
@@ -244,17 +229,6 @@ class Client : interface::Portal::TransportCallback {
additional_header_size);
interest->setLifetime(uint32_t(config_->interestLifetime_));
- if (!signer_) interest->resetFlags();
-
- if (config_->open_ || config_->always_syn_) {
- if (state_ == SYN_STATE) {
- interest->setSyn();
- } else if (state_ == ACK_STATE) {
- interest->setAck();
- }
- } else if (config_->always_ack_) {
- interest->setAck();
- }
interest->setSrcPort(config_->srcPort_);
interest->setDstPort(config_->dstPort_);
@@ -270,7 +244,6 @@ class Client : interface::Portal::TransportCallback {
std::cout << ">>> send interest " << interest->getName()
<< " src port: " << interest->getSrcPort()
<< " dst port: " << interest->getDstPort()
- << " flags: " << interest->printFlags()
<< " TTL: " << (int)interest->getTTL()
<< " suffixes in manifest: "
<< config_->num_int_manifest_suffixes_ << std::endl;
@@ -362,13 +335,6 @@ void help() {
std::cout << " e.g. '-m 6 -a -2' sends two interest (0 and "
"3) with 2 suffixes each (1,2 and 4,5 respectively)"
<< std::endl;
- std::cout << "-O open tcp connection (three way handshake) "
- "(default false)"
- << std::endl;
- std::cout << "-S send always syn messages (default false)"
- << std::endl;
- std::cout << "-A send always ack messages (default false)"
- << std::endl;
std::cout << "HICN options" << std::endl;
std::cout << "-n <val> hicn name (default b001::1)" << std::endl;
std::cout
@@ -383,7 +349,7 @@ void help() {
<< std::endl;
std::cout << "-q quiet, not prints (default false)"
<< std::endl;
- std::cerr << "-z <io_module> IO module to use. Default: hicnlightng_module"
+ std::cerr << "-z <io_module> IO module to use. Default: hicnlight_module"
<< std::endl;
std::cerr << "-F <conf_file> Path to optional configuration file for "
"libtransport"
@@ -405,7 +371,7 @@ int main(int argc, char *argv[]) {
std::string conf_file;
transport::interface::global_config::IoModuleConfiguration io_config;
- io_config.name = "hicnlightng_module";
+ io_config.name = "hicnlight_module";
while ((opt = getopt(argc, argv, "a:j::t:i:m:s:d:n:l:f:c:SAOqVDHz:F:")) !=
-1) {
@@ -445,21 +411,6 @@ int main(int argc, char *argv[]) {
case 'D':
c->dump_ = true;
break;
- case 'O':
- c->always_syn_ = false;
- c->always_ack_ = false;
- c->open_ = true;
- break;
- case 'S':
- c->always_syn_ = true;
- c->always_ack_ = false;
- c->open_ = false;
- break;
- case 'A':
- c->always_syn_ = false;
- c->always_ack_ = true;
- c->open_ = false;
- break;
case 'q':
c->quiet_ = true;
c->verbose_ = false;
diff --git a/apps/ping/src/ping_server.cc b/apps/ping/src/ping_server.cc
index dd7d23b5e..876efd133 100644
--- a/apps/ping/src/ping_server.cc
+++ b/apps/ping/src/ping_server.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021 Cisco and/or its affiliates.
+ * Copyright (c) 2021-2022 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -42,18 +42,15 @@ class CallbackContainer {
public:
CallbackContainer(const Name &prefix, uint32_t object_size, bool verbose,
- bool dump, bool quite, bool flags, bool reset, uint8_t ttl,
- auth::Signer *signer, bool sign, std::string passphrase,
- uint32_t lifetime)
+ bool dump, bool quiet, uint8_t ttl, auth::Signer *signer,
+ bool sign, std::string passphrase, uint32_t lifetime)
: buffer_(object_size, 'X'),
content_objects_((std::uint32_t)(1 << log2_content_object_buffer_size)),
mask_((std::uint16_t)(1 << log2_content_object_buffer_size) - 1),
content_objects_index_(0),
verbose_(verbose),
dump_(dump),
- quite_(quite),
- flags_(flags),
- reset_(reset),
+ quiet_(quiet),
ttl_(ttl),
signer_(signer),
sign_(sign) {
@@ -63,14 +60,14 @@ class CallbackContainer {
core::Packet::Format format;
if (prefix.getAddressFamily() == AF_INET) {
- format = core::Packet::Format::HF_INET_TCP;
+ format = HICN_PACKET_FORMAT_IPV4_TCP;
if (sign_) {
- format = core::Packet::Format::HF_INET_TCP_AH;
+ format = HICN_PACKET_FORMAT_IPV4_TCP_AH;
}
} else {
- format = core::Packet::Format::HF_INET6_TCP;
+ format = HICN_PACKET_FORMAT_IPV6_TCP;
if (sign_) {
- format = core::Packet::Format::HF_INET6_TCP_AH;
+ format = HICN_PACKET_FORMAT_IPV6_TCP_AH;
}
}
@@ -99,11 +96,10 @@ class CallbackContainer {
std::cout << "<<< received interest " << interest.getName()
<< " src port: " << interest.getSrcPort()
<< " dst port: " << interest.getDstPort()
- << " flags: " << interest.printFlags()
<< "TTL: " << (int)interest.getTTL()
<< " suffixes in manifest: " << interest.numberOfSuffixes()
<< std::endl;
- } else if (!quite_) {
+ } else if (!quiet_) {
std::cout << "<<< received interest " << interest.getName() << std::endl;
}
@@ -113,78 +109,60 @@ class CallbackContainer {
std::cout << "-------------------------" << std::endl;
}
- if (interest.testRst()) {
- std::cout << "!!!got a reset, I don't reply" << std::endl;
- } else {
- uint32_t *suffix = interest.firstSuffix();
- uint32_t n_suffixes_in_manifest = interest.numberOfSuffixes();
- uint32_t *request_bitmap = interest.getRequestBitmap();
- if (!interest.isValid()) throw std::runtime_error("Bad interest format");
-
- Name name = interest.getName();
- uint32_t pos = 0; // Position of current suffix in manifest
- do {
- // If suffix can be processed, i.e. no manifest with bitmap excluding it
- if (!interest.hasManifest() || is_bit_set(request_bitmap, pos)) {
- auto &content_object =
- content_objects_[content_objects_index_++ & mask_];
-
- content_object->setName(interest.getName());
- content_object->setLifetime(lifetime);
- content_object->setLocator(interest.getLocator());
- content_object->setSrcPort(interest.getDstPort());
- content_object->setDstPort(interest.getSrcPort());
- content_object->setTTL(ttl_);
-
- if (!sign_) {
- content_object->resetFlags();
- }
-
- if (flags_) {
- if (interest.testSyn()) {
- content_object->setSyn();
- content_object->setAck();
- } else if (interest.testAck()) {
- content_object->setAck();
- } // here I may need to handle the FIN flag;
- } else if (reset_) {
- content_object->setRst();
- }
-
- if (verbose_) {
- std::cout << ">>> send object " << content_object->getName()
- << " src port: " << content_object->getSrcPort()
- << " dst port: " << content_object->getDstPort()
- << " flags: " << content_object->printFlags()
- << " TTL: " << (int)content_object->getTTL() << std::endl;
- } else if (!quite_) {
- std::cout << ">>> send object " << content_object->getName()
- << std::endl;
- }
-
- if (dump_) {
- std::cout << "----- object dump -----" << std::endl;
- content_object->dump();
- std::cout << "-----------------------" << std::endl;
- }
-
- if (sign_ && signer_) {
- signer_->signPacket(content_object.get());
- }
-
- p.produce(*content_object);
+ uint32_t *suffix = interest.firstSuffix();
+ uint32_t n_suffixes_in_manifest = interest.numberOfSuffixes();
+ hicn_uword *request_bitmap = interest.getRequestBitmap();
+ if (!interest.isValid()) throw std::runtime_error("Bad interest format");
+
+ Name name = interest.getName();
+ uint32_t pos = 0; // Position of current suffix in manifest
+ do {
+ // If suffix can be processed, i.e. no manifest with bitmap excluding it
+ if (!interest.hasManifest() ||
+ bitmap_is_set_no_check(request_bitmap, pos)) {
+ auto &content_object =
+ content_objects_[content_objects_index_++ & mask_];
+
+ content_object->setName(interest.getName());
+ content_object->setLifetime(lifetime);
+ content_object->setLocator(interest.getLocator());
+ content_object->setSrcPort(interest.getDstPort());
+ content_object->setDstPort(interest.getSrcPort());
+ content_object->setTTL(ttl_);
+
+ if (verbose_) {
+ std::cout << ">>> send object " << content_object->getName()
+ << " src port: " << content_object->getSrcPort()
+ << " dst port: " << content_object->getDstPort()
+ << " TTL: " << (int)content_object->getTTL() << std::endl;
+ } else if (!quiet_) {
+ std::cout << ">>> send object " << content_object->getName()
+ << std::endl;
}
- if (interest.hasManifest()) {
- uint32_t seq = *suffix;
- suffix++;
+ if (dump_) {
+ std::cout << "----- object dump -----" << std::endl;
+ content_object->dump();
+ std::cout << "-----------------------" << std::endl;
+ }
- interest.setName(name.setSuffix(seq));
+ if (sign_ && signer_) {
+ signer_->signPacket(content_object.get());
}
- } while (pos++ < n_suffixes_in_manifest);
- if (!quite_) std::cout << std::endl;
- }
+ p.produce(*content_object);
+ }
+
+ if (interest.hasManifest()) {
+ uint32_t seq = *suffix;
+ suffix++;
+
+ Name name = interest.getName();
+ interest.setName(name.setSuffix(seq));
+ }
+ } while (pos++ < n_suffixes_in_manifest);
+
+ if (!quiet_) std::cout << std::endl;
}
private:
@@ -194,9 +172,7 @@ class CallbackContainer {
std::uint16_t content_objects_index_;
bool verbose_;
bool dump_;
- bool quite_;
- bool flags_;
- bool reset_;
+ bool quiet_;
uint8_t ttl_;
auth::Signer *signer_;
bool sign_;
@@ -209,13 +185,7 @@ void help() {
std::cout << "-s <val> object content size (default 1350B)"
<< std::endl;
std::cout << "-n <val> hicn name (default b001::/64)" << std::endl;
- std::cout << "-f set tcp flags according to the flag received "
- " (default false)"
- << std::endl;
std::cout << "-l data lifetime" << std::endl;
- std::cout
- << "-r always reply with a reset flag (default false)"
- << std::endl;
std::cout << "-t set ttl (default 64)" << std::endl;
std::cout << "OUTPUT options" << std::endl;
std::cout << "-V verbose, prints statistics about the "
@@ -225,9 +195,9 @@ void help() {
std::cout << "-D dump, dumps sent and received packets "
"(default false)"
<< std::endl;
- std::cout << "-q quite, not prints (default false)"
+ std::cout << "-q quiet, not prints (default false)"
<< std::endl;
- std::cerr << "-z <io_module> IO module to use. Default: hicnlightng_module"
+ std::cerr << "-z <io_module> IO module to use. Default: hicnlight_module"
<< std::endl;
std::cerr << "-F <conf_file> Path to optional configuration file for "
"libtransport"
@@ -250,9 +220,7 @@ int main(int argc, char **argv) {
std::string delimiter = "/";
bool verbose = false;
bool dump = false;
- bool quite = false;
- bool flags = false;
- bool reset = false;
+ bool quiet = false;
uint32_t object_size = 1250;
uint8_t ttl = 64;
std::string keystore_path = "./rsa_crypto_material.p12";
@@ -263,7 +231,7 @@ int main(int argc, char **argv) {
std::string conf_file;
transport::interface::global_config::IoModuleConfiguration io_config;
- io_config.name = "hicnlightng_module";
+ io_config.name = "hicnlight_module";
int opt;
#ifndef _WIN32
@@ -296,19 +264,13 @@ int main(int argc, char **argv) {
case 'q':
verbose = false;
dump = false;
- quite = true;
+ quiet = true;
break;
#ifndef _WIN32
case 'd':
daemon = true;
break;
#endif
- case 'f':
- flags = true;
- break;
- case 'r':
- reset = true;
- break;
case 'k':
keystore_path = optarg;
sign = true;
@@ -359,14 +321,13 @@ int main(int argc, char **argv) {
if (sign) {
signer = std::make_unique<auth::AsymmetricSigner>(keystore_path,
keystore_password);
- stubs = new CallbackContainer(n, object_size, verbose, dump, quite, flags,
- reset, ttl, signer.get(), sign, passphrase,
- data_lifetime);
+ stubs =
+ new CallbackContainer(n, object_size, verbose, dump, quiet, ttl,
+ signer.get(), sign, passphrase, data_lifetime);
} else {
auth::Signer *signer = nullptr;
- stubs = new CallbackContainer(n, object_size, verbose, dump, quite, flags,
- reset, ttl, signer, sign, passphrase,
- data_lifetime);
+ stubs = new CallbackContainer(n, object_size, verbose, dump, quiet, ttl,
+ signer, sign, passphrase, data_lifetime);
}
ProducerSocket p;