aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/includes/hicn/transport/interfaces
diff options
context:
space:
mode:
Diffstat (limited to 'libtransport/includes/hicn/transport/interfaces')
-rw-r--r--libtransport/includes/hicn/transport/interfaces/CMakeLists.txt3
-rw-r--r--libtransport/includes/hicn/transport/interfaces/callbacks.h21
-rw-r--r--libtransport/includes/hicn/transport/interfaces/global_conf_interface.h60
-rw-r--r--libtransport/includes/hicn/transport/interfaces/p2psecure_socket_producer.h5
-rw-r--r--libtransport/includes/hicn/transport/interfaces/portal.h8
-rw-r--r--libtransport/includes/hicn/transport/interfaces/socket_consumer.h30
-rw-r--r--libtransport/includes/hicn/transport/interfaces/socket_options_default_values.h1
-rw-r--r--libtransport/includes/hicn/transport/interfaces/socket_options_keys.h11
-rw-r--r--libtransport/includes/hicn/transport/interfaces/socket_producer.h49
-rw-r--r--libtransport/includes/hicn/transport/interfaces/statistics.h79
10 files changed, 180 insertions, 87 deletions
diff --git a/libtransport/includes/hicn/transport/interfaces/CMakeLists.txt b/libtransport/includes/hicn/transport/interfaces/CMakeLists.txt
index 7370ad1b0..08f880930 100644
--- a/libtransport/includes/hicn/transport/interfaces/CMakeLists.txt
+++ b/libtransport/includes/hicn/transport/interfaces/CMakeLists.txt
@@ -16,12 +16,11 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
list(APPEND HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/socket_consumer.h
${CMAKE_CURRENT_SOURCE_DIR}/socket_producer.h
- ${CMAKE_CURRENT_SOURCE_DIR}/rtc_socket_producer.h
${CMAKE_CURRENT_SOURCE_DIR}/publication_options.h
${CMAKE_CURRENT_SOURCE_DIR}/socket_options_default_values.h
${CMAKE_CURRENT_SOURCE_DIR}/socket_options_keys.h
${CMAKE_CURRENT_SOURCE_DIR}/callbacks.h
- ${CMAKE_CURRENT_SOURCE_DIR}/verification_policy.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/global_conf_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/statistics.h
${CMAKE_CURRENT_SOURCE_DIR}/portal.h
)
diff --git a/libtransport/includes/hicn/transport/interfaces/callbacks.h b/libtransport/includes/hicn/transport/interfaces/callbacks.h
index 6ae07797e..95b4d1977 100644
--- a/libtransport/includes/hicn/transport/interfaces/callbacks.h
+++ b/libtransport/includes/hicn/transport/interfaces/callbacks.h
@@ -16,7 +16,7 @@
#pragma once
#include <hicn/transport/interfaces/statistics.h>
-#include <hicn/transport/interfaces/verification_policy.h>
+#include <hicn/transport/auth/policies.h>
#include <functional>
#include <system_error>
@@ -75,25 +75,6 @@ using ConsumerContentObjectCallback =
std::function<void(ConsumerSocket &, const core::ContentObject &)>;
/**
- * The ConsumerContentObjectVerificationCallback will be called by the transport
- * if an application is willing to verify each content object. Note that a
- * better alternative is to instrument the transport to perform the verification
- * autonomously, without requiring the intervention of the application.
- */
-using ConsumerContentObjectVerificationCallback =
- std::function<bool(ConsumerSocket &, const core::ContentObject &)>;
-
-/**
- * The ConsumerContentObjectVerificationFailedCallback will be caled by the
- * transport if a data packet (either manifest or content object) cannot be
- * verified. The application here decides what to do by returning a
- * VerificationFailedPolicy object.
- */
-using ConsumerContentObjectVerificationFailedCallback =
- std::function<VerificationPolicy(
- ConsumerSocket &, const core::ContentObject &, std::error_code ec)>;
-
-/**
* The ProducerContentObjectCallback will be called in different parts of the
* consumer socket processing pipeline, with a ProducerSocket and an
* ContentObject as parameters.
diff --git a/libtransport/includes/hicn/transport/interfaces/global_conf_interface.h b/libtransport/includes/hicn/transport/interfaces/global_conf_interface.h
new file mode 100644
index 000000000..a9fe6fac6
--- /dev/null
+++ b/libtransport/includes/hicn/transport/interfaces/global_conf_interface.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2021 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:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <string>
+#include <vector>
+
+/**
+ * Global configuration interface.
+ */
+
+namespace transport {
+namespace interface {
+namespace global_config {
+
+static const constexpr char io_module_section[] = "io_module";
+void parseConfigurationFile(const std::string& path = "");
+
+class ConfigurationObject {
+ public:
+ /**
+ * Set configuration.
+ */
+ void set();
+
+ /**
+ * Get configuration.
+ */
+ void get();
+
+ /**
+ * Get configuration key
+ */
+ virtual std::string getKey() const = 0;
+};
+
+class IoModuleConfiguration : public ConfigurationObject {
+ public:
+ std::string getKey() const override { return io_module_section; }
+
+ std::string name;
+ std::vector<std::string> search_path;
+};
+
+} // namespace global_config
+} // namespace interface
+} // namespace transport \ No newline at end of file
diff --git a/libtransport/includes/hicn/transport/interfaces/p2psecure_socket_producer.h b/libtransport/includes/hicn/transport/interfaces/p2psecure_socket_producer.h
index 6f0d48bb9..7b284c520 100644
--- a/libtransport/includes/hicn/transport/interfaces/p2psecure_socket_producer.h
+++ b/libtransport/includes/hicn/transport/interfaces/p2psecure_socket_producer.h
@@ -16,8 +16,7 @@
#pragma once
#include <hicn/transport/interfaces/socket_producer.h>
-
-#include <hicn/transport/security/identity.h>
+#include <hicn/transport/auth/identity.h>
namespace transport {
@@ -27,7 +26,7 @@ class P2PSecureProducerSocket : public ProducerSocket {
public:
P2PSecureProducerSocket();
P2PSecureProducerSocket(bool rtc,
- const std::shared_ptr<utils::Identity> &identity);
+ const std::shared_ptr<auth::Identity> &identity);
~P2PSecureProducerSocket() = default;
};
diff --git a/libtransport/includes/hicn/transport/interfaces/portal.h b/libtransport/includes/hicn/transport/interfaces/portal.h
index 724cd7592..22c8591f4 100644
--- a/libtransport/includes/hicn/transport/interfaces/portal.h
+++ b/libtransport/includes/hicn/transport/interfaces/portal.h
@@ -23,7 +23,6 @@
#define ASIO_STANDALONE
#endif
#include <asio/io_service.hpp>
-
#include <functional>
#define UNSET_CALLBACK 0
@@ -71,8 +70,7 @@ class Portal {
*/
class ConsumerCallback {
public:
- virtual void onContentObject(core::Interest::Ptr &&i,
- core::ContentObject::Ptr &&c) = 0;
+ virtual void onContentObject(core::Interest &i, core::ContentObject &c) = 0;
virtual void onTimeout(core::Interest::Ptr &&i) = 0;
virtual void onError(std::error_code ec) = 0;
};
@@ -83,12 +81,12 @@ class Portal {
*/
class ProducerCallback {
public:
- virtual void onInterest(core::Interest::Ptr &&i) = 0;
+ virtual void onInterest(core::Interest &i) = 0;
virtual void onError(std::error_code ec) = 0;
};
using OnContentObjectCallback =
- std::function<void(core::Interest::Ptr &&, core::ContentObject::Ptr &&)>;
+ std::function<void(core::Interest &, core::ContentObject &)>;
using OnInterestTimeoutCallback = std::function<void(core::Interest::Ptr &&)>;
Portal();
diff --git a/libtransport/includes/hicn/transport/interfaces/socket_consumer.h b/libtransport/includes/hicn/transport/interfaces/socket_consumer.h
index 2447f9b5b..621e7ce6f 100644
--- a/libtransport/includes/hicn/transport/interfaces/socket_consumer.h
+++ b/libtransport/includes/hicn/transport/interfaces/socket_consumer.h
@@ -21,7 +21,7 @@
#include <hicn/transport/interfaces/callbacks.h>
#include <hicn/transport/interfaces/socket_options_default_values.h>
#include <hicn/transport/interfaces/socket_options_keys.h>
-#include <hicn/transport/security/verifier.h>
+#include <hicn/transport/auth/verifier.h>
#ifndef ASIO_STANDALONE
#define ASIO_STANDALONE
@@ -208,14 +208,6 @@ class ConsumerSocket {
int asyncConsume(const Name &name);
/**
- * Verify the packets containing a key after the origin of the key has been
- * validated by the client.
- *
- * @return true if all packets are valid, false otherwise
- */
- bool verifyKeyPackets();
-
- /**
* Stops the consumer socket. If several downloads are queued (using
* asyncConsume), this call stops just the current one.
*/
@@ -251,14 +243,6 @@ class ConsumerSocket {
int setSocketOption(int socket_option_key,
ConsumerContentObjectCallback socket_option_value);
- int setSocketOption(
- int socket_option_key,
- ConsumerContentObjectVerificationFailedCallback socket_option_value);
-
- int setSocketOption(
- int socket_option_key,
- ConsumerContentObjectVerificationCallback socket_option_value);
-
int setSocketOption(int socket_option_key,
ConsumerInterestCallback socket_option_value);
@@ -267,7 +251,7 @@ class ConsumerSocket {
int setSocketOption(
int socket_option_key,
- const std::shared_ptr<utils::Verifier> &socket_option_value);
+ const std::shared_ptr<auth::Verifier> &socket_option_value);
int setSocketOption(int socket_option_key,
const std::string &socket_option_value);
@@ -286,21 +270,13 @@ class ConsumerSocket {
int getSocketOption(int socket_option_key,
ConsumerContentObjectCallback **socket_option_value);
- int getSocketOption(
- int socket_option_key,
- ConsumerContentObjectVerificationFailedCallback **socket_option_value);
-
- int getSocketOption(
- int socket_option_key,
- ConsumerContentObjectVerificationCallback **socket_option_value);
-
int getSocketOption(int socket_option_key,
ConsumerInterestCallback **socket_option_value);
int getSocketOption(int socket_option_key, IcnObserver **socket_option_value);
int getSocketOption(int socket_option_key,
- std::shared_ptr<utils::Verifier> &socket_option_value);
+ std::shared_ptr<auth::Verifier> &socket_option_value);
int getSocketOption(int socket_option_key, std::string &socket_option_value);
diff --git a/libtransport/includes/hicn/transport/interfaces/socket_options_default_values.h b/libtransport/includes/hicn/transport/interfaces/socket_options_default_values.h
index bcf103b8c..f4945ac8a 100644
--- a/libtransport/includes/hicn/transport/interfaces/socket_options_default_values.h
+++ b/libtransport/includes/hicn/transport/interfaces/socket_options_default_values.h
@@ -16,6 +16,7 @@
#pragma once
#include <hicn/base.h>
+
#include <chrono>
#include <cstdint>
diff --git a/libtransport/includes/hicn/transport/interfaces/socket_options_keys.h b/libtransport/includes/hicn/transport/interfaces/socket_options_keys.h
index f50e919b4..00cd44075 100644
--- a/libtransport/includes/hicn/transport/interfaces/socket_options_keys.h
+++ b/libtransport/includes/hicn/transport/interfaces/socket_options_keys.h
@@ -32,6 +32,11 @@ typedef enum {
} TransportProtocolAlgorithms;
typedef enum {
+ BYTE_STREAM = 10,
+ RTC_PROD = 11,
+} ProductionProtocolAlgorithms;
+
+typedef enum {
INPUT_BUFFER_SIZE = 101,
OUTPUT_BUFFER_SIZE = 102,
NETWORK_NAME = 103,
@@ -40,7 +45,6 @@ typedef enum {
DATA_PACKET_SIZE = 106,
INTEREST_LIFETIME = 107,
CONTENT_OBJECT_EXPIRY_TIME = 108,
- KEY_CONTENT = 110,
MIN_WINDOW_SIZE = 111,
MAX_WINDOW_SIZE = 112,
CURRENT_WINDOW_SIZE = 113,
@@ -50,12 +54,10 @@ typedef enum {
RUNNING = 117,
APPLICATION_BUFFER = 118,
HASH_ALGORITHM = 119,
- CRYPTO_SUITE = 120,
SIGNER = 121,
VERIFIER = 122,
- CERTIFICATE = 123,
- VERIFY_SIGNATURE = 124,
STATS_INTERVAL = 125,
+ SUFFIX_STRATEGY = 126
} GeneralTransportOptions;
typedef enum {
@@ -98,6 +100,7 @@ typedef enum {
CONTENT_OBJECT_READY = 510,
CONTENT_OBJECT_OUTPUT = 511,
CONTENT_PRODUCED = 512,
+ CONTENT_OBJECT_TO_SIGN = 513
} ProducerCallbacksOptions;
typedef enum { OUTPUT_INTERFACE = 601 } DataLinkOptions;
diff --git a/libtransport/includes/hicn/transport/interfaces/socket_producer.h b/libtransport/includes/hicn/transport/interfaces/socket_producer.h
index e269fb83d..302b03f3f 100644
--- a/libtransport/includes/hicn/transport/interfaces/socket_producer.h
+++ b/libtransport/includes/hicn/transport/interfaces/socket_producer.h
@@ -21,7 +21,7 @@
#include <hicn/transport/interfaces/callbacks.h>
#include <hicn/transport/interfaces/socket_options_default_values.h>
#include <hicn/transport/interfaces/socket_options_keys.h>
-#include <hicn/transport/security/signer.h>
+#include <hicn/transport/auth/signer.h>
#ifndef ASIO_STANDALONE
#define ASIO_STANDALONE
@@ -40,7 +40,10 @@ using namespace core;
class ProducerSocket {
public:
- explicit ProducerSocket(int protocol = 0);
+ explicit ProducerSocket(
+ int protocol = ProductionProtocolAlgorithms::BYTE_STREAM);
+
+ explicit ProducerSocket(int protocol, asio::io_service &io_service);
virtual ~ProducerSocket();
@@ -48,22 +51,21 @@ class ProducerSocket {
bool isRunning();
- uint32_t produce(Name content_name, const uint8_t *buffer, size_t buffer_size,
- bool is_last = true, uint32_t start_offset = 0) {
- return produce(content_name, utils::MemBuf::copyBuffer(buffer, buffer_size),
- is_last, start_offset);
- }
+ void registerPrefix(const Prefix &producer_namespace);
- uint32_t produce(Name content_name, std::unique_ptr<utils::MemBuf> &&buffer,
- bool is_last = true, uint32_t start_offset = 0);
+ uint32_t produceStream(const Name &content_name, const uint8_t *buffer,
+ size_t buffer_size, bool is_last = true,
+ uint32_t start_offset = 0);
- void produce(ContentObject &content_object);
+ uint32_t produceStream(const Name &content_name,
+ std::unique_ptr<utils::MemBuf> &&buffer,
+ bool is_last = true, uint32_t start_offset = 0);
- void produce(const uint8_t *buffer, size_t buffer_size) {
- produce(utils::MemBuf::copyBuffer(buffer, buffer_size));
- }
+ uint32_t produceDatagram(const Name &content_name, const uint8_t *buffer,
+ size_t buffer_size);
- void produce(std::unique_ptr<utils::MemBuf> &&buffer);
+ uint32_t produceDatagram(const Name &content_name,
+ std::unique_ptr<utils::MemBuf> &&buffer);
void asyncProduce(const Name &suffix, const uint8_t *buf, size_t buffer_size,
bool is_last = true, uint32_t *start_offset = nullptr);
@@ -72,9 +74,7 @@ class ProducerSocket {
bool is_last, uint32_t offset,
uint32_t **last_segment = nullptr);
- void asyncProduce(ContentObject &content_object);
-
- void registerPrefix(const Prefix &producer_namespace);
+ void produce(ContentObject &content_object);
void serveForever();
@@ -104,14 +104,13 @@ class ProducerSocket {
ProducerContentCallback socket_option_value);
int setSocketOption(int socket_option_key,
- utils::CryptoHashType socket_option_value);
+ auth::CryptoHashType socket_option_value);
int setSocketOption(int socket_option_key,
- utils::CryptoSuite socket_option_value);
+ auth::CryptoSuite socket_option_value);
- int setSocketOption(
- int socket_option_key,
- const std::shared_ptr<utils::Signer> &socket_option_value);
+ int setSocketOption(int socket_option_key,
+ const std::shared_ptr<auth::Signer> &socket_option_value);
int setSocketOption(int socket_option_key,
const std::string &socket_option_value);
@@ -133,13 +132,13 @@ class ProducerSocket {
ProducerInterestCallback **socket_option_value);
int getSocketOption(int socket_option_key,
- utils::CryptoHashType &socket_option_value);
+ auth::CryptoHashType &socket_option_value);
int getSocketOption(int socket_option_key,
- utils::CryptoSuite &socket_option_value);
+ auth::CryptoSuite &socket_option_value);
int getSocketOption(int socket_option_key,
- std::shared_ptr<utils::Signer> &socket_option_value);
+ std::shared_ptr<auth::Signer> &socket_option_value);
int getSocketOption(int socket_option_key, std::string &socket_option_value);
diff --git a/libtransport/includes/hicn/transport/interfaces/statistics.h b/libtransport/includes/hicn/transport/interfaces/statistics.h
index 26831fbf1..92c58da23 100644
--- a/libtransport/includes/hicn/transport/interfaces/statistics.h
+++ b/libtransport/includes/hicn/transport/interfaces/statistics.h
@@ -31,6 +31,8 @@ class IcnObserver {
virtual void notifyDownloadTime(double downloadTime) = 0;
};
+class ProductionStatistics {};
+
class TransportStatistics {
static constexpr double default_alpha = 0.7;
@@ -43,7 +45,15 @@ class TransportStatistics {
interest_tx_(0),
alpha_(alpha),
loss_ratio_(0.0),
- queuing_delay_(0.0) {}
+ queuing_delay_(0.0),
+ interest_FEC_tx_(0),
+ bytes_FEC_received_(0),
+ lost_data_(0),
+ recovered_data_(0),
+ status_(-1),
+ // avg_data_rtt_(0),
+ avg_pending_pkt_(0.0),
+ received_nacks_(0) {}
TRANSPORT_ALWAYS_INLINE void updateRetxCount(uint64_t retx) {
retx_count_ += retx;
@@ -74,6 +84,32 @@ class TransportStatistics {
queuing_delay_ = queuing_delay;
}
+ TRANSPORT_ALWAYS_INLINE void updateInterestFecTx(uint64_t int_tx) {
+ interest_FEC_tx_ += int_tx;
+ }
+
+ TRANSPORT_ALWAYS_INLINE void updateBytesFecRecv(uint64_t bytes) {
+ bytes_FEC_received_ += bytes;
+ }
+
+ TRANSPORT_ALWAYS_INLINE void updateLostData(uint64_t pkt) {
+ lost_data_ += pkt;
+ }
+
+ TRANSPORT_ALWAYS_INLINE void updateRecoveredData(uint64_t bytes) {
+ recovered_data_ += bytes;
+ }
+
+ TRANSPORT_ALWAYS_INLINE void updateCCState(int status) { status_ = status; }
+
+ TRANSPORT_ALWAYS_INLINE void updateAveragePendingPktCount(double pkt) {
+ avg_pending_pkt_ = (alpha_ * avg_pending_pkt_) + ((1. - alpha_) * pkt);
+ }
+
+ TRANSPORT_ALWAYS_INLINE void updateReceivedNacks(uint32_t nacks) {
+ received_nacks_ += nacks;
+ }
+
TRANSPORT_ALWAYS_INLINE uint64_t getRetxCount() const { return retx_count_; }
TRANSPORT_ALWAYS_INLINE uint64_t getBytesRecv() const {
@@ -96,6 +132,32 @@ class TransportStatistics {
return queuing_delay_;
}
+ TRANSPORT_ALWAYS_INLINE uint64_t getInterestFecTxCount() const {
+ return interest_FEC_tx_;
+ }
+
+ TRANSPORT_ALWAYS_INLINE uint64_t getBytesFecRecv() const {
+ return bytes_FEC_received_;
+ }
+
+ TRANSPORT_ALWAYS_INLINE uint64_t getLostData() const { return lost_data_; }
+
+ TRANSPORT_ALWAYS_INLINE uint64_t getBytesRecoveredData() const {
+ return recovered_data_;
+ }
+
+ TRANSPORT_ALWAYS_INLINE int getCCStatus() const { return status_; }
+
+ TRANSPORT_ALWAYS_INLINE double getAveragePendingPktCount() const {
+ return avg_pending_pkt_;
+ }
+
+ TRANSPORT_ALWAYS_INLINE uint32_t getReceivedNacks() const {
+ return received_nacks_;
+ }
+
+ TRANSPORT_ALWAYS_INLINE void setAlpha(double val) { alpha_ = val; }
+
TRANSPORT_ALWAYS_INLINE void reset() {
retx_count_ = 0;
bytes_received_ = 0;
@@ -103,6 +165,14 @@ class TransportStatistics {
avg_window_size_ = 0;
interest_tx_ = 0;
loss_ratio_ = 0;
+ interest_FEC_tx_ = 0;
+ bytes_FEC_received_ = 0;
+ lost_data_ = 0;
+ recovered_data_ = 0;
+ status_ = 0;
+ // avg_data_rtt_ = 0;
+ avg_pending_pkt_ = 0;
+ received_nacks_ = 0;
}
private:
@@ -114,6 +184,13 @@ class TransportStatistics {
double alpha_;
double loss_ratio_;
double queuing_delay_;
+ uint64_t interest_FEC_tx_;
+ uint64_t bytes_FEC_received_;
+ uint64_t lost_data_;
+ uint64_t recovered_data_;
+ int status_; // transport status (e.g. sync status, congestion etc.)
+ double avg_pending_pkt_;
+ uint32_t received_nacks_;
};
} // namespace interface