From bac3da61644515f05663789b122554dc77549286 Mon Sep 17 00:00:00 2001 From: Luca Muscariello Date: Thu, 17 Jan 2019 13:47:57 +0100 Subject: This is the first commit of the hicn project Change-Id: I6f2544ad9b9f8891c88cc4bcce3cf19bd3cc863f Signed-off-by: Luca Muscariello --- .../hicn/transport/interfaces/socket_consumer.h | 259 +++++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100755 libtransport/src/hicn/transport/interfaces/socket_consumer.h (limited to 'libtransport/src/hicn/transport/interfaces/socket_consumer.h') diff --git a/libtransport/src/hicn/transport/interfaces/socket_consumer.h b/libtransport/src/hicn/transport/interfaces/socket_consumer.h new file mode 100755 index 000000000..9e309aae8 --- /dev/null +++ b/libtransport/src/hicn/transport/interfaces/socket_consumer.h @@ -0,0 +1,259 @@ +/* + * Copyright (c) 2017-2019 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 + +#include +#include +#include +#include +#include + +#include +#include + +#define CONSUMER_READY 0 +#define CONSUMER_BUSY 1 + +namespace transport { + +namespace interface { + +class ConsumerSocket : public BaseSocket { + friend class protocol::TransportProtocol; + friend class protocol::VegasTransportProtocol; + friend class protocol::RaaqmTransportProtocol; + friend class protocol::CbrTransportProtocol; + + public: + explicit ConsumerSocket(int protocol); + explicit ConsumerSocket(int protocol, asio::io_service &io_service); + + ~ConsumerSocket(); + + void connect() override; + + int consume(const Name &name, utils::SharableVector &receive_buffer); + + int asyncConsume( + const Name &name, + std::shared_ptr> receive_buffer); + + void asyncSendInterest(Interest::Ptr &&interest, + Portal::ConsumerCallback *callback); + + void stop(); + + void resume(); + + asio::io_service &getIoService() override; + + int setSocketOption(int socket_option_key, + uint32_t socket_option_value) override; + + int setSocketOption(int socket_option_key, + double socket_option_value) override; + + int setSocketOption(int socket_option_key, bool socket_option_value) override; + + int setSocketOption(int socket_option_key, Name socket_option_value) override; + + int setSocketOption(int socket_option_key, + std::list socket_option_value) override; + + int setSocketOption( + int socket_option_key, + ProducerContentObjectCallback socket_option_value) override; + + int setSocketOption( + int socket_option_key, + ConsumerContentObjectVerificationCallback socket_option_value) override; + + int setSocketOption( + int socket_option_key, + ConsumerContentObjectCallback socket_option_value) override; + + int setSocketOption(int socket_option_key, + ConsumerInterestCallback socket_option_value) override; + + int setSocketOption(int socket_option_key, + ProducerInterestCallback socket_option_value) override; + + int setSocketOption(int socket_option_key, + ConsumerContentCallback socket_option_value) override; + + int setSocketOption(int socket_option_key, + ConsumerManifestCallback socket_option_value) override; + + int setSocketOption(int socket_option_key, + IcnObserver *socket_option_value) override; + + int setSocketOption(int socket_option_key, + HashAlgorithm socket_option_value) override; + + int setSocketOption(int socket_option_key, + utils::CryptoSuite crypto_suite) override; + + int setSocketOption(int socket_option_key, + const utils::Identity &crypto_suite) override; + + int setSocketOption(int socket_option_key, + const std::string &socket_option_value) override; + + int setSocketOption(int socket_option_key, + ConsumerTimerCallback socket_option_value) override; + + int setSocketOption(int socket_option_key, + ProducerContentCallback socket_option_value) override; + + int getSocketOption(int socket_option_key, + uint32_t &socket_option_value) override; + + int getSocketOption(int socket_option_key, + double &socket_option_value) override; + + int getSocketOption(int socket_option_key, + bool &socket_option_value) override; + + int getSocketOption(int socket_option_key, + Name &socket_option_value) override; + + int getSocketOption(int socket_option_key, + std::list &socket_option_value) override; + + int getSocketOption( + int socket_option_key, + ProducerContentObjectCallback &socket_option_value) override; + + int getSocketOption( + int socket_option_key, + ConsumerContentObjectVerificationCallback &socket_option_value) override; + + int getSocketOption( + int socket_option_key, + ConsumerContentObjectCallback &socket_option_value) override; + + int getSocketOption(int socket_option_key, + ConsumerInterestCallback &socket_option_value) override; + + int getSocketOption(int socket_option_key, + ProducerInterestCallback &socket_option_value) override; + + int getSocketOption(int socket_option_key, + ConsumerContentCallback &socket_option_value) override; + + int getSocketOption(int socket_option_key, + ConsumerManifestCallback &socket_option_value) override; + + int getSocketOption(int socket_option_key, + std::shared_ptr &socket_option_value) override; + + int getSocketOption(int socket_option_key, + IcnObserver **socket_option_value) override; + + int getSocketOption(int socket_option_key, + HashAlgorithm &socket_option_value) override; + + int getSocketOption(int socket_option_key, + utils::CryptoSuite &crypto_suite) override; + + int getSocketOption(int socket_option_key, + utils::Identity &crypto_suite) override; + + int getSocketOption(int socket_option_key, + std::string &socket_option_value) override; + + int getSocketOption(int socket_option_key, + ConsumerTimerCallback &socket_option_value) override; + + int getSocketOption(int socket_option_key, + ProducerContentCallback &socket_option_value) override; + + protected: + std::shared_ptr transport_protocol_; + + private: + // context inner state variables + asio::io_service internal_io_service_; + asio::io_service &io_service_; + + std::shared_ptr portal_; + + utils::EventThread async_downloader_; + + Name network_name_; + + int interest_lifetime_; + + double min_window_size_; + double max_window_size_; + double current_window_size_; + uint32_t max_retransmissions_; + size_t output_buffer_size_; + size_t input_buffer_size_; + + // RAAQM Parameters + + double minimum_drop_probability_; + unsigned int sample_number_; + double gamma_; + double beta_; + double drop_factor_; + + // Rate estimation parameters + double rate_estimation_alpha_; + IcnObserver *rate_estimation_observer_; + int rate_estimation_batching_parameter_; + int rate_estimation_choice_; + + bool is_async_; + + utils::Verifier verifier_; + PARCKeyId *key_id_; + bool verify_signature_; + + std::shared_ptr> content_buffer_; + + ConsumerInterestCallback on_interest_retransmission_; + ConsumerInterestCallback on_interest_output_; + ConsumerInterestCallback on_interest_timeout_; + ConsumerInterestCallback on_interest_satisfied_; + + ConsumerContentObjectCallback on_content_object_input_; + ConsumerContentObjectVerificationCallback on_content_object_verification_; + + ConsumerContentObjectCallback on_content_object_; + ConsumerManifestCallback on_manifest_; + + ConsumerContentCallback on_payload_retrieved_; + + ConsumerTimerCallback on_timer_expires_; + + // Virtual download for traffic generator + + bool virtual_download_; + bool rtt_stats_; + + Time t0_; + Time t1_; + asio::steady_timer timer_; + uint32_t timer_interval_milliseconds_; +}; + +} // namespace interface + +} // end namespace transport -- cgit 1.2.3-korg